@microsoft/windows-admin-center-sdk 2.523.1 → 2.538.1

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.
Files changed (67) hide show
  1. package/angular/bundles/microsoft-windows-admin-center-sdk-angular.umd.js +88 -41
  2. package/angular/bundles/microsoft-windows-admin-center-sdk-angular.umd.js.map +1 -1
  3. package/angular/bundles/microsoft-windows-admin-center-sdk-angular.umd.min.js +1 -1
  4. package/angular/bundles/microsoft-windows-admin-center-sdk-angular.umd.min.js.map +1 -1
  5. package/angular/esm2015/src/controls/data-table/data-table.component.js +6 -2
  6. package/angular/esm2015/src/controls/dialog/dialog.component.js +11 -11
  7. package/angular/esm2015/src/controls/dialog/extension-dialog/extension-dialog.component.js +7 -7
  8. package/angular/esm2015/src/controls/header/header.component.js +52 -14
  9. package/angular/esm2015/src/controls/layout/layout-config.js +1 -2
  10. package/angular/esm2015/src/controls/query-editor/query-editor.component.js +4 -4
  11. package/angular/esm2015/src/controls/snap-in-extension/snap-in-extension.component.js +1 -1
  12. package/angular/fesm2015/microsoft-windows-admin-center-sdk-angular.js +75 -34
  13. package/angular/fesm2015/microsoft-windows-admin-center-sdk-angular.js.map +1 -1
  14. package/angular/src/controls/header/header.component.d.ts +14 -1
  15. package/angular/src/controls/query-editor/query-editor.component.d.ts +1 -1
  16. package/core/data/active-directory/active-directory.js +2 -2
  17. package/core/data/active-directory/active-directory.js.map +1 -1
  18. package/core/data/powershell.d.ts +2 -2
  19. package/core/data/powershell.js +2 -2
  20. package/core/data/powershell.js.map +1 -1
  21. package/core/notification/notification-manager.d.ts +18 -0
  22. package/core/notification/notification-manager.js +55 -10
  23. package/core/notification/notification-manager.js.map +1 -1
  24. package/core/notification/notification-message.d.ts +41 -0
  25. package/core/notification/notification-message.js +3 -0
  26. package/core/notification/notification-message.js.map +1 -0
  27. package/core/notification/notification.d.ts +10 -1
  28. package/core/notification/notification.js +30 -33
  29. package/core/notification/notification.js.map +1 -1
  30. package/core/notification/powershell-notification.d.ts +15 -15
  31. package/core/notification/powershell-notification.js +19 -8
  32. package/core/notification/powershell-notification.js.map +1 -1
  33. package/core/notification/socket-signalr.d.ts +8 -14
  34. package/core/notification/socket-signalr.js +18 -19
  35. package/core/notification/socket-signalr.js.map +1 -1
  36. package/core/notification/work-item-manager.d.ts +4 -0
  37. package/core/notification/work-item-manager.js +76 -20
  38. package/core/notification/work-item-manager.js.map +1 -1
  39. package/e2e/assets/strings/cs-CZ/strings.json +1 -1
  40. package/e2e/assets/strings/de-DE/strings.json +1 -1
  41. package/e2e/assets/strings/es-ES/strings.json +1 -1
  42. package/e2e/assets/strings/fr-FR/strings.json +1 -1
  43. package/e2e/assets/strings/hu-HU/strings.json +1 -1
  44. package/e2e/assets/strings/id-ID/strings.json +1 -1
  45. package/e2e/assets/strings/it-IT/strings.json +1 -1
  46. package/e2e/assets/strings/ja-JP/strings.json +1 -1
  47. package/e2e/assets/strings/ko-KR/strings.json +1 -1
  48. package/e2e/assets/strings/nl-NL/strings.json +1 -1
  49. package/e2e/assets/strings/pl-PL/strings.json +1 -1
  50. package/e2e/assets/strings/pt-BR/strings.json +1 -1
  51. package/e2e/assets/strings/pt-PT/strings.json +1 -1
  52. package/e2e/assets/strings/ru-RU/strings.json +1 -1
  53. package/e2e/assets/strings/strings.json +1 -1
  54. package/e2e/assets/strings/sv-SE/strings.json +1 -1
  55. package/e2e/assets/strings/tr-TR/strings.json +1 -1
  56. package/e2e/assets/strings/zh-CN/strings.json +1 -1
  57. package/e2e/assets/strings/zh-TW/strings.json +1 -1
  58. package/package.json +3 -6
  59. package/styles/css/main-v2.css +1 -1
  60. package/tools/test-runner/index.js +12 -2
  61. package/tools/test-runner/index.js.map +1 -1
  62. package/tools/wac-cli/templates/internal/package.json +0 -4
  63. package/tools/wac-cli/templates/library/angular.json +0 -3
  64. package/tools/wac-cli/templates/library/tsconfig.lib.json +1 -1
  65. package/tools/wac-cli/templates/wac-template/angular.json +0 -3
  66. package/tools/wac-cli/templates/wac-template/package.json +0 -4
  67. package/tools/wac-cli/templates/wac-template/tsconfig.base.json +23 -24
@@ -24,8 +24,17 @@ export declare class HeaderComponent extends CoreBaseComponent implements OnInit
24
24
  private static h3style;
25
25
  private static h4style;
26
26
  styleTo: string;
27
+ /**
28
+ * The header type
29
+ */
27
30
  type: string;
31
+ /**
32
+ * The font text for the main header
33
+ */
28
34
  text: string;
35
+ /**
36
+ * The font size level for the main header
37
+ */
29
38
  level: string;
30
39
  /**
31
40
  * The sme icon class for MDL icons
@@ -35,11 +44,15 @@ export declare class HeaderComponent extends CoreBaseComponent implements OnInit
35
44
  * The sme icon class for URL icons
36
45
  */
37
46
  urlIcon: string;
47
+ /**
48
+ * The subtitle of the header
49
+ */
50
+ subtitle: string;
38
51
  constructor(injector: Injector);
39
52
  /**
40
53
  * The method run when the component is initialized
41
54
  */
42
55
  ngOnInit(): void;
43
56
  static ɵfac: i0.ɵɵFactoryDef<HeaderComponent, never>;
44
- static ɵcmp: i0.ɵɵComponentDefWithMeta<HeaderComponent, "sme-header", never, { "type": "type"; "text": "text"; "level": "level"; "smeIconClassName": "smeIconClassName"; "urlIcon": "urlIcon"; }, {}, never, ["*"]>;
57
+ static ɵcmp: i0.ɵɵComponentDefWithMeta<HeaderComponent, "sme-header", never, { "type": "type"; "text": "text"; "level": "level"; "smeIconClassName": "smeIconClassName"; "urlIcon": "urlIcon"; "subtitle": "subtitle"; }, {}, never, ["*"]>;
45
58
  }
