Skip to content

Commit

Permalink
fix: front end build issue
Browse files Browse the repository at this point in the history
  • Loading branch information
jcdcdev committed Oct 23, 2024
1 parent 2653b06 commit ab8b22d
Show file tree
Hide file tree
Showing 13 changed files with 116 additions and 158 deletions.
6 changes: 3 additions & 3 deletions src/TestSite/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@
},
"jcdcdev.Umbraco.Core": {
"type": "Transitive",
"resolved": "15.0.0-alpha0003",
"contentHash": "IwGyIPb9dvDkHeyw9NBJdZuU4Q1Ef7A4AILiSiitJh/KTb74jtKieulP4oJ0qRKBcB2ZL3BXl/pNUeEfNIJIzg==",
"resolved": "15.0.0-alpha0005",
"contentHash": "ylSeZfMtd0bTzD3tJoOhV8HZVnqdNCFf4mR+PNvz1L0v1rpc2L+MT2hKEk5mqxrZpr+KszOmnkLIgYfk05ni9Q==",
"dependencies": {
"Umbraco.Cms.Web.Common": "15.0.0-rc2"
}
Expand Down Expand Up @@ -2942,7 +2942,7 @@
"Umbraco.Cms.Api.Common": "[15.0.0-rc2, )",
"Umbraco.Cms.Api.Management": "[15.0.0-rc2, )",
"Umbraco.Cms.Core": "[15.0.0-rc2, )",
"jcdcdev.Umbraco.Core": "[15.0.0-alpha0003, )"
"jcdcdev.Umbraco.Core": "[15.0.0-alpha0005, )"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineConfig } from '@hey-api/openapi-ts';
import {defineConfig} from '@hey-api/openapi-ts';

