Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
2aa6fa0
remove tildes
beyackle Jun 1, 2020
34adef5
Merge branch 'master' into beyackle/tildes
beyackle Jun 1, 2020
c541a49
add no-bitwise rule
beyackle Jun 2, 2020
adb5729
Merge branch 'master' into beyackle/tildes
beyackle Jun 2, 2020
8e5e20a
Merge branch 'master' into beyackle/tildes
beyackle Jun 2, 2020
d10d089
Merge branch 'master' into beyackle/tildes
beyackle Jun 2, 2020
f03a9a2
update luPublisher with typo fixes and some cleanup
beyackle Jun 2, 2020
63bbd09
fix typo
beyackle Jun 2, 2020
f87eaa3
Merge branch 'master' into beyackle/tildes
beyackle Jun 2, 2020
5fd41d8
Merge branch 'master' into beyackle/tildes
beyackle Jun 3, 2020
75d35ae
remove tildes
beyackle Jun 1, 2020
e896efc
add no-bitwise rule
beyackle Jun 2, 2020
f49e848
update luPublisher with typo fixes and some cleanup
beyackle Jun 2, 2020
84b2cf5
fix typo
beyackle Jun 2, 2020
b886f73
Merge branch 'beyackle/tildes' of https://github.com/microsoft/BotFra…
beyackle Jun 3, 2020
6a7cb51
Merge branch 'master' into beyackle/tildes
beyackle Jun 3, 2020
36fd810
Merge branch 'master' into beyackle/tildes
beyackle Jun 4, 2020
e78207e
Merge branch 'master' into beyackle/tildes
beyackle Jun 4, 2020
21d3614
Merge branch 'master' into beyackle/tildes
beyackle Jun 4, 2020
498dc86
Merge branch 'master' into beyackle/tildes
beyackle Jun 8, 2020
1c47348
Merge branch 'master' into beyackle/tildes
beyackle Jun 9, 2020
f5bcb27
Merge branch 'master' into beyackle/tildes
beyackle Jun 10, 2020
a3a33eb
Merge branch 'master' into beyackle/tildes
beyackle Jun 15, 2020
b3d4c38
fix endpoint issue
beyackle Jun 16, 2020
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
1 change: 1 addition & 0 deletions Composer/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ module.exports = {
'no-console': 'warn',
'dot-notation': 'error',
yoda: 'error',
'no-bitwise': 'error',
// eqeqeq: 'error',

// plugin: import
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ const WelcomeModal = () => {
{stepSets.map(({ steps: { length }, title }, index) => (
<StepStatus
key={index}
isComplete={index < currentSet || (index === currentSet && !~currentStep)}
isComplete={index < currentSet || (index === currentSet && currentStep === -1)}
steps={length}
title={title}
/>
))}
</div>
<div css={footerStyle}>
{!~currentStep && (
{currentStep === -1 && (
<div>
{currentSet + 1 < stepSets.length && (
<PrimaryButton data-testid="onboardingNextSet" text={stepSets[currentSet + 1].title} onClick={nextSet} />
Expand Down
2 changes: 1 addition & 1 deletion Composer/packages/client/src/Onboarding/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const Onboarding: React.FC = () => {
!complete && projectId && navigateTo && navigate(navigateTo);
setTeachingBubble({ currentStep, id, location, setLength: steps.length, targetId });

setMinimized(!!~currentStep);
setMinimized(currentStep >= 0);

if (currentSet > -1 && currentSet < stepSets.length) {
onboardingState.setCurrentSet(stepSets[currentSet].id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const ExportSkillModal: React.FC<ExportSkillModalProps> = ({ onSubmit, onDismiss

const handleEditJson = () => {
const step = order.findIndex((step) => step === ManifestEditorSteps.MANIFEST_REVIEW);
if (~step) {
if (step >= 0) {
setCurrentStep(step);
setErrors({});
}
Expand Down
2 changes: 1 addition & 1 deletion Composer/packages/client/src/utils/luUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export * from '@bfc/indexers/lib/utils/luUtil';
export function getReferredFiles(luFiles: LuFile[], dialogs: DialogInfo[]) {
return luFiles.filter((file) => {
const idWithOutLocale = getBaseName(file.id);
return !!~dialogs.findIndex((dialog) => dialog.luFile === idWithOutLocale);
return dialogs.some((dialog) => dialog.luFile === idWithOutLocale);
});
}

Expand Down
2 changes: 2 additions & 0 deletions Composer/packages/lib/code-editor/src/LuEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ const LuEditor: React.FC<LULSPEditorProps> = (props) => {

const m = monacoRef.current;
if (m) {
// this is the correct way to combine keycodes in Monaco
// eslint-disable-next-line no-bitwise
editor.addCommand(m.KeyMod.Shift | m.KeyCode.Enter, function () {
const position = editor.getPosition();
SendRequestWithRetry(languageClient, 'labelingExperienceRequest', { uri, position });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const createPath = (path: string, type: string): string => {
if (/\[|\]/.test(x)) {
const reg = /\[.*\]/;
x = x.replace(reg, '');
return ~values(FieldNames).indexOf(x);
return values(FieldNames).includes(x);
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ const isExpression = (value: string | boolean | number, types: string[]): boolea
//TODO: returnType is number, schem type is string, need map or unify
const checkReturnType = (returnType: ReturnType, types: string[]): string => {
return returnType === ReturnType.Object ||
~types.indexOf(ExpressionTypeMapString[returnType]) ||
(returnType === ReturnType.Number && ~types.indexOf(ExpressionType.integer))
types.includes(ExpressionTypeMapString[returnType]) ||
(returnType === ReturnType.Number && types.includes(ExpressionType.integer))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cant this just be types[ExpressionType.integer] instead of doing includes everytime?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor Author

@beyackle beyackle Jun 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at this again, I'm not sure we can do anything about it yet. Types is an array but ExpressionType.integer is a string; we want to check if the string is a value in the array, so includes is appropriate here. The more correct thing here would be to make types a Set<string>, but that ought to be its own cleanup ticket later - it's a non-trivial amount of work.

? ''
: formatMessage('the expression type is not match');
: formatMessage('the return type does not match');
};

export const checkExpression = (exp: string | boolean | number, required: boolean, types: string[]): string => {
Expand Down
2 changes: 1 addition & 1 deletion Composer/packages/server/src/models/bot/botProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ export class BotProject {

private getLocale(id: string): string {
const index = id.lastIndexOf('.');
if (~index) return '';
if (index >= 0) return '';
return id.substring(index + 1);
}

Expand Down
46 changes: 24 additions & 22 deletions Composer/packages/server/src/models/bot/luPublisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class LuPublisher {
public botDir: string;
public dialogsDir: string;
public generatedFolderPath: string;
public interuptionFolderPath: string;
public interruptionFolderPath: string;
public storage: IFileStorage;
public config: ILuisConfig | null = null;
public downSamplingConfig: IDownSamplingConfig = { maxImbalanceRatio: 0, maxUtteranceAllowed: 0 };
Expand All @@ -60,7 +60,7 @@ export class LuPublisher {
this.botDir = path;
this.dialogsDir = this.botDir;
this.generatedFolderPath = Path.join(this.dialogsDir, GENERATEDFOLDER);
this.interuptionFolderPath = Path.join(this.generatedFolderPath, INTERUPTION);
this.interruptionFolderPath = Path.join(this.generatedFolderPath, INTERUPTION);
this.storage = storage;
this._locale = locale;
}
Expand Down Expand Up @@ -135,7 +135,7 @@ export class LuPublisher {
return luObject;
}

private async _downSizeUtterances(luContents: any) {
private async _downsizeUtterances(luContents: any) {
return await Promise.all(
luContents.map(async (luContent) => {
const result = await LuisBuilder.fromLUAsync(luContent.content);
Expand All @@ -147,27 +147,26 @@ export class LuPublisher {
}

private async _writeFiles(crossTrainResult) {
if (!(await this.storage.exists(this.interuptionFolderPath))) {
await this.storage.mkDir(this.interuptionFolderPath);
if (!(await this.storage.exists(this.interruptionFolderPath))) {
await this.storage.mkDir(this.interruptionFolderPath);
}
for (const key of crossTrainResult.keys()) {
const fileName = Path.basename(key);
const newFileId = Path.join(this.interuptionFolderPath, fileName);
const newFileId = Path.join(this.interruptionFolderPath, fileName);
await this.storage.writeFile(newFileId, crossTrainResult.get(key).Content);
}
}

private async _runBuild(files: FileInfo[]) {
const config = await this._getConfig(files);
if (config.models.length === 0) {
throw new Error('No luis file exist');
}
const loadResult = await this._loadLuConatents(config.models);
loadResult.luContents = await this._downSizeUtterances(loadResult.luContents);
let authoringEndpoint = config.authoringEndpoint;
if (!authoringEndpoint) {
authoringEndpoint = `https://${config.region}.api.cognitive.microsoft.com`;
throw new Error('No LUIS files exist');
}

const loadResult = await this._loadLuContents(config.models);
loadResult.luContents = await this._downsizeUtterances(loadResult.luContents);
const authoringEndpoint = config.endpoint ?? `https://${config.region}.api.cognitive.microsoft.com`;

const buildResult = await this.builder.build(
loadResult.luContents,
loadResult.recognizers,
Expand Down Expand Up @@ -201,35 +200,38 @@ export class LuPublisher {

private _getConfig = async (files: FileInfo[]) => {
if (!this.config) {
throw new Error('Please complete your Luis settings');
throw new Error('Please complete your LUIS settings');
}

const luConfig: any = {
const luConfig = {
authoringKey: this.config.authoringKey || '',
region: this.config.authoringRegion || '',
botName: this.config.name || '',
suffix: this.config.environment || '',
fallbackLocal: this.config.defaultLanguage || 'en-us',
endpoint: this.config.endpoint || null,
models: [] as string[],
};

luConfig.models = [];
//add all lu file after cross train
let paths: string[] = [];
if (this._needCrossTrain()) {
paths = await this.storage.glob('**/*.lu', this.interuptionFolderPath);
luConfig.models = paths.map((filePath) => Path.join(this.interuptionFolderPath, filePath));
paths = await this.storage.glob('**/*.lu', this.interruptionFolderPath);
luConfig.models = paths.map((filePath) => Path.join(this.interruptionFolderPath, filePath));
}

//add the lu file that are not in interuption folder.
const pathSet = new Set(paths);

//add the lu file that are not in interruption folder.
files.forEach((file) => {
if (!~paths.indexOf(file.name)) {
if (!pathSet.has(file.name)) {
luConfig.models.push(Path.resolve(this.botDir, file.relativePath));
}
});
return luConfig;
};

private _loadLuConatents = async (paths: string[]) => {
private _loadLuContents = async (paths: string[]) => {
return await this.builder.loadContents(
paths,
this._locale,
Expand All @@ -240,6 +242,6 @@ export class LuPublisher {

private async _cleanCrossTrain() {
if (!this._needCrossTrain()) return;
await this._deleteDir(this.interuptionFolderPath);
await this._deleteDir(this.interruptionFolderPath);
}
}