Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copilot automation to include run time #1017

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
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
145 changes: 145 additions & 0 deletions src/web/client/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*/

import { EXTENSION_NAME } from "../../../common/constants";
import { getExtensionVersion } from "../../../common/utilities/Utils";

// Default and constants
export const PORTAL_LANGUAGE_DEFAULT = "1033";
export const PORTALS_FOLDER_NAME_DEFAULT = "site";
Expand Down Expand Up @@ -135,3 +138,145 @@ export const WEB_EXTENSION_SEND_EMAIL_NOT_AVAILABLE = "Send email is not availab
export const WEB_EXTENSION_QUICK_PICK_TITLE = "People on this file"
export const WEB_EXTENSION_QUICK_PICK_PLACEHOLDER = "Search for people";
export const WEB_EXTENSION_COLLABORATION_OPTIONS_CONTACT = "Contact";

export enum FormConstants {
BasicForm = '[aria-label="Basic Form"]',
EmailField = '[aria-label="Email"]',
SubjectField = '[id="title"]',
MessageField = '[aria-label="Message"]',
SubmitButton = '[id="InsertButton"]',
NameIsRequired = "//li[text()='Name is a required field.']",
NameField = 'input[id="adx_createdbycontact"]',
MinimumRating = 'input[id="minrating"]',
MaximumRating = 'input[id="maxrating"]',
SubmissionSuccessful = "//span[text()='Submission completed successfully.']",
ValidEmail = "//li[text()='Please enter a valid email address.']",
SpecialCharacters = "//li[text()='{0} cannot contain special characters.']",
Lessthan5Characters = "//li[text()='Name must be less than 5 characters.']",
ValidationSummary = '[class*="validation-summary"]',
RatingBeAtleast10 = "//li[text()='Minimum rating must be at least 10.']",
RatingBeAtmost95 = "//li[text()='Maximum Rating must not be greater than 95.']",
RatingBeAtleast5 = "//li[text()='Minimum Rating must be at least 5.']",
RatingAtmost95 = "//li[text()='Maximum Rating must be at most 95.']",
}

export enum ListConstants {
DataRecord = 'tr[data-name="rf"]',
AmountColumn = '[data-attribute="cr1ae_amount"]',
}

export enum AdvanceFormConstants {
PhoneField = '#telephone1',
NameField = '#name',
NextButton = '#NextButton',
EmailField = '#emailaddress1',
ValidationSummary = '#ValidationSummaryEntityFormView li',
PreviousButton = '#PreviousButton',
AccountNumber = '#accountnumber',
MessageLabel = '#MessageLabel'
}

export enum PageConstants {
TestButton = "//button[text()='Test']",
MicrosoftURL = 'https://www.microsoft.com/en-in/',
MicrosoftLogo = 'img[alt="Microsoft Logo"]',
Button = '[type="button"][class*="button"]',
RedColor = 'rgb(255, 0, 0)',
Button1 = '[class="button1"]',
YellowColor = 'rgb(255, 255, 0)',
Section = '.sectionBlockLayout:first-of-type',
GreenColor = 'rgb(0, 128, 0)'
}

export enum TextConstants{
MicrosoftURL = 'https://www.microsoft.com/en-in/',
Italic = 'italic'
}

export enum FormQueries {
Query1 = "Write JavaScript code for name field validation in form.",
Query2 = "Write JavaScript code to hide email field in form.",
Query3 = "Write JavaScript code to disable email field in form.",
Query4 = "Write JavaScript code for form field validation to check email field value is in the valid format.",
Query5 = "Write JavaScript code to add field validation to check for the length of the name field to be less than 5",
Query6 = "Write Javascript code to add field validation to check for the value of the minimum rating field to not to be less than 10.",
Query7 = "Write Javascript code to add field validation to check for the value of the maximum rating field to not to be greater than 95.",
Query8 = "Write Javascript code to add field validation to check for the value of the minimum rating field to not to be less than 5 and maximum rating not to be greater than 95."
}
export enum AdvancedFormQueries {
Query1 = "Write JavaScript code for Phone field validation to check phone field value is in the valid format.",
Query2 = "Write javascript code to rename Next button to Forward",
Query3 = "Write javascript code to make Phone field a required field",
Query4 = "Write javascript code for Account Number field to accept only numbers",
Query5 = "Write javascript code to make email field readonly in the form",
}

