-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #364 from ai-cfia/360-label-data-validation-page-i…
…ntegration issue #367: fertiscan-backend client API
- Loading branch information
Showing
42 changed files
with
3,526 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,3 +36,5 @@ yarn-error.log* | |
# typescript | ||
*.tsbuildinfo | ||
next-env.d.ts | ||
|
||
/backend-openapi |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { inspectionsApi, pipelineApi } from "@/utils/server/backend"; | ||
|
||
export async function POST(request: Request) { | ||
const formData = await request.formData(); | ||
const files = formData.getAll("files") as File[]; | ||
|
||
const authHeader = request.headers.get("Authorization"); | ||
if (!authHeader) { | ||
return new Response( | ||
JSON.stringify({ error: "Missing Authorization header" }), | ||
{ | ||
status: 401, | ||
}, | ||
); | ||
} | ||
|
||
return pipelineApi | ||
.analyzeDocumentAnalyzePost(files) | ||
.then((analyzeResponse) => { | ||
console.log( | ||
"Analyze response:", | ||
JSON.stringify(analyzeResponse.data, null, 2), | ||
); | ||
return inspectionsApi.postInspectionInspectionsPost( | ||
analyzeResponse.data, | ||
files, | ||
{ | ||
headers: { Authorization: authHeader }, | ||
}, | ||
); | ||
}) | ||
.then((inspectionsResponse) => { | ||
return Response.json(inspectionsResponse.data); | ||
}) | ||
.catch((error) => { | ||
if (error.response) { | ||
console.error( | ||
"Error response:", | ||
JSON.stringify(error.response.data, null, 2), | ||
); | ||
} else if (error.request) { | ||
console.error("Error request:", error.request); | ||
} else { | ||
console.error("Error message:", error.message); | ||
} | ||
return new Response(JSON.stringify({ error: error.message }), { | ||
status: 500, | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
/** | ||
* FastAPI | ||
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) | ||
* | ||
* The version of the OpenAPI document: 0.1.0 | ||
* | ||
* | ||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). | ||
* https://openapi-generator.tech | ||
* Do not edit the class manually. | ||
*/ | ||
|
||
export * from "./api/home-api"; | ||
export * from "./api/inspections-api"; | ||
export * from "./api/monitoring-api"; | ||
export * from "./api/pipeline-api"; | ||
export * from "./api/users-api"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
/** | ||
* FastAPI | ||
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) | ||
* | ||
* The version of the OpenAPI document: 0.1.0 | ||
* | ||
* | ||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). | ||
* https://openapi-generator.tech | ||
* Do not edit the class manually. | ||
*/ | ||
|
||
import type { AxiosInstance, AxiosPromise, RawAxiosRequestConfig } from "axios"; | ||
import globalAxios from "axios"; | ||
import type { Configuration } from "../configuration"; | ||
// Some imports not used depending on template conditions | ||
// @ts-ignore | ||
import { | ||
DUMMY_BASE_URL, | ||
createRequestFunction, | ||
setSearchParams, | ||
toPathString, | ||
} from "../common"; | ||
// @ts-ignore | ||
import { | ||
BASE_PATH, | ||
BaseAPI, | ||
RequiredError, | ||
operationServerMap, | ||
type RequestArgs, | ||
} from "../base"; | ||
/** | ||
* HomeApi - axios parameter creator | ||
* @export | ||
*/ | ||
export const HomeApiAxiosParamCreator = function ( | ||
configuration?: Configuration, | ||
) { | ||
return { | ||
/** | ||
* | ||
* @summary Home | ||
* @param {*} [options] Override http request option. | ||
* @throws {RequiredError} | ||
*/ | ||
homeGet: async ( | ||
options: RawAxiosRequestConfig = {}, | ||
): Promise<RequestArgs> => { | ||
const localVarPath = `/`; | ||
// use dummy base URL string because the URL constructor only accepts absolute URLs. | ||
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); | ||
let baseOptions; | ||
if (configuration) { | ||
baseOptions = configuration.baseOptions; | ||
} | ||
|
||
const localVarRequestOptions = { | ||
method: "GET", | ||
...baseOptions, | ||
...options, | ||
}; | ||
const localVarHeaderParameter = {} as any; | ||
const localVarQueryParameter = {} as any; | ||
|
||
setSearchParams(localVarUrlObj, localVarQueryParameter); | ||
let headersFromBaseOptions = | ||
baseOptions && baseOptions.headers ? baseOptions.headers : {}; | ||
localVarRequestOptions.headers = { | ||
...localVarHeaderParameter, | ||
...headersFromBaseOptions, | ||
...options.headers, | ||
}; | ||
|
||
return { | ||
url: toPathString(localVarUrlObj), | ||
options: localVarRequestOptions, | ||
}; | ||
}, | ||
}; | ||
}; | ||
|
||
/** | ||
* HomeApi - functional programming interface | ||
* @export | ||
*/ | ||
export const HomeApiFp = function (configuration?: Configuration) { | ||
const localVarAxiosParamCreator = HomeApiAxiosParamCreator(configuration); | ||
return { | ||
/** | ||
* | ||
* @summary Home | ||
* @param {*} [options] Override http request option. | ||
* @throws {RequiredError} | ||
*/ | ||
async homeGet( | ||
options?: RawAxiosRequestConfig, | ||
): Promise< | ||
(axios?: AxiosInstance, basePath?: string) => AxiosPromise<any> | ||
> { | ||
const localVarAxiosArgs = | ||
await localVarAxiosParamCreator.homeGet(options); | ||
const localVarOperationServerIndex = configuration?.serverIndex ?? 0; | ||
const localVarOperationServerBasePath = | ||
operationServerMap["HomeApi.homeGet"]?.[localVarOperationServerIndex] | ||
?.url; | ||
return (axios, basePath) => | ||
createRequestFunction( | ||
localVarAxiosArgs, | ||
globalAxios, | ||
BASE_PATH, | ||
configuration, | ||
)(axios, localVarOperationServerBasePath || basePath); | ||
}, | ||
}; | ||
}; | ||
|
||
/** | ||
* HomeApi - factory interface | ||
* @export | ||
*/ | ||
export const HomeApiFactory = function ( | ||
configuration?: Configuration, | ||
basePath?: string, | ||
axios?: AxiosInstance, | ||
) { | ||
const localVarFp = HomeApiFp(configuration); | ||
return { | ||
/** | ||
* | ||
* @summary Home | ||
* @param {*} [options] Override http request option. | ||
* @throws {RequiredError} | ||
*/ | ||
homeGet(options?: RawAxiosRequestConfig): AxiosPromise<any> { | ||
return localVarFp | ||
.homeGet(options) | ||
.then((request) => request(axios, basePath)); | ||
}, | ||
}; | ||
}; | ||
|
||
/** | ||
* HomeApi - object-oriented interface | ||
* @export | ||
* @class HomeApi | ||
* @extends {BaseAPI} | ||
*/ | ||
export class HomeApi extends BaseAPI { | ||
/** | ||
* | ||
* @summary Home | ||
* @param {*} [options] Override http request option. | ||
* @throws {RequiredError} | ||
* @memberof HomeApi | ||
*/ | ||
public homeGet(options?: RawAxiosRequestConfig) { | ||
return HomeApiFp(this.configuration) | ||
.homeGet(options) | ||
.then((request) => request(this.axios, this.basePath)); | ||
} | ||
} |
Oops, something went wrong.