Update to ADO 5ed9b2130da7f822153531489d802c28986f5d30

This commit is contained in:
Steve Faulkner 2020-05-26 13:53:41 -05:00
parent 36581fb6d9
commit 0494da4162
42 changed files with 1186 additions and 2242 deletions

132
package-lock.json generated
View File

@ -13060,80 +13060,110 @@
"dev": true
},
"office-ui-fabric-react": {
"version": "6.210.5",
"resolved": "https://registry.npmjs.org/office-ui-fabric-react/-/office-ui-fabric-react-6.210.5.tgz",
"integrity": "sha512-kq2nLG20qwxez5N8QdrEs5eFJwpKa/V1qemob9cqAUrioxR29GAlqAHRFSjg+U6UYEm6ypUBS0cF1235jwspWw==",
"version": "7.115.0",
"resolved": "https://registry.npmjs.org/office-ui-fabric-react/-/office-ui-fabric-react-7.115.0.tgz",
"integrity": "sha512-FZG5SM9ZHI+gTiJsW7RRpEVQReasCNni25BpsLY+sjvdn3jTpeXOYFXDmfV8yiUDetLvDBTf5O0b0intWCOCqw==",
"requires": {
"@microsoft/load-themed-styles": "^1.7.13",
"@uifabric/foundation": "^0.8.3",
"@uifabric/icons": "^6.5.5",
"@uifabric/merge-styles": "^6.19.4",
"@uifabric/set-version": "^1.1.3",
"@uifabric/styling": "^6.50.7",
"@uifabric/utilities": "^6.45.1",
"prop-types": "^15.5.10",
"tslib": "^1.7.1"
"@fluentui/react-focus": "^7.11.7",
"@fluentui/react-icons": "^0.1.18",
"@microsoft/load-themed-styles": "^1.10.26",
"@uifabric/foundation": "^7.7.16",
"@uifabric/icons": "^7.3.42",
"@uifabric/merge-styles": "^7.14.0",
"@uifabric/react-hooks": "^7.3.7",
"@uifabric/set-version": "^7.0.12",
"@uifabric/styling": "^7.12.9",
"@uifabric/utilities": "^7.17.3",
"prop-types": "^15.7.2",
"tslib": "^1.10.0"
},
"dependencies": {
"@uifabric/foundation": {
"version": "0.8.3",
"resolved": "https://registry.npmjs.org/@uifabric/foundation/-/foundation-0.8.3.tgz",
"integrity": "sha512-r3WhRj7Out8QAOe50BGA36R8zgRPy0D0GNPuwFK9BB9oIidf91ycj7/miY8U0TZRZi5fB3Kg+dy/uxSDfgC6Og==",
"@fluentui/react-focus": {
"version": "7.11.7",
"resolved": "https://registry.npmjs.org/@fluentui/react-focus/-/react-focus-7.11.7.tgz",
"integrity": "sha512-EHPwScf8k4Rlzki6M7cWA09D80rZiN7E0tZmh6yoZVvdPY0AcrnUTLy0lWIVRk/1oAt7Ko4Yhss7aaYX7jqNXQ==",
"requires": {
"@uifabric/set-version": "^1.1.3",
"@uifabric/styling": "^6.50.7",
"@uifabric/utilities": "^6.41.7",
"tslib": "^1.7.1"
"@fluentui/keyboard-key": "^0.2.0",
"@uifabric/merge-styles": "^7.14.0",
"@uifabric/set-version": "^7.0.12",
"@uifabric/styling": "^7.12.9",
"@uifabric/utilities": "^7.17.3",
"tslib": "^1.10.0"
}
},
"@fluentui/react-icons": {
"version": "0.1.18",
"resolved": "https://registry.npmjs.org/@fluentui/react-icons/-/react-icons-0.1.18.tgz",
"integrity": "sha512-63u5sO568nI4ORgwewqKynB+M+NkGQys1F8EDkW/wYcF24uNuAQUID4JIBvIbB57M10YDDYHCqXYB8RTJy1Cww==",
"requires": {
"@uifabric/set-version": "^7.0.12",
"@uifabric/styling": "^7.12.9",
"@uifabric/utilities": "^7.17.3",
"tslib": "^1.10.0"
}
},
"@uifabric/foundation": {
"version": "7.7.16",
"resolved": "https://registry.npmjs.org/@uifabric/foundation/-/foundation-7.7.16.tgz",
"integrity": "sha512-9ED+nyAmfBcLbL5LuVDoSSxGxexGs11fCsDyVoPoJ4Er2qmSIH30STe/+AwFHq3nEBD1ztiHDIVcKfLf4GT7VQ==",
"requires": {
"@uifabric/merge-styles": "^7.14.0",
"@uifabric/set-version": "^7.0.12",
"@uifabric/styling": "^7.12.9",
"@uifabric/utilities": "^7.17.3",
"tslib": "^1.10.0"
}
},
"@uifabric/icons": {
"version": "6.5.5",
"resolved": "https://registry.npmjs.org/@uifabric/icons/-/icons-6.5.5.tgz",
"integrity": "sha512-cGjzdpT0jzQ2RJvzlCVTrewaHCi4rb+ZNL2LWoceMi+5h196Y32qJwKMsc0ggR6u5CjMrzBiAxUFNppBSCutdA==",
"version": "7.3.42",
"resolved": "https://registry.npmjs.org/@uifabric/icons/-/icons-7.3.42.tgz",
"integrity": "sha512-RWGXdOBWaEjIqtOc4y/xwp3Cgc0gmU5ApBXw8AipjdwJyEPuV2UGjtk4URs0Iog42WoUxDfDKnRrH4dAjGV34g==",
"requires": {
"@uifabric/set-version": "^1.1.3",
"@uifabric/styling": "^6.50.7",
"tslib": "^1.7.1"
"@uifabric/set-version": "^7.0.12",
"@uifabric/styling": "^7.12.9",
"tslib": "^1.10.0"
}
},
"@uifabric/merge-styles": {
"version": "6.19.4",
"resolved": "https://registry.npmjs.org/@uifabric/merge-styles/-/merge-styles-6.19.4.tgz",
"integrity": "sha512-bjQdDHxmRIZVPwL//MtErODhEfcRJ2y+zJXoIWNh3T8JfAepeRDdoJ/pGNnnyJxA/AHMtlWt0IgMaz150/nfAA==",
"version": "7.14.0",
"resolved": "https://registry.npmjs.org/@uifabric/merge-styles/-/merge-styles-7.14.0.tgz",
"integrity": "sha512-LR70l856QTVYfceUA1HtHws0iFUQI3pN1Z2fyH2M1RPeBA35NimpaGkEaNSPHsCAiJ09evVsG6JP7iTUItWHUQ==",
"requires": {
"@uifabric/set-version": "^1.1.3",
"tslib": "^1.7.1"
"@uifabric/set-version": "^7.0.12",
"tslib": "^1.10.0"
}
},
"@uifabric/set-version": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/@uifabric/set-version/-/set-version-1.1.3.tgz",
"integrity": "sha512-IYpwVIuN7MJOeiWzZzr9AmFSvA5zc6gJn4fNHtEFIQnNB8WVWIcYrvx8Tbf7wWj9MvhdHYp70F054zZlHbL/Ag==",
"@uifabric/react-hooks": {
"version": "7.3.7",
"resolved": "https://registry.npmjs.org/@uifabric/react-hooks/-/react-hooks-7.3.7.tgz",
"integrity": "sha512-hNMma78ewtM4adwpVS+nFKvJpZ9blYz5AuNFjUfsn85YmutmfJ2BuV//SWnELKgX+ahASZSdSIwJLVYXHwYrKw==",
"requires": {
"tslib": "^1.7.1"
"@uifabric/set-version": "^7.0.12",
"@uifabric/utilities": "^7.17.3",
"tslib": "^1.10.0"
}
},
"@uifabric/styling": {
"version": "6.50.7",
"resolved": "https://registry.npmjs.org/@uifabric/styling/-/styling-6.50.7.tgz",
"integrity": "sha512-F2aBiB30ZiFxlZzy5hzLXODWOl6jySvPFAsoaTofk37xucHiunBLZYjX6WkfZrCWiyGPva+DLssNcwly9ZHVjg==",
"version": "7.12.9",
"resolved": "https://registry.npmjs.org/@uifabric/styling/-/styling-7.12.9.tgz",
"integrity": "sha512-eImcC3YiLoCp6RaxtQLqcRSj5ErcI/96+nvGlR+7F+KZ0aAj4vWDCCU5cUd5UI+wL11yCREN7DnWTQWpP98I7Q==",
"requires": {
"@microsoft/load-themed-styles": "^1.7.13",
"@uifabric/merge-styles": "^6.19.4",
"@uifabric/set-version": "^1.1.3",
"@uifabric/utilities": "^6.41.7",
"tslib": "^1.7.1"
"@microsoft/load-themed-styles": "^1.10.26",
"@uifabric/merge-styles": "^7.14.0",
"@uifabric/set-version": "^7.0.12",
"@uifabric/utilities": "^7.17.3",
"tslib": "^1.10.0"
}
},
"@uifabric/utilities": {
"version": "6.45.2",
"resolved": "https://registry.npmjs.org/@uifabric/utilities/-/utilities-6.45.2.tgz",
"integrity": "sha512-JiC92OjMOkVoiIAeS2b3R9B1XQU0cJ5bDr9B7VvrxlwKe1W9xMtVsCer7b8gNCU5NFNYBN5ckM3Q7x2Zs5cH0A==",
"version": "7.17.3",
"resolved": "https://registry.npmjs.org/@uifabric/utilities/-/utilities-7.17.3.tgz",
"integrity": "sha512-NeLL6Bsg7F/1BMYrg/dcnxm7LjwPm9OSg14aK/YI60iBSO6QQpPJ6UrSTflVh6JKBAAA26kTR9/3fJiLxO+2PA==",
"requires": {
"@uifabric/merge-styles": "^6.19.4",
"@uifabric/set-version": "^1.1.3",
"prop-types": "^15.5.10",
"tslib": "^1.7.1"
"@uifabric/merge-styles": "^7.14.0",
"@uifabric/set-version": "^7.0.12",
"prop-types": "^15.7.2",
"tslib": "^1.10.0"
}
}
}

View File

@ -60,7 +60,7 @@
"knockout": "3.5.1",
"monaco-editor": "0.15.6",
"object.entries": "1.1.0",
"office-ui-fabric-react": "6.210.5",
"office-ui-fabric-react": "7.115.0",
"plotly.js-cartesian-dist-min": "1.52.3",
"promise-polyfill": "8.1.0",
"promise.prototype.finally": "3.1.0",

View File

@ -41,7 +41,7 @@ export class ArmApiVersions {
public static readonly arcadiaLivy: string = "2019-11-01-preview";
public static readonly arm: string = "2015-11-01";
public static readonly armFeatures: string = "2014-08-01-preview";
public static readonly publicVersion = "2020-03-01";
public static readonly publicVersion = "2020-04-01";
}
export class ArmResourceTypes {
@ -334,11 +334,13 @@ export class HttpHeaders {
public static populateCollectionThroughputInfo = "x-ms-documentdb-populatecollectionthroughputinfo";
public static supportSpatialLegacyCoordinates = "x-ms-documentdb-supportspatiallegacycoordinates";
public static usePolygonsSmallerThanAHemisphere = "x-ms-documentdb-usepolygonssmallerthanahemisphere";
public static autoPilotThroughput = "ProvisionedThroughputSettings";
public static autoPilotThroughput = "autoscaleSettings";
public static autoPilotThroughputSDK = "x-ms-cosmos-offer-autopilot-settings";
public static autoPilotTier = "x-ms-cosmos-offer-autopilot-tier";
public static partitionKey: string = "x-ms-documentdb-partitionkey";
public static migrateOfferToManualThroughput: string = "x-ms-cosmos-migrate-offer-to-manual-throughput";
public static migrateOfferToAutopilot: string = "x-ms-cosmos-migrate-offer-to-autopilot";
public static mongoFixedCollectionWithSharedThroughput: string = "InsertSystemPartitionKey";
}
export class ApiType {

View File

@ -544,7 +544,7 @@ export abstract class DataAccessUtilityBase {
const initialHeaders = request.autoPilot
? !hasAutoPilotV2FeatureFlag
? {
[Constants.HttpHeaders.autoPilotThroughput]: JSON.stringify({
[Constants.HttpHeaders.autoPilotThroughputSDK]: JSON.stringify({
maxThroughput: request.autoPilot.maxThroughput
})
}
@ -654,7 +654,7 @@ export abstract class DataAccessUtilityBase {
const initialHeaders = autoPilot
? !hasAutoPilotV2FeatureFlag
? {
[Constants.HttpHeaders.autoPilotThroughput]: JSON.stringify({ maxThroughput: autoPilot.maxThroughput })
[Constants.HttpHeaders.autoPilotThroughputSDK]: JSON.stringify({ maxThroughput: autoPilot.maxThroughput })
}
: {
[Constants.HttpHeaders.autoPilotTier]: autoPilot.autopilotTier

View File

@ -259,15 +259,19 @@ describe("MongoProxyClient", () => {
sid: "a2",
rg: "c1",
dba: "main",
is: false
is: false,
isFixedCollectionWithSharedThroughputBeingCreated: true
};
_createMongoCollectionWithARM("management.azure.com", properties, { "x-ms-cosmos-offer-autopilot-tier": "1" });
expect(
resourceProviderClientPutAsyncSpy
).toHaveBeenCalledWith(
expect(resourceProviderClientPutAsyncSpy).toHaveBeenCalledWith(
"subscriptions/a2/resourceGroups/c1/providers/Microsoft.DocumentDB/databaseAccounts/foo/mongodbDatabases/a1-db/collections/abc-collection",
"2020-03-01",
{ properties: { options: { "x-ms-cosmos-offer-autopilot-tier": "1" }, resource: { id: "abc-collection" } } }
"2020-04-01",
{
properties: {
options: { "x-ms-cosmos-offer-autopilot-tier": "1", InsertSystemPartitionKey: "true" },
resource: { id: "abc-collection" }
}
}
);
});
it("should create a collection with provisioned throughput when provisioned throughput is selected + shared throughput is false", () => {
@ -282,15 +286,19 @@ describe("MongoProxyClient", () => {
rg: "c1",
dba: "main",
is: false,
offerThroughput: 400
offerThroughput: 400,
isFixedCollectionWithSharedThroughputBeingCreated: true
};
_createMongoCollectionWithARM("management.azure.com", properties, undefined);
expect(
resourceProviderClientPutAsyncSpy
).toHaveBeenCalledWith(
expect(resourceProviderClientPutAsyncSpy).toHaveBeenCalledWith(
"subscriptions/a2/resourceGroups/c1/providers/Microsoft.DocumentDB/databaseAccounts/foo/mongodbDatabases/a1-db/collections/abc-collection",
"2020-03-01",
{ properties: { options: { throughput: "400" }, resource: { id: "abc-collection" } } }
"2020-04-01",
{
properties: {
options: { throughput: "400", InsertSystemPartitionKey: "true" },
resource: { id: "abc-collection" }
}
}
);
});
});

View File

@ -356,6 +356,7 @@ export function createMongoCollectionWithARM(
armEndpoint: string,
databaseId: string,
analyticalStorageTtl: number,
isFixedCollectionWithSharedThroughputBeingCreated: boolean,
collectionId: string,
offerThroughput: number,
shardKey: string,
@ -379,7 +380,8 @@ export function createMongoCollectionWithARM(
sid: CosmosClient.subscriptionId(),
rg: CosmosClient.resourceGroup(),
dba: databaseAccount.name,
analyticalStorageTtl
analyticalStorageTtl,
isFixedCollectionWithSharedThroughputBeingCreated
};
if (createDatabase) {
@ -451,6 +453,11 @@ export async function _createMongoCollectionWithARM(
}
}
if (params.isFixedCollectionWithSharedThroughputBeingCreated) {
rpPayloadToCreateCollection.properties.options[Constants.HttpHeaders.mongoFixedCollectionWithSharedThroughput] =
"true";
}
if (params.analyticalStorageTtl) {
rpPayloadToCreateCollection.properties.resource.analyticalStorageTtl = params.analyticalStorageTtl;
}

View File

@ -31,7 +31,7 @@ interface Config {
// Default configuration
let config: Config = {
platform: Platform.Portal,
allowedParentFrameOrigins: /^https:\/\/portal\.azure\.com$|^https:\/\/portal\.azure\.us$|^https:\/\/portal\.azure\.cn$|^https:\/\/portal\.microsoftazure\.de$|^https:\/\/.+\.portal\.azure\.com$|^https:\/\/.+\.portal\.azure\.us$|^https:\/\/.+\.portal\.azure\.cn$|^https:\/\/.+\.portal\.microsoftazure\.de$/,
allowedParentFrameOrigins: /^https:\/\/portal\.azure\.com$|^https:\/\/portal\.azure\.us$|^https:\/\/portal\.azure\.cn$|^https:\/\/portal\.microsoftazure\.de$|^https:\/\/.+\.portal\.azure\.com$|^https:\/\/.+\.portal\.azure\.us$|^https:\/\/.+\.portal\.azure\.cn$|^https:\/\/.+\.portal\.microsoftazure\.de$|^https:\/\/main\.documentdb\.ext\.azure\.com$|^https:\/\/main\.documentdb\.ext\.microsoftazure\.de$|^https:\/\/main\.documentdb\.ext\.azure\.cn$|^https:\/\/main\.documentdb\.ext\.azure\.us$/,
// Webpack injects this at build time
gitSha: process.env.GIT_SHA,
hostedExplorerURL: "https://cosmos.azure.com/",

View File

@ -301,6 +301,7 @@ export enum AutopilotTier {
}
export interface RpOptions {
// tier is sent as string, autoscale as object (AutoPilotCreationSettings)
[key: string]: string | AutoPilotCreationSettings;
}
@ -546,6 +547,7 @@ export interface MongoParameters extends RpParameters {
autoPilotTier?: string;
autoPilotThroughput?: string;
analyticalStorageTtl?: number;
isFixedCollectionWithSharedThroughputBeingCreated?: boolean;
}
export interface GraphParameters extends RpParameters {

View File

@ -77,6 +77,7 @@ export interface Explorer {
isAccountReady: ko.Observable<boolean>;
collectionCreationDefaults: CollectionCreationDefaults;
isEmulator: boolean;
features: ko.Observable<any>;
serverId: ko.Observable<string>;
@ -1257,6 +1258,26 @@ export interface DataExplorerInputsFrame {
sharedThroughputDefault?: number;
dataExplorerVersion?: string;
isAuthWithresourceToken?: boolean;
defaultCollectionThroughput?: CollectionCreationDefaults;
}
export interface CollectionCreationDefaults {
storage: string;
throughput: ThroughputDefaults;
}
export interface ThroughputDefaults {
fixed: number;
unlimited:
| number
| {
collectionThreshold: number;
lessThanOrEqualToThreshold: number;
greatThanThreshold: number;
};
unlimitedmax: number;
unlimitedmin: number;
shared: number;
}
export enum SubscriptionType {

View File

@ -90,7 +90,10 @@ describe("test function", () => {
const wrapper = mount(<DefaultDirectoryDropdownComponent {...props} />);
wrapper.find("div.defaultDirectoryDropdown").simulate("click");
wrapper
.find("div.defaultDirectoryDropdown")
.find("div.ms-Dropdown")
.simulate("click");
expect(wrapper.exists("div.ms-Callout-main")).toBe(true);
wrapper
.find("button.ms-Dropdown-item")
@ -99,7 +102,10 @@ describe("test function", () => {
expect(props.onDefaultDirectoryChange).toBeCalled();
expect(props.onDefaultDirectoryChange).toHaveBeenCalled();
wrapper.find("div.defaultDirectoryDropdown").simulate("click");
wrapper
.find("div.defaultDirectoryDropdown")
.find("div.ms-Dropdown")
.simulate("click");
expect(wrapper.exists("div.ms-Callout-main")).toBe(true);
wrapper
.find("button.ms-Dropdown-item")

View File

@ -51,7 +51,7 @@ export class DirectoryListComponent extends React.Component<DirectoryListProps,
const textFieldProps: ITextFieldProps = {
className: "directoryListFilterTextBox",
placeholder: "Filter by directory name",
onBeforeChange: this._onFilterChanged,
onChange: this._onFilterChanged,
ariaLabel: "Directory filter text box"
};
@ -66,7 +66,7 @@ export class DirectoryListComponent extends React.Component<DirectoryListProps,
);
}
private _onFilterChanged = (text: string): void => {
private _onFilterChanged = (event: React.FormEvent<HTMLInputElement | HTMLTextAreaElement>, text?: string): void => {
this.setState({
filterText: text
});

View File

@ -2,13 +2,13 @@ import { DefaultButton, IButtonProps, ITextFieldProps, TextField } from "office-
import * as React from "react";
import * as ViewModels from "../../../Contracts/ViewModels";
import * as Constants from "../../../Common/Constants";
import { Action, ActionModifiers } from "../../../Shared/Telemetry/TelemetryConstants";
import { Areas } from "../../../Common/Constants";
import { Action } from "../../../Shared/Telemetry/TelemetryConstants";
import { RepoListItem } from "./GitHubReposComponent";
import { ChildrenMargin } from "./GitHubStyleConstants";
import { GitHubUtils } from "../../../Utils/GitHubUtils";
import { IGitHubRepo } from "../../../GitHub/GitHubClient";
import TelemetryProcessor from "../../../Shared/Telemetry/TelemetryProcessor";
import UrlUtility from "../../../Common/UrlUtility";
export interface AddRepoComponentProps {
container: ViewModels.Explorer;
@ -80,24 +80,24 @@ export class AddRepoComponent extends React.Component<AddRepoComponentProps, Add
});
let enteredUrl = this.state.textFieldValue;
if (enteredUrl.indexOf("/tree/") === -1) {
enteredUrl = `${enteredUrl}/tree/${AddRepoComponent.DefaultBranchName}`;
enteredUrl = UrlUtility.createUri(enteredUrl, `tree/${AddRepoComponent.DefaultBranchName}`);
}
const gitHubInfo = GitHubUtils.fromGitHubUri(enteredUrl);
if (gitHubInfo) {
const repoInfo = GitHubUtils.fromRepoUri(enteredUrl);
if (repoInfo) {
this.setState({
textFieldValue: "",
textFieldErrorMessage: undefined
});
const repo = await this.props.getRepo(gitHubInfo.owner, gitHubInfo.repo);
const repo = await this.props.getRepo(repoInfo.owner, repoInfo.repo);
if (repo) {
const item: RepoListItem = {
key: GitHubUtils.toRepoFullName(repo.owner.login, repo.name),
repo,
branches: [
{
name: gitHubInfo.branch
name: repoInfo.branch
}
]
};

View File

@ -1,4 +1,4 @@
import { DefaultButton, IButtonProps, Link, PrimaryButton } from "office-ui-fabric-react";
import { DefaultButton, IButtonProps, PrimaryButton } from "office-ui-fabric-react";
import * as React from "react";
import { IGitHubBranch, IGitHubRepo } from "../../../GitHub/GitHubClient";
import { AddRepoComponent, AddRepoComponentProps } from "./AddRepoComponent";

View File

@ -204,7 +204,9 @@ export class ReposListComponent extends React.Component<ReposListComponentProps>
return <Dropdown {...dropdownProps} />;
};
private onRenderBranchesDropdownList = (props: ISelectableDroppableTextProps<IDropdown, IDropdown>): JSX.Element => {
private onRenderBranchesDropdownList = (
props: ISelectableDroppableTextProps<IDropdown, HTMLDivElement>
): JSX.Element => {
const renderedList: JSX.Element[] = [];
props.options.forEach((option: IDropdownOption) => {
const item = (

View File

@ -112,6 +112,7 @@ export default class Explorer implements ViewModels.Explorer {
public collapsedResourceTreeWidth: number = ExplorerMetrics.CollapsedResourceTreeWidth;
public databaseAccount: ko.Observable<ViewModels.DatabaseAccount>;
public collectionCreationDefaults: ViewModels.CollectionCreationDefaults = SharedConstants.CollectionCreationDefaults;
public subscriptionType: ko.Observable<ViewModels.SubscriptionType>;
public quotaId: ko.Observable<string>;
public defaultExperience: ko.Observable<string>;
@ -2161,6 +2162,9 @@ export default class Explorer implements ViewModels.Explorer {
const authorizationToken = inputs.authorizationToken || "";
const masterKey = inputs.masterKey || "";
const databaseAccount = inputs.databaseAccount || null;
if (inputs.defaultCollectionThroughput) {
this.collectionCreationDefaults = inputs.defaultCollectionThroughput;
}
this.features(inputs.features);
this.serverId(inputs.serverId);
this.extensionEndpoint(inputs.extensionEndpoint || "");
@ -2575,7 +2579,7 @@ export default class Explorer implements ViewModels.Explorer {
}
public async importAndOpen(path: string): Promise<boolean> {
const name = NotebookUtil.getContentName(path);
const name = NotebookUtil.getName(path);
const item = NotebookUtil.createNotebookContentItem(name, path, "file");
const parent = this.resourceTree.myNotebooksContentRoot;
@ -3106,14 +3110,15 @@ export default class Explorer implements ViewModels.Explorer {
})
.then(() => this.resourceTree.triggerRender())
.catch(reason => {
NotificationConsoleUtils.logConsoleMessage(ConsoleDataType.Error, reason);
const error = `Failed to create a new notebook: ${reason}`;
NotificationConsoleUtils.logConsoleMessage(ConsoleDataType.Error, error);
TelemetryProcessor.traceFailure(
Action.CreateNewNotebook,
{
databaseAccountName: this.databaseAccount().name,
defaultExperience: this.defaultExperience(),
dataExplorerArea: Constants.Areas.Notebook,
error: JSON.stringify(reason)
error
},
startKey
);

View File

@ -28,6 +28,7 @@ exports[`test render renders signed in with full info 1`] = `
<FocusZone
direction={2}
isCircularNavigation={false}
preventDefaultWhenHandled={true}
>
<CustomizedDefaultButton
className="mecontrolHeaderButton"

View File

@ -60,7 +60,7 @@ export class NotebookContentProvider implements IContentProvider {
}
private getContentProvider(path: string): IContentProvider {
if (GitHubUtils.fromGitHubUri(path)) {
if (GitHubUtils.fromContentUri(path)) {
return this.gitHubContentProvider;
}

View File

@ -141,8 +141,7 @@ export class NotebookContentClient implements ViewModels.INotebookContentClient
targetName += extension;
}
}
const parsedPath = NotebookContentClient.parsePath(sourcePath);
const targetPath = `${parsedPath.dirpath}${targetName}`;
const targetPath = NotebookUtil.replaceName(sourcePath, targetName);
return this.contentProvider
.update<"file" | "notebook" | "directory">(this.getServerConfig(), sourcePath, { path: targetPath })
.toPromise()
@ -214,21 +213,6 @@ export class NotebookContentClient implements ViewModels.INotebookContentClient
});
}
/**
*
* @param path
* @returns basename and dirpath. Note: dirpath has trailing / already
*/
private static parsePath(path: string): { dirpath: string; basename: string } {
const basename = path.split("/").pop();
const dirpath = path.split(basename).shift();
return {
dirpath,
basename
};
}
private deleteNotebookFile(path: string): Promise<string> {
return this.contentProvider
.remove(this.getServerConfig(), path)

View File

@ -0,0 +1,49 @@
import { NotebookUtil } from "./NotebookUtil";
import { GitHubUtils } from "../../Utils/GitHubUtils";
const fileName = "file";
const notebookName = "file.ipynb";
const filePath = `folder/${fileName}`;
const notebookPath = `folder/${notebookName}`;
const gitHubFileUri = GitHubUtils.toContentUri("owner", "repo", "branch", filePath);
const gitHubNotebookUri = GitHubUtils.toContentUri("owner", "repo", "branch", notebookPath);
describe("NotebookUtil", () => {
describe("isNotebookFile", () => {
it("works for jupyter file paths", () => {
expect(NotebookUtil.isNotebookFile(filePath)).toBeFalsy();
expect(NotebookUtil.isNotebookFile(notebookPath)).toBeTruthy();
});
it("works for github file uris", () => {
expect(NotebookUtil.isNotebookFile(gitHubFileUri)).toBeFalsy();
expect(NotebookUtil.isNotebookFile(gitHubNotebookUri)).toBeTruthy();
});
});
describe("getName", () => {
it("works for jupyter file paths", () => {
expect(NotebookUtil.getName(filePath)).toEqual(fileName);
expect(NotebookUtil.getName(notebookPath)).toEqual(notebookName);
});
it("works for github file uris", () => {
expect(NotebookUtil.getName(gitHubFileUri)).toEqual(fileName);
expect(NotebookUtil.getName(gitHubNotebookUri)).toEqual(notebookName);
});
});
describe("replaceName", () => {
it("works for jupyter file paths", () => {
expect(NotebookUtil.replaceName(filePath, "newName")).toEqual(filePath.replace(fileName, "newName"));
expect(NotebookUtil.replaceName(notebookPath, "newName")).toEqual(notebookPath.replace(notebookName, "newName"));
});
it("works for github file uris", () => {
expect(NotebookUtil.replaceName(gitHubFileUri, "newName")).toEqual(gitHubFileUri.replace(fileName, "newName"));
expect(NotebookUtil.replaceName(gitHubNotebookUri, "newName")).toEqual(
gitHubNotebookUri.replace(notebookName, "newName")
);
});
});
});

View File

@ -2,6 +2,7 @@ import path from "path";
import { ImmutableNotebook } from "@nteract/commutable";
import { NotebookContentItem, NotebookContentItemType } from "./NotebookContentItem";
import { StringUtils } from "../../Utils/StringUtils";
import { GitHubUtils } from "../../Utils/GitHubUtils";
// Must match rx-jupyter' FileType
export type FileType = "directory" | "file" | "notebook";
@ -11,7 +12,8 @@ export class NotebookUtil {
* It's a notebook file if the filename ends with .ipynb.
*/
public static isNotebookFile(notebookPath: string): boolean {
return StringUtils.endsWith(notebookPath, ".ipynb");
const fileName = NotebookUtil.getName(notebookPath);
return !!fileName && StringUtils.endsWith(fileName, ".ipynb");
}
/**
@ -68,8 +70,34 @@ export class NotebookUtil {
};
}
public static getContentName(uri: string): string | undefined {
const parts = uri.split("/");
return parts.pop() || parts.pop(); // handle potential trailing slash
public static getName(path: string): undefined | string {
let relativePath: string = path;
const contentInfo = GitHubUtils.fromContentUri(path);
if (contentInfo) {
relativePath = contentInfo.path;
}
return relativePath.split("/").pop();
}
public static replaceName(path: string, newName: string): string {
const contentInfo = GitHubUtils.fromContentUri(path);
if (contentInfo) {
const contentName = contentInfo.path.split("/").pop();
if (!contentName) {
throw new Error(`Failed to extract name from github path ${contentInfo.path}`);
}
const basePath = contentInfo.path.split(contentName).shift();
return GitHubUtils.toContentUri(contentInfo.owner, contentInfo.repo, contentInfo.branch, `${basePath}${newName}`);
}
const contentName = path.split("/").pop();
if (!contentName) {
throw new Error(`Failed to extract name from path ${path}`);
}
const basePath = path.split(contentName).shift();
return `${basePath}${newName}`;
}
}

View File

@ -20,6 +20,7 @@ import { TextFieldProps } from "./Controls/DialogReactComponent/DialogComponent"
import { UploadDetails } from "../workers/upload/definitions";
import { UploadFilePane } from "./Panes/UploadFilePane";
import { Versions } from "../../src/Contracts/ExplorerContracts";
import { CollectionCreationDefaults } from "../Shared/Constants";
export class ExplorerStub implements ViewModels.Explorer {
public flight: ko.Observable<string>;
@ -32,6 +33,7 @@ export class ExplorerStub implements ViewModels.Explorer {
public collectionTreeNodeAltText: ko.Observable<string>;
public refreshTreeTitle: ko.Observable<string>;
public collapsedResourceTreeWidth: number;
public collectionCreationDefaults: ViewModels.CollectionCreationDefaults = CollectionCreationDefaults;
public hasWriteAccess: ko.Observable<boolean> = ko.observable<boolean>(false);
public databaseAccount: ko.Observable<ViewModels.DatabaseAccount>;
public subscriptionType: ko.Observable<ViewModels.SubscriptionType>;

View File

@ -13,13 +13,13 @@ import EnvironmentUtility from "../../Common/EnvironmentUtility";
import Q from "q";
import TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstants";
import { config, Platform } from "../../Config";
import { ContextualPaneBase } from "./ContextualPaneBase";
import { CosmosClient } from "../../Common/CosmosClient";
import { createMongoCollectionWithARM, createMongoCollectionWithProxy } from "../../Common/MongoProxyClient";
import { DynamicListItem } from "../Controls/DynamicList/DynamicListComponent";
import { HashMap } from "../../Common/HashMap";
import { PlatformType } from "../../PlatformType";
import { config, Platform } from "../../Config";
export default class AddCollectionPane extends ContextualPaneBase implements ViewModels.AddCollectionPane {
public defaultExperience: ko.Computed<string>;
@ -832,7 +832,7 @@ export default class AddCollectionPane extends ContextualPaneBase implements Vie
const isAadUser = EnvironmentUtility.isAadUser();
// note: v3 autopilot not supported yet for Mongo fixed collections (only tier supported)
if (!isAadUser || isFixedCollectionWithSharedThroughputBeingCreated) {
if (!isAadUser) {
createCollectionFunc = () =>
Q(
createMongoCollectionWithProxy(
@ -853,6 +853,7 @@ export default class AddCollectionPane extends ContextualPaneBase implements Vie
this.container.armEndpoint(),
databaseId,
this._getAnalyticalStorageTtl(),
isFixedCollectionWithSharedThroughputBeingCreated,
collectionId,
offerThroughput,
partitionKeyPath,
@ -1007,14 +1008,14 @@ export default class AddCollectionPane extends ContextualPaneBase implements Vie
this.uniqueKeys([]);
this.useIndexingForSharedThroughput(true);
const subscriptionType = this.container.subscriptionType();
const flight = this.container.flight();
const defaultStorage = AddCollectionUtility.Utilities.getDefaultStorage(flight, subscriptionType);
const defaultStorage = this.container.collectionCreationDefaults.storage;
this.storage(defaultStorage);
const defaultThroughput = AddCollectionUtility.Utilities.getDefaultThroughput(flight, subscriptionType);
const defaultThroughput = this.container.collectionCreationDefaults.throughput;
this.throughputSinglePartition(defaultThroughput.fixed);
this.throughputMultiPartition(defaultThroughput.unlimited(this.container));
this.throughputMultiPartition(
AddCollectionUtility.Utilities.getMaxThroughput(this.container.collectionCreationDefaults, this.container)
);
this.throughputDatabase(defaultThroughput.shared);
this.databaseCreateNew(true);
@ -1211,7 +1212,7 @@ export default class AddCollectionPane extends ContextualPaneBase implements Vie
) {
return !this.hasAutoPilotV2FeatureFlag()
? {
[Constants.HttpHeaders.autoPilotThroughput]: `{ "maxThroughput": ${this.sharedAutoPilotThroughput() * 1} }`
[Constants.HttpHeaders.autoPilotThroughput]: { maxThroughput: this.sharedAutoPilotThroughput() * 1 }
}
: { [Constants.HttpHeaders.autoPilotTier]: this.selectedSharedAutoPilotTier().toString() };
}
@ -1221,7 +1222,7 @@ export default class AddCollectionPane extends ContextualPaneBase implements Vie
) {
return !this.hasAutoPilotV2FeatureFlag()
? {
[Constants.HttpHeaders.autoPilotThroughput]: `{ "maxThroughput": ${this.autoPilotThroughput() * 1} }`
[Constants.HttpHeaders.autoPilotThroughput]: { maxThroughput: this.autoPilotThroughput() * 1 }
}
: { [Constants.HttpHeaders.autoPilotTier]: this.selectedAutoPilotTier().toString() };
}
@ -1268,12 +1269,16 @@ export default class AddCollectionPane extends ContextualPaneBase implements Vie
}
private _updateThroughputLimitByCollectionStorage() {
const subscriptionType = this.container.subscriptionType();
const flight = this.container.flight();
const storage = this.storage();
const minThroughputRU = AddCollectionUtility.Utilities.getMinRUForStorageOption(subscriptionType, flight, storage);
const minThroughputRU = AddCollectionUtility.Utilities.getMinRUForStorageOption(
this.container.collectionCreationDefaults,
storage
);
let maxThroughputRU = AddCollectionUtility.Utilities.getMaxRUForStorageOption(subscriptionType, flight, storage);
let maxThroughputRU = AddCollectionUtility.Utilities.getMaxRUForStorageOption(
this.container.collectionCreationDefaults,
storage
);
if (this.isTryCosmosDBSubscription()) {
maxThroughputRU = Constants.TryCosmosExperience.maxRU;
}
@ -1283,10 +1288,7 @@ export default class AddCollectionPane extends ContextualPaneBase implements Vie
}
private _updateThroughputLimitByDatabase() {
const subscriptionType = this.container.subscriptionType();
const flight = this.container.flight();
const defaultThruoghput = AddCollectionUtility.Utilities.getDefaultThroughput(flight, subscriptionType);
const defaultThruoghput = this.container.collectionCreationDefaults.throughput;
this.maxThroughputRU(defaultThruoghput.unlimitedmax);
this.minThroughputRU(defaultThruoghput.unlimitedmin);
}

View File

@ -578,7 +578,7 @@ export default class AddDatabasePane extends ContextualPaneBase implements ViewM
) {
return !this.hasAutoPilotV2FeatureFlag()
? {
[Constants.HttpHeaders.autoPilotThroughput]: `{ "maxThroughput": ${this.maxAutoPilotThroughputSet() * 1} }`
[Constants.HttpHeaders.autoPilotThroughput]: { maxThroughput: this.maxAutoPilotThroughputSet() * 1 }
}
: { [Constants.HttpHeaders.autoPilotTier]: this.selectedAutoPilotTier().toString() };
}
@ -586,13 +586,7 @@ export default class AddDatabasePane extends ContextualPaneBase implements ViewM
}
private _updateThroughputLimitByDatabase() {
const subscriptionType = this.container.subscriptionType();
const flight = this.container.flight();
const throughputDefaults: AddCollectionUtility.ThroughputDefaults = AddCollectionUtility.Utilities.getDefaultThroughput(
flight,
subscriptionType
);
const throughputDefaults = this.container.collectionCreationDefaults.throughput;
this.throughput(throughputDefaults.shared);
this.maxThroughputRU(throughputDefaults.unlimitedmax);
this.minThroughputRU(throughputDefaults.unlimitedmin);

View File

@ -74,10 +74,7 @@ export default class CassandraAddCollectionPane extends ContextualPaneBase
});
this.keyspaceId.extend({ rateLimit: 100 });
this.dedicateTableThroughput = ko.observable<boolean>(false);
const flight = this.container.flight();
const subscriptionType = this.container.subscriptionType();
const throughputDefaults = AddCollectionUtility.Utilities.getDefaultThroughput(flight, subscriptionType);
const throughputDefaults = this.container.collectionCreationDefaults.throughput;
this.maxThroughputRU = ko.observable<number>(throughputDefaults.unlimitedmax);
this.minThroughputRU = ko.observable<number>(throughputDefaults.unlimitedmin);
@ -489,17 +486,16 @@ export default class CassandraAddCollectionPane extends ContextualPaneBase
public resetData() {
super.resetData();
const throughputDefaults = AddCollectionUtility.Utilities.getDefaultThroughput(
this.container.flight(),
this.container.subscriptionType()
);
const throughputDefaults = this.container.collectionCreationDefaults.throughput;
this.isAutoPilotSelected(false);
this.isSharedAutoPilotSelected(false);
this.selectedAutoPilotTier(null);
this.selectedSharedAutoPilotTier(null);
this.selectedAutoPilotThroughput(AutoPilotUtils.minAutoPilotThroughput);
this.sharedAutoPilotThroughput(AutoPilotUtils.minAutoPilotThroughput);
this.throughput(throughputDefaults.unlimited(this.container));
this.throughput(
AddCollectionUtility.Utilities.getMaxThroughput(this.container.collectionCreationDefaults, this.container)
);
this.keyspaceThroughput(throughputDefaults.shared);
this.maxThroughputRU(throughputDefaults.unlimitedmax);
this.minThroughputRU(throughputDefaults.unlimitedmin);

View File

@ -13,6 +13,7 @@ import { GitHubReposComponentAdapter } from "../Controls/GitHub/GitHubReposCompo
import { BranchesProps, PinnedReposProps, UnpinnedReposProps } from "../Controls/GitHub/ReposListComponent";
import { ConsoleDataType } from "../Menus/NotificationConsole/NotificationConsoleComponent";
import { ContextualPaneBase } from "./ContextualPaneBase";
import { JunoUtils } from "../../Utils/JunoUtils";
export class GitHubReposPane extends ContextualPaneBase {
private static readonly PageSize = 30;
@ -84,7 +85,7 @@ export class GitHubReposPane extends ContextualPaneBase {
public async submit(): Promise<void> {
const pinnedReposUpdated = this.pinnedReposUpdated;
const reposToPin: IPinnedRepo[] = this.pinnedReposProps.repos.map(repo => GitHubUtils.toPinnedRepo(repo));
const reposToPin: IPinnedRepo[] = this.pinnedReposProps.repos.map(repo => JunoUtils.toPinnedRepo(repo));
// Submit resets data too
super.submit();
@ -298,7 +299,7 @@ export class GitHubReposPane extends ContextualPaneBase {
({
key: GitHubUtils.toRepoFullName(pinnedRepo.owner, pinnedRepo.name),
branches: pinnedRepo.branches,
repo: GitHubUtils.toGitHubRepo(pinnedRepo)
repo: JunoUtils.toGitHubRepo(pinnedRepo)
} as RepoListItem)
);

View File

@ -245,11 +245,7 @@ export default class DatabaseSettingsTab extends TabsBase
if (collectionThroughputInfo && !!collectionThroughputInfo.minimumRUForCollection) {
return collectionThroughputInfo.minimumRUForCollection;
}
const flight = this.container.flight();
const subscriptionType = this.container.subscriptionType();
const throughputDefaults = AddCollectionUtility.Utilities.getDefaultThroughput(flight, subscriptionType);
const throughputDefaults = this.container.collectionCreationDefaults.throughput;
return throughputDefaults.unlimitedmin;
});
@ -269,10 +265,7 @@ export default class DatabaseSettingsTab extends TabsBase
return SharedConstants.CollectionCreation.MaxRUPerPartition * numPartitions;
}
const flight = this.container.flight();
const subscriptionType = this.container.subscriptionType();
const throughputDefaults = AddCollectionUtility.Utilities.getDefaultThroughput(flight, subscriptionType);
const throughputDefaults = this.container.collectionCreationDefaults.throughput;
return throughputDefaults.unlimitedmax;
});

View File

@ -329,7 +329,6 @@ export default class QueryTab extends TabsBase implements ViewModels.QueryTab, V
this.requestChargeDisplayText(`${queryResults.requestCharge} RUs`);
if (!this.queryResults() && !results) {
const appInsights: any = (<any>window).appInsights;
const errorMessage: string = JSON.stringify({
error: `Returned no results after query execution`,
accountName: this.collection && this.collection.container.databaseAccount(),
@ -341,7 +340,6 @@ export default class QueryTab extends TabsBase implements ViewModels.QueryTab, V
responseHeaders: queryResults && queryResults.headers
});
Logger.logError(errorMessage, "QueryTab");
appInsights && appInsights.trackTrace(errorMessage);
}
this.queryResults(results);

View File

@ -106,10 +106,7 @@
</throughput-input>
<!-- /ko -->
<div
class="storageCapacityTitle throughputStorageValue"
data-bind="html: storageCapacityTitle, visible: !isAutoPilotSelected()"
></div>
<div class="storageCapacityTitle throughputStorageValue" data-bind="html: storageCapacityTitle"></div>
<!-- /ko -->
<div data-bind="visible: rupmVisible">

View File

@ -103,10 +103,11 @@ export class ResourceTreeAdapter implements ReactAdapter {
this.sampleNotebooksContentRoot = {
name: "Sample Notebooks (View Only)",
path: GitHubUtils.toGitHubUriForRepoAndBranch(
path: GitHubUtils.toContentUri(
ResourceTreeAdapter.SamplesRepo.owner.login,
ResourceTreeAdapter.SamplesRepo.name,
ResourceTreeAdapter.SamplesBranch.name
ResourceTreeAdapter.SamplesBranch.name,
""
),
type: NotebookContentItemType.Directory
};
@ -157,7 +158,7 @@ export class ResourceTreeAdapter implements ReactAdapter {
pinnedRepo.branches.forEach(branch => {
repoTreeItem.children.push({
name: branch.name,
path: GitHubUtils.toGitHubUriForRepoAndBranch(pinnedRepo.owner, pinnedRepo.name, branch.name),
path: GitHubUtils.toContentUri(pinnedRepo.owner, pinnedRepo.name, branch.name, ""),
type: NotebookContentItemType.Directory
});
});
@ -620,7 +621,7 @@ export class ResourceTreeAdapter implements ReactAdapter {
];
// For GitHub paths remove "Delete", "Rename", "New Directory", "Upload File"
if (GitHubUtils.fromGitHubUri(item.path)) {
if (GitHubUtils.fromContentUri(item.path)) {
items = items.filter(
item =>
item.label !== "Delete" &&

View File

@ -28,8 +28,6 @@ export interface IGitHubFile {
path: string;
content?: string;
sha: string;
url: string;
html_url: string;
// Custom properties
children?: IGitHubFile[];
@ -68,6 +66,10 @@ export class GitHubClient {
}
};
private static readonly samplesBranch: IGitHubBranch = {
name: "master"
};
private static readonly samplesTopCommit: IGitHubCommit = {
sha: "41b964f442b638097a75a3f3b6a6451db05a12bf",
committer: {
@ -82,8 +84,6 @@ export class GitHubClient {
path: ".github",
sha: "5e6794a8177a0c07a8719f6e1d7b41cce6f92e1e",
size: 0,
url: "https://api.github.com/repos/Azure-Samples/cosmos-notebooks/contents/.github?ref=master",
html_url: "https://github.com/Azure-Samples/cosmos-notebooks/tree/master/.github",
type: "dir"
},
{
@ -91,8 +91,6 @@ export class GitHubClient {
path: ".gitignore",
sha: "3e759b75bf455ac809d0987d369aab89137b5689",
size: 5582,
url: "https://api.github.com/repos/Azure-Samples/cosmos-notebooks/contents/.gitignore?ref=master",
html_url: "https://github.com/Azure-Samples/cosmos-notebooks/blob/master/.gitignore",
type: "file"
},
{
@ -100,8 +98,6 @@ export class GitHubClient {
path: "1. GettingStarted.ipynb",
sha: "0732ff5366e4aefdc4c378c61cbd968664f0acec",
size: 3933,
url: "https://api.github.com/repos/Azure-Samples/cosmos-notebooks/contents/1.%20GettingStarted.ipynb?ref=master",
html_url: "https://github.com/Azure-Samples/cosmos-notebooks/blob/master/1.%20GettingStarted.ipynb",
type: "file"
},
{
@ -109,8 +105,6 @@ export class GitHubClient {
path: "2. Visualization.ipynb",
sha: "f480134ac4adf2f50ce5fe66836c6966749d3ca1",
size: 814261,
url: "https://api.github.com/repos/Azure-Samples/cosmos-notebooks/contents/2.%20Visualization.ipynb?ref=master",
html_url: "https://github.com/Azure-Samples/cosmos-notebooks/blob/master/2.%20Visualization.ipynb",
type: "file"
},
{
@ -118,8 +112,6 @@ export class GitHubClient {
path: "3. RequestUnits.ipynb",
sha: "252b79a4adc81e9f2ffde453231b695d75e270e8",
size: 9490,
url: "https://api.github.com/repos/Azure-Samples/cosmos-notebooks/contents/3.%20RequestUnits.ipynb?ref=master",
html_url: "https://github.com/Azure-Samples/cosmos-notebooks/blob/master/3.%20RequestUnits.ipynb",
type: "file"
},
{
@ -127,8 +119,6 @@ export class GitHubClient {
path: "4. Indexing.ipynb",
sha: "e10dd67bd1c55c345226769e4f80e43659ef9cd5",
size: 10394,
url: "https://api.github.com/repos/Azure-Samples/cosmos-notebooks/contents/4.%20Indexing.ipynb?ref=master",
html_url: "https://github.com/Azure-Samples/cosmos-notebooks/blob/master/4.%20Indexing.ipynb",
type: "file"
},
{
@ -136,9 +126,6 @@ export class GitHubClient {
path: "5. StoredProcedures.ipynb",
sha: "949941949920de4d2d111149e2182e9657cc8134",
size: 11818,
url:
"https://api.github.com/repos/Azure-Samples/cosmos-notebooks/contents/5.%20StoredProcedures.ipynb?ref=master",
html_url: "https://github.com/Azure-Samples/cosmos-notebooks/blob/master/5.%20StoredProcedures.ipynb",
type: "file"
},
{
@ -146,9 +133,6 @@ export class GitHubClient {
path: "6. GlobalDistribution.ipynb",
sha: "b91c31dacacbc9e35750d9054063dda4a5309f3b",
size: 11375,
url:
"https://api.github.com/repos/Azure-Samples/cosmos-notebooks/contents/6.%20GlobalDistribution.ipynb?ref=master",
html_url: "https://github.com/Azure-Samples/cosmos-notebooks/blob/master/6.%20GlobalDistribution.ipynb",
type: "file"
},
{
@ -156,9 +140,6 @@ export class GitHubClient {
path: "7. IoTAnomalyDetection.ipynb",
sha: "82057ae52a67721a5966e2361317f5dfbd0ee595",
size: 377939,
url:
"https://api.github.com/repos/Azure-Samples/cosmos-notebooks/contents/7.%20IoTAnomalyDetection.ipynb?ref=master",
html_url: "https://github.com/Azure-Samples/cosmos-notebooks/blob/master/7.%20IoTAnomalyDetection.ipynb",
type: "file"
},
{
@ -166,8 +147,6 @@ export class GitHubClient {
path: "All_API_quickstarts",
sha: "07054293e6c8fc00771fccd0cde207f5c8053978",
size: 0,
url: "https://api.github.com/repos/Azure-Samples/cosmos-notebooks/contents/All_API_quickstarts?ref=master",
html_url: "https://github.com/Azure-Samples/cosmos-notebooks/tree/master/All_API_quickstarts",
type: "dir"
},
{
@ -175,8 +154,6 @@ export class GitHubClient {
path: "CSharp_quickstarts",
sha: "10e7f5704e6b56a40cac74bc39f15b7708954f52",
size: 0,
url: "https://api.github.com/repos/Azure-Samples/cosmos-notebooks/contents/CSharp_quickstarts?ref=master",
html_url: "https://github.com/Azure-Samples/cosmos-notebooks/tree/master/CSharp_quickstarts",
type: "dir"
}
];
@ -315,7 +292,9 @@ export class GitHubClient {
if (GitHubClient.isSamplesCall(owner, repo, branch) && path === "") {
return {
status: HttpStatusCodes.OK,
data: GitHubClient.samplesFiles
data: GitHubClient.samplesFiles.map(file =>
GitHubClient.toGitHubFile(file, GitHubClient.samplesRepo, GitHubClient.samplesBranch)
)
};
}
@ -515,8 +494,6 @@ export class GitHubClient {
path: element.path,
content: element.content,
sha: element.sha,
url: element.url,
html_url: element.html_url,
repo,
branch
};

View File

@ -3,13 +3,13 @@ import { fixture } from "@nteract/fixtures";
import { HttpStatusCodes } from "../Common/Constants";
import { GitHubClient, IGitHubCommit, IGitHubFile } from "./GitHubClient";
import { GitHubContentProvider } from "./GitHubContentProvider";
import { GitHubUtils } from "../Utils/GitHubUtils";
const gitHubClient = new GitHubClient("token", () => {});
const gitHubContentProvider = new GitHubContentProvider({
gitHubClient,
promptForCommitMsg: () => Promise.resolve("commit msg")
});
const sampleGitHubUri = `https://github.com/login/repo/blob/branch/dir/name.ipynb`;
const sampleFile: IGitHubFile = {
type: "file",
encoding: "encoding",
@ -18,8 +18,6 @@ const sampleFile: IGitHubFile = {
path: "dir/name.ipynb",
content: btoa(fixture),
sha: "sha",
url: "url",
html_url: sampleGitHubUri,
repo: {
owner: {
login: "login"
@ -31,9 +29,15 @@ const sampleFile: IGitHubFile = {
name: "branch"
}
};
const sampleGitHubUri = GitHubUtils.toContentUri(
sampleFile.repo.owner.login,
sampleFile.repo.name,
sampleFile.branch.name,
sampleFile.path
);
const sampleNotebookModel: IContent<"notebook"> = {
name: sampleFile.name,
path: sampleFile.html_url,
path: sampleGitHubUri,
type: "notebook",
writable: true,
created: "",

View File

@ -7,6 +7,7 @@ import { Logger } from "../Common/Logger";
import { NotebookUtil } from "../Explorer/Notebook/NotebookUtil";
import { GitHubClient, IGitHubFile, IGitHubResponse, IGitHubCommit } from "./GitHubClient";
import { GitHubUtils } from "../Utils/GitHubUtils";
import UrlUtility from "../Common/UrlUtility";
export interface GitHubContentProviderParams {
gitHubClient: GitHubClient;
@ -53,12 +54,12 @@ export class GitHubContentProvider implements IContentProvider {
throw new GitHubContentProviderError("Failed to get content", content.status);
}
const gitHubInfo = GitHubUtils.fromGitHubUri(uri);
const contentInfo = GitHubUtils.fromContentUri(uri);
const commitResponse = await this.params.gitHubClient.getCommitsAsync(
gitHubInfo.owner,
gitHubInfo.repo,
gitHubInfo.branch,
gitHubInfo.path,
contentInfo.owner,
contentInfo.repo,
contentInfo.branch,
contentInfo.path,
1,
1
);
@ -95,7 +96,7 @@ export class GitHubContentProvider implements IContentProvider {
gitHubFile.branch.name,
commitMsg,
gitHubFile.path,
GitHubUtils.fromGitHubUri(newUri).path
GitHubUtils.fromContentUri(newUri).path
);
if (response.status !== HttpStatusCodes.OK) {
throw new GitHubContentProviderError("Failed to rename", response.status);
@ -134,8 +135,8 @@ export class GitHubContentProvider implements IContentProvider {
throw new GitHubContentProviderError("Unsupported content type");
}
const gitHubInfo = GitHubUtils.fromGitHubUri(uri);
if (!gitHubInfo) {
const contentInfo = GitHubUtils.fromContentUri(uri);
if (!contentInfo) {
throw new GitHubContentProviderError(`Failed to parse ${uri}`);
}
@ -151,14 +152,14 @@ export class GitHubContentProvider implements IContentProvider {
};
const name = `Untitled-${new Date().toLocaleString("default", options)}.ipynb`;
let path = name;
if (gitHubInfo.path) {
path = `${gitHubInfo.path}/${name}`;
if (contentInfo.path) {
path = UrlUtility.createUri(contentInfo.path, name);
}
const response = await this.params.gitHubClient.createOrUpdateFileAsync(
gitHubInfo.owner,
gitHubInfo.repo,
gitHubInfo.branch,
contentInfo.owner,
contentInfo.repo,
contentInfo.branch,
path,
commitMsg,
content
@ -167,12 +168,7 @@ export class GitHubContentProvider implements IContentProvider {
throw new GitHubContentProviderError("Failed to create", response.status);
}
const newUri = GitHubUtils.toGitHubUriForRepoAndBranch(
gitHubInfo.owner,
gitHubInfo.repo,
gitHubInfo.branch,
path
);
const newUri = GitHubUtils.toContentUri(contentInfo.owner, contentInfo.repo, contentInfo.branch, path);
const newContentResponse = await this.getContent(newUri);
if (newContentResponse.status !== HttpStatusCodes.OK) {
throw new GitHubContentProviderError("Failed to get content after creating", newContentResponse.status);
@ -288,9 +284,9 @@ export class GitHubContentProvider implements IContentProvider {
}
private getContent(uri: string): Promise<IGitHubResponse<IGitHubFile | IGitHubFile[]>> {
const gitHubInfo = GitHubUtils.fromGitHubUri(uri);
if (gitHubInfo) {
const { owner, repo, branch, path } = gitHubInfo;
const contentInfo = GitHubUtils.fromContentUri(uri);
if (contentInfo) {
const { owner, repo, branch, path } = contentInfo;
return this.params.gitHubClient.getContentsAsync(owner, repo, branch, path);
}
@ -324,7 +320,7 @@ export class GitHubContentProvider implements IContentProvider {
commit: IGitHubCommit
): IContent<"directory"> {
return {
name: NotebookUtil.getContentName(uri),
name: GitHubUtils.fromContentUri(uri).path,
path: uri,
type: "directory",
writable: true, // TODO: tamitta: we don't know this info here
@ -333,9 +329,14 @@ export class GitHubContentProvider implements IContentProvider {
mimetype: undefined,
content: gitHubFiles?.map(
(file: IGitHubFile) =>
this.createContentModel(GitHubUtils.toGitHubUriForFile(file), file, commit, {
content: 0
}) as IEmptyContent<FileType>
this.createContentModel(
GitHubUtils.toContentUri(file.repo.owner.login, file.repo.name, file.branch.name, file.path),
file,
commit,
{
content: 0
}
) as IEmptyContent<FileType>
),
format: "json"
};
@ -350,7 +351,12 @@ export class GitHubContentProvider implements IContentProvider {
gitHubFile.content && params.content !== 0 ? JSON.parse(atob(gitHubFile.content)) : undefined;
return {
name: gitHubFile.name,
path: GitHubUtils.toGitHubUriForFile(gitHubFile),
path: GitHubUtils.toContentUri(
gitHubFile.repo.owner.login,
gitHubFile.repo.name,
gitHubFile.branch.name,
gitHubFile.path
),
type: "notebook",
writable: true, // TODO: tamitta: we don't know this info here
created: "", // TODO: tamitta: we don't know this info here
@ -369,7 +375,12 @@ export class GitHubContentProvider implements IContentProvider {
const content: string = gitHubFile.content && params.content !== 0 ? atob(gitHubFile.content) : undefined;
return {
name: gitHubFile.name,
path: GitHubUtils.toGitHubUriForFile(gitHubFile),
path: GitHubUtils.toContentUri(
gitHubFile.repo.owner.login,
gitHubFile.repo.name,
gitHubFile.branch.name,
gitHubFile.path
),
type: "file",
writable: true, // TODO: tamitta: we don't know this info here
created: "", // TODO: tamitta: we don't know this info here

View File

@ -1,13 +1,5 @@
import * as ViewModels from "../Contracts/ViewModels";
import ko from "knockout";
import { AddDbUtilities } from "../Shared/AddDatabaseUtility";
import {
CollectionDefaults,
CreateCollectionUtilities,
CreateSqlCollectionUtilities,
Utilities
} from "./AddCollectionUtility";
import { CollectionStub, DatabaseStub, ExplorerStub } from "../Explorer/OpenActionsStubs";
import { CreateCollectionUtilities, CreateSqlCollectionUtilities, Utilities } from "./AddCollectionUtility";
jest.mock("AddDatabaseUtility");
const armEndpoint = "https://management.azure.com";
@ -159,985 +151,3 @@ describe("Add Collection Utitlity", () => {
});
});
});
describe("Add Collection Utilility", () => {
describe("_getDefaults()", () => {
describe("default storage", () => {
describe("for Benefits subscriptions", () => {
it("should be '100' in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.Benefits);
expect(value.storage).toBe("100");
});
it("should be '100' in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.Benefits);
expect(value.storage).toBe("100");
});
it("should be '100' in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.Benefits);
expect(value.storage).toBe("100");
});
it("should be '100' in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.Benefits);
expect(value.storage).toBe("100");
});
});
describe("for EA subscriptions", () => {
it("should be '100' in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.EA);
expect(value.storage).toBe("100");
});
it("should be '100' in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.EA);
expect(value.storage).toBe("100");
});
it("should be '100' in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.EA);
expect(value.storage).toBe("100");
});
it("should be '100' in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.EA);
expect(value.storage).toBe("100");
});
});
describe("for Free subscriptions", () => {
it("should be '100' in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.Free);
expect(value.storage).toBe("100");
});
it("should be '100' in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.Free);
expect(value.storage).toBe("100");
});
it("should be '100' in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.Free);
expect(value.storage).toBe("100");
});
it("should be '100' in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.Free);
expect(value.storage).toBe("100");
});
});
describe("for Internal subscriptions", () => {
it("should be '100' in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.Internal);
expect(value.storage).toBe("100");
});
it("should be '100' in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.Internal);
expect(value.storage).toBe("100");
});
it("should be '100' in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.Internal);
expect(value.storage).toBe("100");
});
it("should be '100' in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.Internal);
expect(value.storage).toBe("100");
});
});
describe("for PAYG subscriptions", () => {
it("should be '100' in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.PAYG);
expect(value.storage).toBe("100");
});
it("should be '100' in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.PAYG);
expect(value.storage).toBe("100");
});
it("should be '100' in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.PAYG);
expect(value.storage).toBe("100");
});
it("should be '100' in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.PAYG);
expect(value.storage).toBe("100");
});
});
});
describe("default throughput for fixed collections", () => {
describe("for Benefits subscriptions", () => {
it("should be 400 in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.fixed).toBe(400);
});
it("should be 400 in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.fixed).toBe(400);
});
it("should be 400 in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.fixed).toBe(400);
});
it("should be 400 in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.fixed).toBe(400);
});
it("should be 400 in flight '20190618.1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.1", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.fixed).toBe(400);
});
it("should be 400 in flight '20190618.2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.2", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.fixed).toBe(400);
});
});
describe("for EA subscriptions", () => {
it("should be 400 in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.EA);
expect(value.throughput.fixed).toBe(400);
});
it("should be 400 in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.EA);
expect(value.throughput.fixed).toBe(400);
});
it("should be 400 in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.EA);
expect(value.throughput.fixed).toBe(400);
});
it("should be 400 in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.EA);
expect(value.throughput.fixed).toBe(400);
});
it("should be 400 in flight '20190618.1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.1", ViewModels.SubscriptionType.EA);
expect(value.throughput.fixed).toBe(400);
});
it("should be 400 in flight '20190618.2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.2", ViewModels.SubscriptionType.EA);
expect(value.throughput.fixed).toBe(400);
});
});
describe("for Free subscriptions", () => {
it("should be 400 in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.Free);
expect(value.throughput.fixed).toBe(400);
});
it("should be 400 in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.Free);
expect(value.throughput.fixed).toBe(400);
});
it("should be 400 in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.Free);
expect(value.throughput.fixed).toBe(400);
});
it("should be 400 in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.Free);
expect(value.throughput.fixed).toBe(400);
});
it("should be 400 in flight '20190618.1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.1", ViewModels.SubscriptionType.Free);
expect(value.throughput.fixed).toBe(400);
});
it("should be 400 in flight '20190618.2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.2", ViewModels.SubscriptionType.Free);
expect(value.throughput.fixed).toBe(400);
});
});
describe("for Internal subscriptions", () => {
it("should be 400 in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.Internal);
expect(value.throughput.fixed).toBe(400);
});
it("should be 400 in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.Internal);
expect(value.throughput.fixed).toBe(400);
});
it("should be 400 in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.Internal);
expect(value.throughput.fixed).toBe(400);
});
it("should be 400 in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.Internal);
expect(value.throughput.fixed).toBe(400);
});
it("should be 400 in flight '20190618.1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.1", ViewModels.SubscriptionType.Internal);
expect(value.throughput.fixed).toBe(400);
});
it("should be 400 in flight '20190618.2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.2", ViewModels.SubscriptionType.Internal);
expect(value.throughput.fixed).toBe(400);
});
});
describe("for PAYG subscriptions", () => {
it("should be 400 in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.fixed).toBe(400);
});
it("should be 400 in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.fixed).toBe(400);
});
it("should be 400 in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.fixed).toBe(400);
});
it("should be 400 in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.fixed).toBe(400);
});
it("should be 400 in flight '20190618.1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.1", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.fixed).toBe(400);
});
it("should be 400 in flight '20190618.2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.2", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.fixed).toBe(400);
});
});
});
describe("default throughput for unlimited collections", () => {
describe("for Benefits subscriptions", () => {
it("should be 400 in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.unlimited(null)).toBe(400);
});
it("should be 400 in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.unlimited(null)).toBe(400);
});
it("should be 400 in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.unlimited(null)).toBe(400);
});
it("should be 400 in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.unlimited(null)).toBe(400);
});
it("should be 400 in flight '20190618.1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.1", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.unlimited(null)).toBe(400);
});
it("should be 400 in flight '20190618.2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.2", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.unlimited(null)).toBe(400);
});
});
describe("for EA subscriptions", () => {
const explorer5 = new ExplorerStub();
explorer5.databases = ko.observableArray([
new DatabaseStub({
id: ko.observable("db"),
collections: ko.observableArray([
new CollectionStub({
id: ko.observable("1")
}),
new CollectionStub({
id: ko.observable("2")
}),
new CollectionStub({
id: ko.observable("3")
}),
new CollectionStub({
id: ko.observable("4")
}),
new CollectionStub({
id: ko.observable("5")
})
])
})
]);
const explorer6 = new ExplorerStub();
explorer6.databases = ko.observableArray([
new DatabaseStub({
id: ko.observable("db"),
collections: ko.observableArray([
new CollectionStub({
id: ko.observable("1")
}),
new CollectionStub({
id: ko.observable("2")
}),
new CollectionStub({
id: ko.observable("3")
}),
new CollectionStub({
id: ko.observable("4")
}),
new CollectionStub({
id: ko.observable("5")
}),
new CollectionStub({
id: ko.observable("6")
})
])
})
]);
it("should be 400 in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.EA);
expect(value.throughput.unlimited(null)).toBe(400);
});
it("should be 400 in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.EA);
expect(value.throughput.unlimited(null)).toBe(400);
});
it("should be 400 in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.EA);
expect(value.throughput.unlimited(null)).toBe(400);
});
it("should be 400 in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.EA);
expect(value.throughput.unlimited(null)).toBe(400);
});
it("should be 10,000 in flight '20190618.1' and database with 5 collections or less", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.1", ViewModels.SubscriptionType.EA);
expect(value.throughput.unlimited(explorer5)).toBe(10000);
});
it("should be 10,000 in flight '20190618.1' and database with more than 5 collections", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.1", ViewModels.SubscriptionType.EA);
expect(value.throughput.unlimited(explorer6)).toBe(1000);
});
it("should be 1,000 in flight '20190618.2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.2", ViewModels.SubscriptionType.EA);
expect(value.throughput.unlimited(null)).toBe(1000);
});
});
describe("for Free subscriptions", () => {
it("should be 400 in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.Free);
expect(value.throughput.unlimited(null)).toBe(400);
});
it("should be 400 in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.Free);
expect(value.throughput.unlimited(null)).toBe(400);
});
it("should be 400 in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.Free);
expect(value.throughput.unlimited(null)).toBe(400);
});
it("should be 400 in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.Free);
expect(value.throughput.unlimited(null)).toBe(400);
});
it("should be 400 in flight '20190618.1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.1", ViewModels.SubscriptionType.Free);
expect(value.throughput.unlimited(null)).toBe(400);
});
it("should be 400 in flight '20190618.2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.2", ViewModels.SubscriptionType.Free);
expect(value.throughput.unlimited(null)).toBe(400);
});
});
describe("for Internal subscriptions", () => {
it("should be 400 in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.Internal);
expect(value.throughput.unlimited(null)).toBe(400);
});
it("should be 400 in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.Internal);
expect(value.throughput.unlimited(null)).toBe(400);
});
it("should be 400 in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.Internal);
expect(value.throughput.unlimited(null)).toBe(400);
});
it("should be 400 in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.Internal);
expect(value.throughput.unlimited(null)).toBe(400);
});
it("should be 400 in flight '20190618.1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.1", ViewModels.SubscriptionType.Internal);
expect(value.throughput.unlimited(null)).toBe(400);
});
it("should be 400 in flight '20190618.2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.2", ViewModels.SubscriptionType.Internal);
expect(value.throughput.unlimited(null)).toBe(400);
});
});
describe("for PAYG subscriptions", () => {
it("should be 400 in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.unlimited(null)).toBe(400);
});
it("should be 400 in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.unlimited(null)).toBe(400);
});
it("should be 400 in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.unlimited(null)).toBe(400);
});
it("should be 400 in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.unlimited(null)).toBe(400);
});
it("should be 400 in flight '20190618.1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.1", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.unlimited(null)).toBe(400);
});
it("should be 400 in flight '20190618.2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.2", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.unlimited(null)).toBe(400);
});
});
});
describe("min throughput for unlimited collections", () => {
describe("for Benefits subscriptions", () => {
it("should be 400 in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.unlimitedmin).toBe(400);
});
it("should be 400 in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.unlimitedmin).toBe(400);
});
it("should be 400 in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.unlimitedmin).toBe(400);
});
it("should be 400 in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.unlimitedmin).toBe(400);
});
it("should be 400 in flight '20190618.1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.1", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.unlimitedmin).toBe(400);
});
it("should be 400 in flight '20190618.2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.2", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.unlimitedmin).toBe(400);
});
});
describe("for EA subscriptions", () => {
it("should be 400 in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.EA);
expect(value.throughput.unlimitedmin).toBe(400);
});
it("should be 400 in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.EA);
expect(value.throughput.unlimitedmin).toBe(400);
});
it("should be 400 in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.EA);
expect(value.throughput.unlimitedmin).toBe(400);
});
it("should be 400 in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.EA);
expect(value.throughput.unlimitedmin).toBe(400);
});
it("should be 400 in flight '20190618.1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.1", ViewModels.SubscriptionType.EA);
expect(value.throughput.unlimitedmin).toBe(400);
});
it("should be 400 in flight '20190618.2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.2", ViewModels.SubscriptionType.EA);
expect(value.throughput.unlimitedmin).toBe(400);
});
});
describe("for Free subscriptions", () => {
it("should be 400 in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.Free);
expect(value.throughput.unlimitedmin).toBe(400);
});
it("should be 400 in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.Free);
expect(value.throughput.unlimitedmin).toBe(400);
});
it("should be 400 in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.Free);
expect(value.throughput.unlimitedmin).toBe(400);
});
it("should be 400 in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.Free);
expect(value.throughput.unlimitedmin).toBe(400);
});
it("should be 400 in flight '20190618.1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.1", ViewModels.SubscriptionType.Free);
expect(value.throughput.unlimitedmin).toBe(400);
});
it("should be 400 in flight '20190618.2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.2", ViewModels.SubscriptionType.Free);
expect(value.throughput.unlimitedmin).toBe(400);
});
});
describe("for Internal subscriptions", () => {
it("should be 400 in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.Internal);
expect(value.throughput.unlimitedmin).toBe(400);
});
it("should be 400 in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.Internal);
expect(value.throughput.unlimitedmin).toBe(400);
});
it("should be 400 in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.Internal);
expect(value.throughput.unlimitedmin).toBe(400);
});
it("should be 400 in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.Internal);
expect(value.throughput.unlimitedmin).toBe(400);
});
it("should be 400 in flight '20190618.1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.1", ViewModels.SubscriptionType.Internal);
expect(value.throughput.unlimitedmin).toBe(400);
});
it("should be 400 in flight '20190618.2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.2", ViewModels.SubscriptionType.Internal);
expect(value.throughput.unlimitedmin).toBe(400);
});
});
describe("for PAYG subscriptions", () => {
it("should be 400 in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.unlimitedmin).toBe(400);
});
it("should be 400 in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.unlimitedmin).toBe(400);
});
it("should be 400 in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.unlimitedmin).toBe(400);
});
it("should be 400 in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.unlimitedmin).toBe(400);
});
it("should be 400 in flight '20190618.1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.1", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.unlimitedmin).toBe(400);
});
it("should be 400 in flight '20190618.2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.2", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.unlimitedmin).toBe(400);
});
});
});
describe("max throughput for unlimited collections", () => {
describe("for Benefits subscriptions", () => {
it("should be 100,000 in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.unlimitedmax).toBe(100000);
});
it("should be 100,000 in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.unlimitedmax).toBe(100000);
});
it("should be 100,000 in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.unlimitedmax).toBe(100000);
});
it("should be 100,000 in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.unlimitedmax).toBe(100000);
});
it("should be 100,000 in flight '20190618.1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.1", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.unlimitedmax).toBe(100000);
});
it("should be 100,000 in flight '20190618.2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.2", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.unlimitedmax).toBe(100000);
});
});
describe("for EA subscriptions", () => {
it("should be 1,000,000 in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.EA);
expect(value.throughput.unlimitedmax).toBe(1000000);
});
it("should be 1,000,000 in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.EA);
expect(value.throughput.unlimitedmax).toBe(1000000);
});
it("should be 1,000,000 in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.EA);
expect(value.throughput.unlimitedmax).toBe(1000000);
});
it("should be 1,000,000 in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.EA);
expect(value.throughput.unlimitedmax).toBe(1000000);
});
it("should be 1,000,000 in flight '20190618.1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.1", ViewModels.SubscriptionType.EA);
expect(value.throughput.unlimitedmax).toBe(1000000);
});
it("should be 1,000,000 in flight '20190618.2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.2", ViewModels.SubscriptionType.EA);
expect(value.throughput.unlimitedmax).toBe(1000000);
});
});
describe("for Free subscriptions", () => {
it("should be 100,000 in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.Free);
expect(value.throughput.unlimitedmax).toBe(100000);
});
it("should be 100,000 in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.Free);
expect(value.throughput.unlimitedmax).toBe(100000);
});
it("should be 100,000 in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.Free);
expect(value.throughput.unlimitedmax).toBe(100000);
});
it("should be 100,000 in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.Free);
expect(value.throughput.unlimitedmax).toBe(100000);
});
it("should be 100,000 in flight '20190618.1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.1", ViewModels.SubscriptionType.Free);
expect(value.throughput.unlimitedmax).toBe(100000);
});
it("should be 100,000 in flight '20190618.2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.2", ViewModels.SubscriptionType.Free);
expect(value.throughput.unlimitedmax).toBe(100000);
});
});
describe("for Internal subscriptions", () => {
it("should be 100,000 in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.Internal);
expect(value.throughput.unlimitedmax).toBe(100000);
});
it("should be 100,000 in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.Internal);
expect(value.throughput.unlimitedmax).toBe(100000);
});
it("should be 100,000 in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.Internal);
expect(value.throughput.unlimitedmax).toBe(100000);
});
it("should be 100,000 in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.Internal);
expect(value.throughput.unlimitedmax).toBe(100000);
});
it("should be 100,000 in flight '20190618.1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.1", ViewModels.SubscriptionType.Internal);
expect(value.throughput.unlimitedmax).toBe(100000);
});
it("should be 100,000 in flight '20190618.2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.2", ViewModels.SubscriptionType.Internal);
expect(value.throughput.unlimitedmax).toBe(100000);
});
});
describe("for PAYG subscriptions", () => {
it("should be 1,000,000 in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.unlimitedmax).toBe(1000000);
});
it("should be 1,000,000 in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.unlimitedmax).toBe(1000000);
});
it("should be 1,000,000 in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.unlimitedmax).toBe(1000000);
});
it("should be 1,000,000 in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.unlimitedmax).toBe(1000000);
});
it("should be 1,000,000 in flight '20190618.1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.1", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.unlimitedmax).toBe(1000000);
});
it("should be 1,000,000 in flight '20190618.2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.2", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.unlimitedmax).toBe(1000000);
});
});
});
describe("default throughput for shared offers", () => {
describe("for Benefits subscriptions", () => {
it("should be 400 in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.shared).toBe(400);
});
it("should be 400 in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.shared).toBe(400);
});
it("should be 400 in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.shared).toBe(400);
});
it("should be 400 in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.shared).toBe(400);
});
it("should be 400 in flight '20190618.1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.1", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.shared).toBe(400);
});
it("should be 400 in flight '20190618.2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.2", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.shared).toBe(400);
});
});
describe("for EA subscriptions", () => {
it("should be 400 in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.EA);
expect(value.throughput.shared).toBe(400);
});
it("should be 400 in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.EA);
expect(value.throughput.shared).toBe(400);
});
it("should be 400 in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.EA);
expect(value.throughput.shared).toBe(400);
});
it("should be 400 in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.EA);
expect(value.throughput.shared).toBe(400);
});
it("should be 20,000 in flight '20190618.1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.1", ViewModels.SubscriptionType.EA);
expect(value.throughput.shared).toBe(20000);
});
it("should be 5,000 in flight '20190618.2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.2", ViewModels.SubscriptionType.EA);
expect(value.throughput.shared).toBe(5000);
});
});
describe("for Free subscriptions", () => {
it("should be 400 in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.Free);
expect(value.throughput.shared).toBe(400);
});
it("should be 400 in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.Free);
expect(value.throughput.shared).toBe(400);
});
it("should be 400 in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.Free);
expect(value.throughput.shared).toBe(400);
});
it("should be 400 in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.Free);
expect(value.throughput.shared).toBe(400);
});
it("should be 400 in flight '20190618.1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.1", ViewModels.SubscriptionType.Free);
expect(value.throughput.shared).toBe(400);
});
it("should be 400 in flight '20190618.2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.2", ViewModels.SubscriptionType.Free);
expect(value.throughput.shared).toBe(400);
});
});
describe("for Internal subscriptions", () => {
it("should be 400 in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.Internal);
expect(value.throughput.shared).toBe(400);
});
it("should be 400 in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.Internal);
expect(value.throughput.shared).toBe(400);
});
it("should be 400 in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.Internal);
expect(value.throughput.shared).toBe(400);
});
it("should be 400 in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.Internal);
expect(value.throughput.shared).toBe(400);
});
it("should be 400 in flight '20190618.1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.1", ViewModels.SubscriptionType.Internal);
expect(value.throughput.shared).toBe(400);
});
it("should be 400 in flight '20190618.2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.2", ViewModels.SubscriptionType.Internal);
expect(value.throughput.shared).toBe(400);
});
});
describe("for PAYG subscriptions", () => {
it("should be 400 in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.shared).toBe(400);
});
it("should be 400 in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.shared).toBe(400);
});
it("should be 400 in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.shared).toBe(400);
});
it("should be 400 in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.shared).toBe(400);
});
it("should be 400 in flight '20190618.1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.1", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.shared).toBe(400);
});
it("should be 400 in flight '20190618.2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.2", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.shared).toBe(400);
});
});
});
});
});