export enum ListQueries {
Query1 = "Write JavaScript code to highlight the row where title column value is rf in table list.",
Query2 = "Write javascript code to Mark rows with amount > 500 with yellow and amount datatype is dollars",
Query3 = "write javascript code to arrange amount column values in descending order",
Query4 = "write javascript code to arrange amount column values in ascending order",
}

export enum HtmlQueries {
Query1 = "Write code to add 'Account' entity form to my webpage 'html' with some section code.",
Query2 = "Write code to add a button with name Test which should redirect to microsoft.com url.",
Query3 = "Write html code to add an image for microsoft and choose image from online",
}

export enum CssQueries {
Query1 = "Write css code to change the first section color of home page to yellow",
Query2 = "Write css code to change first existing button background color to red",
Query3 = "Write css code to change button text to italic for all buttons",
Query4 = "Write css code to update first existing button background color to green important on hover",
}

export enum Paths{
HtmlWebpageCopy = "C:\\Users\\v-ankopuri\\Downloads\\CopilotSiteLatest\\latest-site-for-copilot---site-uo67k\\web-pages\\html\\content-pages\\Html.en-US.webpage.copy.html",
HomePageCss = 'C:\\Users\\v-ankopuri\\Downloads\\CopilotSiteLatest\\latest-site-for-copilot---site-uo67k\\web-pages\\home\\content-pages\\Home.en-US.webpage.custom_css.css',
ListJsFile = 'C:\\Users\\v-ankopuri\\Downloads\\CopilotSiteLatest\\latest-site-for-copilot---site-uo67k\\lists\\Active-Feedback.list.custom_javascript.js',
FormJsFile = 'C:\\Users\\v-ankopuri\\Downloads\\CopilotSiteLatest\\latest-site-for-copilot---site-uo67k\\basic-forms\\simple-contact-us-form\\simple-contact-us-form.basicform.custom_javascript.js',
AdvFormStep1JsFile = 'C:\\Users\\v-ankopuri\\Downloads\\CopilotSiteLatest\\latest-site-for-copilot---site-uo67k\\advanced-forms\\multistep-form-1\\advanced-form-steps\\step1\\Step1.advancedformstep.custom_javascript.js',
AdvFormStep2JsFile = 'C:\\Users\\v-ankopuri\\Downloads\\CopilotSiteLatest\\latest-site-for-copilot---site-uo67k\\advanced-forms\\multistep-form-1\\advanced-form-steps\\step2\\Step2.advancedformstep.custom_javascript.js'
}

// Copilot constants
export const AIB_ENDPOINT = 'https://aibuildertextapiservice.us-il108.gateway.prod.island.powerapps.com/v1.0/63efacda-3db4-ee11-a564-000d3a106f1e/appintelligence/chat';


// JSON request to be sent to the API.
export const ApiRequestJson = {
"question": "{0}",
"top": 1,
"context":
{
"scenario": "PowerPagesProDev",
"subScenario": "PowerPagesProDevGeneric",
"version": "V1",
"information":
{
"activeFileContent": "{6}",
"dataverseEntity": "{2}",
"entityField": "{3}",
"fieldType": "{4}",
"targetEntity": "{5}",
"targetColumns": "{1}", // Placeholder value for targetColumns
"clientType": EXTENSION_NAME + '-' + 'Desktop',
"clientVersion": getExtensionVersion()
}
}
};

export const ExpectedResponses = {
COPILOT_IT_UNSUPPORTED_EXPECTED_RESPONSE: {
"displayText":"Try a different prompt that’s related to writing code for Power Pages sites. You can get help with HTML, CSS, and JS languages.",
"Code":"violation",
"language":"text",
"useCase":"unsupported"
}
};

export const SuggestedPromptsConstants : Record<string, string> = {
// Name: "Write javascript code to validate name field to not accept special characters",
Subject: "Write javascript code to validate subject field to not accept special characters",
}
16 changes: 16 additions & 0 deletions src/web/client/common/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

import * as vscode from 'vscode';
import fs from 'fs';

export interface IEntityRequestUrl {
requestUrl: string;
Expand Down Expand Up @@ -38,3 +39,18 @@ export interface ISearchQueryResults {
matches: ISearchQueryMatch[];
limitHit: boolean;
}

export interface IApiRequestParams {
aibEndPoint: string;
apiToken: string;
data: unknown;
}

export interface ITestLogParams {
testName: string,
testStartTime: Date,
testEndTime: Date,
actualResponse: string,
status: string,
logStream: fs.WriteStream
}
Loading
Loading