387a1c26e3
清理已跟踪原始日志与个人本地配置 修复前后端有效门禁、测试和构建问题 补齐生产 Jenkins、SpacetimeDB 本地命令与文档约束 收紧图片编辑器状态、附件与媒体引用测试 排除已下线旧创作入口测试并清理 warning
77 lines
1.9 KiB
TypeScript
77 lines
1.9 KiB
TypeScript
import {
|
|
type ApiAuthImpact,
|
|
type ApiRetryOptions,
|
|
BACKGROUND_AUTH_REQUEST_OPTIONS,
|
|
requestJson,
|
|
} from '../apiClient';
|
|
|
|
const RUNTIME_API_BASE = '/api/runtime';
|
|
const RUNTIME_READ_RETRY: ApiRetryOptions = {
|
|
maxRetries: 1,
|
|
baseDelayMs: 180,
|
|
maxDelayMs: 480,
|
|
};
|
|
const RUNTIME_WRITE_RETRY: ApiRetryOptions = {
|
|
maxRetries: 1,
|
|
baseDelayMs: 240,
|
|
maxDelayMs: 640,
|
|
retryUnsafeMethods: true,
|
|
};
|
|
|
|
export type RpgCreationRuntimeRequestOptions = {
|
|
signal?: AbortSignal;
|
|
retry?: ApiRetryOptions;
|
|
skipAuth?: boolean;
|
|
skipRefresh?: boolean;
|
|
authImpact?: ApiAuthImpact;
|
|
notifyAuthStateChange?: boolean;
|
|
clearAuthOnUnauthorized?: boolean;
|
|
timeoutMs?: number;
|
|
};
|
|
|
|
export const RPG_CREATION_BACKGROUND_AUTH_OPTIONS =
|
|
BACKGROUND_AUTH_REQUEST_OPTIONS satisfies RpgCreationRuntimeRequestOptions;
|
|
|
|
export function requestRpgCreationRuntimeJson<T>(
|
|
path: string,
|
|
init: RequestInit,
|
|
fallbackMessage: string,
|
|
options: RpgCreationRuntimeRequestOptions = {},
|
|
) {
|
|
const method = (init.method ?? 'GET').toUpperCase();
|
|
const retry =
|
|
options.retry ??
|
|
(method === 'GET' ? RUNTIME_READ_RETRY : RUNTIME_WRITE_RETRY);
|
|
|
|
return requestJson<T>(
|
|
`${RUNTIME_API_BASE}${path}`,
|
|
{
|
|
...init,
|
|
signal: options.signal,
|
|
},
|
|
fallbackMessage,
|
|
{
|
|
retry,
|
|
skipAuth: options.skipAuth,
|
|
skipRefresh: options.skipRefresh,
|
|
authImpact: options.authImpact,
|
|
notifyAuthStateChange: options.notifyAuthStateChange,
|
|
clearAuthOnUnauthorized: options.clearAuthOnUnauthorized,
|
|
timeoutMs: options.timeoutMs,
|
|
},
|
|
);
|
|
}
|
|
|
|
export function requestPublicRpgCreationRuntimeJson<T>(
|
|
path: string,
|
|
init: RequestInit,
|
|
fallbackMessage: string,
|
|
options: RpgCreationRuntimeRequestOptions = {},
|
|
) {
|
|
return requestRpgCreationRuntimeJson<T>(path, init, fallbackMessage, {
|
|
...options,
|
|
skipAuth: true,
|
|
skipRefresh: true,
|
|
});
|
|
}
|