View File

@ -11,7 +11,6 @@ import { MessageHandler } from "../Common/MessageHandler";
import { MessageTypes } from "../Contracts/ExplorerContracts";
import { NotificationConsoleUtils } from "../Utils/NotificationConsoleUtils";
import { ResourceProviderClient } from "../ResourceProvider/ResourceProviderClient";
import { SubscriptionType } from "../Contracts/ViewModels";
export class CreateSqlCollectionUtilities {
public static createSqlCollection(
@ -243,61 +242,43 @@ export class Utilities {
}
}
public static getDefaultStorage(flight: string, subscriptionType: SubscriptionType): string {
const flightDefaults: string = Utilities._getDefaults(flight, subscriptionType).storage;
return flightDefaults;
}
public static getDefaultThroughput(flight: string, subscriptionType: SubscriptionType): ThroughputDefaults {
const flightDefaults: ThroughputDefaults = Utilities._getDefaults(flight, subscriptionType).throughput;
return flightDefaults;
}
public static getMaxRUForStorageOption(
subscriptionType = SharedConstants.CollectionCreation.DefaultSubscriptionType,
flight = SharedConstants.CollectionCreation.DefaultAddCollectionDefaultFlight,
defaults: ViewModels.CollectionCreationDefaults,
storageOption: string
): number {
if (storageOption === SharedConstants.CollectionCreation.storage10Gb) {
return SharedConstants.CollectionCreation.DefaultCollectionRUs10K;
}
const defaults = Utilities._getDefaults(flight, subscriptionType);
return defaults.throughput.unlimitedmax;
}
public static getMinRUForStorageOption(
subscriptionType = SharedConstants.CollectionCreation.DefaultSubscriptionType,
flight = SharedConstants.CollectionCreation.DefaultAddCollectionDefaultFlight,
defaults: ViewModels.CollectionCreationDefaults,
storageOption: string
): number {
if (storageOption === SharedConstants.CollectionCreation.storage10Gb) {
return SharedConstants.CollectionCreation.DefaultCollectionRUs400;
}
const collectionDefaults = Utilities._getCollectionDefaults(subscriptionType, flight);
return collectionDefaults.throughput.unlimitedmin;
return defaults.throughput.unlimitedmin;
}
public static _getDefaults(flight: string, subscriptionType: SubscriptionType): CollectionDefaults {
return Utilities._getCollectionDefaults(subscriptionType, flight);
}
private static _getCollectionDefaults(
subscriptionType = SharedConstants.CollectionCreation.DefaultSubscriptionType,
flight = SharedConstants.CollectionCreation.DefaultAddCollectionDefaultFlight
): CollectionDefaults {
if (!(flight in Utilities._defaultsMap)) {
flight = SharedConstants.CollectionCreation.DefaultAddCollectionDefaultFlight;
public static getMaxThroughput(
defaults: ViewModels.CollectionCreationDefaults,
container: ViewModels.Explorer
): number {
const throughput = defaults.throughput.unlimited;
if (typeof throughput === "number") {
return throughput;
} else {
return this._exceedsThreshold(throughput.collectionThreshold, container)
? throughput.greatThanThreshold
: throughput.lessThanOrEqualToThreshold;
}
return Utilities._defaultsMap[flight][SubscriptionType[subscriptionType]];
}
private static _exceedsThreshold(container: ViewModels.Explorer): boolean {
const unlimitedThreshold: number = 5;
private static _exceedsThreshold(unlimitedThreshold: number, container: ViewModels.Explorer): boolean {
const databases = (container && container.databases && container.databases()) || [];
return _.any(
databases,
@ -306,340 +287,9 @@ export class Utilities {
);
}
private static _defaultsMap: { [flight: string]: { [subscriptionType: string]: CollectionDefaults } } = {
"0": {
Benefits: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs100K,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
},
Free: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs100K,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
},
EA: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs1Million,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
},
Internal: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs100K,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
},
PAYG: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs1Million,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
}
},
"1": {
Benefits: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs100K,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
},
Free: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs100K,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
},
EA: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs1Million,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
},
Internal: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs100K,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
},
PAYG: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs1Million,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
}
},
"2": {
Benefits: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs100K,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
},
Free: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs100K,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
},
EA: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs1Million,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
},
Internal: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs100K,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
},
PAYG: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs1Million,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
}
},
"3": {
Benefits: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs100K,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
},
Free: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs100K,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
},
EA: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs1Million,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
},
Internal: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs100K,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
},
PAYG: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs1Million,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
}
},
"20190618.1": {
Benefits: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs100K,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
},
Free: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs100K,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
},
EA: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: container =>
Utilities._exceedsThreshold(container)
? SharedConstants.CollectionCreation.DefaultCollectionRUs1000
: SharedConstants.CollectionCreation.DefaultCollectionRUs10K,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs1Million,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs20000
}
},
Internal: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs100K,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
},
PAYG: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs1Million,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
}
},
"20190618.2": {
Benefits: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs100K,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
},
Free: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs100K,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
},
EA: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs1000,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs1Million,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs5000
}
},
Internal: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs100K,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
},
PAYG: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs1Million,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
}
}
};
private static _getAzureTableUri(params: DataModels.CreateDatabaseAndCollectionRequest): string {
return `subscriptions/${CosmosClient.subscriptionId()}/resourceGroups/${CosmosClient.resourceGroup()}/providers/Microsoft.DocumentDB/databaseAccounts/${
CosmosClient.databaseAccount().name
}/tables/${params.collectionId}`;
}
}
export interface CollectionDefaults {
storage: string;
throughput: ThroughputDefaults;
}
export interface ThroughputDefaults {
fixed: number;
unlimited: (explorer: ViewModels.Explorer) => number;
unlimitedmax: number;
unlimitedmin: number;
shared: number;
}

