Skip to content

Commit

Permalink
MINOR: serialize basic document data in /me/visa responses (#769)
Browse files Browse the repository at this point in the history
* MINOR: serialize basic document data in /me/visa responses

* fix minor mistakes

* fix parent_id in doc

* fix prefetch
  • Loading branch information
Bimdata-io committed Sep 4, 2024
1 parent 0c16ab6 commit 54c8f6d
Show file tree
Hide file tree
Showing 6 changed files with 284 additions and 16 deletions.
2 changes: 2 additions & 0 deletions package/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ src/models/Layer.ts
src/models/LayerElement.ts
src/models/LayerElementRequest.ts
src/models/LayerRequest.ts
src/models/LightDocument.ts
src/models/Line.ts
src/models/LineRequest.ts
src/models/LogEntry.ts
Expand Down Expand Up @@ -237,6 +238,7 @@ src/models/VisaCommentRequest.ts
src/models/VisaRequest.ts
src/models/VisaValidation.ts
src/models/VisaValidationRequest.ts
src/models/VisaWithDocument.ts
src/models/Visibility.ts
src/models/VisibilityRequest.ts
src/models/WebHook.ts
Expand Down
19 changes: 11 additions & 8 deletions package/src/apis/CollaborationApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ import {
VisaValidationRequest,
VisaValidationRequestFromJSON,
VisaValidationRequestToJSON,
VisaWithDocument,
VisaWithDocumentFromJSON,
VisaWithDocumentToJSON,
WriteFolderRequest,
WriteFolderRequestFromJSON,
WriteFolderRequestToJSON,
Expand Down Expand Up @@ -1674,7 +1677,7 @@ export class CollaborationApi extends runtime.BaseAPI {
}

/**
* Create a document. If the document is one of {\'DWG\', \'OBJ\', \'DXF\', \'POINT_CLOUD\', \'IFC\', \'GLTF\'}, a model will be created and attached to this document Required scopes: document:write
* Create a document. If the document is one of {\'POINT_CLOUD\', \'GLTF\', \'DWG\', \'IFC\', \'OBJ\', \'DXF\'}, a model will be created and attached to this document Required scopes: document:write
* Create a document
*/
async createDocumentRaw(requestParameters: CreateDocumentRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<Document>> {
Expand Down Expand Up @@ -1777,7 +1780,7 @@ export class CollaborationApi extends runtime.BaseAPI {
}

/**
* Create a document. If the document is one of {\'DWG\', \'OBJ\', \'DXF\', \'POINT_CLOUD\', \'IFC\', \'GLTF\'}, a model will be created and attached to this document Required scopes: document:write
* Create a document. If the document is one of {\'POINT_CLOUD\', \'GLTF\', \'DWG\', \'IFC\', \'OBJ\', \'DXF\'}, a model will be created and attached to this document Required scopes: document:write
* Create a document
*/
async createDocument(cloud_pk: number, project_pk: number, name: string, file: Blob, parent_id?: number | null, file_name?: string, description?: string | null, model_source?: CreateDocumentModelSourceEnum, ifc_source?: CreateDocumentIfcSourceEnum, successor_of?: number, initOverrides?: RequestInit): Promise<Document> {
Expand Down Expand Up @@ -4841,7 +4844,7 @@ export class CollaborationApi extends runtime.BaseAPI {
* List visas created by user in a project Required scopes: document:read
* List visas created by user
*/
async getProjectCreatorVisasRaw(requestParameters: GetProjectCreatorVisasRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<Array<Visa>>> {
async getProjectCreatorVisasRaw(requestParameters: GetProjectCreatorVisasRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<Array<VisaWithDocument>>> {
if (requestParameters.cloud_pk === null || requestParameters.cloud_pk === undefined) {
throw new runtime.RequiredError('cloud_pk','Required parameter requestParameters.cloud_pk was null or undefined when calling getProjectCreatorVisas.');
}
Expand Down Expand Up @@ -4899,14 +4902,14 @@ export class CollaborationApi extends runtime.BaseAPI {
query: queryParameters,
}, initOverrides);

return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(VisaFromJSON));
return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(VisaWithDocumentFromJSON));
}

/**
* List visas created by user in a project Required scopes: document:read
* List visas created by user
*/
async getProjectCreatorVisas(cloud_pk: number, project_pk: number, deadline_after?: Date, deadline_before?: Date, has__past_deadline?: boolean, status?: GetProjectCreatorVisasStatusEnum, validation_status?: string, initOverrides?: RequestInit): Promise<Array<Visa>> {
async getProjectCreatorVisas(cloud_pk: number, project_pk: number, deadline_after?: Date, deadline_before?: Date, has__past_deadline?: boolean, status?: GetProjectCreatorVisasStatusEnum, validation_status?: string, initOverrides?: RequestInit): Promise<Array<VisaWithDocument>> {
const response = await this.getProjectCreatorVisasRaw({ cloud_pk: cloud_pk, project_pk: project_pk, deadline_after: deadline_after, deadline_before: deadline_before, has__past_deadline: has__past_deadline, status: status, validation_status: validation_status }, initOverrides);
return await response.value();
}
Expand Down Expand Up @@ -5305,7 +5308,7 @@ export class CollaborationApi extends runtime.BaseAPI {
* List visas where user is a validator in a project Required scopes: document:read
* List visas where user is a validator
*/
async getProjectValidatorVisasRaw(requestParameters: GetProjectValidatorVisasRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<Array<Visa>>> {
async getProjectValidatorVisasRaw(requestParameters: GetProjectValidatorVisasRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<Array<VisaWithDocument>>> {
if (requestParameters.cloud_pk === null || requestParameters.cloud_pk === undefined) {
throw new runtime.RequiredError('cloud_pk','Required parameter requestParameters.cloud_pk was null or undefined when calling getProjectValidatorVisas.');
}
Expand Down Expand Up @@ -5363,14 +5366,14 @@ export class CollaborationApi extends runtime.BaseAPI {
query: queryParameters,
}, initOverrides);

return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(VisaFromJSON));
return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(VisaWithDocumentFromJSON));
}

/**
* List visas where user is a validator in a project Required scopes: document:read
* List visas where user is a validator
*/
async getProjectValidatorVisas(cloud_pk: number, project_pk: number, deadline_after?: Date, deadline_before?: Date, has__past_deadline?: boolean, status?: GetProjectValidatorVisasStatusEnum, validation_status?: string, initOverrides?: RequestInit): Promise<Array<Visa>> {
async getProjectValidatorVisas(cloud_pk: number, project_pk: number, deadline_after?: Date, deadline_before?: Date, has__past_deadline?: boolean, status?: GetProjectValidatorVisasStatusEnum, validation_status?: string, initOverrides?: RequestInit): Promise<Array<VisaWithDocument>> {
const response = await this.getProjectValidatorVisasRaw({ cloud_pk: cloud_pk, project_pk: project_pk, deadline_after: deadline_after, deadline_before: deadline_before, has__past_deadline: has__past_deadline, status: status, validation_status: validation_status }, initOverrides);
return await response.value();
}
Expand Down
90 changes: 90 additions & 0 deletions package/src/models/LightDocument.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/* tslint:disable */
/* eslint-disable */
/**
* BIMData API
* BIMData API is a tool to interact with your models stored on BIMData’s servers. Through the API, you can manage your projects, the clouds, upload your IFC files and manage them through endpoints.
*
* The version of the OpenAPI document: v1 (v1)
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/

import { exists, mapValues } from '../runtime';
/**
*
* @export
* @interface LightDocument
*/
export interface LightDocument {
/**
*
* @type {number}
* @memberof LightDocument
*/
readonly id: number;
/**
*
* @type {number}
* @memberof LightDocument
*/
readonly parent_id: number;
/**
* Shown name of the file
* @type {string}
* @memberof LightDocument
*/
readonly name: string;
/**
* Description of the file
* @type {string}
* @memberof LightDocument
*/
readonly description: string | null;
/**
* Document id of head version
* @type {number}
* @memberof LightDocument
*/
readonly head_id: number | null;
/**
* Document is a head of version or is owned by another document
* @type {boolean}
* @memberof LightDocument
*/
readonly is_head_version: boolean;
}

export function LightDocumentFromJSON(json: any): LightDocument {
return LightDocumentFromJSONTyped(json, false);
}

export function LightDocumentFromJSONTyped(json: any, ignoreDiscriminator: boolean): LightDocument {
if ((json === undefined) || (json === null)) {
return json;
}
return {

'id': json['id'],
'parent_id': json['parent_id'],
'name': json['name'],
'description': json['description'],
'head_id': json['head_id'],
'is_head_version': json['is_head_version'],
};
}

export function LightDocumentToJSON(value?: LightDocument | null): any {
if (value === undefined) {
return undefined;
}
if (value === null) {
return null;
}
return {

};
}

171 changes: 171 additions & 0 deletions package/src/models/VisaWithDocument.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
/* tslint:disable */
/* eslint-disable */
/**
* BIMData API
* BIMData API is a tool to interact with your models stored on BIMData’s servers. Through the API, you can manage your projects, the clouds, upload your IFC files and manage them through endpoints.
*
* The version of the OpenAPI document: v1 (v1)
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/

import { exists, mapValues } from '../runtime';
import {
LightDocument,
LightDocumentFromJSON,
LightDocumentFromJSONTyped,
LightDocumentToJSON,
} from './LightDocument';
import {
UserProject,
UserProjectFromJSON,
UserProjectFromJSONTyped,
UserProjectToJSON,
} from './UserProject';
import {
VisaComment,
VisaCommentFromJSON,
VisaCommentFromJSONTyped,
VisaCommentToJSON,
} from './VisaComment';
import {
VisaValidation,
VisaValidationFromJSON,
VisaValidationFromJSONTyped,
VisaValidationToJSON,
} from './VisaValidation';

/**
*
* @export
* @interface VisaWithDocument
*/
export interface VisaWithDocument {
/**
*
* @type {number}
* @memberof VisaWithDocument
*/
readonly id: number;
/**
*
* @type {Array<VisaValidation>}
* @memberof VisaWithDocument
*/
readonly validations: Array<VisaValidation>;
/**
* Validation IDs where one or more validators have no longer access to the visa document.
* @type {Array<number>}
* @memberof VisaWithDocument
*/
readonly validations_in_error: Array<number>;
/**
*
* @type {UserProject}
* @memberof VisaWithDocument
*/
readonly creator: UserProject | null;
/**
*
* @type {number}
* @memberof VisaWithDocument
*/
readonly document_id: number;
/**
* * `O` - opened
* * `P` - paused
* * `C` - closed
* @type {string}
* @memberof VisaWithDocument
*/
readonly status: VisaWithDocumentStatusEnum;
/**
* Description of the visa
* @type {string}
* @memberof VisaWithDocument
*/
description?: string | null;
/**
*
* @type {Array<VisaComment>}
* @memberof VisaWithDocument
*/
readonly comments: Array<VisaComment>;
/**
*
* @type {Date}
* @memberof VisaWithDocument
*/
deadline?: Date | null;
/**
*
* @type {Date}
* @memberof VisaWithDocument
*/
readonly created_at: Date;
/**
*
* @type {Date}
* @memberof VisaWithDocument
*/
readonly updated_at: Date;
/**
*
* @type {LightDocument}
* @memberof VisaWithDocument
*/
readonly document: LightDocument | null;
}

/**
* @export
* @enum {string}
*/
export enum VisaWithDocumentStatusEnum {
O = 'O',
P = 'P',
C = 'C'
}

export function VisaWithDocumentFromJSON(json: any): VisaWithDocument {
return VisaWithDocumentFromJSONTyped(json, false);
}

export function VisaWithDocumentFromJSONTyped(json: any, ignoreDiscriminator: boolean): VisaWithDocument {
if ((json === undefined) || (json === null)) {
return json;
}
return {

'id': json['id'],
'validations': ((json['validations'] as Array<any>).map(VisaValidationFromJSON)),
'validations_in_error': json['validations_in_error'],
'creator': UserProjectFromJSON(json['creator']),
'document_id': json['document_id'],
'status': json['status'],
'description': !exists(json, 'description') ? undefined : json['description'],
'comments': ((json['comments'] as Array<any>).map(VisaCommentFromJSON)),
'deadline': !exists(json, 'deadline') ? undefined : (json['deadline'] === null ? null : new Date(json['deadline'])),
'created_at': (new Date(json['created_at'])),
'updated_at': (new Date(json['updated_at'])),
'document': LightDocumentFromJSON(json['document']),
};
}

export function VisaWithDocumentToJSON(value?: VisaWithDocument | null): any {
if (value === undefined) {
return undefined;
}
if (value === null) {
return null;
}
return {

'description': value.description,
'deadline': value.deadline === undefined ? undefined : (value.deadline === null ? null : value.deadline.toISOString().substr(0,10)),
};
}

Loading

0 comments on commit 54c8f6d

Please sign in to comment.