Skip to content

Commit

Permalink
refactor: put api version in constants (#332)
Browse files Browse the repository at this point in the history
  • Loading branch information
kunzms authored Jun 19, 2020
1 parent d636432 commit 8297b18
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/common/constants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

const apiVersion = "v2.1-preview.1";

/**
* Constants used throughout application
*/
Expand All @@ -22,9 +24,7 @@ export const constants = {
convertedImageQuality: 0.7,
convertedThumbnailQuality: 0.2,

apiModelsPath: "/formrecognizer/v2.0-preview/custom/models",
apiPreviewPath: "/formrecognizer/v2.1-preview.1/custom/models",
apiPreviewComposePath: "/formrecognizer/v2.1-preview.1/custom/models/compose",
apiModelsPath: `/formrecognizer/${apiVersion}/custom/models`,

pdfjsWorkerSrc(version: string) {
return `//fotts.azureedge.net/npm/pdfjs-dist/${version}/pdf.worker.js`;
Expand Down
8 changes: 4 additions & 4 deletions src/react/components/pages/modelCompose/modelCompose.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ export default class ModelComposePage extends React.Component<IModelComposePageP
composedModelIds = this.getComposedIds();
predictModelFlag = true;
if (composedModelIds.indexOf(this.state.composeModelId[0]) === -1) {
const idURL = constants.apiPreviewPath + "/" + this.state.composeModelId[0];
const idURL = constants.apiModelsPath + "/" + this.state.composeModelId[0];
const newComposeModel = await this.getComposeModelByURl(idURL);
composedModels.push(newComposeModel);
composedModelIds.push(this.state.composeModelId[0]);
Expand Down Expand Up @@ -410,7 +410,7 @@ export default class ModelComposePage extends React.Component<IModelComposePageP
private reloadComposedModel = (models: IModel[]): IModel[] => {
models.forEach(async (m) => {
if (m.status !== "ready" && m.status !== "invalid") {
const url = constants.apiPreviewPath + "/" + m.modelId;
const url = constants.apiModelsPath + "/" + m.modelId;
const newModel = await this.getComposeModelByURl(url);
const newStatus = newModel.status;
m.status = newStatus;
Expand Down Expand Up @@ -487,7 +487,7 @@ export default class ModelComposePage extends React.Component<IModelComposePageP
private async getResponse(nextLink?: string) {
const baseURL = nextLink === undefined ? url.resolve(
this.props.project.apiUriBase,
constants.apiPreviewPath,
constants.apiModelsPath,
) : url.resolve(
this.props.project.apiUriBase,
nextLink,
Expand Down Expand Up @@ -614,7 +614,7 @@ export default class ModelComposePage extends React.Component<IModelComposePageP
modelIds: idList,
modelName: name,
};
const link = constants.apiPreviewComposePath;
const link = constants.apiModelsPath + "/compose";
const composeRes = await this.post(link, payload);
const composeModelId = this.getComposeModelId(composeRes);
const newCols = this.state.columns;
Expand Down
2 changes: 1 addition & 1 deletion src/react/components/pages/train/trainPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export default class TrainPage extends React.Component<ITrainPageProps, ITrainPa
private async train(): Promise<any> {
const baseURL = url.resolve(
this.props.project.apiUriBase,
constants.apiPreviewPath,
constants.apiModelsPath,
);
const provider = this.props.project.sourceConnection.providerOptions as any;
const trainSourceURL = provider.sas;
Expand Down

0 comments on commit 8297b18

Please sign in to comment.