export default defineConfig({
input:
Expand All @@ -7,6 +7,7 @@ export default defineConfig({
format: 'prettier',
path: './src/api',
},
client: "legacy/fetch",
types: {
enums: 'typescript',
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
export type ApiRequestOptions = {
readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH';
readonly url: string;
readonly path?: Record<string, unknown>;
export type ApiRequestOptions<T = unknown> = {
readonly body?: any;
readonly cookies?: Record<string, unknown>;
readonly errors?: Record<number | string, string>;
readonly formData?: Record<string, unknown> | any[] | Blob | File;
readonly headers?: Record<string, unknown>;
readonly query?: Record<string, unknown>;
readonly formData?: Record<string, unknown>;
readonly body?: any;
readonly mediaType?: string;
readonly method:
| 'DELETE'
| 'GET'
| 'HEAD'
| 'OPTIONS'
| 'PATCH'
| 'POST'
| 'PUT';
readonly path?: Record<string, unknown>;
readonly query?: Record<string, unknown>;
readonly responseHeader?: string;
readonly errors?: Record<number | string, string>;
readonly responseTransformer?: (data: unknown) => Promise<T>;
readonly url: string;
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { ApiRequestOptions } from './ApiRequestOptions';

type Headers = Record<string, string>;
type Middleware<T> = (value: T) => T | Promise<T>;
type Resolver<T> = (options: ApiRequestOptions) => Promise<T>;
type Resolver<T> = (options: ApiRequestOptions<T>) => Promise<T>;

export class Interceptors<T> {
_fns: Middleware<T>[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,20 +101,24 @@ export const getFormData = (options: ApiRequestOptions): FormData | undefined =>
return undefined;
};

type Resolver<T> = (options: ApiRequestOptions) => Promise<T>;
type Resolver<T> = (options: ApiRequestOptions<T>) => Promise<T>;

export const resolve = async <T>(options: ApiRequestOptions, resolver?: T | Resolver<T>): Promise<T | undefined> => {
export const resolve = async <T>(options: ApiRequestOptions<T>, resolver?: T | Resolver<T>): Promise<T | undefined> => {
if (typeof resolver === 'function') {
return (resolver as Resolver<T>)(options);
}
return resolver;
};

export const getHeaders = async (config: OpenAPIConfig, options: ApiRequestOptions): Promise<Headers> => {
export const getHeaders = async <T>(config: OpenAPIConfig, options: ApiRequestOptions<T>): Promise<Headers> => {
const [token, username, password, additionalHeaders] = await Promise.all([
// @ts-ignore
resolve(options, config.TOKEN),
// @ts-ignore
resolve(options, config.USERNAME),
// @ts-ignore
resolve(options, config.PASSWORD),
// @ts-ignore
resolve(options, config.HEADERS),
]);

Expand Down Expand Up @@ -304,7 +308,7 @@ export const catchErrorCodes = (options: ApiRequestOptions, result: ApiResult):
* @returns CancelablePromise<T>
* @throws ApiError
*/
export const request = <T>(config: OpenAPIConfig, options: ApiRequestOptions): CancelablePromise<T> => {
export const request = <T>(config: OpenAPIConfig, options: ApiRequestOptions<T>): CancelablePromise<T> => {
return new CancelablePromise(async (resolve, reject, onCancel) => {
try {
const url = getUrl(config, options);
Expand All @@ -322,12 +326,17 @@ export const request = <T>(config: OpenAPIConfig, options: ApiRequestOptions): C
const responseBody = await getResponseBody(response);
const responseHeader = getResponseHeader(response, options.responseHeader);

let transformedBody = responseBody;
if (options.responseTransformer && response.ok) {
transformedBody = await options.responseTransformer(responseBody)
}

const result: ApiResult = {
url,
ok: response.ok,
status: response.status,
statusText: response.statusText,
body: responseHeader ?? responseBody,
body: responseHeader ?? transformedBody,
};

catchErrorCodes(options, result);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is auto-generated by @hey-api/openapi-ts

export const $CreateRequestModel = {
export const CreateRequestModelSchema = {
required: ['childId', 'parentId', 'relationType'],
type: 'object',
properties: {
Expand All @@ -24,12 +24,12 @@ export const $CreateRequestModel = {
additionalProperties: false
} as const;

export const $EventMessageTypeModel = {
export const EventMessageTypeModelSchema = {
enum: ['Default', 'Info', 'Error', 'Success', 'Warning'],
type: 'string'
} as const;

export const $NotificationHeaderModel = {
export const NotificationHeaderModelSchema = {
required: ['category', 'message', 'type'],
type: 'object',
properties: {
Expand All @@ -46,7 +46,7 @@ export const $NotificationHeaderModel = {
additionalProperties: false
} as const;

export const $PagedRelationTypeTreeItemResponseModel = {
export const PagedRelationTypeTreeItemResponseModelSchema = {
required: ['items', 'total'],
type: 'object',
properties: {
Expand All @@ -68,7 +68,7 @@ export const $PagedRelationTypeTreeItemResponseModel = {
additionalProperties: false
} as const;

export const $PaginationModel_1 = {
export const PaginationModel_1Schema = {
required: ['currentPage', 'items', 'itemsPerPage', 'totalItems', 'totalPages'],
type: 'object',
properties: {
Expand Down Expand Up @@ -102,7 +102,7 @@ export const $PaginationModel_1 = {
additionalProperties: false
} as const;

export const $ReferenceByIdModel = {
export const ReferenceByIdModelSchema = {
required: ['id'],
type: 'object',
properties: {
Expand All @@ -114,7 +114,7 @@ export const $ReferenceByIdModel = {
additionalProperties: false
} as const;

export const $RelationModel = {
export const RelationModelSchema = {
required: ['childId', 'createDate', 'id', 'parentId', 'relationType'],
type: 'object',
properties: {
Expand Down Expand Up @@ -170,7 +170,7 @@ export const $RelationModel = {
additionalProperties: false
} as const;

export const $RelationTypeModel = {
export const RelationTypeModelSchema = {
required: ['id', 'relations'],
type: 'object',
properties: {
Expand Down Expand Up @@ -205,7 +205,7 @@ export const $RelationTypeModel = {
additionalProperties: false
} as const;

export const $RelationTypeTreeItemResponseModel = {
export const RelationTypeTreeItemResponseModelSchema = {
required: ['hasChildren', 'id'],
type: 'object',
properties: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export const getUmbracoRelationsmanagerApiV1RelationById = (data: GetUmbracoRela
* @param data The data for the request.
* @param data.id
* @returns string OK
* @returns string No Content
* @throws ApiError
*/
export const deleteUmbracoRelationsmanagerApiV1RelationById = (data: DeleteUmbracoRelationsmanagerApiV1RelationByIdData): CancelablePromise<DeleteUmbracoRelationsmanagerApiV1RelationByIdResponse> => { return __request(OpenAPI, {
Expand Down
110 changes: 23 additions & 87 deletions src/jcdcdev.Umbraco.RelationsManager.Client/src/api/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export type CreateRequestModel = {
parentId: string;
childId: string;
relationType: string;
comment?: string | null;
comment?: (string) | null;
};

export enum EventMessageTypeModel {
Expand Down Expand Up @@ -41,55 +41,55 @@ export type ReferenceByIdModel = {
export type RelationModel = {
parentId: number;
childId: number;
comment?: string | null;
comment?: (string) | null;
id: number;
createDate: string;
relationType: number;
childName?: string | null;
parentName?: string | null;
childUrl?: string | null;
parentUrl?: string | null;
childEntityType?: string | null;
parentEntityType?: string | null;
childName?: (string) | null;
parentName?: (string) | null;
childUrl?: (string) | null;
parentUrl?: (string) | null;
childEntityType?: (string) | null;
parentEntityType?: (string) | null;
};

export type RelationTypeModel = {
id: number;
name?: string | undefined;
alias?: string | undefined;
parentEntityType?: string | undefined;
childEntityType?: string | undefined;
relations: PaginationModel_1;
name?: (string) | null;
alias?: (string) | null;
parentEntityType?: (string) | null;
childEntityType?: (string) | null;
relations: (PaginationModel_1);
};

export type RelationTypeTreeItemResponseModel = {
name?: string | null;
name?: (string) | null;
id: string;
childObjectType?: string | null;
parentObjectType?: string | null;
childObjectType?: (string) | null;
parentObjectType?: (string) | null;
hasChildren: boolean;
parent?: ReferenceByIdModel | null;
parent?: ((ReferenceByIdModel) | null);
};

export type GetUmbracoRelationsmanagerApiV1TreeItemNullData = {
skip?: number;
take?: number;
};

export type GetUmbracoRelationsmanagerApiV1TreeItemNullResponse = PagedRelationTypeTreeItemResponseModel;
export type GetUmbracoRelationsmanagerApiV1TreeItemNullResponse = ((PagedRelationTypeTreeItemResponseModel));

export type GetUmbracoRelationsmanagerApiV1TreeRootData = {
skip?: number;
take?: number;
};

export type GetUmbracoRelationsmanagerApiV1TreeRootResponse = PagedRelationTypeTreeItemResponseModel;
export type GetUmbracoRelationsmanagerApiV1TreeRootResponse = ((PagedRelationTypeTreeItemResponseModel));

export type PostUmbracoRelationsmanagerApiV1RelationData = {
requestBody?: CreateRequestModel;
requestBody?: (CreateRequestModel);
};

export type PostUmbracoRelationsmanagerApiV1RelationResponse = number | string;
export type PostUmbracoRelationsmanagerApiV1RelationResponse = (number | string);

export type GetUmbracoRelationsmanagerApiV1RelationByIdData = {
desc?: boolean;
Expand All @@ -99,74 +99,10 @@ export type GetUmbracoRelationsmanagerApiV1RelationByIdData = {
take?: number;
};

export type GetUmbracoRelationsmanagerApiV1RelationByIdResponse = RelationTypeModel;
export type GetUmbracoRelationsmanagerApiV1RelationByIdResponse = ((RelationTypeModel));

export type DeleteUmbracoRelationsmanagerApiV1RelationByIdData = {
id: number;
};

export type DeleteUmbracoRelationsmanagerApiV1RelationByIdResponse = string;

export type $OpenApiTs = {
'/umbraco/relationsmanager/api/v1/tree/item/null': {
get: {
req: GetUmbracoRelationsmanagerApiV1TreeItemNullData;
res: {
/**
* OK
*/
200: PagedRelationTypeTreeItemResponseModel;
};
};
};
'/umbraco/relationsmanager/api/v1/tree/root': {
get: {
req: GetUmbracoRelationsmanagerApiV1TreeRootData;
res: {
/**
* OK
*/
200: PagedRelationTypeTreeItemResponseModel;
};
};
};
'/umbraco/relationsmanager/api/v1/relation': {
post: {
req: PostUmbracoRelationsmanagerApiV1RelationData;
res: {
/**
* OK
*/
200: number;
/**
* Created
*/
201: string;
/**
* Bad Request
*/
400: string;
};
};
};
'/umbraco/relationsmanager/api/v1/relation/{id}': {
get: {
req: GetUmbracoRelationsmanagerApiV1RelationByIdData;
res: {
/**
* OK
*/
200: RelationTypeModel;
};
};
delete: {
req: DeleteUmbracoRelationsmanagerApiV1RelationByIdData;
res: {
/**
* OK
*/
200: string;
};
};
};
};
export type DeleteUmbracoRelationsmanagerApiV1RelationByIdResponse = (string);
Loading

0 comments on commit ab8b22d

Please sign in to comment.