fix schemas

This commit is contained in:
yusing 2025-01-25 12:50:16 +08:00
parent 322878b0b7
commit 9b66772a12
14 changed files with 79 additions and 40 deletions

View file

@ -100,6 +100,7 @@ gen-schema-single:
python3 -c "import json; f=open('schemas/${OUT}', 'r'); j=json.load(f); f.close(); f=open('schemas/${OUT}', 'w'); json.dump(j, f, separators=(',', ':'));"
gen-schema:
bun --bun tsc
make IN=config/config.ts \
CLASS=Config \
OUT=config.schema.json \

View file

@ -1,6 +1,6 @@
{
"name": "godoxy-schemas",
"version": "0.9.0-13",
"version": "0.9.0-20",
"description": "JSON Schema and typescript types for GoDoxy configuration",
"license": "MIT",
"repository": {

File diff suppressed because one or more lines are too long

View file

@ -5,7 +5,7 @@ export type EntrypointConfig = {
*
* @examples require(".").middlewaresExamples
*/
middlewares: MiddlewareCompose;
middlewares?: MiddlewareCompose;
/** Entrypoint access log configuration
*
* @examples require(".").accessLogExamples

View file

@ -6,7 +6,7 @@ export type EntrypointConfig = {
*
* @examples require(".").middlewaresExamples
*/
middlewares: MiddlewareCompose;
middlewares?: MiddlewareCompose;
/** Entrypoint access log configuration
*
* @examples require(".").accessLogExamples

File diff suppressed because one or more lines are too long

View file

@ -1,15 +1,18 @@
import * as types from "../types";
export type MiddlewareComposeObjectRef = `${string}@file`;
export type KeyOptMapping<T extends {
use: string;
}> = {
[key in T["use"]]: Omit<T, "use">;
} | {
use: MiddlewareComposeObjectRef;
[key in T["use"]]?: Omit<T, "use">;
};
export type MiddlewaresMap = KeyOptMapping<CustomErrorPage> | KeyOptMapping<RedirectHTTP> | KeyOptMapping<SetXForwarded> | KeyOptMapping<HideXForwarded> | KeyOptMapping<CIDRWhitelist> | KeyOptMapping<CloudflareRealIP> | KeyOptMapping<ModifyRequest> | KeyOptMapping<ModifyResponse> | KeyOptMapping<OIDC> | KeyOptMapping<RateLimit> | KeyOptMapping<RealIP> | {
[key in MiddlewareComposeObjectRef]: types.NullOrEmptyMap;
export declare const ALL_MIDDLEWARES: readonly ["ErrorPage", "RedirectHTTP", "SetXForwarded", "HideXForwarded", "CIDRWhitelist", "CloudflareRealIP", "ModifyRequest", "ModifyResponse", "OIDC", "RateLimit", "RealIP"];
/**
* @type object
* @patternProperties {"^.*@file$": {"type": "null"}}
*/
export type MiddlewareFileRef = {
[key: `${string}@file`]: null;
};
export type MiddlewaresMap = (KeyOptMapping<CustomErrorPage> & KeyOptMapping<RedirectHTTP> & KeyOptMapping<SetXForwarded> & KeyOptMapping<HideXForwarded> & KeyOptMapping<CIDRWhitelist> & KeyOptMapping<CloudflareRealIP> & KeyOptMapping<ModifyRequest> & KeyOptMapping<ModifyResponse> & KeyOptMapping<OIDC> & KeyOptMapping<RateLimit> & KeyOptMapping<RealIP>) | MiddlewareFileRef;
export type MiddlewareComposeMap = CustomErrorPage | RedirectHTTP | SetXForwarded | HideXForwarded | CIDRWhitelist | CloudflareRealIP | ModifyRequest | ModifyResponse | OIDC | RateLimit | RealIP;
export type CustomErrorPage = {
use: "error_page" | "errorPage" | "ErrorPage" | "custom_error_page" | "customErrorPage" | "CustomErrorPage";

View file

@ -1 +1,13 @@
export {};
export const ALL_MIDDLEWARES = [
"ErrorPage",
"RedirectHTTP",
"SetXForwarded",
"HideXForwarded",
"CIDRWhitelist",
"CloudflareRealIP",
"ModifyRequest",
"ModifyResponse",
"OIDC",
"RateLimit",
"RealIP",
];

View file

@ -1,26 +1,44 @@
import * as types from "../types";
export type MiddlewareComposeObjectRef = `${string}@file`;
export type KeyOptMapping<T extends { use: string }> = {
[key in T["use"]]?: Omit<T, "use">;
};
export type KeyOptMapping<T extends { use: string }> =
| {
[key in T["use"]]: Omit<T, "use">;
}
| { use: MiddlewareComposeObjectRef };
export const ALL_MIDDLEWARES = [
"ErrorPage",
"RedirectHTTP",
"SetXForwarded",
"HideXForwarded",
"CIDRWhitelist",
"CloudflareRealIP",
"ModifyRequest",
"ModifyResponse",
"OIDC",
"RateLimit",
"RealIP",
] as const;
/**
* @type object
* @patternProperties {"^.*@file$": {"type": "null"}}
*/
export type MiddlewareFileRef = {
[key: `${string}@file`]: null;
};
export type MiddlewaresMap =
| KeyOptMapping<CustomErrorPage>
| KeyOptMapping<RedirectHTTP>
| KeyOptMapping<SetXForwarded>
| KeyOptMapping<HideXForwarded>
| KeyOptMapping<CIDRWhitelist>
| KeyOptMapping<CloudflareRealIP>
| KeyOptMapping<ModifyRequest>
| KeyOptMapping<ModifyResponse>
| KeyOptMapping<OIDC>
| KeyOptMapping<RateLimit>
| KeyOptMapping<RealIP>
| { [key in MiddlewareComposeObjectRef]: types.NullOrEmptyMap };
| (KeyOptMapping<CustomErrorPage> &
KeyOptMapping<RedirectHTTP> &
KeyOptMapping<SetXForwarded> &
KeyOptMapping<HideXForwarded> &
KeyOptMapping<CIDRWhitelist> &
KeyOptMapping<CloudflareRealIP> &
KeyOptMapping<ModifyRequest> &
KeyOptMapping<ModifyResponse> &
KeyOptMapping<OIDC> &
KeyOptMapping<RateLimit> &
KeyOptMapping<RealIP>)
| MiddlewareFileRef;
export type MiddlewareComposeMap =
| CustomErrorPage

View file

@ -17,6 +17,11 @@ export type HomepageConfig = {
[key: string]: any;
};
};
export type WalkxcodeIcon = `${"png" | "svg" | "webp"}/${string}/${string}.${string}`;
/** Walkxcode icon
*
* @pattern ^(png|svg|webp)\/[\w\d\-_]+\.\1
* @type string
*/
export type WalkxcodeIcon = string & {};
export type ExternalIcon = `@${"selfhst" | "walkxcode"}/${string}.${string}`;
export type TargetRelativeIconPath = `@target/${string}` | `/${string}`;

View file

@ -25,11 +25,12 @@ export type HomepageConfig = {
};
};
/* Walkxcode icon */
export type WalkxcodeIcon = `${
| "png"
| "svg"
| "webp"}/${string}/${string}.${string}`;
/** Walkxcode icon
*
* @pattern ^(png|svg|webp)\/[\w\d\-_]+\.\1
* @type string
*/
export type WalkxcodeIcon = string & {};
/* Walkxcode / selfh.st icon */
export type ExternalIcon = `@${"selfhst" | "walkxcode"}/${string}.${string}`;

File diff suppressed because one or more lines are too long

3
schemas/types.d.ts vendored
View file

@ -1,8 +1,7 @@
/**
* @type "null"
*/
export interface Null {
}
export type Null = null;
export type Nullable<T> = T | Null;
export type NullOrEmptyMap = {} | Null;
export declare const HTTP_METHODS: readonly ["GET", "POST", "PUT", "PATCH", "DELETE", "CONNECT", "HEAD", "OPTIONS", "TRACE"];

View file

@ -1,7 +1,7 @@
/**
* @type "null"
*/
export interface Null {}
export type Null = null;
export type Nullable<T> = T | Null;
export type NullOrEmptyMap = {} | Null;