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 0af4723 commit 7dd7744
Show file tree
Hide file tree
Showing 16 changed files with 86 additions and 67 deletions.
1 change: 1 addition & 0 deletions src/TestSite/Composer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Umbraco.Cms.Core.Composing;
using Umbraco.Cms.Core.DependencyInjection;
using Umbraco.Community.BackOfficeOrganiser.Composing;

namespace TestSite;
Expand Down
1 change: 1 addition & 0 deletions src/TestSite/ExampleDataTypeOrganiseAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Services;
using Umbraco.Community.BackOfficeOrganiser.Organisers.DataTypes;
using Umbraco.Extensions;

namespace TestSite;

Expand Down
3 changes: 3 additions & 0 deletions src/TestSite/Program.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
using Umbraco.Cms.Core.DependencyInjection;
using Umbraco.Extensions;

var builder = WebApplication.CreateBuilder(args);

builder.CreateUmbracoBuilder()
Expand Down
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 @@ -2941,7 +2941,7 @@
"dependencies": {
"Umbraco.Cms.Core": "[15.0.0-rc2, )",
"Umbraco.Cms.Infrastructure": "[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,11 +1,11 @@
// This file is auto-generated by @hey-api/openapi-ts

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 @@ -22,7 +22,7 @@ export const $NotificationHeaderModel = {
additionalProperties: false
} as const;

export const $OrganiseRequest = {
export const OrganiseRequestSchema = {
required: ['contentTypes', 'dataTypes', 'mediaTypes', 'memberTypes'],
type: 'object',
properties: {
Expand All @@ -42,7 +42,7 @@ export const $OrganiseRequest = {
additionalProperties: false
} as const;

export const $OrganiseResponse = {
export const OrganiseResponseSchema = {
required: ['error', 'message'],
type: 'object',
properties: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type { PostUmbracoBackofficeorganiserApiOrganiseData, PostUmbracoBackoffi
/**
* @param data The data for the request.
* @param data.requestBody
* @returns unknown Success
* @returns unknown OK
* @throws ApiError
*/
export const postUmbracoBackofficeorganiserApiOrganise = (data: PostUmbracoBackofficeorganiserApiOrganiseData = {}): CancelablePromise<PostUmbracoBackofficeorganiserApiOrganiseResponse> => { return __request(OpenAPI, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,7 @@ export type OrganiseResponse = {
};

export type PostUmbracoBackofficeorganiserApiOrganiseData = {
requestBody?: OrganiseRequest;
requestBody?: (OrganiseRequest);
};

export type PostUmbracoBackofficeorganiserApiOrganiseResponse = OrganiseResponse;

export type $OpenApiTs = {
'/umbraco/backofficeorganiser/api/organise': {
post: {
req: PostUmbracoBackofficeorganiserApiOrganiseData;
res: {
/**
* Success
*/
200: OrganiseResponse;
};
};
};
};
export type PostUmbracoBackofficeorganiserApiOrganiseResponse = ((OrganiseResponse));
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ManifestDashboard } from "@umbraco-cms/backoffice/extension-registry";
import {ManifestDashboard} from "@umbraco-cms/backoffice/dashboard";

const dashboards: Array<ManifestDashboard> = [
{
Expand All @@ -15,6 +15,7 @@ const dashboards: Array<ManifestDashboard> = [
conditions: [
{
alias: 'Umb.Condition.SectionAlias',
// @ts-ignore
match: 'Umb.Section.Settings'
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export default class BackofficeOrganiser extends UmbElementMixin(LitElement) {

const response = await this.#backofficeOrganiserContext?.organise(request);
const data = response?.data;
const success = !data?.error ?? false;
const success = !data?.error;
const heading = success ? "Success" : "Error";
const color = success ? "positive" : "danger";
this.#notificationContext?.peek(color, {
Expand Down
53 changes: 31 additions & 22 deletions src/Umbraco.Community.BackOfficeOrganiser.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 @@ -23,9 +23,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="jcdcdev.Umbraco.Core" Version="15.0.0-alpha0003" />
<PackageReference Include="Umbraco.Cms.Core" Version="15.0.0-rc2" />
<PackageReference Include="Umbraco.Cms.Infrastructure" Version="15.0.0-rc2" />
<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.BackOfficeOrganiser/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 7dd7744

Please sign in to comment.