diff --git a/packages/web-app/package.json b/packages/web-app/package.json index 37b17f380..680c63783 100644 --- a/packages/web-app/package.json +++ b/packages/web-app/package.json @@ -68,7 +68,10 @@ "resolutions": { "@elastic/search-ui": "file:../../libs/elastic-search-ui-1.17.1+salad.tgz", "meow@npm:3.7.0/trim-newlines": "3.0.1", - "remark-parse@npm:8.0.3/trim": "0.0.3" + "remark-parse@npm:8.0.3/trim": "0.0.3", + "@microsoft/kiota-abstractions": "1.0.0-preview.53", + "@microsoft/kiota-http-fetchlibrary": "1.0.0-preview.52", + "@microsoft/kiota-serialization-json": "1.0.0-preview.53" }, "dependencies": { "@babel/core": "7.24.5", @@ -86,9 +89,12 @@ "@fortawesome/free-regular-svg-icons": "6.5.2", "@fortawesome/free-solid-svg-icons": "6.5.2", "@fortawesome/react-fontawesome": "0.2.1", + "@microsoft/kiota-abstractions": "1.0.0-preview.53", + "@microsoft/kiota-http-fetchlibrary": "1.0.0-preview.52", + "@microsoft/kiota-serialization-json": "1.0.0-preview.53", "@novu/notification-center": "0.24.2", "@novu/shared": "0.24.2", - "@saladtechnologies/garden-components": "1.4.6", + "@saladtechnologies/garden-components": "1.4.7", "@saladtechnologies/garden-fonts": "1.0.4", "@saladtechnologies/garden-icons": "1.0.23", "@storybook/addon-a11y": "6.5.16", @@ -130,6 +136,7 @@ "eslint-plugin-compat": "4.2.0", "events": "3.3.0", "final-form": "4.20.10", + "guid-typescript": "1.0.9", "history": "4.10.1", "is-retry-allowed": "3.0.0", "lodash": "4.17.21", diff --git a/packages/web-app/src/api/machinesApiClient/generated/kiota-lock.json b/packages/web-app/src/api/machinesApiClient/generated/kiota-lock.json new file mode 100644 index 000000000..252f5508c --- /dev/null +++ b/packages/web-app/src/api/machinesApiClient/generated/kiota-lock.json @@ -0,0 +1,28 @@ +{ + "descriptionHash": "EEE908D27D05B1029AB34D629B7155B790B814FB795CAF4DEDE41501E2B37AC61A4297BCD54CBF2A6CA06DF189D96C610801FC35961CE038D5E3AF3E91750E18", + "descriptionLocation": "..\\openapi.yaml", + "lockFileVersion": "1.0.0", + "kiotaVersion": "1.15.0", + "clientClassName": "MachinesApiClient", + "clientNamespaceName": "ApiSdk", + "language": "TypeScript", + "usesBackingStore": false, + "excludeBackwardCompatible": true, + "includeAdditionalData": true, + "disableSSLValidation": false, + "serializers": [ + "\u0060@microsoft/kiota-serialization-json.JsonSerializationWriterFactory" + ], + "deserializers": [ + "\u0060@microsoft/kiota-serialization-json.JsonParseNodeFactory" + ], + "structuredMimeTypes": [ + "application/json", + "text/plain;q=0.9", + "application/x-www-form-urlencoded;q=0.2", + "multipart/form-data;q=0.1" + ], + "includePatterns": [], + "excludePatterns": [], + "disabledValidationRules": [] +} \ No newline at end of file diff --git a/packages/web-app/src/api/machinesApiClient/generated/machinesApiClient.ts b/packages/web-app/src/api/machinesApiClient/generated/machinesApiClient.ts new file mode 100644 index 000000000..87e532c8c --- /dev/null +++ b/packages/web-app/src/api/machinesApiClient/generated/machinesApiClient.ts @@ -0,0 +1,64 @@ +/* tslint:disable */ +/* eslint-disable */ +// Generated by Microsoft Kiota +// @ts-ignore +import { V2RequestBuilderNavigationMetadata, type V2RequestBuilder } from './v2' +// @ts-ignore +import { + apiClientProxifier, + registerDefaultDeserializer, + registerDefaultSerializer, + type BaseRequestBuilder, + type KeysToExcludeForNavigationMetadata, + type NavigationMetadata, + type RequestAdapter, +} from '@microsoft/kiota-abstractions' +// @ts-ignore +import { JsonParseNodeFactory, JsonSerializationWriterFactory } from '@microsoft/kiota-serialization-json' + +/** + * Instantiates a new {@link MachinesApiClient} and sets the default values. + * @param requestAdapter The request adapter to use to execute the requests. + */ +export function createMachinesApiClient(requestAdapter: RequestAdapter) { + registerDefaultSerializer(JsonSerializationWriterFactory) + registerDefaultDeserializer(JsonParseNodeFactory) + if (requestAdapter.baseUrl === undefined || requestAdapter.baseUrl === '') { + requestAdapter.baseUrl = 'https://app-api.salad.com/api' + } + const pathParameters: Record = { + baseurl: requestAdapter.baseUrl, + } + return apiClientProxifier( + requestAdapter, + pathParameters, + MachinesApiClientNavigationMetadata, + undefined, + ) +} +/** + * The main entry point of the SDK, exposes the configuration and the fluent API. + */ +export interface MachinesApiClient extends BaseRequestBuilder { + /** + * The v2 property + */ + get v2(): V2RequestBuilder +} +/** + * Uri template for the request builder. + */ +export const MachinesApiClientUriTemplate = '{+baseurl}' +/** + * Metadata for all the navigation properties in the request builder. + */ +export const MachinesApiClientNavigationMetadata: Record< + Exclude, + NavigationMetadata +> = { + v2: { + navigationMetadata: V2RequestBuilderNavigationMetadata, + }, +} +/* tslint:enable */ +/* eslint-enable */ diff --git a/packages/web-app/src/api/machinesApiClient/generated/models/index.ts b/packages/web-app/src/api/machinesApiClient/generated/models/index.ts new file mode 100644 index 000000000..13986705e --- /dev/null +++ b/packages/web-app/src/api/machinesApiClient/generated/models/index.ts @@ -0,0 +1,305 @@ +/* tslint:disable */ +/* eslint-disable */ +// Generated by Microsoft Kiota +// @ts-ignore +import { + type AdditionalDataHolder, + type ApiError, + type Parsable, + type ParseNode, + type SerializationWriter, +} from '@microsoft/kiota-abstractions' +// @ts-ignore +import { type Guid } from 'guid-typescript' + +/** + * Creates a new instance of the appropriate class based on discriminator value + * @param parseNode The parse node to use to read the discriminator value and create the object + * @returns {MachineEarningHistory_earnings} + */ +export function createMachineEarningHistory_earningsFromDiscriminatorValue(): ( + instance?: Parsable, +) => Record void> { + return deserializeIntoMachineEarningHistory_earnings +} +/** + * Creates a new instance of the appropriate class based on discriminator value + * @param parseNode The parse node to use to read the discriminator value and create the object + * @returns {MachineEarningHistory} + */ +export function createMachineEarningHistoryFromDiscriminatorValue(): ( + instance?: Parsable, +) => Record void> { + return deserializeIntoMachineEarningHistory +} +/** + * Creates a new instance of the appropriate class based on discriminator value + * @param parseNode The parse node to use to read the discriminator value and create the object + * @returns {Machine} + */ +export function createMachineFromDiscriminatorValue(): ( + instance?: Parsable, +) => Record void> { + return deserializeIntoMachine +} +/** + * Creates a new instance of the appropriate class based on discriminator value + * @param parseNode The parse node to use to read the discriminator value and create the object + * @returns {MachineList} + */ +export function createMachineListFromDiscriminatorValue(): ( + instance?: Parsable, +) => Record void> { + return deserializeIntoMachineList +} +/** + * Creates a new instance of the appropriate class based on discriminator value + * @param parseNode The parse node to use to read the discriminator value and create the object + * @returns {ProblemDetails} + */ +export function createProblemDetailsFromDiscriminatorValue(): ( + instance?: Parsable, +) => Record void> { + return deserializeIntoProblemDetails +} +/** + * The deserialization information for the current model + * @returns {Record void>} + */ +export function deserializeIntoMachine( + machine: Partial | undefined = {}, +): Record void> { + return { + create_time: (n) => { + machine.create_time = n.getDateValue() + }, + lifetime_balance: (n) => { + machine.lifetime_balance = n.getNumberValue() + }, + machine_id: (n) => { + machine.machine_id = n.getGuidValue() + }, + update_time: (n) => { + machine.update_time = n.getDateValue() + }, + } +} +/** + * The deserialization information for the current model + * @returns {Record void>} + */ +export function deserializeIntoMachineEarningHistory( + machineEarningHistory: Partial | undefined = {}, +): Record void> { + return { + earnings: (n) => { + machineEarningHistory.earnings = n.getObjectValue( + createMachineEarningHistory_earningsFromDiscriminatorValue, + ) + }, + machine_id: (n) => { + machineEarningHistory.machine_id = n.getGuidValue() + }, + } +} +/** + * The deserialization information for the current model + * @returns {Record void>} + */ +export function deserializeIntoMachineEarningHistory_earnings(): Record void> { + return {} +} +/** + * The deserialization information for the current model + * @returns {Record void>} + */ +export function deserializeIntoMachineList( + machineList: Partial | undefined = {}, +): Record void> { + return { + continuation_token: (n) => { + machineList.continuation_token = n.getStringValue() + }, + items: (n) => { + machineList.items = n.getCollectionOfObjectValues(createMachineFromDiscriminatorValue) + }, + } +} +/** + * The deserialization information for the current model + * @returns {Record void>} + */ +export function deserializeIntoProblemDetails( + problemDetails: Partial | undefined = {}, +): Record void> { + return { + detail: (n) => { + problemDetails.detail = n.getStringValue() + }, + instance: (n) => { + problemDetails.instance = n.getStringValue() + }, + status: (n) => { + problemDetails.status = n.getNumberValue() + }, + title: (n) => { + problemDetails.title = n.getStringValue() + }, + type: (n) => { + problemDetails.type = n.getStringValue() ?? 'about:blank' + }, + } +} +export type EarningHistoryTimeframeEnum = + (typeof EarningHistoryTimeframeEnumObject)[keyof typeof EarningHistoryTimeframeEnumObject] +/** + * Represents a machine + */ +export interface Machine extends Parsable { + /** + * The time the machine was created + */ + create_time?: Date + /** + * The lifetime earnings of the machine + */ + lifetime_balance?: number + /** + * The unique machine identifier + */ + machine_id?: Guid + /** + * The time the machine was last updated + */ + update_time?: Date +} +/** + * Represents a machine earning history + */ +export interface MachineEarningHistory extends Parsable { + /** + * The machine earnings histogram + */ + earnings?: MachineEarningHistory_earnings + /** + * The unique machine identifier + */ + machine_id?: Guid +} +/** + * The machine earnings histogram + */ +export interface MachineEarningHistory_earnings extends AdditionalDataHolder, Parsable { + /** + * Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + */ + additionalData?: Record +} +/** + * Represents a list of machines + */ +export interface MachineList extends Parsable { + /** + * The continuation token to fetch the next page of results + */ + continuation_token?: string + /** + * The list of machines on the current page + */ + items?: Machine[] +} +/** + * Represents a problem + */ +export interface ProblemDetails extends ApiError, Parsable { + /** + * A human-readable explanation specific to this occurrence of the problem + */ + detail?: string + /** + * The URI reference that identifies the specific occurrence of the problem + */ + instance?: string + /** + * The HTTP status code generated by the origin server + */ + status?: number + /** + * A short, human-readable summary of the problem type + */ + title?: string + /** + * The URI reference that identifies the problem type + */ + type?: string +} +/** + * Serializes information the current object + * @param writer Serialization writer to use to serialize this model + */ +export function serializeMachine(writer: SerializationWriter, machine: Partial | undefined = {}): void { + writer.writeDateValue('create_time', machine.create_time) + writer.writeNumberValue('lifetime_balance', machine.lifetime_balance) + writer.writeGuidValue('machine_id', machine.machine_id) + writer.writeDateValue('update_time', machine.update_time) +} +/** + * Serializes information the current object + * @param writer Serialization writer to use to serialize this model + */ +export function serializeMachineEarningHistory( + writer: SerializationWriter, + machineEarningHistory: Partial | undefined = {}, +): void { + writer.writeObjectValue( + 'earnings', + machineEarningHistory.earnings, + serializeMachineEarningHistory_earnings, + ) + writer.writeGuidValue('machine_id', machineEarningHistory.machine_id) +} +/** + * Serializes information the current object + * @param writer Serialization writer to use to serialize this model + */ +export function serializeMachineEarningHistory_earnings( + writer: SerializationWriter, + machineEarningHistory_earnings: Partial | undefined = {}, +): void { + writer.writeAdditionalData(machineEarningHistory_earnings.additionalData) +} +/** + * Serializes information the current object + * @param writer Serialization writer to use to serialize this model + */ +export function serializeMachineList( + writer: SerializationWriter, + machineList: Partial | undefined = {}, +): void { + writer.writeStringValue('continuation_token', machineList.continuation_token) + writer.writeCollectionOfObjectValues('items', machineList.items, serializeMachine) +} +/** + * Serializes information the current object + * @param writer Serialization writer to use to serialize this model + */ +export function serializeProblemDetails( + writer: SerializationWriter, + problemDetails: Partial | undefined = {}, +): void { + writer.writeStringValue('detail', problemDetails.detail) + writer.writeStringValue('instance', problemDetails.instance) + writer.writeNumberValue('status', problemDetails.status) + writer.writeStringValue('title', problemDetails.title) + writer.writeStringValue('type', problemDetails.type ?? 'about:blank') +} +/** + * The earning history timeframe + */ +export const EarningHistoryTimeframeEnumObject = { + TwoFourh: '24h', + Sevend: '7d', + ThreeZerod: '30d', +} as const +/* tslint:enable */ +/* eslint-enable */ diff --git a/packages/web-app/src/api/machinesApiClient/generated/v2/index.ts b/packages/web-app/src/api/machinesApiClient/generated/v2/index.ts new file mode 100644 index 000000000..0364c726a --- /dev/null +++ b/packages/web-app/src/api/machinesApiClient/generated/v2/index.ts @@ -0,0 +1,32 @@ +/* tslint:disable */ +/* eslint-disable */ +// Generated by Microsoft Kiota +// @ts-ignore +import { MachinesRequestBuilderNavigationMetadata, MachinesRequestBuilderRequestsMetadata, type MachinesRequestBuilder } from './machines/'; +// @ts-ignore +import { type BaseRequestBuilder, type KeysToExcludeForNavigationMetadata, type NavigationMetadata } from '@microsoft/kiota-abstractions'; + +/** + * Builds and executes requests for operations under /v2 + */ +export interface V2RequestBuilder extends BaseRequestBuilder { + /** + * Operations for machines + */ + get machines(): MachinesRequestBuilder; +} +/** + * Uri template for the request builder. + */ +export const V2RequestBuilderUriTemplate = "{+baseurl}/v2"; +/** + * Metadata for all the navigation properties in the request builder. + */ +export const V2RequestBuilderNavigationMetadata: Record, NavigationMetadata> = { + machines: { + requestsMetadata: MachinesRequestBuilderRequestsMetadata, + navigationMetadata: MachinesRequestBuilderNavigationMetadata, + }, +}; +/* tslint:enable */ +/* eslint-enable */ diff --git a/packages/web-app/src/api/machinesApiClient/generated/v2/machines/index.ts b/packages/web-app/src/api/machinesApiClient/generated/v2/machines/index.ts new file mode 100644 index 000000000..ab0c0e45e --- /dev/null +++ b/packages/web-app/src/api/machinesApiClient/generated/v2/machines/index.ts @@ -0,0 +1,84 @@ +/* tslint:disable */ +/* eslint-disable */ +// Generated by Microsoft Kiota +// @ts-ignore +import { createMachineListFromDiscriminatorValue, createProblemDetailsFromDiscriminatorValue, type MachineList, type ProblemDetails } from '../../models/'; +// @ts-ignore +import { type WithMachine_ItemRequestBuilder, WithMachine_ItemRequestBuilderNavigationMetadata, WithMachine_ItemRequestBuilderRequestsMetadata } from './item/'; +// @ts-ignore +import { type BaseRequestBuilder, type KeysToExcludeForNavigationMetadata, type NavigationMetadata, type Parsable, type ParsableFactory, type RequestConfiguration, type RequestInformation, type RequestsMetadata } from '@microsoft/kiota-abstractions'; +// @ts-ignore +import { type Guid } from 'guid-typescript'; + +/** + * Operations for machines + */ +export interface MachinesRequestBuilder extends BaseRequestBuilder { + /** + * Operations for a single machine + * @param machine_id The unique machine identifier + * @returns {WithMachine_ItemRequestBuilder} + */ + byMachine_id(machine_id: Guid) : WithMachine_ItemRequestBuilder; + /** + * Gets the paginated list of machines + * @param requestConfiguration Configuration for the request such as headers, query parameters, and middleware options. + * @returns {Promise} + * @throws {ProblemDetails} error when the service returns a 401 status code + * @throws {ProblemDetails} error when the service returns a 4XX or 5XX status code + */ + get(requestConfiguration?: RequestConfiguration | undefined) : Promise; + /** + * Gets the paginated list of machines + * @param requestConfiguration Configuration for the request such as headers, query parameters, and middleware options. + * @returns {RequestInformation} + */ + toGetRequestInformation(requestConfiguration?: RequestConfiguration | undefined) : RequestInformation; +} +/** + * Gets the paginated list of machines + */ +export interface MachinesRequestBuilderGetQueryParameters { + /** + * The continuation token to fetch the next page of results + */ + continuationToken?: string; +} +/** + * Uri template for the request builder. + */ +export const MachinesRequestBuilderUriTemplate = "{+baseurl}/v2/machines{?continuation_token*}"; +/** + * Mapper for query parameters from symbol name to serialization name represented as a constant. + */ +const MachinesRequestBuilderGetQueryParametersMapper: Record = { + "continuationToken": "continuation_token", +}; +/** + * Metadata for all the navigation properties in the request builder. + */ +export const MachinesRequestBuilderNavigationMetadata: Record, NavigationMetadata> = { + byMachine_id: { + requestsMetadata: WithMachine_ItemRequestBuilderRequestsMetadata, + navigationMetadata: WithMachine_ItemRequestBuilderNavigationMetadata, + pathParametersMappings: ["machine_id"], + }, +}; +/** + * Metadata for all the requests in the request builder. + */ +export const MachinesRequestBuilderRequestsMetadata: RequestsMetadata = { + get: { + uriTemplate: MachinesRequestBuilderUriTemplate, + responseBodyContentType: "application/json", + errorMappings: { + 401: createProblemDetailsFromDiscriminatorValue as ParsableFactory, + XXX: createProblemDetailsFromDiscriminatorValue as ParsableFactory, + }, + adapterMethodName: "send", + responseBodyFactory: createMachineListFromDiscriminatorValue, + queryParametersMapper: MachinesRequestBuilderGetQueryParametersMapper, + }, +}; +/* tslint:enable */ +/* eslint-enable */ diff --git a/packages/web-app/src/api/machinesApiClient/generated/v2/machines/item/earningHistory/index.ts b/packages/web-app/src/api/machinesApiClient/generated/v2/machines/item/earningHistory/index.ts new file mode 100644 index 000000000..e5a3c0ae1 --- /dev/null +++ b/packages/web-app/src/api/machinesApiClient/generated/v2/machines/item/earningHistory/index.ts @@ -0,0 +1,61 @@ +/* tslint:disable */ +/* eslint-disable */ +// Generated by Microsoft Kiota +// @ts-ignore +import { createMachineEarningHistoryFromDiscriminatorValue, createProblemDetailsFromDiscriminatorValue, EarningHistoryTimeframeEnum, type MachineEarningHistory, type ProblemDetails } from '../../../../models/'; +// @ts-ignore +import { type BaseRequestBuilder, type Parsable, type ParsableFactory, type RequestConfiguration, type RequestInformation, type RequestsMetadata } from '@microsoft/kiota-abstractions'; + +/** + * Operations for a single machine + */ +export interface EarningHistoryRequestBuilder extends BaseRequestBuilder { + /** + * Gets a single machine earning history within a given timeframe by its unique identifier + * @param requestConfiguration Configuration for the request such as headers, query parameters, and middleware options. + * @returns {Promise} + * @throws {ProblemDetails} error when the service returns a 400 status code + * @throws {ProblemDetails} error when the service returns a 401 status code + * @throws {ProblemDetails} error when the service returns a 404 status code + * @throws {ProblemDetails} error when the service returns a 4XX or 5XX status code + */ + get(requestConfiguration?: RequestConfiguration | undefined) : Promise; + /** + * Gets a single machine earning history within a given timeframe by its unique identifier + * @param requestConfiguration Configuration for the request such as headers, query parameters, and middleware options. + * @returns {RequestInformation} + */ + toGetRequestInformation(requestConfiguration?: RequestConfiguration | undefined) : RequestInformation; +} +/** + * Gets a single machine earning history within a given timeframe by its unique identifier + */ +export interface EarningHistoryRequestBuilderGetQueryParameters { + /** + * The earning history time frame + */ + timeframe?: EarningHistoryTimeframeEnum; +} +/** + * Uri template for the request builder. + */ +export const EarningHistoryRequestBuilderUriTemplate = "{+baseurl}/v2/machines/{machine_id}/earning-history{?timeframe*}"; +/** + * Metadata for all the requests in the request builder. + */ +export const EarningHistoryRequestBuilderRequestsMetadata: RequestsMetadata = { + get: { + uriTemplate: EarningHistoryRequestBuilderUriTemplate, + responseBodyContentType: "application/json", + errorMappings: { + 400: createProblemDetailsFromDiscriminatorValue as ParsableFactory, + 401: createProblemDetailsFromDiscriminatorValue as ParsableFactory, + 404: createProblemDetailsFromDiscriminatorValue as ParsableFactory, + XXX: createProblemDetailsFromDiscriminatorValue as ParsableFactory, + }, + adapterMethodName: "send", + responseBodyFactory: createMachineEarningHistoryFromDiscriminatorValue, + }, +}; +/* tslint:enable */ +/* eslint-enable */ diff --git a/packages/web-app/src/api/machinesApiClient/generated/v2/machines/item/index.ts b/packages/web-app/src/api/machinesApiClient/generated/v2/machines/item/index.ts new file mode 100644 index 000000000..bec4a7186 --- /dev/null +++ b/packages/web-app/src/api/machinesApiClient/generated/v2/machines/item/index.ts @@ -0,0 +1,64 @@ +/* tslint:disable */ +/* eslint-disable */ +// Generated by Microsoft Kiota +// @ts-ignore +import { createMachineFromDiscriminatorValue, createProblemDetailsFromDiscriminatorValue, type Machine, type ProblemDetails } from '../../../models/'; +// @ts-ignore +import { EarningHistoryRequestBuilderRequestsMetadata, type EarningHistoryRequestBuilder } from './earningHistory/'; +// @ts-ignore +import { type BaseRequestBuilder, type KeysToExcludeForNavigationMetadata, type NavigationMetadata, type Parsable, type ParsableFactory, type RequestConfiguration, type RequestInformation, type RequestsMetadata } from '@microsoft/kiota-abstractions'; + +/** + * Operations for a single machine + */ +export interface WithMachine_ItemRequestBuilder extends BaseRequestBuilder { + /** + * Operations for a single machine + */ + get earningHistory(): EarningHistoryRequestBuilder; + /** + * Gets a single machine by its unique identifier + * @param requestConfiguration Configuration for the request such as headers, query parameters, and middleware options. + * @returns {Promise} + * @throws {ProblemDetails} error when the service returns a 401 status code + * @throws {ProblemDetails} error when the service returns a 404 status code + * @throws {ProblemDetails} error when the service returns a 4XX or 5XX status code + */ + get(requestConfiguration?: RequestConfiguration | undefined) : Promise; + /** + * Gets a single machine by its unique identifier + * @param requestConfiguration Configuration for the request such as headers, query parameters, and middleware options. + * @returns {RequestInformation} + */ + toGetRequestInformation(requestConfiguration?: RequestConfiguration | undefined) : RequestInformation; +} +/** + * Uri template for the request builder. + */ +export const WithMachine_ItemRequestBuilderUriTemplate = "{+baseurl}/v2/machines/{machine_id}"; +/** + * Metadata for all the navigation properties in the request builder. + */ +export const WithMachine_ItemRequestBuilderNavigationMetadata: Record, NavigationMetadata> = { + earningHistory: { + requestsMetadata: EarningHistoryRequestBuilderRequestsMetadata, + }, +}; +/** + * Metadata for all the requests in the request builder. + */ +export const WithMachine_ItemRequestBuilderRequestsMetadata: RequestsMetadata = { + get: { + uriTemplate: WithMachine_ItemRequestBuilderUriTemplate, + responseBodyContentType: "application/json", + errorMappings: { + 401: createProblemDetailsFromDiscriminatorValue as ParsableFactory, + 404: createProblemDetailsFromDiscriminatorValue as ParsableFactory, + XXX: createProblemDetailsFromDiscriminatorValue as ParsableFactory, + }, + adapterMethodName: "send", + responseBodyFactory: createMachineFromDiscriminatorValue, + }, +}; +/* tslint:enable */ +/* eslint-enable */ diff --git a/packages/web-app/src/api/machinesApiClient/getMachinesApiClient.ts b/packages/web-app/src/api/machinesApiClient/getMachinesApiClient.ts new file mode 100644 index 000000000..a08a536d5 --- /dev/null +++ b/packages/web-app/src/api/machinesApiClient/getMachinesApiClient.ts @@ -0,0 +1,85 @@ +import { FetchRequestAdapter, HttpClient } from '@microsoft/kiota-http-fetchlibrary' +import type { AxiosInstance, AxiosResponse } from 'axios' +import { config } from '../../config' +import type { MachinesApiClient } from './generated/machinesApiClient' +import { createMachinesApiClient } from './generated/machinesApiClient' + +const apiUrl = `${config.apiBaseUrl}/api` + +const convertAxiosResponseToFetchResponse = (axiosResponse: AxiosResponse): Response => { + const fetchResponse = { + ok: axiosResponse.status >= 200 && axiosResponse.status < 300, + status: axiosResponse.status, + statusText: axiosResponse.statusText, + headers: new Headers(axiosResponse.headers as Record), + url: axiosResponse.config.url || '', + redirected: false, + type: 'basic' as ResponseType, + bodyUsed: false, + body: new ReadableStream({ + start(controller) { + controller.enqueue(axiosResponse.data) + controller.close() + }, + }), + async json() { + if (this.bodyUsed) throw new TypeError('Already read') + this.bodyUsed = true + return axiosResponse.data + }, + async text() { + if (this.bodyUsed) throw new TypeError('Already read') + this.bodyUsed = true + return JSON.stringify(axiosResponse.data) + }, + async blob() { + if (this.bodyUsed) throw new TypeError('Already read') + this.bodyUsed = true + const data = JSON.stringify(axiosResponse.data) + return new Blob([data], { type: 'application/json' }) + }, + async arrayBuffer() { + if (this.bodyUsed) throw new TypeError('Already read') + this.bodyUsed = true + const data = JSON.stringify(axiosResponse.data) + const buffer = new ArrayBuffer(data.length) + const view = new Uint8Array(buffer) + for (let i = 0; i < data.length; i++) { + view[i] = data.charCodeAt(i) + } + return buffer + }, + async formData() { + if (this.bodyUsed) throw new TypeError('Already read') + this.bodyUsed = true + const formData = new FormData() + const json = axiosResponse.data as Record + if (typeof json === 'object') { + Object.keys(json).forEach((key) => formData.append(key, json[key])) + } + return formData + }, + clone() { + return convertAxiosResponseToFetchResponse(axiosResponse) + }, + } + + return fetchResponse +} + +class AuthenticationProviderStub { + authenticateRequest = () => Promise.resolve() +} + +export const getMachinesApiClient = (axios: AxiosInstance): MachinesApiClient => { + const httpClient = new HttpClient((request: string, init: RequestInit) => { + return axios.request({ url: request, method: init.method }).then((response) => { + return convertAxiosResponseToFetchResponse(response) + }) + }) + + const requestAdapter = new FetchRequestAdapter(new AuthenticationProviderStub(), undefined, undefined, httpClient) + + requestAdapter.baseUrl = apiUrl + return createMachinesApiClient(requestAdapter) +} diff --git a/packages/web-app/yarn.lock b/packages/web-app/yarn.lock index b7682ed48..e5e48580c 100644 --- a/packages/web-app/yarn.lock +++ b/packages/web-app/yarn.lock @@ -3125,6 +3125,43 @@ __metadata: languageName: node linkType: hard +"@microsoft/kiota-abstractions@npm:1.0.0-preview.53": + version: 1.0.0-preview.53 + resolution: "@microsoft/kiota-abstractions@npm:1.0.0-preview.53" + dependencies: + "@opentelemetry/api": "npm:^1.7.0" + "@std-uritemplate/std-uritemplate": "npm:^0.0.57" + guid-typescript: "npm:^1.0.9" + tinyduration: "npm:^3.3.0" + tslib: "npm:^2.6.2" + uuid: "npm:^9.0.1" + checksum: 10c0/e0edb1729327ddc2f1bc495702641b62a18978a65da75efae1ebffdab0397506bbd7259035dc27b5769cafc6ef8839878f2fe7d217f18a6e627fab40ddbd9e53 + languageName: node + linkType: hard + +"@microsoft/kiota-http-fetchlibrary@npm:1.0.0-preview.52": + version: 1.0.0-preview.52 + resolution: "@microsoft/kiota-http-fetchlibrary@npm:1.0.0-preview.52" + dependencies: + "@microsoft/kiota-abstractions": "npm:*" + "@opentelemetry/api": "npm:^1.7.0" + guid-typescript: "npm:^1.0.9" + tslib: "npm:^2.6.2" + checksum: 10c0/4b2fa4f918e03f950a8a92b78bf6086d0b1efecb002aef88f8b0e0294a02de68393ce9d62f332704d5e6b79a825a66a653cd670b97ab36b835b10b75fc436397 + languageName: node + linkType: hard + +"@microsoft/kiota-serialization-json@npm:1.0.0-preview.53": + version: 1.0.0-preview.53 + resolution: "@microsoft/kiota-serialization-json@npm:1.0.0-preview.53" + dependencies: + "@microsoft/kiota-abstractions": "npm:*" + guid-typescript: "npm:^1.0.9" + tslib: "npm:^2.6.2" + checksum: 10c0/885d04000ca8e91513118f4c5a6b2be57b1b34f1cc7491e8b3060086b7068120fb306a47234aab02affbd249884e7d284e143bfaca0682389ea50bc99cf817de + languageName: node + linkType: hard + "@mrmlnc/readdir-enhanced@npm:^2.2.1": version: 2.2.1 resolution: "@mrmlnc/readdir-enhanced@npm:2.2.1" @@ -3268,6 +3305,13 @@ __metadata: languageName: node linkType: hard +"@opentelemetry/api@npm:^1.7.0": + version: 1.9.0 + resolution: "@opentelemetry/api@npm:1.9.0" + checksum: 10c0/9aae2fe6e8a3a3eeb6c1fdef78e1939cf05a0f37f8a4fae4d6bf2e09eb1e06f966ece85805626e01ba5fab48072b94f19b835449e58b6d26720ee19a58298add + languageName: node + linkType: hard + "@pkgjs/parseargs@npm:^0.11.0": version: 0.11.0 resolution: "@pkgjs/parseargs@npm:0.11.0" @@ -3540,9 +3584,12 @@ __metadata: "@fortawesome/free-regular-svg-icons": "npm:6.5.2" "@fortawesome/free-solid-svg-icons": "npm:6.5.2" "@fortawesome/react-fontawesome": "npm:0.2.1" + "@microsoft/kiota-abstractions": "npm:1.0.0-preview.53" + "@microsoft/kiota-http-fetchlibrary": "npm:1.0.0-preview.52" + "@microsoft/kiota-serialization-json": "npm:1.0.0-preview.53" "@novu/notification-center": "npm:0.24.2" "@novu/shared": "npm:0.24.2" - "@saladtechnologies/garden-components": "npm:1.4.6" + "@saladtechnologies/garden-components": "npm:1.4.7" "@saladtechnologies/garden-fonts": "npm:1.0.4" "@saladtechnologies/garden-icons": "npm:1.0.23" "@storybook/addon-a11y": "npm:6.5.16" @@ -3584,6 +3631,7 @@ __metadata: eslint-plugin-compat: "npm:4.2.0" events: "npm:3.3.0" final-form: "npm:4.20.10" + guid-typescript: "npm:1.0.9" history: "npm:4.10.1" is-retry-allowed: "npm:3.0.0" lodash: "npm:4.17.21" @@ -3641,9 +3689,9 @@ __metadata: languageName: unknown linkType: soft -"@saladtechnologies/garden-components@npm:1.4.6": - version: 1.4.6 - resolution: "@saladtechnologies/garden-components@npm:1.4.6" +"@saladtechnologies/garden-components@npm:1.4.7": + version: 1.4.7 + resolution: "@saladtechnologies/garden-components@npm:1.4.7" peerDependencies: "@emotion/react": 11.x "@emotion/styled": 11.x @@ -3658,7 +3706,7 @@ __metadata: react-intl: 6.x react-range: 1.x react-responsive: 9.x - checksum: 10c0/9634da2d11c2bf69152a5a868d04d3879da0ab20186cf45ba2df95f1a8d819a4220d3777337540e61226dd29c5f6601c9a0b6ad39c5b5c5d611ae6551d45ea29 + checksum: 10c0/d2bbbe03a43ebce92fedd8cc8ae1276668f876d34a6f475d1817d85f24498a3b4042d7d1d0d746f7f5476bcde7b079568ed9343922e2a6c2bb6b9cae7e2d1646 languageName: node linkType: hard @@ -3718,6 +3766,13 @@ __metadata: languageName: node linkType: hard +"@std-uritemplate/std-uritemplate@npm:^0.0.57": + version: 0.0.57 + resolution: "@std-uritemplate/std-uritemplate@npm:0.0.57" + checksum: 10c0/5aed0bbcb8c5492bb4c8211deebe6731539aa0656a2e8270cbd7ac046de85aa1d58ae6389a6dd80417599ddc8e010ae464eb4e081c8d3ab4f085cf060673eb23 + languageName: node + linkType: hard + "@storybook/addon-a11y@npm:6.5.16": version: 6.5.16 resolution: "@storybook/addon-a11y@npm:6.5.16" @@ -12389,6 +12444,13 @@ __metadata: languageName: node linkType: hard +"guid-typescript@npm:1.0.9, guid-typescript@npm:^1.0.9": + version: 1.0.9 + resolution: "guid-typescript@npm:1.0.9" + checksum: 10c0/fa0a2b2b4e06e0976a81c947b74e114b92f6647e84b52e24ab0981d2fdbaa1a640641d8fd269004dd7c581baebeb4f9d9782b74391e717e47c9b822bea4b3be6 + languageName: node + linkType: hard + "gzip-size@npm:^6.0.0": version: 6.0.0 resolution: "gzip-size@npm:6.0.0" @@ -21856,6 +21918,13 @@ __metadata: languageName: node linkType: hard +"tinyduration@npm:^3.3.0": + version: 3.3.1 + resolution: "tinyduration@npm:3.3.1" + checksum: 10c0/2a0311065188b25bcc3b0568b3893d0d8e498b58ca5a772fba69c12c99b4294f7cc9f7a62056e9c8dd7d8194c8d6669af4ab89faa5fb7eef55b0939b730af911 + languageName: node + linkType: hard + "tinylogic@npm:^1.0.3": version: 1.0.3 resolution: "tinylogic@npm:1.0.3" @@ -22111,6 +22180,13 @@ __metadata: languageName: node linkType: hard +"tslib@npm:^2.6.2": + version: 2.6.3 + resolution: "tslib@npm:2.6.3" + checksum: 10c0/2598aef53d9dbe711af75522464b2104724d6467b26a60f2bdac8297d2b5f1f6b86a71f61717384aa8fd897240467aaa7bcc36a0700a0faf751293d1331db39a + languageName: node + linkType: hard + "tsutils@npm:^3.21.0": version: 3.21.0 resolution: "tsutils@npm:3.21.0" @@ -22827,7 +22903,7 @@ __metadata: languageName: node linkType: hard -"uuid@npm:9.0.1": +"uuid@npm:9.0.1, uuid@npm:^9.0.1": version: 9.0.1 resolution: "uuid@npm:9.0.1" bin: