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 1ecdef2 commit 06610ec
Show file tree
Hide file tree
Showing 11 changed files with 83 additions and 72 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 @@ -2943,7 +2943,7 @@
"Umbraco.Cms.Api.Management": "[15.0.0-rc2, )",
"Umbraco.Cms.Core": "[15.0.0-rc2, )",
"Umbraco.Cms.Web.Website": "[15.0.0-rc2, )",
"jcdcdev.Umbraco.Core": "[15.0.0-alpha0003, )"
"jcdcdev.Umbraco.Core": "[15.0.0-alpha0005, )"
}
}
}
Expand Down
21 changes: 11 additions & 10 deletions src/Umbraco.Community.SimpleDashboards.Client/openapi-ts.config.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { defineConfig } from '@hey-api/openapi-ts';
import {defineConfig} from '@hey-api/openapi-ts';

export default defineConfig({
input:
'http://localhost:54813/umbraco/swagger/SimpleDashboards/swagger.json',
output: {
format: 'prettier',
path: './src/api',
},
types: {
enums: 'typescript',
},
input:
'http://localhost:54813/umbraco/swagger/SimpleDashboards/swagger.json',
output: {
format: 'prettier',
path: './src/api',
},
client: "legacy/fetch",
types: {
enums: 'typescript',
},
});
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 $SimpleDashboardRenderModel = {
export const SimpleDashboardRenderModelSchema = {
required: ['body'],
type: 'object',
properties: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,4 @@ export type GetUmbracoSimpledashboardsApiV1RenderByDashboardData = {
dashboard: string;
};

export type GetUmbracoSimpledashboardsApiV1RenderByDashboardResponse = SimpleDashboardRenderModel;

export type $OpenApiTs = {
'/umbraco/simpledashboards/api/v1/render/{dashboard}': {
get: {
req: GetUmbracoSimpledashboardsApiV1RenderByDashboardData;
res: {
/**
* OK
*/
200: SimpleDashboardRenderModel;
};
};
};
};
export type GetUmbracoSimpledashboardsApiV1RenderByDashboardResponse = ((SimpleDashboardRenderModel));
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import {ManifestLocalization} from "@umbraco-cms/backoffice/extension-registry";

export const ManifestLocalizations: Array<ManifestLocalization> = [
export const ManifestLocalizations: Array<UmbExtensionManifest> = [
{
type: 'localization',
alias: 'simple-dashboards.lang.enus',
Expand Down
53 changes: 31 additions & 22 deletions src/Umbraco.Community.SimpleDashboards.Client/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
{
"compilerOptions": {
"target": "ES2020",
"experimentalDecorators": true,
"useDefineForClassFields": false,
"module": "ESNext",
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"skipLibCheck": true,

/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,

/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src"]
"compilerOptions": {
"types": [
"@umbraco-cms/backoffice/extension-registry",
"@umbraco-cms/backoffice/icon",
"@umbraco-cms/backoffice/localization"
],
"target": "ES2020",
"experimentalDecorators": true,
"useDefineForClassFields": false,
"module": "ESNext",
"lib": [
"ES2020",
"DOM",
"DOM.Iterable"
],
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": [
"src"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<PackageReference Include="Umbraco.Cms.Api.Management" Version="15.0.0-rc2" />
<PackageReference Include="Umbraco.Cms.Core" Version="15.0.0-rc2" />
<PackageReference Include="Umbraco.Cms.Web.Website" Version="15.0.0-rc2" />
<PackageReference Include="jcdcdev.Umbraco.Core" Version="15.0.0-alpha0003" />
<PackageReference Include="jcdcdev.Umbraco.Core" Version="15.0.0-alpha0005" />
</ItemGroup>

<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
Expand Down
6 changes: 3 additions & 3 deletions src/Umbraco.Community.SimpleDashboards/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"net9.0": {
"jcdcdev.Umbraco.Core": {
"type": "Direct",
"requested": "[15.0.0-alpha0003, )",
"resolved": "15.0.0-alpha0003",
"contentHash": "IwGyIPb9dvDkHeyw9NBJdZuU4Q1Ef7A4AILiSiitJh/KTb74jtKieulP4oJ0qRKBcB2ZL3BXl/pNUeEfNIJIzg==",
"requested": "[15.0.0-alpha0005, )",
"resolved": "15.0.0-alpha0005",
"contentHash": "ylSeZfMtd0bTzD3tJoOhV8HZVnqdNCFf4mR+PNvz1L0v1rpc2L+MT2hKEk5mqxrZpr+KszOmnkLIgYfk05ni9Q==",
"dependencies": {
"Umbraco.Cms.Web.Common": "15.0.0-rc2"
}
Expand Down

0 comments on commit 06610ec

Please sign in to comment.