@@ -21,7 +21,7 @@ export interface QueryEditorColumnDropdownData {
21
21
  export declare class QueryEditorComponent extends CoreBaseComponent implements OnInit, OnDestroy {
22
22
  queryEditor: QueryData;
23
23
  internalColumnList: QueryEditorDataTableColumnListItem[];
24
- operands: Array<QueryDataOperand>;
24
+ operands: any[];
25
25
  columnsDropdownData: Array<QueryEditorColumnDropdownData>;
26
26
  columnDropdownData: Array<any>;
27
27
  columnDropdownField: string;
@@ -14,7 +14,7 @@ export class ActiveDirectory {
14
14
  this.defaultDirectorySearchSizeLimit = 150;
15
15
  this.isGatewayDomainJoinedSubject = new ReplaySubject(1);
16
16
  this.isGatewayDomainJoined = this.isGatewayDomainJoinedSubject.asObservable();
17
- this.gateway.get('gateway/domain').subscribe((response) => {
17
+ this.gateway.get('activeDirectory/domain').subscribe((response) => {
18
18
  // if response is not empty, the gateway is domain joined
19
19
  this.isGatewayDomainJoinedSubject.next(!!response);
20
20
  }, error => {
@@ -31,7 +31,7 @@ export class ActiveDirectory {
31
31
  if (MsftSme.isNullOrUndefined(options.sizeLimit)) {
32
32
  options.sizeLimit = this.defaultDirectorySearchSizeLimit;
33
33
  }
34
- const requestUrl = `gateway/accounts?type=${type}&filter=${searchString}&size=${options.sizeLimit}`;
34
+ const requestUrl = `activeDirectory/accounts?type=${type}&filter=${searchString}&size=${options.sizeLimit}`;
35
35
  return this.gateway.get(requestUrl).pipe(catchError(error => {
36
36
  const exceptionMessage = MsftSme.getValue(error, 'response.exceptionMessage');
37
37
  if (exceptionMessage) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../packages/core/data/active-directory/active-directory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,aAAa,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAI5C,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD;;GAEG;AACH,MAAM,OAAO,eAAe;IAMxB;;;OAGG;IACH,YAAoB,OAA0B;QAA1B,YAAO,GAAP,OAAO,CAAmB;QAC1C,IAAI,CAAC,+BAA+B,GAAG,GAAG,CAAC;QAC3C,IAAI,CAAC,4BAA4B,GAAG,IAAI,aAAa,CAAC,CAAC,CAAC,CAAC;QACzD,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC,4BAA4B,CAAC,YAAY,EAAE,CAAC;QAE9E,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,SAAS,CACxC,CAAC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OAAO,CAAC,iBAAiB,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;YAC7C,OAAO,KAAK,CAAC;SAChB;QAED,OAAO,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC;QAElD,IAAI,OAAO,CAAC,iBAAiB,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,EAAE;YACzD,OAAO,OAAO,CAAC,QAAQ,CAAC;SAC3B;QAED,OAAO,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACxC,CAAC;CACJ","file":"active-directory.js","sourcesContent":["import { Observable, ReplaySubject, throwError } from 'rxjs';\r\nimport { catchError } from 'rxjs/operators';\r\nimport { GatewayConnection } from '../gateway-connection';\r\nimport { AccountInfo } from './models/account-info';\r\nimport { ActiveDirectorySearchOptions } from './models/active-directory-search-options';\r\nimport { SearchType } from './models/search-type';\r\n\r\n/**\r\n * Active Directory Service implementation.\r\n */\r\nexport class ActiveDirectory {\r\n\r\n public defaultDirectorySearchSizeLimit: number;\r\n public readonly isGatewayDomainJoined: Observable<boolean>;\r\n private isGatewayDomainJoinedSubject: ReplaySubject<boolean>;\r\n\r\n /**\r\n * Initializes a new instance of the ActiveDirectory class.\r\n * @param gateway the gateway instance.\r\n */\r\n constructor(private gateway: GatewayConnection) {\r\n this.defaultDirectorySearchSizeLimit = 150;\r\n this.isGatewayDomainJoinedSubject = new ReplaySubject(1);\r\n this.isGatewayDomainJoined = this.isGatewayDomainJoinedSubject.asObservable();\r\n\r\n this.gateway.get('gateway/domain').subscribe(\r\n (response: any) => {\r\n // if response is not empty, the gateway is domain joined\r\n this.isGatewayDomainJoinedSubject.next(!!response);\r\n }, error => {\r\n this.isGatewayDomainJoinedSubject.next(false);\r\n // TODO: LOG THIS ERROR\r\n });\r\n }\r\n\r\n /**\r\n * Search computer list from active directory through gateway api\r\n */\r\n public search(options: ActiveDirectorySearchOptions): Observable<AccountInfo[]> {\r\n const type = encodeURIComponent(this.getSearchType(options));\r\n const searchString = encodeURIComponent(options.searchString) || '';\r\n if (MsftSme.isNullOrUndefined(options.sizeLimit)) {\r\n options.sizeLimit = this.defaultDirectorySearchSizeLimit;\r\n }\r\n const requestUrl = `gateway/accounts?type=${type}&filter=${searchString}&size=${options.sizeLimit}`;\r\n return this.gateway.get(requestUrl).pipe(\r\n catchError(error => {\r\n const exceptionMessage = MsftSme.getValue(error, 'response.exceptionMessage');\r\n if (exceptionMessage) {\r\n return throwError(exceptionMessage);\r\n }\r\n return throwError(error);\r\n })\r\n );\r\n }\r\n\r\n\r\n /**\r\n * Get the appropriate search type string from the search options\r\n */\r\n private getSearchType(options: ActiveDirectorySearchOptions): string {\r\n if (Array.isArray(options.searchOn)) {\r\n options.searchOn = options.searchOn[0];\r\n }\r\n\r\n if (MsftSme.isNullOrUndefined(options.searchOn)) {\r\n return 'any';\r\n }\r\n\r\n options.searchOn = options.searchOn.toLowerCase();\r\n\r\n if (MsftSme.isNullOrUndefined(SearchType[options.searchOn])) {\r\n return options.searchOn;\r\n }\r\n\r\n return SearchType[options.searchOn];\r\n }\r\n}\r\n"]}
1
+ {"version":3,"sources":["../../../packages/core/data/active-directory/active-directory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,aAAa,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAI5C,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD;;GAEG;AACH,MAAM,OAAO,eAAe;IAMxB;;;OAGG;IACH,YAAoB,OAA0B;QAA1B,YAAO,GAAP,OAAO,CAAmB;QAC1C,IAAI,CAAC,+BAA+B,GAAG,GAAG,CAAC;QAC3C,IAAI,CAAC,4BAA4B,GAAG,IAAI,aAAa,CAAC,CAAC,CAAC,CAAC;QACzD,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC,4BAA4B,CAAC,YAAY,EAAE,CAAC;QAE9E,I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AAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;SAC1C;QAED,IAAI,OAAO,CAAC,iBAAiB,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;YAC7C,OAAO,KAAK,CAAC;SAChB;QAED,OAAO,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC;QAElD,IAAI,OAAO,CAAC,iBAAiB,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,EAAE;YACzD,OAAO,OAAO,CAAC,QAAQ,CAAC;SAC3B;QAED,OAAO,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACxC,CAAC;CACJ","file":"active-directory.js","sourcesContent":["import { Observable, ReplaySubject, throwError } from 'rxjs';\r\nimport { catchError } from 'rxjs/operators';\r\nimport { GatewayConnection } from '../gateway-connection';\r\nimport { AccountInfo } from './models/account-info';\r\nimport { ActiveDirectorySearchOptions } from './models/active-directory-search-options';\r\nimport { SearchType } from './models/search-type';\r\n\r\n/**\r\n * Active Directory Service implementation.\r\n */\r\nexport class ActiveDirectory {\r\n\r\n public defaultDirectorySearchSizeLimit: number;\r\n public readonly isGatewayDomainJoined: Observable<boolean>;\r\n private isGatewayDomainJoinedSubject: ReplaySubject<boolean>;\r\n\r\n /**\r\n * Initializes a new instance of the ActiveDirectory class.\r\n * @param gateway the gateway instance.\r\n */\r\n constructor(private gateway: GatewayConnection) {\r\n this.defaultDirectorySearchSizeLimit = 150;\r\n this.isGatewayDomainJoinedSubject = new ReplaySubject(1);\r\n this.isGatewayDomainJoined = this.isGatewayDomainJoinedSubject.asObservable();\r\n\r\n this.gateway.get('activeDirectory/domain').subscribe(\r\n (response: any) => {\r\n // if response is not empty, the gateway is domain joined\r\n this.isGatewayDomainJoinedSubject.next(!!response);\r\n }, error => {\r\n this.isGatewayDomainJoinedSubject.next(false);\r\n // TODO: LOG THIS ERROR\r\n });\r\n }\r\n\r\n /**\r\n * Search computer list from active directory through gateway api\r\n */\r\n public search(options: ActiveDirectorySearchOptions): Observable<AccountInfo[]> {\r\n const type = encodeURIComponent(this.getSearchType(options));\r\n const searchString = encodeURIComponent(options.searchString) || '';\r\n if (MsftSme.isNullOrUndefined(options.sizeLimit)) {\r\n options.sizeLimit = this.defaultDirectorySearchSizeLimit;\r\n }\r\n const requestUrl = `activeDirectory/accounts?type=${type}&filter=${searchString}&size=${options.sizeLimit}`;\r\n return this.gateway.get(requestUrl).pipe(\r\n catchError(error => {\r\n const exceptionMessage = MsftSme.getValue(error, 'response.exceptionMessage');\r\n if (exceptionMessage) {\r\n return throwError(exceptionMessage);\r\n }\r\n return throwError(error);\r\n })\r\n );\r\n }\r\n\r\n\r\n /**\r\n * Get the appropriate search type string from the search options\r\n */\r\n private getSearchType(options: ActiveDirectorySearchOptions): string {\r\n if (Array.isArray(options.searchOn)) {\r\n options.searchOn = options.searchOn[0];\r\n }\r\n\r\n if (MsftSme.isNullOrUndefined(options.searchOn)) {\r\n return 'any';\r\n }\r\n\r\n options.searchOn = options.searchOn.toLowerCase();\r\n\r\n if (MsftSme.isNullOrUndefined(SearchType[options.searchOn])) {\r\n return options.searchOn;\r\n }\r\n\r\n return SearchType[options.searchOn];\r\n }\r\n}\r\n"]}
@@ -224,9 +224,9 @@ export declare class PowerShell {
224
224
  */
225
225
  static smePowerShellEndpoint: string;
226
226
  /**
227
- * SME CredSSP PowerShell endpoint to control client role of CredSSP on the gateway.
227
+ * WAC (v2) CredSSP PowerShell endpoint to control client role of CredSSP on the gateway.
228
228
  */
229
- static smeCredSSPEndpoint: string;
229
+ static wacCredSSPEndpoint: string;
230
230
  /**
231
231
  * Static collection of PowerShell objects.
232
232
  */
@@ -672,9 +672,9 @@ PowerShell.defaultPowerShellEndpoint = 'http://schemas.microsoft.com/powershell/
672
672
  */
673
673
  PowerShell.smePowerShellEndpoint = 'http://schemas.microsoft.com/powershell/microsoft.sme.powershell';
674
674
  /**
675
- * SME CredSSP PowerShell endpoint to control client role of CredSSP on the gateway.
675
+ * WAC (v2) CredSSP PowerShell endpoint to control client role of CredSSP on the gateway.
676
676
  */
677
- PowerShell.smeCredSSPEndpoint = 'http://schemas.microsoft.com/powershell/microsoft.sme.credssp';
677
+ PowerShell.wacCredSSPEndpoint = 'http://schemas.microsoft.com/powershell/Microsoft.WindowsAdminCenter.Credssp';
678
678
  /**
679
679
  * Static collection of PowerShell objects.
680
680
  */
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../packages/core/data/powershell.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,UAAU,EAAY,UAAU,EAAE,MAAM,MAAM,CAAC;AAE/D,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAC;AAE/E,OAAO,EAAyC,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAkB,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAkJ5B;;GAEG;AACH,MAAM,OAAO,iBAAiB;IAS1B,YAA0B,UAAsB,EAAU,QAAoC;QAApE,eAAU,GAAV,UAAU,CAAY;QAAU,aAAQ,GAAR,QAAQ,CAA4B;IAC9F,CAAC;IAED;;OAEG;IACH,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;IACpC,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,IAAI,CAAC,QAAQ,EAAE;YACf,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;SAC3B;IACL,CAAC;CACJ;AASD;;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, Observer, throwError } from 'rxjs';\r\nimport { AjaxError } from 'rxjs/ajax';\r\nimport { catchError, expand, mergeMap, tap } from 'rxjs/operators';\r\nimport { LogLevel } from '../diagnostics/log-level';\r\nimport { Logging } from '../diagnostics/logging';\r\nimport { SmeWebTelemetry } from '../diagnostics/sme-web-telemetry';\r\nimport { TelemetryEventStates } from '../diagnostics/sme-web-telemetry-models';\r\nimport { Strings } from '../generated/strings';\r\nimport { Disposable, DisposableLifetimeManager, Disposer } from './disposable';\r\nimport { headerConstants, HttpStatusCode } from './http-constants';\r\nimport { Net } from './net';\r\nimport { NodeConnection, NodeRequestOptions } from './node-connection';\r\n\r\n/**\r\n * PowerShell run options.\r\n */\r\nexport interface PowerShellOptions extends NodeRequestOptions {\r\n /**\r\n * Close the runspace after the call.\r\n * (default is false)\r\n */\r\n close?: boolean;\r\n\r\n /**\r\n * Close the runspace on error.\r\n */\r\n closeOnError?: boolean;\r\n\r\n /**\r\n * Timeout milliseconds to shutdown the session.\r\n * (default is null and forever)\r\n */\r\n timeoutMs?: number;\r\n\r\n /**\r\n * Processing data progressively instead of waiting all result.\r\n */\r\n partial?: boolean;\r\n\r\n /**\r\n * Specify the initial waiting time before starting polling of result of invoke script.\r\n */\r\n waitTimeMs?: number;\r\n}\r\n\r\n/**\r\n * The node request options to control the underlying node connections in a powershell session\r\n */\r\nexport interface PowerShellSessionRequestOptions extends NodeRequestOptions {\r\n /**\r\n * Specify the session pool mode on the gateway.\r\n */\r\n automatic?: boolean;\r\n}\r\n\r\n/**\r\n * PowerShell context object interface.\r\n */\r\nexport interface PowerShellContext {\r\n /**\r\n * The node name.\r\n */\r\n nodeName: string;\r\n\r\n /**\r\n * The shared key name for runspace.\r\n */\r\n key: string;\r\n\r\n /**\r\n * The array of referenced containers.\r\n */\r\n lifetimes: DisposableLifetimeManager[];\r\n\r\n /**\r\n * The request options for the powershell session\r\n */\r\n requestOptions: PowerShellSessionRequestOptions;\r\n}\r\n\r\n/**\r\n * PowerShell command object.\r\n */\r\n export interface PowerShellCommandWithoutState {\r\n /**\r\n * The name of PowerShell module. (optional, it uses default module if not specified.)\r\n */\r\n module?: string;\r\n\r\n /**\r\n * The command name.\r\n */\r\n command: string;\r\n\r\n /**\r\n * The parameters (arguments).\r\n */\r\n parameters?: any;\r\n\r\n /**\r\n * Set if the command should be run in a local runspace.\r\n */\r\n useInProcRunspace?: boolean;\r\n\r\n /**\r\n * The script string.\r\n */\r\n script: string;\r\n}\r\n\r\n\r\n/**\r\n * PowerShell command object.\r\n */\r\nexport interface PowerShellCommand extends PowerShellCommandWithoutState {\r\n /**\r\n * The state of command object.\r\n */\r\n state: string;\r\n}\r\n\r\n/**\r\n * PowerShell command queue item.\r\n */\r\nexport interface PowerShellCommandItem {\r\n /**\r\n * The command to execute.\r\n */\r\n command: PowerShellCommand;\r\n\r\n /**\r\n * Options for how to handle the command (reserved)\r\n */\r\n options?: PowerShellOptions;\r\n\r\n /**\r\n * Deferred object currently waiting for command run.\r\n */\r\n observer: Observer<any>;\r\n}\r\n\r\ninterface PowerShellCommandPacket extends PowerShellCommand {\r\n\r\n /**\r\n * The invocation mode with Net.powerShellApiInvokeCommand API.\r\n * Default is WorkItem which uses WebSocket communication.\r\n * Polling mode uses pooled runspaces on the gateway and the gateway will recycle and shutdown them automatically.\r\n */\r\n invokeMode?: 'WorkItem' | 'Polling';\r\n\r\n /**\r\n * Specify the initial waiting time before starting polling of result of invoke script.\r\n */\r\n waitTimeMs?: number;\r\n}\r\n\r\n/**\r\n * The PowerShellSession class.\r\n */\r\nexport class PowerShellSession implements Disposable {\r\n /**\r\n * Initializes a new instance of the PowerShellSession class.\r\n *\r\n * @param powerShell the PowerShell object.\r\n * @param lifetime the disposable lifetime manager object.\r\n */\r\n public constructor(powerShell: PowerShell);\r\n public constructor(powerShell: PowerShell, lifetime: DisposableLifetimeManager);\r\n public constructor(public powerShell: PowerShell, private lifetime?: DisposableLifetimeManager) {\r\n }\r\n\r\n /**\r\n * Gets the node name of session.\r\n */\r\n public get nodeName(): string {\r\n return this.powerShell.nodeName;\r\n }\r\n\r\n /**\r\n * Dispose the session object.\r\n */\r\n public dispose(): void {\r\n if (this.lifetime) {\r\n this.lifetime.dispose();\r\n }\r\n }\r\n}\r\n\r\nexport interface FallbackError extends AjaxError {\r\n handlerError: {\r\n message: string;\r\n code: 'ManageAsDialogCancel';\r\n };\r\n}\r\n\r\n/**\r\n * Class containing methods related to PowerShell runspace creation/deletion/command using PowerShell Raw API plugin.\r\n * - It's auto holding the session as long as it's used within last 3 minutes.\r\n */\r\nexport class PowerShellRaw implements Disposable {\r\n // 3 minutes holding time.\r\n private static maxDeltaTimeInMs: number = 3 * 60 * 1000;\r\n private sessionId: string;\r\n private timestampInMs = 0;\r\n private markDelete = false;\r\n private internalActive = false;\r\n private cancelPending = false;\r\n\r\n /**\r\n * Initializes a new instance of the PowerShellRaw class.\r\n *\r\n * @param nodeConnection The node connection service.\r\n * @param context The context of PowerShell run.\r\n */\r\n constructor(private nodeConnection: NodeConnection, private context: PowerShellContext) {\r\n }\r\n\r\n /**\r\n * Gets active status of PowerShell execution.\r\n */\r\n public get active(): boolean {\r\n return this.internalActive;\r\n }\r\n\r\n /**\r\n * Dispose the runspace.\r\n */\r\n public dispose(): void {\r\n if (!this.active) {\r\n // only close sessions that have been created.\r\n // If a result was cached a component may not\r\n // execute a command and still dispose the session\r\n // when the component is destroyed.\r\n if (this.sessionId) {\r\n this.close();\r\n }\r\n } else {\r\n this.markDelete = true;\r\n }\r\n }\r\n\r\n /**\r\n * Runs the given command\r\n *\r\n * @param command The command to execute.\r\n * @param options the powershell options.\r\n */\r\n public runCommand(command: PowerShellCommand, options?: PowerShellOptions): Observable<any> {\r\n // take the timestamp only success/healthy case.\r\n // error session would be auto-deleted after expiration time.\r\n this.internalActive = true;\r\n return this.command(command, options)\r\n .pipe(\r\n catchError((error) => this.fallbackToJea(error, command, options)),\r\n expand((data: any, index: number) => {\r\n this.timestampInMs = Date.now();\r\n if (this.checkCompleted(data)) {\r\n return empty();\r\n }\r\n\r\n if (this.cancelPending) {\r\n // submit cancel request.\r\n // after set active state to false and complete the observable.\r\n this.cancelPending = false;\r\n return this.cancel()\r\n .pipe(\r\n catchError((error, caught) => {\r\n this.internalActive = false;\r\n return empty();\r\n }),\r\n mergeMap(x => {\r\n this.internalActive = false;\r\n return empty();\r\n }));\r\n }\r\n\r\n const url = Net.powerShellApiRetrieveOutput.format(this.sessionId);\r\n return this.nodeConnection.get(this.context.nodeName, url, this.context.requestOptions)\r\n .pipe(\r\n catchError((error) => {\r\n SmeWebTelemetry.tracePowershellEvent(command, TelemetryEventStates.Error, { response: error.response });\r\n return this.fallbackToJea(error, command, options);\r\n }\r\n ));\r\n }));\r\n }\r\n\r\n /**\r\n * Close/Delete the session / runspace.\r\n */\r\n public close(): void {\r\n if (this.context.requestOptions.automatic) {\r\n return;\r\n }\r\n\r\n if (this.sessionId) {\r\n const sessionUri: string = Net.powerShellApiSessions.format(this.sessionId);\r\n this.sessionId = null;\r\n this.nodeConnection.deleteQuick(this.context.nodeName, sessionUri, <NodeRequestOptions>this.context.requestOptions);\r\n return;\r\n }\r\n\r\n Logging.log({\r\n level: LogLevel.Verbose,\r\n source: 'PowerShell/close',\r\n message: MsftSme.getStrings<Strings>().MsftSmeShell.Core.Error.PowerShellUnableSessionClose.message\r\n });\r\n }\r\n\r\n /**\r\n * Cancel the command.\r\n */\r\n public cancelCommand(): Observable<any> {\r\n if (this.internalActive) {\r\n this.cancelPending = true;\r\n }\r\n\r\n return empty();\r\n }\r\n\r\n /**\r\n * Perform the JEA fallback, if applicable.\r\n *\r\n * @param error The error to handle\r\n * @param command The command\r\n * @param options The request options\r\n */\r\n private fallbackToJea(error: FallbackError, command: PowerShellCommand, options: PowerShellOptions): Observable<any> {\r\n const authError = Net.isUnauthorized(error) || error.status === HttpStatusCode.BadRequest;\r\n const responseEndpoint = error && error.xhr && error.xhr.getResponseHeader(headerConstants.POWERSHELL_ENDPOINT);\r\n let requestEndpoint = (options && options.powerShellEndpoint);\r\n requestEndpoint = requestEndpoint || (this.context.requestOptions && this.context.requestOptions.powerShellEndpoint);\r\n const cancel = error.handlerError && error.handlerError.code && error.handlerError.code === 'ManageAsDialogCancel';\r\n const credSSP = (options && options.authenticationMechanism === 'Credssp');\r\n\r\n if (!cancel && authError && responseEndpoint && requestEndpoint !== responseEndpoint && !credSSP) {\r\n this.context.requestOptions.powerShellEndpoint = responseEndpoint;\r\n return this.command(command, options)\r\n .pipe(tap(() => {\r\n // The JEA request went through - persist this context in authorization manager.\r\n this.nodeConnection.saveJeaContext(this.context.nodeName, responseEndpoint);\r\n }));\r\n }\r\n\r\n // close on error if sessionId is available.\r\n if (options && options.closeOnError) {\r\n if (!this.sessionId) {\r\n this.sessionId = error && error.xhr && error.xhr.response && error.xhr.response.sessionId;\r\n }\r\n\r\n if (this.sessionId) {\r\n this.close();\r\n }\r\n }\r\n\r\n this.internalActive = false;\r\n return throwError(error);\r\n }\r\n\r\n private cancel(): Observable<any> {\r\n if (this.sessionId && this.internalActive) {\r\n const cancelUri: string = Net.powerShellApiCancelCommand.format(this.sessionId);\r\n return this.nodeConnection.post(this.context.nodeName, cancelUri, null, this.context.requestOptions);\r\n }\r\n\r\n Logging.log({\r\n level: LogLevel.Warning,\r\n source: 'PowerShell',\r\n message: MsftSme.getStrings<Strings>().MsftSmeShell.Core.Error.PowerShellUnableCancelCommand.message\r\n });\r\n return empty();\r\n }\r\n\r\n /**\r\n * Gets if timestamp was expired.\r\n */\r\n private get _isExpired(): boolean {\r\n const now = Date.now();\r\n return this.timestampInMs !== 0 && (now - this.timestampInMs) > PowerShellRaw.maxDeltaTimeInMs;\r\n }\r\n\r\n /**\r\n * Initiate command execution. It auto recycles old sessions.\r\n *\r\n * @param command the PowerShell command.\r\n */\r\n private command(command: PowerShellCommand, options?: PowerShellOptions): Observable<any> {\r\n const commandPacket: PowerShellCommandPacket = { ...command };\r\n\r\n commandPacket.useInProcRunspace = !!options?.useInProcRunspace;\r\n\r\n const polling = !!this.context.requestOptions.automatic;\r\n if (polling) {\r\n commandPacket.invokeMode = 'Polling';\r\n }\r\n\r\n if (options && options.waitTimeMs) {\r\n commandPacket.waitTimeMs = options.waitTimeMs;\r\n }\r\n\r\n const data = Net.createPropertiesJSONString(commandPacket);\r\n const newOptions: NodeRequestOptions = <NodeRequestOptions>{\r\n ...this.context.requestOptions,\r\n ...{\r\n logAudit: options && options.logAudit,\r\n logTelemetry: options && options.logTelemetry\r\n }\r\n };\r\n\r\n const endpoint = options && options.powerShellEndpoint;\r\n if (endpoint) {\r\n newOptions.powerShellEndpoint = endpoint;\r\n }\r\n\r\n const token = options && options.authToken;\r\n if (token) {\r\n newOptions.authToken = token;\r\n }\r\n\r\n const authenticationMechanism = options && options.authenticationMechanism;\r\n if (authenticationMechanism) {\r\n newOptions.authenticationMechanism = authenticationMechanism;\r\n }\r\n\r\n let commandResponse: Observable<any>;\r\n if (polling) {\r\n this.sessionId = null;\r\n commandResponse = this.nodeConnection.post(this.context.nodeName, Net.powerShellApiInvokeCommand, data, newOptions);\r\n } else if (this.sessionId == null || this._isExpired) {\r\n this.sessionId = null;\r\n const generatedName = this.context.key ? this.context.key + '-newSession' : 'instantSession';\r\n const sessionUri: string = Net.powerShellApiSessions.format(generatedName);\r\n commandResponse = this.nodeConnection.put(this.context.nodeName, sessionUri, data, newOptions);\r\n } else {\r\n const executeUri: string = Net.powerShellApiExecuteCommand.format(this.sessionId);\r\n commandResponse = this.nodeConnection.post(this.context.nodeName, executeUri, data, newOptions);\r\n }\r\n return commandResponse.pipe(catchError((error) => {\r\n SmeWebTelemetry.tracePowershellEvent(command, TelemetryEventStates.Error, { response: error.response });\r\n return throwError(error);\r\n }));\r\n }\r\n\r\n private checkCompleted(data: any): boolean {\r\n const properties: any = Net.getItemProperties(data);\r\n if (properties.sessionId) {\r\n // keep the PS session GUID\r\n this.sessionId = properties.sessionId;\r\n }\r\n\r\n if (properties.completed.toLowerCase() === 'true') {\r\n this.internalActive = false;\r\n if (this.markDelete) {\r\n this.close();\r\n }\r\n\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n}\r\n\r\n/**\r\n * The PowerShell class.\r\n *\r\n * - Single instance of PowerShell class manages single runspace.\r\n * - It queues coming requests and process one at a time sequentially.\r\n * - If a command is slow and causing with multiple responses, it aggregates response into single Q result.\r\n * - A PowerShell instance should be created through create() function, and it's statically stored/managed into _map collection.\r\n * - In QueryCache operation, it can find the PowerShell instance to run PowerShell command by using find() function.\r\n * - Once all lifetime references are gone, it deletes the runspace.\r\n * - To dispose the PowerShell instance, it can use lifetime.dispose().\r\n */\r\nexport class PowerShell {\r\n /**\r\n * Default PowerShell endpoint.\r\n */\r\n public static defaultPowerShellEndpoint = 'http://schemas.microsoft.com/powershell/microsoft.powershell';\r\n\r\n /**\r\n * SME PowerShell endpoint.\r\n */\r\n public static smePowerShellEndpoint = 'http://schemas.microsoft.com/powershell/microsoft.sme.powershell';\r\n\r\n /**\r\n * SME CredSSP PowerShell endpoint to control client role of CredSSP on the gateway.\r\n */\r\n\r\n public static smeCredSSPEndpoint = 'http://schemas.microsoft.com/powershell/microsoft.sme.credssp';\r\n\r\n /**\r\n * Static collection of PowerShell objects.\r\n */\r\n private static map: MsftSme.StringMap<PowerShell> = {};\r\n\r\n /**\r\n * Regular expression to match all the occurrences of a single quote\r\n */\r\n private static escapeRegex = new RegExp('\\'', 'g');\r\n\r\n /**\r\n * The context of PowerShell object.\r\n */\r\n private context: PowerShellContext;\r\n\r\n /**\r\n * The queue of PowerShell command requests.\r\n */\r\n private queue: PowerShellCommandItem[] = [];\r\n\r\n /**\r\n * The reference to PowerShellRaw class object.\r\n */\r\n private raw: PowerShellRaw;\r\n\r\n /**\r\n * Current data to aggregate from multiple data responses.\r\n */\r\n private currentData: any;\r\n\r\n /**\r\n * Timestamp when last command started.\r\n */\r\n private timestamp: number;\r\n\r\n /**\r\n * Create script as string.\r\n * (Notes: Use createCommand() function which is based on PowerShell module,\r\n * Update gulpfile.js to generate a PowerShell module to support Show script, JEA and localization.)\r\n *\r\n * @param resource the script text from legacy ps-code converter.\r\n * @param parameters the arguments.\r\n * @param flags (optional) the switch flags.\r\n */\r\n public static createScript(\r\n script: string,\r\n parameters?: any,\r\n flags?: string[]): string {\r\n script = 'function cvt ($o) { return ConvertFrom-Json $o }\\n function SmeSubmit {\\n' + script + '}\\n SmeSubmit';\r\n for (const parameter in parameters) {\r\n if (parameters.hasOwnProperty(parameter)) {\r\n const value = parameters[parameter];\r\n\r\n if (value == null) {\r\n script += ' -{0} $null'.format(parameter);\r\n } else {\r\n script += ' -{0} (cvt \\'{1}\\')'.format(\r\n parameter,\r\n JSON.stringify(value).replace(PowerShell.escapeRegex, '\\'\\''));\r\n }\r\n }\r\n }\r\n\r\n if (flags) {\r\n for (let i = 0; i < flags.length; i++) {\r\n script += ' -{0}'.format(flags[i]);\r\n }\r\n }\r\n\r\n return script;\r\n }\r\n\r\n /**\r\n * Create PowerShell request command.\r\n * (It creates a command object of JEA PowerShell request under restricted user role environment.)\r\n *\r\n * @param resource the script resource object with command and script data from new ps-code converter.\r\n * @param parameters the arguments.\r\n * @param flags (optional) the switch flags.\r\n * @return PowerShellCommand the PowerShell request command object.\r\n */\r\n public static createCommand(\r\n resource: { command: string, script: string, module?: string },\r\n parameters?: any,\r\n flags?: string[],\r\n resourceName?: string): PowerShellCommand {\r\n // step1: Add Jea prefix dynamically\r\n const powerShellPrefix = MsftSme.self().Init.powerShellPrefix;\r\n let command = resource.command;\r\n if (powerShellPrefix && resource && resource.command) {\r\n command = PowerShell.addPowerShellPrefix(powerShellPrefix, resource.command);\r\n }\r\n\r\n // step2: Adding parameters converter from JSON to PowerShell.\r\n // step3: Surround full content into SmeSubmit function.\r\n let script = 'function cvt($o){return ConvertFrom-Json $o}\\n function SmeSubmit{\\n' + resource.script + '}\\nSmeSubmit';\r\n\r\n // step4: Adding localized resources strings overriding Import-LocalizedData as function.\r\n if (resourceName) {\r\n const strings = MsftSme.getStrings<any>()[resourceName];\r\n if (strings && strings['PowerShell']) {\r\n const items = strings['PowerShell'];\r\n const keys = Object.keys(items);\r\n const rightSingleQuotationMark = '\\u2019';\r\n const lines = keys.map(key =>\r\n (key + '=\\''\r\n + items[key]\r\n .split(rightSingleQuotationMark)\r\n .join('\\'\\'')\r\n .split('\\'')\r\n .join('\\'\\'')\r\n + '\\'\\n'));\r\n script = 'function Import-LocalizedData{$script:strings=@{\\n' + lines.join('') + '}}' + script;\r\n }\r\n }\r\n\r\n // step5: Adding each parameter with using converter.\r\n for (const parameter in parameters) {\r\n if (parameters.hasOwnProperty(parameter)) {\r\n const value = parameters[parameter];\r\n\r\n if (value == null) {\r\n script += ' -{0} $null'.format(parameter);\r\n } else {\r\n script += ' -{0} (cvt \\'{1}\\')'.format(\r\n parameter,\r\n JSON.stringify(value).replace(PowerShell.escapeRegex, '\\'\\''));\r\n }\r\n }\r\n }\r\n\r\n // step6: Adding switch parameters.\r\n const flagParameters = {};\r\n if (flags) {\r\n for (let i = 0; i < flags.length; i++) {\r\n script += ' -{0}'.format(flags[i]);\r\n flagParameters[flags[i]] = true;\r\n }\r\n }\r\n\r\n return <PowerShellCommand>{\r\n module: resource.module,\r\n command,\r\n parameters: { ...flagParameters, ...parameters },\r\n script,\r\n state: 'ready'\r\n };\r\n }\r\n\r\n /**\r\n * Update the parameters in the PowerShellCommand object, and update the SmeSubmit part of the\r\n * script with these new parameters.\r\n *\r\n * @param command The PowerShellCommand instance to update.\r\n * @param parameters The new collection of parameters.\r\n *\r\n * Note: flags support can be added when it becomes necessary.\r\n */\r\n public static updateCommandParameters(command: PowerShellCommand, parameters?: any): void {\r\n for (const parameter in parameters) {\r\n if (parameters.hasOwnProperty(parameter)) {\r\n command.parameters[parameter] = parameters[parameter];\r\n const value = parameters[parameter];\r\n // Regular expression to capture existing parameter.\r\n const regex = new RegExp('(?<=}\\\\s+SMESubmit.*) -{0}[^-]+(?= |$)'.format(parameter), 'i');\r\n if (command.script.match(regex)) {\r\n if (value == null) {\r\n command.script = command.script.replace(regex, ' -{0} $null'.format(parameter));\r\n } else {\r\n command.script = command.script.replace(regex, ' -{0} (cvt \\'{1}\\')'.format(\r\n parameter,\r\n JSON.stringify(value).replace(PowerShell.escapeRegex, '\\'\\'')));\r\n }\r\n } else {\r\n command.script += ' -{0} (cvt \\'{1}\\')'.format(\r\n parameter,\r\n JSON.stringify(value).replace(PowerShell.escapeRegex, '\\'\\''));\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Find or create new PowerShell object.\r\n *\r\n * @param nodeName The node to connect to.\r\n * @param nodeConnection The node connection.\r\n * @param key The shared key to queue the requests to use the single runspace.\r\n * @param lifetime The lifetime container.\r\n * @param requestOptions the options to apply to every request in this session\r\n */\r\n public static create(nodeName: string, nodeConnection: NodeConnection): PowerShell;\r\n public static create(nodeName: string, nodeConnection: NodeConnection, key: string, lifetime: DisposableLifetimeManager): PowerShell;\r\n public static create(\r\n nodeName: string,\r\n nodeConnection: NodeConnection,\r\n key: string,\r\n lifetime: DisposableLifetimeManager,\r\n requestOptions: PowerShellSessionRequestOptions): PowerShell;\r\n public static create(\r\n nodeName: string,\r\n nodeConnection: NodeConnection,\r\n key?: string,\r\n lifetime?: DisposableLifetimeManager,\r\n requestOptions?: PowerShellSessionRequestOptions): PowerShell {\r\n let ps: PowerShell;\r\n if (key && lifetime) {\r\n ps = PowerShell.map[PowerShell.indexName(nodeName, key)];\r\n if (ps) {\r\n ps.addLifetime(lifetime);\r\n return ps;\r\n }\r\n }\r\n\r\n ps = new PowerShell(nodeName, nodeConnection, key, lifetime, requestOptions);\r\n if (key && lifetime) {\r\n PowerShell.map[PowerShell.indexName(nodeName, key)] = ps;\r\n }\r\n\r\n return ps;\r\n }\r\n\r\n /**\r\n * Find existing PowerShell object. Create call must be called before to create the PowerShell instance.\r\n *\r\n * @param nodeName The node name.\r\n * @param key The shared key to queue the requests to use the single runspace.\r\n */\r\n public static find(nodeName: string, key: string): PowerShell {\r\n return PowerShell.map[PowerShell.indexName(nodeName, key)];\r\n }\r\n\r\n /**\r\n * Gets the command object from string or PowerShellCommand.\r\n *\r\n * @param scriptOrCommand the script string or PowerShellCommand object.\r\n */\r\n public static getPowerShellCommand(scriptOrCommand: string | PowerShellCommand): PowerShellCommand {\r\n return typeof scriptOrCommand === 'string' ?\r\n {\r\n script: <string>scriptOrCommand,\r\n command: null,\r\n module: null,\r\n state: 'ready'\r\n }\r\n : {\r\n script: scriptOrCommand.script,\r\n command: scriptOrCommand.command,\r\n module: scriptOrCommand.module || MsftSme.self().Init.powerShellModuleName,\r\n parameters: scriptOrCommand.parameters,\r\n state: 'ready'\r\n };\r\n }\r\n\r\n /**\r\n * Create new options with debugging endpoint if requested.\r\n *\r\n * @param options the PowerShell session request options.\r\n */\r\n public static newEndpointOptions(options: NodeRequestOptions): NodeRequestOptions {\r\n // if there is no endpoint but configured with powerShellEndpoint, set debugging endpoint.\r\n const newOptions = { ...(options || {}) };\r\n if (!newOptions.powerShellEndpoint && MsftSme.self().Init.powerShellEndpoint) {\r\n newOptions.powerShellEndpoint = MsftSme.self().Init.powerShellEndpoint;\r\n }\r\n\r\n return newOptions;\r\n }\r\n\r\n /**\r\n * Create the index name in map collection.\r\n *\r\n * @param nodeName The node name.\r\n * @param key The shared key to queue the requests to use the single runspace.\r\n */\r\n private static indexName(nodeName: string, key: string): string {\r\n return nodeName + ':' + key;\r\n }\r\n\r\n /**\r\n * Adds jea prefix to the command name\r\n *\r\n * @param jeaPrefix The jea prefix originating from main.ts.\r\n * @param command The powershell command to run.\r\n */\r\n private static addPowerShellPrefix(powerShellPrefix: string, command: string): string {\r\n const hyphenSeparatorIndex = command.indexOf('-');\r\n const verb = command.substring(0, hyphenSeparatorIndex);\r\n const target = command.substring(hyphenSeparatorIndex + 1);\r\n if (target.indexOf(powerShellPrefix) === 0) {\r\n throw new Error('Command already contains prefix');\r\n }\r\n\r\n return verb + '-' + powerShellPrefix + target;\r\n }\r\n\r\n /**\r\n * Initializes a new instance of the PowerShell class.\r\n * (private constructor which shouldn't be called directly.)\r\n *\r\n * @param nodeConnection The node connection service.\r\n * @param key The shared key to queue the requests to use the single runspace.\r\n * @param lifetime The lifetime container.\r\n */\r\n constructor(\r\n nodeName: string,\r\n nodeConnection: NodeConnection,\r\n key: string,\r\n lifetime: DisposableLifetimeManager,\r\n options: PowerShellSessionRequestOptions) {\r\n this.context = {\r\n nodeName: nodeName,\r\n key: key,\r\n lifetimes: [],\r\n requestOptions: PowerShell.newEndpointOptions(options)\r\n };\r\n this.timestamp = 0;\r\n this.raw = new PowerShellRaw(nodeConnection, this.context);\r\n if (key && lifetime) {\r\n lifetime.registerForDispose(new Disposer(() => this.lifetimeDisposer(lifetime)));\r\n this.context.lifetimes.push(lifetime);\r\n }\r\n }\r\n\r\n /**\r\n * Gets node name from current context.\r\n */\r\n public get nodeName(): string {\r\n return this.context.nodeName;\r\n }\r\n\r\n /**\r\n * Run PowerShell command.\r\n *\r\n * @param command The command.\r\n * @param options The options.\r\n * @return PromiseV The result of PowerShell command.\r\n */\r\n public run(scriptOrCommand: string | PowerShellCommand, options?: PowerShellOptions): Observable<any> {\r\n const command = PowerShell.getPowerShellCommand(scriptOrCommand);\r\n if (this.context.lifetimes.length === 0) {\r\n // no disposer is assigned, force to close the session after every query.\r\n const timeoutMs: number = options && options.timeoutMs;\r\n\r\n if (options) {\r\n options.timeoutMs = timeoutMs;\r\n options.close = true;\r\n } else {\r\n options = { timeoutMs: timeoutMs, close: true };\r\n }\r\n }\r\n\r\n // queue the request.\r\n const observable = this.enqueue(command, options);\r\n return observable;\r\n }\r\n\r\n /**\r\n * Cancel PowerShell command.\r\n */\r\n public cancel(): Observable<any> {\r\n return this.raw.cancelCommand();\r\n }\r\n\r\n /**\r\n * Enqueue a command request.\r\n *\r\n * @param command The command.\r\n * @param options The options.\r\n */\r\n private enqueue(command: PowerShellCommand, options?: PowerShellOptions): Observable<any> {\r\n return Observable.create((observer: Observer<any>) => {\r\n this.queue.push(<PowerShellCommandItem>{ observer, command, options });\r\n this.dequeue();\r\n });\r\n }\r\n\r\n /**\r\n * Dequeue a command request.\r\n */\r\n private dequeue(): boolean {\r\n if (this.raw.active) {\r\n return false;\r\n }\r\n\r\n const item: PowerShellCommandItem = this.queue.shift();\r\n if (item) {\r\n this.currentData = null;\r\n this.timestamp = Date.now();\r\n this.raw.runCommand(item.command, item.options).subscribe(\r\n data => {\r\n const properties: any = Net.getItemProperties(data);\r\n this.collect(\r\n properties,\r\n item.options && item.options.timeoutMs,\r\n item.options && item.options.partial ? item.observer : null);\r\n },\r\n error => {\r\n if (item.options && item.options.close) {\r\n this.raw.close();\r\n }\r\n\r\n item.observer.error(error);\r\n this.timestamp = 0;\r\n this.dequeue();\r\n },\r\n () => {\r\n if (item.options && item.options.close) {\r\n this.raw.close();\r\n }\r\n\r\n if (!item.options || !item.options.partial) {\r\n item.observer.next(this.currentData);\r\n }\r\n\r\n item.observer.complete();\r\n this.timestamp = 0;\r\n this.dequeue();\r\n });\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n /**\r\n * Collect response result and aggregate into single object.\r\n *\r\n * @param properties The properties of response object.\r\n * @param timeoutMs The timeout to cancel command.\r\n * @param observer The observer of powershell results.\r\n */\r\n private collect(properties: any, timeoutMs: number, observer: Observer<any>): void {\r\n if (timeoutMs && this.timestamp && (Date.now() - this.timestamp > timeoutMs)) {\r\n // force to cancel the command because of unexpected longer execution.\r\n this.raw.cancelCommand();\r\n this.timestamp = 0;\r\n return;\r\n }\r\n\r\n if (observer) {\r\n // return partial data if observer is not null.\r\n observer.next(properties);\r\n this.currentData = properties;\r\n return;\r\n }\r\n\r\n if (this.currentData != null && this.currentData.results && properties.results) {\r\n let array: any[];\r\n if (MsftSme.getTypeOf(this.currentData.results) === 'array') {\r\n array = this.currentData.results;\r\n } else {\r\n array = [this.currentData.results];\r\n }\r\n\r\n if (MsftSme.getTypeOf(properties.results) === 'array') {\r\n properties.results.forEach((x: any) => {\r\n array.push(x);\r\n });\r\n } else {\r\n array.push(properties.results);\r\n }\r\n\r\n this.currentData.results = array;\r\n return;\r\n }\r\n\r\n this.currentData = properties;\r\n }\r\n\r\n /**\r\n * Attach lifetime object to disposer when disposing.\r\n *\r\n * @param lifetime The lifetime object.\r\n */\r\n private addLifetime(lifetime: DisposableLifetimeManager): void {\r\n const found: DisposableLifetimeManager = MsftSme.find(\r\n this.context.lifetimes, (value: DisposableLifetimeManager) => value === lifetime);\r\n if (!found) {\r\n this.context.lifetimes.push(lifetime);\r\n lifetime.registerForDispose(new Disposer(() => this.lifetimeDisposer(lifetime)));\r\n }\r\n }\r\n\r\n /**\r\n * Callback when disposing the container of view model.\r\n * If none, reference the PowerShell object. Dispose it. (Delete runspace)\r\n *\r\n * @param lifetime The lifetime object.\r\n */\r\n private lifetimeDisposer(lifetime: DisposableLifetimeManager): void {\r\n const found: DisposableLifetimeManager = MsftSme.find(\r\n this.context.lifetimes, (value: DisposableLifetimeManager) => value === lifetime);\r\n if (found) {\r\n MsftSme.remove(this.context.lifetimes, lifetime);\r\n if (this.context.lifetimes.length === 0) {\r\n // cancel queue command requests.\r\n this.queue.forEach((value: PowerShellCommandItem, index: number, array: PowerShellCommandItem[]) => {\r\n value.observer.next(null);\r\n value.observer.complete();\r\n });\r\n\r\n // delete from the map collection and delete the runspace/session.\r\n delete PowerShell.map[PowerShell.indexName(this.context.nodeName, this.context.key)];\r\n this.raw.dispose();\r\n }\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"sources":["../../../packages/core/data/powershell.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,UAAU,EAAY,UAAU,EAAE,MAAM,MAAM,CAAC;AAE/D,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,eAAe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KAAK,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;gBAC9B,CAAC,CAAC,CAAC;gBAEH,kEAAkE;gBAClE,OAAO,UAAU,CAAC,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;gBACrF,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;aACtB;SACJ;IACL,CAAC;;AA1gBD;;GAEG;AACW,oCAAyB,GAAG,8DAA8D,CAAC;AAEzG;;GAEG;AACW,gCAAqB,GAAG,kEAAkE,CAAC;AAEzG;;GAEG;AACW,6BAAkB,GAAG,8EAA8E,CAAC;AAElH;;GAEG;AACY,cAAG,GAAkC,EAAE,CAAC;AAEvD;;GAEG;AACY,sBAAW,GAAG,IAAI,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC","file":"powershell.js","sourcesContent":["\r\nimport { empty, Observable, Observer, throwError } from 'rxjs';\r\nimport { AjaxError } from 'rxjs/ajax';\r\nimport { catchError, expand, mergeMap, tap } from 'rxjs/operators';\r\nimport { LogLevel } from '../diagnostics/log-level';\r\nimport { Logging } from '../diagnostics/logging';\r\nimport { SmeWebTelemetry } from '../diagnostics/sme-web-telemetry';\r\nimport { TelemetryEventStates } from '../diagnostics/sme-web-telemetry-models';\r\nimport { Strings } from '../generated/strings';\r\nimport { Disposable, DisposableLifetimeManager, Disposer } from './disposable';\r\nimport { headerConstants, HttpStatusCode } from './http-constants';\r\nimport { Net } from './net';\r\nimport { NodeConnection, NodeRequestOptions } from './node-connection';\r\n\r\n/**\r\n * PowerShell run options.\r\n */\r\nexport interface PowerShellOptions extends NodeRequestOptions {\r\n /**\r\n * Close the runspace after the call.\r\n * (default is false)\r\n */\r\n close?: boolean;\r\n\r\n /**\r\n * Close the runspace on error.\r\n */\r\n closeOnError?: boolean;\r\n\r\n /**\r\n * Timeout milliseconds to shutdown the session.\r\n * (default is null and forever)\r\n */\r\n timeoutMs?: number;\r\n\r\n /**\r\n * Processing data progressively instead of waiting all result.\r\n */\r\n partial?: boolean;\r\n\r\n /**\r\n * Specify the initial waiting time before starting polling of result of invoke script.\r\n */\r\n waitTimeMs?: number;\r\n}\r\n\r\n/**\r\n * The node request options to control the underlying node connections in a powershell session\r\n */\r\nexport interface PowerShellSessionRequestOptions extends NodeRequestOptions {\r\n /**\r\n * Specify the session pool mode on the gateway.\r\n */\r\n automatic?: boolean;\r\n}\r\n\r\n/**\r\n * PowerShell context object interface.\r\n */\r\nexport interface PowerShellContext {\r\n /**\r\n * The node name.\r\n */\r\n nodeName: string;\r\n\r\n /**\r\n * The shared key name for runspace.\r\n */\r\n key: string;\r\n\r\n /**\r\n * The array of referenced containers.\r\n */\r\n lifetimes: DisposableLifetimeManager[];\r\n\r\n /**\r\n * The request options for the powershell session\r\n */\r\n requestOptions: PowerShellSessionRequestOptions;\r\n}\r\n\r\n/**\r\n * PowerShell command object.\r\n */\r\n export interface PowerShellCommandWithoutState {\r\n /**\r\n * The name of PowerShell module. (optional, it uses default module if not specified.)\r\n */\r\n module?: string;\r\n\r\n /**\r\n * The command name.\r\n */\r\n command: string;\r\n\r\n /**\r\n * The parameters (arguments).\r\n */\r\n parameters?: any;\r\n\r\n /**\r\n * Set if the command should be run in a local runspace.\r\n */\r\n useInProcRunspace?: boolean;\r\n\r\n /**\r\n * The script string.\r\n */\r\n script: string;\r\n}\r\n\r\n\r\n/**\r\n * PowerShell command object.\r\n */\r\nexport interface PowerShellCommand extends PowerShellCommandWithoutState {\r\n /**\r\n * The state of command object.\r\n */\r\n state: string;\r\n}\r\n\r\n/**\r\n * PowerShell command queue item.\r\n */\r\nexport interface PowerShellCommandItem {\r\n /**\r\n * The command to execute.\r\n */\r\n command: PowerShellCommand;\r\n\r\n /**\r\n * Options for how to handle the command (reserved)\r\n */\r\n options?: PowerShellOptions;\r\n\r\n /**\r\n * Deferred object currently waiting for command run.\r\n */\r\n observer: Observer<any>;\r\n}\r\n\r\ninterface PowerShellCommandPacket extends PowerShellCommand {\r\n\r\n /**\r\n * The invocation mode with Net.powerShellApiInvokeCommand API.\r\n * Default is WorkItem which uses WebSocket communication.\r\n * Polling mode uses pooled runspaces on the gateway and the gateway will recycle and shutdown them automatically.\r\n */\r\n invokeMode?: 'WorkItem' | 'Polling';\r\n\r\n /**\r\n * Specify the initial waiting time before starting polling of result of invoke script.\r\n */\r\n waitTimeMs?: number;\r\n}\r\n\r\n/**\r\n * The PowerShellSession class.\r\n */\r\nexport class PowerShellSession implements Disposable {\r\n /**\r\n * Initializes a new instance of the PowerShellSession class.\r\n *\r\n * @param powerShell the PowerShell object.\r\n * @param lifetime the disposable lifetime manager object.\r\n */\r\n public constructor(powerShell: PowerShell);\r\n public constructor(powerShell: PowerShell, lifetime: DisposableLifetimeManager);\r\n public constructor(public powerShell: PowerShell, private lifetime?: DisposableLifetimeManager) {\r\n }\r\n\r\n /**\r\n * Gets the node name of session.\r\n */\r\n public get nodeName(): string {\r\n return this.powerShell.nodeName;\r\n }\r\n\r\n /**\r\n * Dispose the session object.\r\n */\r\n public dispose(): void {\r\n if (this.lifetime) {\r\n this.lifetime.dispose();\r\n }\r\n }\r\n}\r\n\r\nexport interface FallbackError extends AjaxError {\r\n handlerError: {\r\n message: string;\r\n code: 'ManageAsDialogCancel';\r\n };\r\n}\r\n\r\n/**\r\n * Class containing methods related to PowerShell runspace creation/deletion/command using PowerShell Raw API plugin.\r\n * - It's auto holding the session as long as it's used within last 3 minutes.\r\n */\r\nexport class PowerShellRaw implements Disposable {\r\n // 3 minutes holding time.\r\n private static maxDeltaTimeInMs: number = 3 * 60 * 1000;\r\n private sessionId: string;\r\n private timestampInMs = 0;\r\n private markDelete = false;\r\n private internalActive = false;\r\n private cancelPending = false;\r\n\r\n /**\r\n * Initializes a new instance of the PowerShellRaw class.\r\n *\r\n * @param nodeConnection The node connection service.\r\n * @param context The context of PowerShell run.\r\n */\r\n constructor(private nodeConnection: NodeConnection, private context: PowerShellContext) {\r\n }\r\n\r\n /**\r\n * Gets active status of PowerShell execution.\r\n */\r\n public get active(): boolean {\r\n return this.internalActive;\r\n }\r\n\r\n /**\r\n * Dispose the runspace.\r\n */\r\n public dispose(): void {\r\n if (!this.active) {\r\n // only close sessions that have been created.\r\n // If a result was cached a component may not\r\n // execute a command and still dispose the session\r\n // when the component is destroyed.\r\n if (this.sessionId) {\r\n this.close();\r\n }\r\n } else {\r\n this.markDelete = true;\r\n }\r\n }\r\n\r\n /**\r\n * Runs the given command\r\n *\r\n * @param command The command to execute.\r\n * @param options the powershell options.\r\n */\r\n public runCommand(command: PowerShellCommand, options?: PowerShellOptions): Observable<any> {\r\n // take the timestamp only success/healthy case.\r\n // error session would be auto-deleted after expiration time.\r\n this.internalActive = true;\r\n return this.command(command, options)\r\n .pipe(\r\n catchError((error) => this.fallbackToJea(error, command, options)),\r\n expand((data: any, index: number) => {\r\n this.timestampInMs = Date.now();\r\n if (this.checkCompleted(data)) {\r\n return empty();\r\n }\r\n\r\n if (this.cancelPending) {\r\n // submit cancel request.\r\n // after set active state to false and complete the observable.\r\n this.cancelPending = false;\r\n return this.cancel()\r\n .pipe(\r\n catchError((error, caught) => {\r\n this.internalActive = false;\r\n return empty();\r\n }),\r\n mergeMap(x => {\r\n this.internalActive = false;\r\n return empty();\r\n }));\r\n }\r\n\r\n const url = Net.powerShellApiRetrieveOutput.format(this.sessionId);\r\n return this.nodeConnection.get(this.context.nodeName, url, this.context.requestOptions)\r\n .pipe(\r\n catchError((error) => {\r\n SmeWebTelemetry.tracePowershellEvent(command, TelemetryEventStates.Error, { response: error.response });\r\n return this.fallbackToJea(error, command, options);\r\n }\r\n ));\r\n }));\r\n }\r\n\r\n /**\r\n * Close/Delete the session / runspace.\r\n */\r\n public close(): void {\r\n if (this.context.requestOptions.automatic) {\r\n return;\r\n }\r\n\r\n if (this.sessionId) {\r\n const sessionUri: string = Net.powerShellApiSessions.format(this.sessionId);\r\n this.sessionId = null;\r\n this.nodeConnection.deleteQuick(this.context.nodeName, sessionUri, <NodeRequestOptions>this.context.requestOptions);\r\n return;\r\n }\r\n\r\n Logging.log({\r\n level: LogLevel.Verbose,\r\n source: 'PowerShell/close',\r\n message: MsftSme.getStrings<Strings>().MsftSmeShell.Core.Error.PowerShellUnableSessionClose.message\r\n });\r\n }\r\n\r\n /**\r\n * Cancel the command.\r\n */\r\n public cancelCommand(): Observable<any> {\r\n if (this.internalActive) {\r\n this.cancelPending = true;\r\n }\r\n\r\n return empty();\r\n }\r\n\r\n /**\r\n * Perform the JEA fallback, if applicable.\r\n *\r\n * @param error The error to handle\r\n * @param command The command\r\n * @param options The request options\r\n */\r\n private fallbackToJea(error: FallbackError, command: PowerShellCommand, options: PowerShellOptions): Observable<any> {\r\n const authError = Net.isUnauthorized(error) || error.status === HttpStatusCode.BadRequest;\r\n const responseEndpoint = error && error.xhr && error.xhr.getResponseHeader(headerConstants.POWERSHELL_ENDPOINT);\r\n let requestEndpoint = (options && options.powerShellEndpoint);\r\n requestEndpoint = requestEndpoint || (this.context.requestOptions && this.context.requestOptions.powerShellEndpoint);\r\n const cancel = error.handlerError && error.handlerError.code && error.handlerError.code === 'ManageAsDialogCancel';\r\n const credSSP = (options && options.authenticationMechanism === 'Credssp');\r\n\r\n if (!cancel && authError && responseEndpoint && requestEndpoint !== responseEndpoint && !credSSP) {\r\n this.context.requestOptions.powerShellEndpoint = responseEndpoint;\r\n return this.command(command, options)\r\n .pipe(tap(() => {\r\n // The JEA request went through - persist this context in authorization manager.\r\n this.nodeConnection.saveJeaContext(this.context.nodeName, responseEndpoint);\r\n }));\r\n }\r\n\r\n // close on error if sessionId is available.\r\n if (options && options.closeOnError) {\r\n if (!this.sessionId) {\r\n this.sessionId = error && error.xhr && error.xhr.response && error.xhr.response.sessionId;\r\n }\r\n\r\n if (this.sessionId) {\r\n this.close();\r\n }\r\n }\r\n\r\n this.internalActive = false;\r\n return throwError(error);\r\n }\r\n\r\n private cancel(): Observable<any> {\r\n if (this.sessionId && this.internalActive) {\r\n const cancelUri: string = Net.powerShellApiCancelCommand.format(this.sessionId);\r\n return this.nodeConnection.post(this.context.nodeName, cancelUri, null, this.context.requestOptions);\r\n }\r\n\r\n Logging.log({\r\n level: LogLevel.Warning,\r\n source: 'PowerShell',\r\n message: MsftSme.getStrings<Strings>().MsftSmeShell.Core.Error.PowerShellUnableCancelCommand.message\r\n });\r\n return empty();\r\n }\r\n\r\n /**\r\n * Gets if timestamp was expired.\r\n */\r\n private get _isExpired(): boolean {\r\n const now = Date.now();\r\n return this.timestampInMs !== 0 && (now - this.timestampInMs) > PowerShellRaw.maxDeltaTimeInMs;\r\n }\r\n\r\n /**\r\n * Initiate command execution. It auto recycles old sessions.\r\n *\r\n * @param command the PowerShell command.\r\n */\r\n private command(command: PowerShellCommand, options?: PowerShellOptions): Observable<any> {\r\n const commandPacket: PowerShellCommandPacket = { ...command };\r\n\r\n commandPacket.useInProcRunspace = !!options?.useInProcRunspace;\r\n\r\n const polling = !!this.context.requestOptions.automatic;\r\n if (polling) {\r\n commandPacket.invokeMode = 'Polling';\r\n }\r\n\r\n if (options && options.waitTimeMs) {\r\n commandPacket.waitTimeMs = options.waitTimeMs;\r\n }\r\n\r\n const data = Net.createPropertiesJSONString(commandPacket);\r\n const newOptions: NodeRequestOptions = <NodeRequestOptions>{\r\n ...this.context.requestOptions,\r\n ...{\r\n logAudit: options && options.logAudit,\r\n logTelemetry: options && options.logTelemetry\r\n }\r\n };\r\n\r\n const endpoint = options && options.powerShellEndpoint;\r\n if (endpoint) {\r\n newOptions.powerShellEndpoint = endpoint;\r\n }\r\n\r\n const token = options && options.authToken;\r\n if (token) {\r\n newOptions.authToken = token;\r\n }\r\n\r\n const authenticationMechanism = options && options.authenticationMechanism;\r\n if (authenticationMechanism) {\r\n newOptions.authenticationMechanism = authenticationMechanism;\r\n }\r\n\r\n let commandResponse: Observable<any>;\r\n if (polling) {\r\n this.sessionId = null;\r\n commandResponse = this.nodeConnection.post(this.context.nodeName, Net.powerShellApiInvokeCommand, data, newOptions);\r\n } else if (this.sessionId == null || this._isExpired) {\r\n this.sessionId = null;\r\n const generatedName = this.context.key ? this.context.key + '-newSession' : 'instantSession';\r\n const sessionUri: string = Net.powerShellApiSessions.format(generatedName);\r\n commandResponse = this.nodeConnection.put(this.context.nodeName, sessionUri, data, newOptions);\r\n } else {\r\n const executeUri: string = Net.powerShellApiExecuteCommand.format(this.sessionId);\r\n commandResponse = this.nodeConnection.post(this.context.nodeName, executeUri, data, newOptions);\r\n }\r\n return commandResponse.pipe(catchError((error) => {\r\n SmeWebTelemetry.tracePowershellEvent(command, TelemetryEventStates.Error, { response: error.response });\r\n return throwError(error);\r\n }));\r\n }\r\n\r\n private checkCompleted(data: any): boolean {\r\n const properties: any = Net.getItemProperties(data);\r\n if (properties.sessionId) {\r\n // keep the PS session GUID\r\n this.sessionId = properties.sessionId;\r\n }\r\n\r\n if (properties.completed.toLowerCase() === 'true') {\r\n this.internalActive = false;\r\n if (this.markDelete) {\r\n this.close();\r\n }\r\n\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n}\r\n\r\n/**\r\n * The PowerShell class.\r\n *\r\n * - Single instance of PowerShell class manages single runspace.\r\n * - It queues coming requests and process one at a time sequentially.\r\n * - If a command is slow and causing with multiple responses, it aggregates response into single Q result.\r\n * - A PowerShell instance should be created through create() function, and it's statically stored/managed into _map collection.\r\n * - In QueryCache operation, it can find the PowerShell instance to run PowerShell command by using find() function.\r\n * - Once all lifetime references are gone, it deletes the runspace.\r\n * - To dispose the PowerShell instance, it can use lifetime.dispose().\r\n */\r\nexport class PowerShell {\r\n /**\r\n * Default PowerShell endpoint.\r\n */\r\n public static defaultPowerShellEndpoint = 'http://schemas.microsoft.com/powershell/microsoft.powershell';\r\n\r\n /**\r\n * SME PowerShell endpoint.\r\n */\r\n public static smePowerShellEndpoint = 'http://schemas.microsoft.com/powershell/microsoft.sme.powershell';\r\n\r\n /**\r\n * WAC (v2) CredSSP PowerShell endpoint to control client role of CredSSP on the gateway.\r\n */\r\n public static wacCredSSPEndpoint = 'http://schemas.microsoft.com/powershell/Microsoft.WindowsAdminCenter.Credssp';\r\n\r\n /**\r\n * Static collection of PowerShell objects.\r\n */\r\n private static map: MsftSme.StringMap<PowerShell> = {};\r\n\r\n /**\r\n * Regular expression to match all the occurrences of a single quote\r\n */\r\n private static escapeRegex = new RegExp('\\'', 'g');\r\n\r\n /**\r\n * The context of PowerShell object.\r\n */\r\n private context: PowerShellContext;\r\n\r\n /**\r\n * The queue of PowerShell command requests.\r\n */\r\n private queue: PowerShellCommandItem[] = [];\r\n\r\n /**\r\n * The reference to PowerShellRaw class object.\r\n */\r\n private raw: PowerShellRaw;\r\n\r\n /**\r\n * Current data to aggregate from multiple data responses.\r\n */\r\n private currentData: any;\r\n\r\n /**\r\n * Timestamp when last command started.\r\n */\r\n private timestamp: number;\r\n\r\n /**\r\n * Create script as string.\r\n * (Notes: Use createCommand() function which is based on PowerShell module,\r\n * Update gulpfile.js to generate a PowerShell module to support Show script, JEA and localization.)\r\n *\r\n * @param resource the script text from legacy ps-code converter.\r\n * @param parameters the arguments.\r\n * @param flags (optional) the switch flags.\r\n */\r\n public static createScript(\r\n script: string,\r\n parameters?: any,\r\n flags?: string[]): string {\r\n script = 'function cvt ($o) { return ConvertFrom-Json $o }\\n function SmeSubmit {\\n' + script + '}\\n SmeSubmit';\r\n for (const parameter in parameters) {\r\n if (parameters.hasOwnProperty(parameter)) {\r\n const value = parameters[parameter];\r\n\r\n if (value == null) {\r\n script += ' -{0} $null'.format(parameter);\r\n } else {\r\n script += ' -{0} (cvt \\'{1}\\')'.format(\r\n parameter,\r\n JSON.stringify(value).replace(PowerShell.escapeRegex, '\\'\\''));\r\n }\r\n }\r\n }\r\n\r\n if (flags) {\r\n for (let i = 0; i < flags.length; i++) {\r\n script += ' -{0}'.format(flags[i]);\r\n }\r\n }\r\n\r\n return script;\r\n }\r\n\r\n /**\r\n * Create PowerShell request command.\r\n * (It creates a command object of JEA PowerShell request under restricted user role environment.)\r\n *\r\n * @param resource the script resource object with command and script data from new ps-code converter.\r\n * @param parameters the arguments.\r\n * @param flags (optional) the switch flags.\r\n * @return PowerShellCommand the PowerShell request command object.\r\n */\r\n public static createCommand(\r\n resource: { command: string, script: string, module?: string },\r\n parameters?: any,\r\n flags?: string[],\r\n resourceName?: string): PowerShellCommand {\r\n // step1: Add Jea prefix dynamically\r\n const powerShellPrefix = MsftSme.self().Init.powerShellPrefix;\r\n let command = resource.command;\r\n if (powerShellPrefix && resource && resource.command) {\r\n command = PowerShell.addPowerShellPrefix(powerShellPrefix, resource.command);\r\n }\r\n\r\n // step2: Adding parameters converter from JSON to PowerShell.\r\n // step3: Surround full content into SmeSubmit function.\r\n let script = 'function cvt($o){return ConvertFrom-Json $o}\\n function SmeSubmit{\\n' + resource.script + '}\\nSmeSubmit';\r\n\r\n // step4: Adding localized resources strings overriding Import-LocalizedData as function.\r\n if (resourceName) {\r\n const strings = MsftSme.getStrings<any>()[resourceName];\r\n if (strings && strings['PowerShell']) {\r\n const items = strings['PowerShell'];\r\n const keys = Object.keys(items);\r\n const rightSingleQuotationMark = '\\u2019';\r\n const lines = keys.map(key =>\r\n (key + '=\\''\r\n + items[key]\r\n .split(rightSingleQuotationMark)\r\n .join('\\'\\'')\r\n .split('\\'')\r\n .join('\\'\\'')\r\n + '\\'\\n'));\r\n script = 'function Import-LocalizedData{$script:strings=@{\\n' + lines.join('') + '}}' + script;\r\n }\r\n }\r\n\r\n // step5: Adding each parameter with using converter.\r\n for (const parameter in parameters) {\r\n if (parameters.hasOwnProperty(parameter)) {\r\n const value = parameters[parameter];\r\n\r\n if (value == null) {\r\n script += ' -{0} $null'.format(parameter);\r\n } else {\r\n script += ' -{0} (cvt \\'{1}\\')'.format(\r\n parameter,\r\n JSON.stringify(value).replace(PowerShell.escapeRegex, '\\'\\''));\r\n }\r\n }\r\n }\r\n\r\n // step6: Adding switch parameters.\r\n const flagParameters = {};\r\n if (flags) {\r\n for (let i = 0; i < flags.length; i++) {\r\n script += ' -{0}'.format(flags[i]);\r\n flagParameters[flags[i]] = true;\r\n }\r\n }\r\n\r\n return <PowerShellCommand>{\r\n module: resource.module,\r\n command,\r\n parameters: { ...flagParameters, ...parameters },\r\n script,\r\n state: 'ready'\r\n };\r\n }\r\n\r\n /**\r\n * Update the parameters in the PowerShellCommand object, and update the SmeSubmit part of the\r\n * script with these new parameters.\r\n *\r\n * @param command The PowerShellCommand instance to update.\r\n * @param parameters The new collection of parameters.\r\n *\r\n * Note: flags support can be added when it becomes necessary.\r\n */\r\n public static updateCommandParameters(command: PowerShellCommand, parameters?: any): void {\r\n for (const parameter in parameters) {\r\n if (parameters.hasOwnProperty(parameter)) {\r\n command.parameters[parameter] = parameters[parameter];\r\n const value = parameters[parameter];\r\n // Regular expression to capture existing parameter.\r\n const regex = new RegExp('(?<=}\\\\s+SMESubmit.*) -{0}[^-]+(?= |$)'.format(parameter), 'i');\r\n if (command.script.match(regex)) {\r\n if (value == null) {\r\n command.script = command.script.replace(regex, ' -{0} $null'.format(parameter));\r\n } else {\r\n command.script = command.script.replace(regex, ' -{0} (cvt \\'{1}\\')'.format(\r\n parameter,\r\n JSON.stringify(value).replace(PowerShell.escapeRegex, '\\'\\'')));\r\n }\r\n } else {\r\n command.script += ' -{0} (cvt \\'{1}\\')'.format(\r\n parameter,\r\n JSON.stringify(value).replace(PowerShell.escapeRegex, '\\'\\''));\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Find or create new PowerShell object.\r\n *\r\n * @param nodeName The node to connect to.\r\n * @param nodeConnection The node connection.\r\n * @param key The shared key to queue the requests to use the single runspace.\r\n * @param lifetime The lifetime container.\r\n * @param requestOptions the options to apply to every request in this session\r\n */\r\n public static create(nodeName: string, nodeConnection: NodeConnection): PowerShell;\r\n public static create(nodeName: string, nodeConnection: NodeConnection, key: string, lifetime: DisposableLifetimeManager): PowerShell;\r\n public static create(\r\n nodeName: string,\r\n nodeConnection: NodeConnection,\r\n key: string,\r\n lifetime: DisposableLifetimeManager,\r\n requestOptions: PowerShellSessionRequestOptions): PowerShell;\r\n public static create(\r\n nodeName: string,\r\n nodeConnection: NodeConnection,\r\n key?: string,\r\n lifetime?: DisposableLifetimeManager,\r\n requestOptions?: PowerShellSessionRequestOptions): PowerShell {\r\n let ps: PowerShell;\r\n if (key && lifetime) {\r\n ps = PowerShell.map[PowerShell.indexName(nodeName, key)];\r\n if (ps) {\r\n ps.addLifetime(lifetime);\r\n return ps;\r\n }\r\n }\r\n\r\n ps = new PowerShell(nodeName, nodeConnection, key, lifetime, requestOptions);\r\n if (key && lifetime) {\r\n PowerShell.map[PowerShell.indexName(nodeName, key)] = ps;\r\n }\r\n\r\n return ps;\r\n }\r\n\r\n /**\r\n * Find existing PowerShell object. Create call must be called before to create the PowerShell instance.\r\n *\r\n * @param nodeName The node name.\r\n * @param key The shared key to queue the requests to use the single runspace.\r\n */\r\n public static find(nodeName: string, key: string): PowerShell {\r\n return PowerShell.map[PowerShell.indexName(nodeName, key)];\r\n }\r\n\r\n /**\r\n * Gets the command object from string or PowerShellCommand.\r\n *\r\n * @param scriptOrCommand the script string or PowerShellCommand object.\r\n */\r\n public static getPowerShellCommand(scriptOrCommand: string | PowerShellCommand): PowerShellCommand {\r\n return typeof scriptOrCommand === 'string' ?\r\n {\r\n script: <string>scriptOrCommand,\r\n command: null,\r\n module: null,\r\n state: 'ready'\r\n }\r\n : {\r\n script: scriptOrCommand.script,\r\n command: scriptOrCommand.command,\r\n module: scriptOrCommand.module || MsftSme.self().Init.powerShellModuleName,\r\n parameters: scriptOrCommand.parameters,\r\n state: 'ready'\r\n };\r\n }\r\n\r\n /**\r\n * Create new options with debugging endpoint if requested.\r\n *\r\n * @param options the PowerShell session request options.\r\n */\r\n public static newEndpointOptions(options: NodeRequestOptions): NodeRequestOptions {\r\n // if there is no endpoint but configured with powerShellEndpoint, set debugging endpoint.\r\n const newOptions = { ...(options || {}) };\r\n if (!newOptions.powerShellEndpoint && MsftSme.self().Init.powerShellEndpoint) {\r\n newOptions.powerShellEndpoint = MsftSme.self().Init.powerShellEndpoint;\r\n }\r\n\r\n return newOptions;\r\n }\r\n\r\n /**\r\n * Create the index name in map collection.\r\n *\r\n * @param nodeName The node name.\r\n * @param key The shared key to queue the requests to use the single runspace.\r\n */\r\n private static indexName(nodeName: string, key: string): string {\r\n return nodeName + ':' + key;\r\n }\r\n\r\n /**\r\n * Adds jea prefix to the command name\r\n *\r\n * @param jeaPrefix The jea prefix originating from main.ts.\r\n * @param command The powershell command to run.\r\n */\r\n private static addPowerShellPrefix(powerShellPrefix: string, command: string): string {\r\n const hyphenSeparatorIndex = command.indexOf('-');\r\n const verb = command.substring(0, hyphenSeparatorIndex);\r\n const target = command.substring(hyphenSeparatorIndex + 1);\r\n if (target.indexOf(powerShellPrefix) === 0) {\r\n throw new Error('Command already contains prefix');\r\n }\r\n\r\n return verb + '-' + powerShellPrefix + target;\r\n }\r\n\r\n /**\r\n * Initializes a new instance of the PowerShell class.\r\n * (private constructor which shouldn't be called directly.)\r\n *\r\n * @param nodeConnection The node connection service.\r\n * @param key The shared key to queue the requests to use the single runspace.\r\n * @param lifetime The lifetime container.\r\n */\r\n constructor(\r\n nodeName: string,\r\n nodeConnection: NodeConnection,\r\n key: string,\r\n lifetime: DisposableLifetimeManager,\r\n options: PowerShellSessionRequestOptions) {\r\n this.context = {\r\n nodeName: nodeName,\r\n key: key,\r\n lifetimes: [],\r\n requestOptions: PowerShell.newEndpointOptions(options)\r\n };\r\n this.timestamp = 0;\r\n this.raw = new PowerShellRaw(nodeConnection, this.context);\r\n if (key && lifetime) {\r\n lifetime.registerForDispose(new Disposer(() => this.lifetimeDisposer(lifetime)));\r\n this.context.lifetimes.push(lifetime);\r\n }\r\n }\r\n\r\n /**\r\n * Gets node name from current context.\r\n */\r\n public get nodeName(): string {\r\n return this.context.nodeName;\r\n }\r\n\r\n /**\r\n * Run PowerShell command.\r\n *\r\n * @param command The command.\r\n * @param options The options.\r\n * @return PromiseV The result of PowerShell command.\r\n */\r\n public run(scriptOrCommand: string | PowerShellCommand, options?: PowerShellOptions): Observable<any> {\r\n const command = PowerShell.getPowerShellCommand(scriptOrCommand);\r\n if (this.context.lifetimes.length === 0) {\r\n // no disposer is assigned, force to close the session after every query.\r\n const timeoutMs: number = options && options.timeoutMs;\r\n\r\n if (options) {\r\n options.timeoutMs = timeoutMs;\r\n options.close = true;\r\n } else {\r\n options = { timeoutMs: timeoutMs, close: true };\r\n }\r\n }\r\n\r\n // queue the request.\r\n const observable = this.enqueue(command, options);\r\n return observable;\r\n }\r\n\r\n /**\r\n * Cancel PowerShell command.\r\n */\r\n public cancel(): Observable<any> {\r\n return this.raw.cancelCommand();\r\n }\r\n\r\n /**\r\n * Enqueue a command request.\r\n *\r\n * @param command The command.\r\n * @param options The options.\r\n */\r\n private enqueue(command: PowerShellCommand, options?: PowerShellOptions): Observable<any> {\r\n return Observable.create((observer: Observer<any>) => {\r\n this.queue.push(<PowerShellCommandItem>{ observer, command, options });\r\n this.dequeue();\r\n });\r\n }\r\n\r\n /**\r\n * Dequeue a command request.\r\n */\r\n private dequeue(): boolean {\r\n if (this.raw.active) {\r\n return false;\r\n }\r\n\r\n const item: PowerShellCommandItem = this.queue.shift();\r\n if (item) {\r\n this.currentData = null;\r\n this.timestamp = Date.now();\r\n this.raw.runCommand(item.command, item.options).subscribe(\r\n data => {\r\n const properties: any = Net.getItemProperties(data);\r\n this.collect(\r\n properties,\r\n item.options && item.options.timeoutMs,\r\n item.options && item.options.partial ? item.observer : null);\r\n },\r\n error => {\r\n if (item.options && item.options.close) {\r\n this.raw.close();\r\n }\r\n\r\n item.observer.error(error);\r\n this.timestamp = 0;\r\n this.dequeue();\r\n },\r\n () => {\r\n if (item.options && item.options.close) {\r\n this.raw.close();\r\n }\r\n\r\n if (!item.options || !item.options.partial) {\r\n item.observer.next(this.currentData);\r\n }\r\n\r\n item.observer.complete();\r\n this.timestamp = 0;\r\n this.dequeue();\r\n });\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n /**\r\n * Collect response result and aggregate into single object.\r\n *\r\n * @param properties The properties of response object.\r\n * @param timeoutMs The timeout to cancel command.\r\n * @param observer The observer of powershell results.\r\n */\r\n private collect(properties: any, timeoutMs: number, observer: Observer<any>): void {\r\n if (timeoutMs && this.timestamp && (Date.now() - this.timestamp > timeoutMs)) {\r\n // force to cancel the command because of unexpected longer execution.\r\n this.raw.cancelCommand();\r\n this.timestamp = 0;\r\n return;\r\n }\r\n\r\n if (observer) {\r\n // return partial data if observer is not null.\r\n observer.next(properties);\r\n this.currentData = properties;\r\n return;\r\n }\r\n\r\n if (this.currentData != null && this.currentData.results && properties.results) {\r\n let array: any[];\r\n if (MsftSme.getTypeOf(this.currentData.results) === 'array') {\r\n array = this.currentData.results;\r\n } else {\r\n array = [this.currentData.results];\r\n }\r\n\r\n if (MsftSme.getTypeOf(properties.results) === 'array') {\r\n properties.results.forEach((x: any) => {\r\n array.push(x);\r\n });\r\n } else {\r\n array.push(properties.results);\r\n }\r\n\r\n this.currentData.results = array;\r\n return;\r\n }\r\n\r\n this.currentData = properties;\r\n }\r\n\r\n /**\r\n * Attach lifetime object to disposer when disposing.\r\n *\r\n * @param lifetime The lifetime object.\r\n */\r\n private addLifetime(lifetime: DisposableLifetimeManager): void {\r\n const found: DisposableLifetimeManager = MsftSme.find(\r\n this.context.lifetimes, (value: DisposableLifetimeManager) => value === lifetime);\r\n if (!found) {\r\n this.context.lifetimes.push(lifetime);\r\n lifetime.registerForDispose(new Disposer(() => this.lifetimeDisposer(lifetime)));\r\n }\r\n }\r\n\r\n /**\r\n * Callback when disposing the container of view model.\r\n * If none, reference the PowerShell object. Dispose it. (Delete runspace)\r\n *\r\n * @param lifetime The lifetime object.\r\n */\r\n private lifetimeDisposer(lifetime: DisposableLifetimeManager): void {\r\n const found: DisposableLifetimeManager = MsftSme.find(\r\n this.context.lifetimes, (value: DisposableLifetimeManager) => value === lifetime);\r\n if (found) {\r\n MsftSme.remove(this.context.lifetimes, lifetime);\r\n if (this.context.lifetimes.length === 0) {\r\n // cancel queue command requests.\r\n this.queue.forEach((value: PowerShellCommandItem, index: number, array: PowerShellCommandItem[]) => {\r\n value.observer.next(null);\r\n value.observer.complete();\r\n });\r\n\r\n // delete from the map collection and delete the runspace/session.\r\n delete PowerShell.map[PowerShell.indexName(this.context.nodeName, this.context.key)];\r\n this.raw.dispose();\r\n }\r\n }\r\n }\r\n}\r\n"]}
@@ -4,6 +4,7 @@ import { Rpc } from '../rpc/rpc';
4
4
  import { RpcWorkItemFind, RpcWorkItemFindResult } from '../rpc/work-item-find/rpc-work-item-find-model';
5
5
  import { RpcWorkItem } from '../rpc/work-item/rpc-work-item-model';
6
6
  import { Notification, NotificationEvent } from './notification';
7
+ import { NotificationMessage } from './notification-message';
7
8
  import { NotificationState } from './notification-state';
8
9
  import { PowerShellWorkItemMessage } from './powershell-notification';
9
10
  import { SocketMessage } from './socket-signalr';
@@ -121,6 +122,16 @@ export declare class NotificationManager {
121
122
  * @return notification the notification object.
122
123
  */
123
124
  addFromRecover(recover: RecoveredWorkItem): void;
125
+ /**
126
+ * Add initial notification for Message Notification.
127
+ *
128
+ * @param id the notification ID.
129
+ * @param workItem the RPC work item.
130
+ * @param state the initial state.
131
+ * @param object the object from query result.
132
+ * @return notification the notification object.
133
+ */
134
+ addForNotificationMessage(state: NotificationState, message: NotificationMessage): boolean;
124
135
  /**
125
136
  * Update notification from socket message.
126
137
  *
@@ -128,6 +139,13 @@ export declare class NotificationManager {
128
139
  * @param message the socket message.
129
140
  */
130
141
  updateFromMessage(psSessionId: string, message: SocketMessage<PowerShellWorkItemMessage>): boolean;
142
+ /**
143
+ * Update notification from socket message.
144
+ *
145
+ * @param psSessionId the psSession ID.
146
+ * @param message the socket message.
147
+ */
148
+ updateFromNotificationMessage(state: NotificationState, item: NotificationMessage): boolean;
131
149
  /**
132
150
  * Add or update client notification.
133
151
  *
@@ -1,4 +1,5 @@
1
- import { empty, ReplaySubject } from 'rxjs';
1
+ import { EMPTY, ReplaySubject } from 'rxjs';
2
+ import { Globalization } from '../data/globalization';
2
3
  import { Net } from '../data/net';
3
4
  import { LogLevel } from '../diagnostics/log-level';
4
5
  import { Logging } from '../diagnostics/logging';
@@ -216,6 +217,39 @@ export class NotificationManager {
216
217
  this.notificationIdToPsSessionIdMap[recover.id] = recover.id;
217
218
  this.addEvent(NotificationChangeEvent.Add, notification);
218
219
  }
220
+ /**
221
+ * Add initial notification for Message Notification.
222
+ *
223
+ * @param id the notification ID.
224
+ * @param workItem the RPC work item.
225
+ * @param state the initial state.
226
+ * @param object the object from query result.
227
+ * @return notification the notification object.
228
+ */
229
+ addForNotificationMessage(state, message) {
230
+ if (this.collection[message.id]) {
231
+ return false;
232
+ }
233
+ const notification = new Notification(message.id);
234
+ const now = new Date();
235
+ notification.isFromRecover = true;
236
+ notification.state = state;
237
+ notification.object = {};
238
+ notification.nodeName = message.sourceName;
239
+ notification.moduleDisplayName = message.sourceName;
240
+ notification.startTimestamp = Globalization.timeOnly(now);
241
+ notification.changedTimestamp = Globalization.timeOnly(now);
242
+ notification.changedTimestampValue = now.getTime();
243
+ notification.description = null;
244
+ notification.typeId = null;
245
+ notification.title = message.title;
246
+ notification.message = message.message;
247
+ this.collection[message.id] = notification;
248
+ this.psSessionIdToNotificationIdMap[message.id] = message.id;
249
+ this.notificationIdToPsSessionIdMap[message.id] = message.id;
250
+ this.addEvent(NotificationChangeEvent.Add, notification);
251
+ return true;
252
+ }
219
253
  /**
220
254
  * Update notification from socket message.
221
255
  *
@@ -233,6 +267,21 @@ export class NotificationManager {
233
267
  }
234
268
  return false;
235
269
  }
270
+ /**
271
+ * Update notification from socket message.
272
+ *
273
+ * @param psSessionId the psSession ID.
274
+ * @param message the socket message.
275
+ */
276
+ updateFromNotificationMessage(state, item) {
277
+ const notification = this.find(item.id);
278
+ if (notification) {
279
+ notification.updateFromNotificationMessage(state, item);
280
+ this.addEvent(NotificationChangeEvent.Change, notification);
281
+ return true;
282
+ }
283
+ return false;
284
+ }
236
285
  /**
237
286
  * Add or update client notification.
238
287
  *
@@ -251,12 +300,12 @@ export class NotificationManager {
251
300
  if (notification.updateFromClient(clientNotification)) {
252
301
  this.addEvent(NotificationChangeEvent.Change, notification);
253
302
  }
254
- return empty();
303
+ return EMPTY;
255
304
  }
256
305
  notification = Notification.createFromClient(clientNotification, this.iFrameService);
257
306
  this.collection[clientNotification.id] = notification;
258
307
  this.addEvent(NotificationChangeEvent.Add, notification);
259
- return empty();
308
+ return EMPTY;
260
309
  }
261
310
  /**
262
311
  * Find current work item by the typeId/sourceName/nodeName.
@@ -300,13 +349,9 @@ export class NotificationManager {
300
349
  }
301
350
  this.changedEventSubject.next({ notification: notificationCopy, changeEvent: changeEvent });
302
351
  // no localization.
303
- Logging.log({
304
- source: 'Notification',
305
- level: LogLevel.Verbose,
306
- message: notification ?
307
- 'addEvent: {0}/{1}\n{2}\n{3}\n{4}'.format(NotificationChangeEvent[changeEvent], NotificationState[notification.state], notification.title, notification.message, notification.link)
308
- : 'addEvent: {0}'.format(NotificationChangeEvent[changeEvent])
309
- });
352
+ Logging.logVerbose('Notification', notification ?
353
+ 'addEvent: {0}/{1}\n{2}\n{3}\n{4}'.format(NotificationChangeEvent[changeEvent], NotificationState[notification.state], notification.title, notification.message, notification.link)
354
+ : 'addEvent: {0}'.format(NotificationChangeEvent[changeEvent]));
310
355
  }
311
356
  }
312
357