View File

@ -51,7 +51,7 @@ describe("Add Database Utitlity", () => {
resourceProviderClientPutAsyncSpy
).toHaveBeenCalledWith(
"subscriptions/a1/resourceGroups/b1/providers/Microsoft.DocumentDB/databaseAccounts/main/gremlinDatabases/a1-db",
"2020-03-01",
"2020-04-01",
{ properties: { options: { throughput: "50000" }, resource: { id: "a1-db" } } }
);
});
@ -63,7 +63,7 @@ describe("Add Database Utitlity", () => {
resourceProviderClientPutAsyncSpy
).toHaveBeenCalledWith(
"subscriptions/a1/resourceGroups/b1/providers/Microsoft.DocumentDB/databaseAccounts/main/gremlinDatabases/a1-db",
"2020-03-01",
"2020-04-01",
{ properties: { options: { "x-ms-cosmos-offer-autopilot-tier": "1" }, resource: { id: "a1-db" } } }
);
});
@ -85,7 +85,7 @@ describe("Add Database Utitlity", () => {
resourceProviderClientPutAsyncSpy
).toHaveBeenCalledWith(
"subscriptions/a2/resourceGroups/c1/providers/Microsoft.DocumentDB/databaseAccounts/main/gremlinDatabases/a2-db",
"2020-03-01",
"2020-04-01",
{ properties: { options: {}, resource: { id: "a2-db" } } }
);
});
@ -111,7 +111,7 @@ describe("Add Database Utitlity", () => {
resourceProviderClientPutAsyncSpy
).toHaveBeenCalledWith(
"subscriptions/a1/resourceGroups/b1/providers/Microsoft.DocumentDB/databaseAccounts/main/sqlDatabases/a1-db",
"2020-03-01",
"2020-04-01",
{ properties: { options: { throughput: "50000" }, resource: { id: "a1-db" } } }
);
});
@ -123,7 +123,7 @@ describe("Add Database Utitlity", () => {
resourceProviderClientPutAsyncSpy
).toHaveBeenCalledWith(
"subscriptions/a1/resourceGroups/b1/providers/Microsoft.DocumentDB/databaseAccounts/main/sqlDatabases/a1-db",
"2020-03-01",
"2020-04-01",
{ properties: { options: { "x-ms-cosmos-offer-autopilot-tier": "1" }, resource: { id: "a1-db" } } }
);
});
@ -145,7 +145,7 @@ describe("Add Database Utitlity", () => {
resourceProviderClientPutAsyncSpy
).toHaveBeenCalledWith(
"subscriptions/a2/resourceGroups/c1/providers/Microsoft.DocumentDB/databaseAccounts/main/sqlDatabases/a2-db",
"2020-03-01",
"2020-04-01",
{ properties: { options: {}, resource: { id: "a2-db" } } }
);
});

