Giter VIP home page Giter VIP logo

cosmos-explorer's Introduction

Cosmos DB Explorer

UI for Azure Cosmos DB. Powers the Azure Portal, https://cosmos.azure.com/, and the Cosmos DB Emulator

Getting Started

  • npm install
  • npm run build

Developing

Watch mode

Run npm start to start the development server and automatically rebuild on changes

Hosted Development (https://cosmos.azure.com)

  • Visit: https://localhost:1234/hostedExplorer.html
  • The default webpack dev server configuration will proxy requests to the production portal backend: https://main.documentdb.ext.azure.com. This will allow you to use production connection strings on your local machine.

Emulator Development

Setting up a Remote Emulator

The Cosmos emulator currently only runs in Windows environments. You can still develop on a non-Windows machine by setting up an emulator on a windows box and exposing its ports publicly:

  1. Expose these ports publicly: 8081, 8900, 8979, 10250, 10251, 10252, 10253, 10254, 10255, 10256

  2. Download and install the emulator: https://docs.microsoft.com/en-us/azure/cosmos-db/local-emulator

  3. Start the emulator from PowerShell:

> cd C:/

> .\CosmosDB.Emulator.exe -AllowNetworkAccess -Key="<EMULATOR MASTER KEY>"

Portal Development

Testing

Unit Tests

Unit tests are located adjacent to the code under test and run with Jest:

npm run test

End to End CI Tests

Jest and Puppeteer are used for end to end browser based tests and are contained in test/. To run these tests locally:

  1. Copy .env.example to .env
  2. Update the values in .env including your local data explorer endpoint (ask a teammate/codeowner for help with .env values)
  3. Make sure all packages are installed npm install
  4. Run the server npm run start and wait for it to start
  5. Run npm run test:e2e

Releasing

We generally adhere to the release strategy documented by the Azure SDK Guidelines. Most releases should happen from the master branch. If master contains commits that cannot be released, you may create a release from a release/ or hotfix/ branch. See linked documentation for more details.

Architecture

Contributing

Please read the contribution guidelines.

cosmos-explorer's People

Contributors

analogrelay avatar asierisayas avatar ato9000 avatar ausfeldt avatar bogercraig avatar chris-ms-896 avatar danielspham avatar deborahc avatar faizc avatar gitanuj avatar hardiknai-techm avatar jawelton74 avatar justinkol avatar kcheekuri avatar klepic95 avatar languy avatar mokireddysampath avatar satya07sb avatar sevoku avatar siddjoshi-ms avatar sindhuba avatar southpolesteve avatar sunghyunkang1111 avatar sunilyadav840 avatar v-darkora avatar vaidankarswapnil avatar vchske avatar victor-meng avatar vignesh-mr avatar zfoster avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cosmos-explorer's Issues

Item filter text box not applying on enter-key press

When I enter an item filter query into the text-box in the items tab, I have to click "Apply filter". This is slow, and I'd prefer to press the Enter key as it's faster. I'm running Firefox 85.0 on Ubuntu 20.04.

For reference, the element in question is here:

<input
type="text"
list="filtersList"
class="querydropdown"
title="Type a query predicate or choose one from the list."
data-bind="
attr:{
placeholder:isPreferredApiMongoDB?'Type a query predicate (e.g., {´a´:´foo´}), or choose one from the drop down list, or leave empty to query all documents.':'Type a query predicate (e.g., WHERE c.id=´1´), or choose one from the drop down list, or leave empty to query all documents.'
},
css: { placeholderVisible: filterContent().length === 0 },
textInput: filterContent"
/>

Invalid auth token reported as firewall issue

Sometimes user will see the following error:
image

But the underlying exception is:
"Microsoft.Azure.Documents.DocumentClientException: The authorization token is not valid at the current time. Please create another token and retryMicrosoft.Azure.Documents.DocumentClientException: The authorization token is not valid at the current time. Please create another token and retry"

Currently any permission error is bucketed as a firewall issue. In this case, the user to spend time trying to "fix" their firewall or ask CSS why firewall isn't working. The exception should be caught separately.

Initial Open Source Release

A list of tasks broken down by phase but not in any particular order:

Pre-release

  • Remove wrapper directories
  • Remove PowerShell scripts or make cross-platform
  • Commit snapshot of code to repo
  • Ensure LICENSE file exists
  • Ensure CONTRIBUTING file exists
  • Open source this repo

Post-release

  • Setup CI

Is Canvas still needed?

When running 'npm install', I get a sym link error for canvas. What installation instructions do you have for resolving this?

Settings Pane: Clarify what "Unlimited means"

When a user toggles "Unlimited" it the code is actually setting the value to 100 page max size:

LocalStorageUtility.setEntryNumber(
StorageKey.ActualItemPerPage,
this.isCustomPageOptionSelected() ? this.customItemPerPage() : Constants.Queries.unlimitedItemsPerPage
);
LocalStorageUtility.setEntryNumber(StorageKey.CustomItemPerPage, this.customItemPerPage());

public static unlimitedItemsPerPage: number = 100; // TODO: Figure out appropriate value so it works for accounts with a large number of partitions

Move All Control Plane calls to Cosmos Resource Provider

Anywhere we are using the JS SDK to perform control plane operations, we need to switch to Cosmos Resource Provider when logged in as an AAD user. I generated a preliminary list of all the operations that need to be checked:

  • Update Collection
  • Update Offer
  • Delete Collection
  • Delete Database
  • Read Collections
  • Read Databases
  • Read Collection
  • Read Collection Quota Info
  • Read Offer
  • Read Offers
  • Read Databases
  • Get or Create Database and Collection
  • Create Database
  • Refresh Cached Offers
  • Refresh Cached Resources
  • Read Subcription
  • Read Subscription Defaults

Each of these will also need possibly support a fallback to the JS SDK for connection string users.

Prohibit "JSON.stringify(error)"

Frequently we see errors logged in the notifications bad that look like "{}". This is because we are using JSON.stringify(error) in many places. Instances of Error have no enumerable properties which is the reason for this behavior. We should add a custom linting rule or type changes to prohibit using JSON.stringify(error).

Remove GitHub PAT from source code

@gitanuj We're getting flagged by GitHub for having PATs in source code https://github.com/Azure/cosmos-explorer/security/secret-scanning

Can we come up with a plan to move these out of source code? They could become an environment variable in tests. Or we could use something like dotenv https://www.npmjs.com/package/dotenv. Let me know if you have other ideas.

Its a bit strange to have the unit tests hit a live endpoint. Could we mock them or use something like nock to record and mock them? https://github.com/nock/nock#recording

Errors Not Reported by Mongo ARM creation

  1. Create a Mongo collection that triggers an error. Example: Try creating a mongo collection with a shard key /id
  2. Get back a cryptic response.text() is not a function error message

The issue is this line here:

} catch (response) {
errorHandling(response, "creating collection", undefined);
return undefined;
}

