Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11,484 changes: 11,484 additions & 0 deletions sampleData/queryCopilotSampleData.json

Large diffs are not rendered by default.

239 changes: 239 additions & 0 deletions src/Common/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ export class Areas {
public static Tab: string = "Tab";
public static ShareDialog: string = "Share Access Dialog";
public static Notebook: string = "Notebook";
public static Copilot: string = "Copilot";
public static CloudShell: string = "Cloud Shell";
}

Expand Down Expand Up @@ -455,6 +456,7 @@ export enum ContainerStatusType {

export enum PoolIdType {
DefaultPoolId = "default",
QueryCopilot = "query-copilot",
}

export const EmulatorMasterKey =
Expand Down Expand Up @@ -541,6 +543,243 @@ export class FeedbackLabels {
public static readonly provideFeedback: string = "Provide feedback";
}

export const QueryCopilotSampleDatabaseId = "CopilotSampleDB";
export const QueryCopilotSampleContainerId = "SampleContainer";

export const QueryCopilotSampleContainerSchema = {
product: {
sampleData: {
id: "c415e70f-9bf5-4cda-aebe-a290cb8b94c2",
name: "Amazing Phone 3000 (Black)",
price: 223.33,
category: "Electronics",
description:
"This Amazing Phone 3000 (Black) is made of black metal! It has a very well made aluminum body and it feels very comfortable. We loved the sound that comes out of it! Also, the design of the phone was a little loose at first because I was using the camera and felt uncomfortable wearing it. The phone is actually made slightly smaller than these photos! This is due to the addition of a 3.3mm filter",
stock: 84,
countryOfOrigin: "USA",
firstAvailable: "2018-09-07 19:41:44",
priceHistory: [238.68, 234.7, 221.49, 205.88, 220.15],
customerRatings: [
{
username: "steven66",
firstName: "Carol",
gender: "female",
lastName: "Shelton",
age: "25-35",
area: "suburban",
address: "261 Collins Burgs Apt. 332\nNorth Taylor, NM 32268",
stars: 5,
date: "2021-04-22 13:42:14",
verifiedUser: true,
},
{
username: "khudson",
firstName: "Ronald",
gender: "male",
lastName: "Webb",
age: "18-24",
area: "suburban",
address: "9912 Parker Court Apt. 068\nNorth Austin, HI 76225",
stars: 5,
date: "2021-02-07 07:00:22",
verifiedUser: false,
},
{
username: "lfrancis",
firstName: "Brady",
gender: "male",
lastName: "Wright",
age: "35-45",
area: "urban",
address: "PSC 5437, Box 3159\nAPO AA 26385",
stars: 2,
date: "2022-02-23 21:40:10",
verifiedUser: false,
},
{
username: "nicolemartinez",
firstName: "Megan",
gender: "female",
lastName: "Tran",
age: "18-24",
area: "rural",
address: "7445 Salazar Brooks\nNew Sarah, PW 18097",
stars: 4,
date: "2021-09-01 22:21:40",
verifiedUser: false,
},
{
username: "uguzman",
firstName: "Deanna",
gender: "female",
lastName: "Campbell",
age: "18-24",
area: "urban",
address: "41104 Moreno Fort Suite 872\nPort Michaelbury, AK 48712",
stars: 1,
date: "2022-03-07 02:23:14",
verifiedUser: false,
},
{
username: "rebeccahunt",
firstName: "Jared",
gender: "male",
lastName: "Lopez",
age: "18-24",
area: "rural",
address: "392 Morgan Village Apt. 785\nGreenshire, CT 05921",
stars: 5,
date: "2021-04-17 04:17:49",
verifiedUser: false,
},
],
rareProperty: true,
},
schema: {
properties: {
id: {
type: "string",
},
name: {
type: "string",
},
price: {
type: "number",
},
category: {
type: "string",
},
description: {
type: "string",
},
stock: {
type: "number",
},
countryOfOrigin: {
type: "string",
},
firstAvailable: {
type: "string",
},
priceHistory: {
items: {
type: "number",
},
type: "array",
},
customerRatings: {
items: {
properties: {
username: {
type: "string",
},
firstName: {
type: "string",
},
gender: {
type: "string",
},
lastName: {
type: "string",
},
age: {
type: "string",
},
area: {
type: "string",
},
address: {
type: "string",
},
stars: {
type: "number",
},
date: {
type: "string",
},
verifiedUser: {
type: "boolean",
},
},
type: "object",
},
type: "array",
},
rareProperty: {
type: "boolean",
},
},
type: "object",
},
},
};

export const ShortenedQueryCopilotSampleContainerSchema = {
containerSchema: {
product: {
sampleData: {
categoryName: "Components, Saddles",

name: "LL Road Seat/Saddle",

price: 27.12,

tags: [
{
id: "0573D684-9140-4DEE-89AF-4E4A90E65666",

name: "Tag-113",
},

{
id: "6C2F05C8-1E61-4912-BE1A-C67A378429BB",

name: "Tag-5",
},
],
},

schema: {
properties: {
categoryName: {
type: "string",
},

name: {
type: "string",
},

price: {
type: "number",
},

tags: {
items: {
properties: {
id: {
type: "string",
},

name: {
type: "string",
},
},

type: "object",
},

type: "array",
},
},

type: "object",
},
},
},

userPrompt: "find all products",
};

export enum MongoGuidRepresentation {
Standard = "Standard",
CSharpLegacy = "CSharpLegacy",
Expand Down
26 changes: 26 additions & 0 deletions src/Common/SampleDataClient.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import * as Cosmos from "@azure/cosmos";
import { userContext } from "UserContext";

let _sampleDataclient: Cosmos.CosmosClient;

export function sampleDataClient(): Cosmos.CosmosClient {
if (_sampleDataclient) {
return _sampleDataclient;
}

const sampleDataConnectionInfo = userContext.sampleDataConnectionInfo;
const options: Cosmos.CosmosClientOptions = {
endpoint: sampleDataConnectionInfo.accountEndpoint,
tokenProvider: async () => {
const sampleDataConnectionInfo = userContext.sampleDataConnectionInfo;
return Promise.resolve(sampleDataConnectionInfo.resourceToken);
},
connectionPolicy: {
enableEndpointDiscovery: false,
},
userAgentSuffix: "Azure Portal",
};

_sampleDataclient = new Cosmos.CosmosClient(options);
return _sampleDataclient;
}
16 changes: 16 additions & 0 deletions src/Common/dataAccess/readCollection.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { CosmosClient } from "@azure/cosmos";
import { sampleDataClient } from "Common/SampleDataClient";
import { userContext } from "UserContext";
import * as DataModels from "../../Contracts/DataModels";
import { client } from "../CosmosClient";
import { handleError } from "../ErrorHandlingUtils";
Expand All @@ -8,6 +10,20 @@ export async function readCollection(databaseId: string, collectionId: string):
return await readCollectionInternal(cosmosClient, databaseId, collectionId);
}

export async function readSampleCollection(): Promise<DataModels.Collection> {
const cosmosClient = sampleDataClient();

const sampleDataConnectionInfo = userContext.sampleDataConnectionInfo;
const databaseId = sampleDataConnectionInfo?.databaseId;
const collectionId = sampleDataConnectionInfo?.collectionId;

if (!databaseId || !collectionId) {
return undefined;
}

return await readCollectionInternal(cosmosClient, databaseId, collectionId);
}

export async function readCollectionInternal(
cosmosClient: CosmosClient,
databaseId: string,
Expand Down
4 changes: 4 additions & 0 deletions src/Contracts/DataModels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,10 @@ export enum PhoenixErrorType {
UserMissingPermissionsError = "UserMissingPermissionsError",
}

export interface CopilotEnabledConfiguration {
isEnabled: boolean;
}

export interface FeatureRegistration {
name: string;
properties: {
Expand Down
27 changes: 26 additions & 1 deletion src/Explorer/ContextMenuButtonFactory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import {
import { useDatabases } from "Explorer/useDatabases";
import { Keys, t } from "Localization";
import { isFabric, isFabricNative, openRestoreContainerDialog } from "Platform/Fabric/FabricUtil";
import { Action } from "Shared/Telemetry/TelemetryConstants";
import { traceOpen } from "Shared/Telemetry/TelemetryProcessor";
import { ReactTabKind, useTabs } from "hooks/useTabs";
import React from "react";
import AddCollectionIcon from "../../images/AddCollection.svg";
import AddSqlQueryIcon from "../../images/AddSqlQuery_16x16.svg";
Expand Down Expand Up @@ -215,7 +218,29 @@ export const createCollectionContextMenuButton = (
};

export const createSampleCollectionContextMenuButton = (): TreeNodeMenuItem[] => {
return [];
const items: TreeNodeMenuItem[] = [];
if (userContext.apiType === "SQL") {
const copilotVersion = userContext.features.copilotVersion;
if (copilotVersion === "v1.0") {
items.push({
iconSrc: AddSqlQueryIcon,
onClick: () => {
useTabs.getState().openAndActivateReactTab(ReactTabKind.QueryCopilot);
traceOpen(Action.OpenQueryCopilotFromNewQuery, { apiType: userContext.apiType });
},
label: t(Keys.contextMenu.newSqlQuery),
});
} else if (copilotVersion === "v2.0") {
const sampleCollection = useDatabases.getState().sampleDataResourceTokenCollection;
items.push({
iconSrc: AddSqlQueryIcon,
onClick: () => sampleCollection && sampleCollection.onNewQueryClick(sampleCollection, undefined),
label: t(Keys.contextMenu.newSqlQuery),
});
}
}

return items;
};

export const createStoreProcedureContextMenuItems = (
Expand Down
11 changes: 9 additions & 2 deletions src/Explorer/DataSamples/ContainerSampleGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,17 @@ export class ContainerSampleGenerator {
/**
* Factory function to load the json data file
*/
public static async createSampleGeneratorAsync(container: Explorer): Promise<ContainerSampleGenerator> {
public static async createSampleGeneratorAsync(
container: Explorer,
isCopilot?: boolean,
): Promise<ContainerSampleGenerator> {
const generator = new ContainerSampleGenerator(container);
let dataFileContent: any;
if (userContext.apiType === "Gremlin") {
if (isCopilot) {
dataFileContent = await import(
/* webpackChunkName: "queryCopilotSampleData" */ "../../../sampleData/queryCopilotSampleData.json"
);
} else if (userContext.apiType === "Gremlin") {
dataFileContent = await import(
/* webpackChunkName: "gremlinSampleJsonData" */ "../../../sampleData/gremlinSampleData.json"
);
Expand Down
Loading
Loading