@microsoft/windows-admin-center-sdk 2.538.1 → 2.541.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.
- package/angular/assets/strings/de-DE/strings.json +1 -1
- package/angular/assets/strings/es-ES/strings.json +1 -1
- package/angular/assets/strings/it-IT/strings.json +1 -1
- package/angular/assets/strings/ko-KR/strings.json +1 -1
- package/angular/assets/strings/nl-NL/strings.json +1 -1
- package/angular/assets/strings/pt-PT/strings.json +1 -1
- package/angular/assets/strings/tr-TR/strings.json +1 -1
- package/angular/assets/strings/zh-CN/strings.json +1 -1
- package/angular/assets/strings/zh-TW/strings.json +1 -1
- package/angular/bundles/microsoft-windows-admin-center-sdk-angular.umd.js +172 -112
- package/angular/bundles/microsoft-windows-admin-center-sdk-angular.umd.js.map +1 -1
- package/angular/bundles/microsoft-windows-admin-center-sdk-angular.umd.min.js +1 -1
- package/angular/bundles/microsoft-windows-admin-center-sdk-angular.umd.min.js.map +1 -1
- package/angular/esm2015/src/controls/header/header.component.js +3 -1
- package/angular/esm2015/src/controls/header/index.js +2 -2
- package/angular/esm2015/src/controls/page-alert-bar/models/page-alert.js +2 -1
- package/angular/esm2015/src/controls/page-alert-bar/page-alert-bar.component.js +11 -3
- package/angular/esm2015/src/controls/property-grid/property-grid.component.js +2 -2
- package/angular/esm2015/src/controls/wizard/wizard-builder.js +13 -1
- package/angular/esm2015/src/controls/wizard/wizard.component.js +126 -109
- package/angular/esm2015/src/controls/wizard/wizard.module.js +12 -7
- package/angular/fesm2015/microsoft-windows-admin-center-sdk-angular.js +156 -113
- package/angular/fesm2015/microsoft-windows-admin-center-sdk-angular.js.map +1 -1
- package/angular/src/controls/header/header.component.d.ts +7 -0
- package/angular/src/controls/header/index.d.ts +1 -1
- package/angular/src/controls/page-alert-bar/models/page-alert.d.ts +2 -1
- package/angular/src/controls/page-alert-bar/page-alert-bar.component.d.ts +1 -0
- package/angular/src/controls/wizard/wizard-builder.d.ts +13 -0
- package/angular/src/controls/wizard/wizard.component.d.ts +5 -0
- package/angular/src/controls/wizard/wizard.module.d.ts +10 -9
- package/core/data/active-directory/active-directory.js +2 -2
- package/core/data/active-directory/active-directory.js.map +1 -1
- package/core/data/powershell.d.ts +2 -2
- package/core/data/powershell.js +2 -2
- package/core/data/powershell.js.map +1 -1
- package/core/notification/notification-manager.d.ts +0 -18
- package/core/notification/notification-manager.js +10 -55
- package/core/notification/notification-manager.js.map +1 -1
- package/core/notification/notification.d.ts +1 -10
- package/core/notification/notification.js +33 -30
- package/core/notification/notification.js.map +1 -1
- package/core/notification/powershell-notification.d.ts +15 -15
- package/core/notification/powershell-notification.js +8 -19
- package/core/notification/powershell-notification.js.map +1 -1
- package/core/notification/socket-signalr.d.ts +14 -8
- package/core/notification/socket-signalr.js +19 -18
- package/core/notification/socket-signalr.js.map +1 -1
- package/core/notification/work-item-manager.d.ts +0 -4
- package/core/notification/work-item-manager.js +20 -76
- package/core/notification/work-item-manager.js.map +1 -1
- package/package.json +5 -2
- package/styles/css/main-v2.css +1 -1
- package/tools/wac-cli/src/create/main.js +0 -1
- package/tools/wac-cli/src/create/main.js.map +1 -1
- package/tools/wac-cli/templates/internal/package.json +4 -0
- package/tools/wac-cli/templates/library/angular.json +3 -0
- package/tools/wac-cli/templates/wac-template/angular.json +3 -0
- package/tools/wac-cli/templates/wac-template/package.json +4 -0
- package/tools/wac-cli/templates/wac-template/src/app/default/default.component.spec.ts +2 -3
- package/core/notification/notification-message.d.ts +0 -41
- package/core/notification/notification-message.js +0 -3
- package/core/notification/notification-message.js.map +0 -1
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { Injector, OnInit } from '@angular/core';
|
|
2
2
|
import { CoreBaseComponent } from '../common/base.component';
|
|
3
3
|
import * as i0 from "@angular/core";
|
|
4
|
+
export declare class SmeHeaderData {
|
|
5
|
+
text: string;
|
|
6
|
+
subtitle?: string;
|
|
7
|
+
smeIconClassName?: string;
|
|
8
|
+
urlIcon?: string;
|
|
9
|
+
level?: string;
|
|
10
|
+
}
|
|
4
11
|
/**
|
|
5
12
|
*
|
|
6
13
|
* @smeDoc {@label Header @id sme-header}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { HeaderComponent } from './header.component';
|
|
1
|
+
export { HeaderComponent, SmeHeaderData } from './header.component';
|
|
2
2
|
export { HeaderModule } from './header.module';
|
|
@@ -28,6 +28,7 @@ export declare class PageAlertBarComponent extends CoreBaseComponent {
|
|
|
28
28
|
get isWarning(): boolean;
|
|
29
29
|
get isPending(): boolean;
|
|
30
30
|
get isInformational(): boolean;
|
|
31
|
+
get isInformationalTransparent(): boolean;
|
|
31
32
|
get isSuccessful(): boolean;
|
|
32
33
|
get isUpsell(): boolean;
|
|
33
34
|
get isNeutral(): boolean;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Type } from '@angular/core';
|
|
2
2
|
import { Strings } from '../../generated/strings';
|
|
3
3
|
import { BannerItem } from '../banner';
|
|
4
|
+
import { SmeHeaderData } from '../header';
|
|
4
5
|
import { WizardStep } from './models';
|
|
5
6
|
import { WizardBuilderInterface } from './models/wizard-builder-interface';
|
|
6
7
|
import { WizardStage } from './models/wizard-stage';
|
|
@@ -22,6 +23,10 @@ export declare class WizardBuilder implements WizardBuilderInterface {
|
|
|
22
23
|
* The heading of the wizard.
|
|
23
24
|
*/
|
|
24
25
|
private wizardHeading;
|
|
26
|
+
/**
|
|
27
|
+
* The subtitle for the heading of the wizard.
|
|
28
|
+
*/
|
|
29
|
+
private wizardHeaderData;
|
|
25
30
|
/**
|
|
26
31
|
* The title of exit button.
|
|
27
32
|
*/
|
|
@@ -71,6 +76,14 @@ export declare class WizardBuilder implements WizardBuilderInterface {
|
|
|
71
76
|
* Sets the wizard heading.
|
|
72
77
|
*/
|
|
73
78
|
set heading(value: string);
|
|
79
|
+
/**
|
|
80
|
+
* Gets the heading subtitle.
|
|
81
|
+
*/
|
|
82
|
+
get headerData(): SmeHeaderData;
|
|
83
|
+
/**
|
|
84
|
+
* Sets the heading subtitle.
|
|
85
|
+
*/
|
|
86
|
+
set headerData(value: SmeHeaderData);
|
|
74
87
|
/**
|
|
75
88
|
* Gets the wizard exit button title.
|
|
76
89
|
*/
|
|
@@ -4,6 +4,7 @@ import { AppContextService } from '../../service/app-context.service';
|
|
|
4
4
|
import { BannerItem } from '../banner';
|
|
5
5
|
import { DynamicComponentBase } from '../common/dynamic.component';
|
|
6
6
|
import { Layout } from '../common/layout';
|
|
7
|
+
import { SmeHeaderData } from '../header/header.component';
|
|
7
8
|
import { PageAlert } from '../page-alert-bar/models/page-alert';
|
|
8
9
|
import { WizardModel } from './models/wizard-model';
|
|
9
10
|
import { WizardNavigationInterface } from './models/wizard-navigation-interface';
|
|
@@ -97,6 +98,10 @@ export declare class WizardComponent<TModel extends WizardModel> extends Dynamic
|
|
|
97
98
|
* The heading of the wizard.
|
|
98
99
|
*/
|
|
99
100
|
heading: string;
|
|
101
|
+
/**
|
|
102
|
+
* The header object.
|
|
103
|
+
*/
|
|
104
|
+
headerData: SmeHeaderData;
|
|
100
105
|
/**
|
|
101
106
|
* The title of the exit button.
|
|
102
107
|
*/
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import * as i0 from "@angular/core";
|
|
2
2
|
import * as i1 from "./wizard.component";
|
|
3
3
|
import * as i2 from "@angular/common";
|
|
4
|
-
import * as i3 from "../
|
|
5
|
-
import * as i4 from "../
|
|
6
|
-
import * as i5 from "../
|
|
7
|
-
import * as i6 from "
|
|
8
|
-
import * as i7 from "
|
|
9
|
-
import * as i8 from "../
|
|
10
|
-
import * as i9 from "../
|
|
11
|
-
import * as i10 from "../
|
|
4
|
+
import * as i3 from "../header/header.module";
|
|
5
|
+
import * as i4 from "../icon/icon.module";
|
|
6
|
+
import * as i5 from "../layout/layout.module";
|
|
7
|
+
import * as i6 from "../loading-wheel/loading-wheel.module";
|
|
8
|
+
import * as i7 from "../../directives/telemetry/telemetry-directives.module";
|
|
9
|
+
import * as i8 from "../tooltip/tooltip.module";
|
|
10
|
+
import * as i9 from "../page-alert-bar/page-alert-bar.module";
|
|
11
|
+
import * as i10 from "../badge/badge.module";
|
|
12
|
+
import * as i11 from "../banner/banner.module";
|
|
12
13
|
export declare class WizardModule {
|
|
13
14
|
static ɵfac: i0.ɵɵFactoryDef<WizardModule, never>;
|
|
14
|
-
static ɵmod: i0.ɵɵNgModuleDefWithMeta<WizardModule, [typeof i1.WizardComponent], [typeof i2.CommonModule, typeof i3.
|
|
15
|
+
static ɵmod: i0.ɵɵNgModuleDefWithMeta<WizardModule, [typeof i1.WizardComponent], [typeof i2.CommonModule, typeof i3.HeaderModule, typeof i4.IconModule, typeof i5.LayoutModule, typeof i6.LoadingWheelModule, typeof i7.TelemetryDirectiveModule, typeof i8.TooltipModule, typeof i9.PageAlertBarModule, typeof i10.BadgeModule, typeof i11.BannerModule], [typeof i1.WizardComponent]>;
|
|
15
16
|
static ɵinj: i0.ɵɵInjectorDef<WizardModule>;
|
|
16
17
|
}
|
|
@@ -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('
|
|
17
|
+
this.gateway.get('gateway/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 = `
|
|
34
|
+
const requestUrl = `gateway/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,
|
|
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,IA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Q,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('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"]}
|
|
@@ -224,9 +224,9 @@ export declare class PowerShell {
|
|
|
224
224
|
*/
|
|
225
225
|
static smePowerShellEndpoint: string;
|
|
226
226
|
/**
|
|
227
|
-
*
|
|
227
|
+
* SME CredSSP PowerShell endpoint to control client role of CredSSP on the gateway.
|
|
228
228
|
*/
|
|
229
|
-
static
|
|
229
|
+
static smeCredSSPEndpoint: string;
|
|
230
230
|
/**
|
|
231
231
|
* Static collection of PowerShell objects.
|
|
232
232
|
*/
|
package/core/data/powershell.js
CHANGED
|
@@ -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
|
-
*
|
|
675
|
+
* SME CredSSP PowerShell endpoint to control client role of CredSSP on the gateway.
|
|
676
676
|
*/
|
|
677
|
-
PowerShell.
|
|
677
|
+
PowerShell.smeCredSSPEndpoint = 'http://schemas.microsoft.com/powershell/microsoft.sme.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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esContent":["\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"]}
|
|
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,M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AC,IAAI,CAAC,IAAI,CAAC,CAAC;oBAC1B,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;;AA3gBD;;GAEG;AACW,oCAAyB,GAAG,8DAA8D,CAAC;AAEzG;;GAEG;AACW,gCAAqB,GAAG,kEAAkE,CAAC;AAEzG;;GAEG;AAEW,6BAAkB,GAAG,+DAA+D,CAAC;AAEnG;;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 * 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"]}
|
|
@@ -4,7 +4,6 @@ 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';
|
|
8
7
|
import { NotificationState } from './notification-state';
|
|
9
8
|
import { PowerShellWorkItemMessage } from './powershell-notification';
|
|
10
9
|
import { SocketMessage } from './socket-signalr';
|
|
@@ -122,16 +121,6 @@ export declare class NotificationManager {
|
|
|
122
121
|
* @return notification the notification object.
|
|
123
122
|
*/
|
|
124
123
|
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;
|
|
135
124
|
/**
|
|
136
125
|
* Update notification from socket message.
|
|
137
126
|
*
|
|
@@ -139,13 +128,6 @@ export declare class NotificationManager {
|
|
|
139
128
|
* @param message the socket message.
|
|
140
129
|
*/
|
|
141
130
|
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;
|
|
149
131
|
/**
|
|
150
132
|
* Add or update client notification.
|
|
151
133
|
*
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Globalization } from '../data/globalization';
|
|
1
|
+
import { empty, ReplaySubject } from 'rxjs';
|
|
3
2
|
import { Net } from '../data/net';
|
|
4
3
|
import { LogLevel } from '../diagnostics/log-level';
|
|
5
4
|
import { Logging } from '../diagnostics/logging';
|
|
@@ -217,39 +216,6 @@ export class NotificationManager {
|
|
|
217
216
|
this.notificationIdToPsSessionIdMap[recover.id] = recover.id;
|
|
218
217
|
this.addEvent(NotificationChangeEvent.Add, notification);
|
|
219
218
|
}
|
|
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
|
-
}
|
|
253
219
|
/**
|
|
254
220
|
* Update notification from socket message.
|
|
255
221
|
*
|
|
@@ -267,21 +233,6 @@ export class NotificationManager {
|
|
|
267
233
|
}
|
|
268
234
|
return false;
|
|
269
235
|
}
|
|
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
|
-
}
|
|
285
236
|
/**
|
|
286
237
|
* Add or update client notification.
|
|
287
238
|
*
|
|
@@ -300,12 +251,12 @@ export class NotificationManager {
|
|
|
300
251
|
if (notification.updateFromClient(clientNotification)) {
|
|
301
252
|
this.addEvent(NotificationChangeEvent.Change, notification);
|
|
302
253
|
}
|
|
303
|
-
return
|
|
254
|
+
return empty();
|
|
304
255
|
}
|
|
305
256
|
notification = Notification.createFromClient(clientNotification, this.iFrameService);
|
|
306
257
|
this.collection[clientNotification.id] = notification;
|
|
307
258
|
this.addEvent(NotificationChangeEvent.Add, notification);
|
|
308
|
-
return
|
|
259
|
+
return empty();
|
|
309
260
|
}
|
|
310
261
|
/**
|
|
311
262
|
* Find current work item by the typeId/sourceName/nodeName.
|
|
@@ -349,9 +300,13 @@ export class NotificationManager {
|
|
|
349
300
|
}
|
|
350
301
|
this.changedEventSubject.next({ notification: notificationCopy, changeEvent: changeEvent });
|
|
351
302
|
// no localization.
|
|
352
|
-
Logging.
|
|
353
|
-
|
|
354
|
-
:
|
|
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
|
+
});
|
|
355
310
|
}
|
|
356
311
|
}
|
|
357
312
|
|