The catch clause has an implicit any type on response. But in this case, it is not an instance of Response. It is a RP specific error format:

return Promise.reject({ code: response.status, message: await response.text() });

TypeScript 4.0 has a fix for this https://devblogs.microsoft.com/typescript/announcing-typescript-4-0-beta/#unknown-on-catch

cc @vchske

Graph paging logic uses double-quotes which breaks if id contains $ sign

How to repro:

  • Have more than 100 vertices in the graph
  • At least one vertex has an id that contains $. For example: foo$bar.
  • Execute g.V() and see the ScriptError coming out of the backend.

The problem:
Double-quoted strings denote Groovy string interpolation where ‘$’ denotes the beginning of a placeholder.
Eg.

"${cosmosAccount}" -- this is expected to be replaced with the value of variable cosmosAccount.

To avoid this and treat the entire string as a literal, single-quoted strings should be used.
Eg.
'$Default'

So the fix would be to ensure that the gremlin result pager uses single quoted strings for partition key/id values in the query builder.

Lint for console.log

We've had a few cases of an errant console.log checked in to production. We should lint for these.

Decrease Coupling between Files

@languy and I had a chat today about how we make better progress on migrating to React, strict mode TypeScript, and full ESlint. Incremental progress has been challenging due to how highly coupled our code is. There is coupling in code, but also between files, that makes incremental change hard. We brainstormed some changes that we think will help decrease coupling:

  • Remove ViewModels where there is only one implementation
  • Split up the ViewModels.ts file
  • Remove OpenActionsStubs and replace with a jest mock for explorer
  • Migrated the entire Hosted explorer wrapper to React
  • Migrate the entire Emulator wrapper to React
  • Remove Sinon (Lower priority. May not reduce coupling)
  • Split up DataModels.ts file

