mirror of
https://github.com/outline/outline.git
synced 2026-11-23 06:11:04 +03:00
* refactor: Decouple ApiClient from auth store and document its public surface Move logout policy out of the transport layer: ApiClient now notifies a registered handler on unauthenticated responses (401 / suspended 403) instead of calling stores.auth.logout directly, breaking the AuthStore -> client -> stores import cycle. AuthStore owns the logout flags and registers the handler. Also add JSDoc across the public surface (setShareId, fetch, get, post, client). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * refactor: Extend request deduplication to PUT via shared helper Extract the in-flight dedup logic into a private deduplicate() helper and route both post() and the new put() through it. The dedup key now includes the HTTP method so a POST and PUT to the same path can't collide. Multipart uploads continue to bypass deduplication. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * Improve types * refactor: Improve ApiClient type safety and address review feedback - Add a Method union ("GET" | "POST" | "PUT") for fetch/deduplicate, replacing the loose string type. Narrowed to methods whose bodies are actually serialized, so callers aren't given false support for PATCH/DELETE. - Type previously implicit-any locals (modifiedPath, urlToFetch, isJson). - Extract an ApiErrorResponse interface for the parsed error payload. - Register the unauthorized handler before fetchAuth() so a 401 on the initial auth request triggers the logout policy. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
17 lines
270 B
TypeScript
17 lines
270 B
TypeScript
/* oxlint-disable */
|
|
import { vi } from "vitest";
|
|
|
|
export const client = {
|
|
setUnauthorizedHandler: vi.fn(),
|
|
post: vi.fn(() =>
|
|
Promise.resolve({
|
|
data: {
|
|
user: {},
|
|
team: {},
|
|
groups: [],
|
|
groupUsers: [],
|
|
},
|
|
})
|
|
),
|
|
};
|