View File

@ -183,6 +183,17 @@ export class CollectionCreation {
public static readonly TablesAPIDefaultDatabase: string = "TablesDB";
}
export const CollectionCreationDefaults = {
storage: CollectionCreation.storage100Gb,
throughput: {
fixed: CollectionCreation.DefaultCollectionRUs400,
unlimited: CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: CollectionCreation.DefaultCollectionRUs1Million,
unlimitedmin: CollectionCreation.DefaultCollectionRUs400,
shared: CollectionCreation.DefaultCollectionRUs400
}
} as const;
export class IndexingPolicies {
public static SharedDatabaseDefault = {
indexingMode: "consistent",

View File

@ -1,6 +1,8 @@
import { Action, ActionModifiers } from "./TelemetryConstants";
import { MessageHandler } from "../../Common/MessageHandler";
import { MessageTypes } from "../../Contracts/ExplorerContracts";
import { appInsights } from "../appInsights";
import { config } from "../../Config";
/**
* Class that persists telemetry data to the portal tables.
@ -18,11 +20,7 @@ export default class TelemetryProcessor {
}
});
const appInsights: Microsoft.ApplicationInsights.IAppInsights = (<any>window).appInsights;
if (!appInsights) {
return;
}
appInsights.trackEvent(Action[action], data);
appInsights.trackEvent({ name: Action[action] }, TelemetryProcessor.getData(data));
}
public static traceStart(action: Action, data?: any): number {
@ -37,10 +35,7 @@ export default class TelemetryProcessor {
}
});
const appInsights: Microsoft.ApplicationInsights.IAppInsights = (<any>window).appInsights;
if (appInsights) {
appInsights.startTrackEvent(Action[action]);
}
appInsights.startTrackEvent(Action[action]);
return timestamp;
}
@ -55,11 +50,7 @@ export default class TelemetryProcessor {
}
});
const appInsights: Microsoft.ApplicationInsights.IAppInsights = (<any>window).appInsights;
if (!appInsights) {
return;
}
appInsights.stopTrackEvent(Action[action], data);
appInsights.stopTrackEvent(Action[action], TelemetryProcessor.getData(data));
}
public static traceFailure(action: Action, data?: any, timestamp?: number): void {
@ -73,11 +64,7 @@ export default class TelemetryProcessor {
}
});
const appInsights: Microsoft.ApplicationInsights.IAppInsights = (<any>window).appInsights;
if (!appInsights) {
return;
}
appInsights.stopTrackEvent(Action[action], data);
appInsights.stopTrackEvent(Action[action], TelemetryProcessor.getData(data));
}
public static traceCancel(action: Action, data?: any, timestamp?: number): void {
@ -91,11 +78,7 @@ export default class TelemetryProcessor {
}
});
const appInsights: Microsoft.ApplicationInsights.IAppInsights = (<any>window).appInsights;
if (!appInsights) {
return;
}
appInsights.stopTrackEvent(Action[action], data);
appInsights.stopTrackEvent(Action[action], TelemetryProcessor.getData(data));
}
public static traceOpen(action: Action, data?: any, timestamp?: number): number {
@ -109,10 +92,7 @@ export default class TelemetryProcessor {
}
});
const appInsights: Microsoft.ApplicationInsights.IAppInsights = (<any>window).appInsights;
if (appInsights) {
appInsights.startTrackEvent(Action[action]);
}
appInsights.startTrackEvent(Action[action]);
return timestamp;
}
@ -127,10 +107,14 @@ export default class TelemetryProcessor {
}
});
const appInsights: Microsoft.ApplicationInsights.IAppInsights = (<any>window).appInsights;
if (appInsights) {
appInsights.startTrackEvent(Action[action]);
}
appInsights.startTrackEvent(Action[action]);
return timestamp;
}
private static getData(data?: any): any {
return {
platform: config.platform,
...(data ? data : [])
};
}
}

View File

@ -1,50 +1,32 @@
import { GitHubUtils } from "./GitHubUtils";
const owner = "owner-1";
const repo = "repo-1";
const branch = "branch/name.1-2";
const path = "folder name/file name1:2.ipynb";
describe("GitHubUtils", () => {
describe("fromGitHubUri", () => {
it("parses github repo url for a branch", () => {
const gitHubInfo = GitHubUtils.fromGitHubUri("https://github.com/owner/repo/tree/branch");
expect(gitHubInfo).toEqual({
owner: "owner",
repo: "repo",
branch: "branch",
path: ""
});
});
it("parses github file url", () => {
const gitHubInfo = GitHubUtils.fromGitHubUri("https://github.com/owner/repo/blob/branch/dir/file.ext");
expect(gitHubInfo).toEqual({
owner: "owner",
repo: "repo",
branch: "branch",
path: "dir/file.ext"
});
});
it("parses github file url with spaces", () => {
const gitHubInfo = GitHubUtils.fromGitHubUri("https://github.com/owner/repo/blob/branch/dir/file name.ext");
expect(gitHubInfo).toEqual({
owner: "owner",
repo: "repo",
branch: "branch",
path: "dir/file name.ext"
});
});
it("parses github file url with encoded chars", () => {
const gitHubInfo = GitHubUtils.fromGitHubUri("https://github.com/owner/repo/blob/branch/dir/file%20name.ext");
expect(gitHubInfo).toEqual({
owner: "owner",
repo: "repo",
branch: "branch",
path: "dir/file%20name.ext"
});
it("fromRepoUri parses github repo url correctly", () => {
const repoInfo = GitHubUtils.fromRepoUri(`https://github.com/${owner}/${repo}/tree/${branch}`);
expect(repoInfo).toEqual({
owner,
repo,
branch
});
});
it("toRepoFullName returns full name in expected format", () => {
const fullName = GitHubUtils.toRepoFullName("owner", "repo");
expect(fullName).toBe("owner/repo");
it("toContentUri generates github uris correctly", () => {
const uri = GitHubUtils.toContentUri(owner, repo, branch, path);
expect(uri).toBe(`github://${owner}/${repo}/${path}?ref=${branch}`);
});
it("fromContentUri parses the github uris correctly", () => {
const contentInfo = GitHubUtils.fromContentUri(`github://${owner}/${repo}/${path}?ref=${branch}`);
expect(contentInfo).toEqual({
owner,
repo,
branch,
path
});
});
});

View File

@ -1,56 +1,46 @@
import UrlUtility from "../Common/UrlUtility";
import { RepoListItem } from "../Explorer/Controls/GitHub/GitHubReposComponent";
import { IGitHubFile, IGitHubRepo } from "../GitHub/GitHubClient";
import { IPinnedRepo } from "../Juno/JunoClient";
export class GitHubUtils {
// The pattern is https://github.com/<owner>/<repo>/(blob|tree)/<branch>/<path>
private static readonly UriPattern = "https://github.com/([^/]*)/([^/]*)/(blob|tree)/([^/]*)/?(.*)";
// https://github.com/<owner>/<repo>/tree/<branch>
// The url when users visit a repo/branch on github.com
private static readonly RepoUriPattern = /https:\/\/github.com\/([^/]*)\/([^/]*)\/tree\/([^?]*)/;
// github://<owner>/<repo>/<path>?ref=<branch>
// Custom scheme for github content
private static readonly ContentUriPattern = /github:\/\/([^/]*)\/([^/]*)\/([^?]*)\?ref=(.*)/;
public static toRepoFullName(owner: string, repo: string): string {
return `${owner}/${repo}`;
}
public static toGitHubUriForRepoAndBranch(owner: string, repo: string, branch: string, path?: string): string {
return UrlUtility.createUri(`https://github.com/${owner}/${repo}/tree/${branch}`, path);
public static fromRepoUri(repoUri: string): undefined | { owner: string; repo: string; branch: string } {
const matches = repoUri.match(GitHubUtils.RepoUriPattern);
if (matches && matches.length > 3) {
return {
owner: matches[1],
repo: matches[2],
branch: matches[3]
};
}
return undefined;
}
public static toGitHubUriForFile(gitHubFile: IGitHubFile): string {
return decodeURIComponent(gitHubFile.html_url);
}
public static fromGitHubUri(
gitHubUri: string
public static fromContentUri(
contentUri: string
): undefined | { owner: string; repo: string; branch: string; path: string } {
try {
const matches = gitHubUri.match(GitHubUtils.UriPattern);
const matches = contentUri.match(GitHubUtils.ContentUriPattern);
if (matches && matches.length > 4) {
return {
owner: matches[1],
repo: matches[2],
branch: matches[4],
path: matches[5]
path: matches[3]
};
} catch (error) {
return undefined;
}
return undefined;
}
public static toPinnedRepo(item: RepoListItem): IPinnedRepo {
return {
owner: item.repo.owner.login,
name: item.repo.name,
private: item.repo.private,
branches: item.branches.map(element => ({ name: element.name }))
};
}
public static toGitHubRepo(pinnedRepo: IPinnedRepo): IGitHubRepo {
return {
owner: {
login: pinnedRepo.owner
},
name: pinnedRepo.name,
private: pinnedRepo.private
};
public static toContentUri(owner: string, repo: string, branch: string, path: string): string {
return `github://${owner}/${repo}/${path}?ref=${branch}`;
}
}

View File

@ -1,5 +1,8 @@
import * as DataModels from "../Contracts/DataModels";
import { config } from "../Config";
import { RepoListItem } from "../Explorer/Controls/GitHub/GitHubReposComponent";
import { IPinnedRepo } from "../Juno/JunoClient";
import { IGitHubRepo } from "../GitHub/GitHubClient";
export class JunoUtils {
public static async getLikedNotebooks(authorizationToken: string): Promise<DataModels.LikedNotebooksJunoResponse> {
@ -41,4 +44,23 @@ export class JunoUtils {
return undefined;
//TODO: add notebookMetadata updation code
}
public static toPinnedRepo(item: RepoListItem): IPinnedRepo {
return {
owner: item.repo.owner.login,
name: item.repo.name,
private: item.repo.private,
branches: item.branches.map(element => ({ name: element.name }))
};
}
public static toGitHubRepo(pinnedRepo: IPinnedRepo): IGitHubRepo {
return {
owner: {
login: pinnedRepo.owner
},
name: pinnedRepo.name,
private: pinnedRepo.private
};
}
}

View File

@ -1,54 +1,61 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"noEmit": true,
"strictNullChecks": true,
"strict": true,
"noUnusedLocals": true
},
"files": [
"./src/AuthType.ts",
"./src/Bindings/ReactBindingHandler.ts",
"./src/Common/ArrayHashMap.ts",
"./src/Common/Constants.ts",
"./src/Common/DeleteFeedback.ts",
"./src/Common/HashMap.ts",
"./src/Common/ObjectCache.ts",
"./src/Common/ThemeUtility.ts",
"extends": "./tsconfig.json",
"compilerOptions": {
"noEmit": true,
"strictNullChecks": true,
"strict": true,
"noUnusedLocals": true
},
"files": [
"./src/AuthType.ts",
"./src/Bindings/ReactBindingHandler.ts",
"./src/Common/ArrayHashMap.ts",
"./src/Common/Constants.ts",
"./src/Common/DeleteFeedback.ts",
"./src/Common/HashMap.ts",
"./src/Common/MessageHandler.ts",
"./src/Common/ObjectCache.ts",
"./src/Common/ThemeUtility.ts",
"./src/Common/UrlUtility.ts",
"./src/Contracts/ActionContracts.ts",
"./src/Contracts/DataModels.ts",
"./src/Contracts/Diagnostics.ts",
"./src/Contracts/ExplorerContracts.ts",
"./src/Contracts/Versions.ts",
"./src/Controls/Heatmap/HeatmapDatatypes.ts",
"./src/Definitions/plotly.js-cartesian-dist.d-min.ts",
"./src/Explorer/Controls/Toolbar/IToolbarAction.ts",
"./src/Explorer/Controls/Toolbar/IToolbarDisplayable.ts",
"./src/Explorer/Controls/Toolbar/IToolbarDropDown.ts",
"./src/Explorer/Controls/Toolbar/IToolbarItem.ts",
"./src/Explorer/Controls/Toolbar/IToolbarSeperator.ts",
"./src/Explorer/Controls/Toolbar/IToolbarToggle.ts",
"./src/Explorer/Controls/Toolbar/KeyCodes.ts",
"./src/Explorer/Notebook/FileSystemUtil.ts",
"./src/Explorer/Notebook/NotebookComponent/actions.ts",
"./src/Explorer/Notebook/NotebookContentItem.ts",
"./src/Explorer/Notebook/NotebookUtil.ts",
"./src/Explorer/Panes/Tables/Validators/EntityPropertyNameValidator.ts",
"./src/Explorer/Panes/Tables/Validators/EntityPropertyValidationCommon.ts",
"./src/Explorer/Tables/Constants.ts",
"./src/Explorer/Tables/QueryBuilder/DateTimeUtilities.ts",
"./src/GitHub/GitHubConnector.ts",
"./src/NotebookWorkspaceManager/NotebookWorkspaceResourceProviderMockClients.ts",
"./src/PlatformType.ts",
"./src/ResourceProvider/IResourceProviderClient.ts",
"./src/Shared/StringUtility.ts",
"./src/Shared/Telemetry/TelemetryConstants.ts",
"./src/Utils/OfferUtils.ts",
"./src/Utils/StringUtils.ts",
"./src/quickstart.ts",
"./src/setupTests.ts",
"./src/workers/upload/definitions.ts"
],
"include": []
"./src/Config.ts",
"./src/Contracts/ActionContracts.ts",
"./src/Contracts/DataModels.ts",
"./src/Contracts/Diagnostics.ts",
"./src/Contracts/ExplorerContracts.ts",
"./src/Contracts/Versions.ts",
"./src/Controls/Heatmap/HeatmapDatatypes.ts",
"./src/Definitions/plotly.js-cartesian-dist.d-min.ts",
"./src/Explorer/Controls/Notebook/NotebookAppMessageHandler.ts",
"./src/Explorer/Controls/Toolbar/IToolbarAction.ts",
"./src/Explorer/Controls/Toolbar/IToolbarDisplayable.ts",
"./src/Explorer/Controls/Toolbar/IToolbarDropDown.ts",
"./src/Explorer/Controls/Toolbar/IToolbarItem.ts",
"./src/Explorer/Controls/Toolbar/IToolbarSeperator.ts",
"./src/Explorer/Controls/Toolbar/IToolbarToggle.ts",
"./src/Explorer/Controls/Toolbar/KeyCodes.ts",
"./src/Explorer/Notebook/FileSystemUtil.ts",
"./src/Explorer/Notebook/NotebookComponent/actions.ts",
"./src/Explorer/Notebook/NotebookComponent/loadTransform.ts",
"./src/Explorer/Notebook/NotebookContentItem.ts",
"./src/Explorer/Notebook/NotebookUtil.ts",
"./src/Explorer/Panes/Tables/Validators/EntityPropertyNameValidator.ts",
"./src/Explorer/Panes/Tables/Validators/EntityPropertyValidationCommon.ts",
"./src/Explorer/Tables/Constants.ts",
"./src/Explorer/Tables/QueryBuilder/DateTimeUtilities.ts",
"./src/GitHub/GitHubConnector.ts",
"./src/NotebookWorkspaceManager/NotebookWorkspaceResourceProviderMockClients.ts",
"./src/PlatformType.ts",
"./src/ResourceProvider/IResourceProviderClient.ts",
"./src/Shared/StringUtility.ts",
"./src/Shared/Telemetry/TelemetryConstants.ts",
"./src/Shared/appInsights.ts",
"./src/Utils/GitHubUtils.ts",
"./src/Utils/MessageValidation.ts",
"./src/Utils/OfferUtils.ts",
"./src/Utils/StringUtils.ts",
"./src/quickstart.ts",
"./src/setupTests.ts",
"./src/workers/upload/definitions.ts"
],
"include": []
}