Unable to edit query after executing stored procedure

  1. Open a query tab
  2. Open a stored procedure
  3. Execute the stored procedure
  4. Go back to query tab
  5. You will not be able to edit the query

Suspect there is some issue here with multiple copies of Monaco on the page. Will take some further investigation

Need to add TimetoLivePropertyPath to TTL section in Data Explorer

Cosmos DB has a feature that allows you to set a custom path to be used in place of '_ts' when deciding whether to delete an item via TTL. As of now, setting and viewing the TimeToLivePropertyPath is possible through the SDK only.

https://docs.microsoft.com/en-us/dotnet/api/microsoft.azure.cosmos.containerproperties.timetolivepropertypath?view=azure-dotnet#definition

The following example has been the cause of a few recent support tickets:

Contoso Dev Team has two developers: Alex and Bob.
1. Alex sets TimeToLivePropertyPath to a customer property “/myTimestamp”
2. Bob goes to use Cosmos DB later and can’t figure out why items aren’t being deleted based on TTL
3. Bob doesn’t realize that Alex had set a TimeToLivePropertyPath. Bob is confused and sees this as unexplainable behavior

Being able to view and modify the TimeToLivePropertyPath in the Portal would help decrease confusion here.

Filtering not working correctly for Tables API

Reported via ICM 214687554:

Data is not showing up with a filter is passed. Tested in Azure storage explorer , Portal and cosmos.azure.com , all of them show similar behavior, data is shown accurately when there is no filter, whenever a filter is passed results are not accurate , 1st page doesn't load , navigating to other page shows some data.

E2E CI Test with AAD

#33 adds support for E2E tests that use connection string. We should also add AAD based tests, but doing this might be a little tricky. One idea is to use a dummy iframe that simulates the portal. The AAD token can be stored in GitHub and injected into the parent dummy iframe to simulate the experience of a logged-in AAD user

Cannot use explorer with emulator when started with custom key

When you start the Cosmos DB Emulator with a custom key using the /Key or /KeyFile command line parameters it seems impossible to use the Explorer as it has no way to provide the key to use. It defaults to the built-in key.

I am running the emulator on my host machine and am developing my application in a Docker container. Therefore I need to enable network access on the emulator, which requires a custom key to be provided. I can successfully connect from the container to the emulator on the host using the generated key, however I am not able to inspect the data using the Explorer on the host.

SELECT VALUE raises unexpected error

Describe the bug
The following queries work as expected:

SELECT VALUE (true)
SELECT VALUE (1)
SELECT VALUE ("foo")

But the following queries return an error "Cannot set property 'headers' of undefined":

SELECT VALUE (false)
SELECT VALUE (0)
SELECT VALUE ("")
SELECT VALUE (null)

To Reproduce
Run the queries in the Data Explorer.

Expected behavior
The correct values being returned without error.

Actual behavior
The above error is raised.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.