@modrinth/api-client 0.31.0 → 0.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +7103 -28
- package/dist/index.js +1 -0
- package/dist/index.js.map +7 -0
- package/package.json +4 -2
- package/dist/core/abstract-client.d.ts +0 -163
- package/dist/core/abstract-feature.d.ts +0 -72
- package/dist/core/abstract-module.d.ts +0 -10
- package/dist/core/abstract-sync.d.ts +0 -61
- package/dist/core/abstract-upload-client.d.ts +0 -20
- package/dist/core/abstract-websocket.d.ts +0 -52
- package/dist/core/errors.d.ts +0 -48
- package/dist/features/auth.d.ts +0 -47
- package/dist/features/circuit-breaker.d.ts +0 -139
- package/dist/features/node-auth.d.ts +0 -58
- package/dist/features/panel-version.d.ts +0 -7
- package/dist/features/retry.d.ts +0 -87
- package/dist/features/verbose-logging.d.ts +0 -6
- package/dist/modules/archon/actions/v1.d.ts +0 -10
- package/dist/modules/archon/backups/v1.d.ts +0 -44
- package/dist/modules/archon/backups-queue/v1.d.ts +0 -25
- package/dist/modules/archon/content/v1.d.ts +0 -48
- package/dist/modules/archon/index.d.ts +0 -8
- package/dist/modules/archon/nodes/internal.d.ts +0 -10
- package/dist/modules/archon/notices/v0.d.ts +0 -38
- package/dist/modules/archon/options/v1.d.ts +0 -9
- package/dist/modules/archon/properties/v1.d.ts +0 -9
- package/dist/modules/archon/server-users/v1.d.ts +0 -30
- package/dist/modules/archon/servers/v0.d.ts +0 -122
- package/dist/modules/archon/servers/v1.d.ts +0 -30
- package/dist/modules/archon/transfers/internal.d.ts +0 -25
- package/dist/modules/archon/types.d.ts +0 -941
- package/dist/modules/index.d.ts +0 -181
- package/dist/modules/iso3166/index.d.ts +0 -24
- package/dist/modules/iso3166/types.d.ts +0 -21
- package/dist/modules/kyros/content/v1.d.ts +0 -23
- package/dist/modules/kyros/files/v0.d.ts +0 -123
- package/dist/modules/kyros/logs/v1.d.ts +0 -6
- package/dist/modules/kyros/types.d.ts +0 -44
- package/dist/modules/kyros/upload-sessions/v1.d.ts +0 -18
- package/dist/modules/labrinth/affiliate/internal.d.ts +0 -30
- package/dist/modules/labrinth/analytics/v3.d.ts +0 -56
- package/dist/modules/labrinth/attribution/internal.d.ts +0 -47
- package/dist/modules/labrinth/auth/internal.d.ts +0 -19
- package/dist/modules/labrinth/auth/v2.d.ts +0 -98
- package/dist/modules/labrinth/billing/internal.d.ts +0 -65
- package/dist/modules/labrinth/campaign/internal.d.ts +0 -10
- package/dist/modules/labrinth/collections.d.ts +0 -80
- package/dist/modules/labrinth/content/v3.d.ts +0 -6
- package/dist/modules/labrinth/external-projects/internal.d.ts +0 -9
- package/dist/modules/labrinth/friends/v3.d.ts +0 -23
- package/dist/modules/labrinth/globals/internal.d.ts +0 -11
- package/dist/modules/labrinth/images/v3.d.ts +0 -7
- package/dist/modules/labrinth/index.d.ts +0 -31
- package/dist/modules/labrinth/limits/v3.d.ts +0 -17
- package/dist/modules/labrinth/moderation/internal.d.ts +0 -12
- package/dist/modules/labrinth/notifications/v2.d.ts +0 -73
- package/dist/modules/labrinth/oauth/internal.d.ts +0 -97
- package/dist/modules/labrinth/organizations/v3.d.ts +0 -66
- package/dist/modules/labrinth/pats/v2.d.ts +0 -31
- package/dist/modules/labrinth/payout/v3.d.ts +0 -30
- package/dist/modules/labrinth/payouts/v3.d.ts +0 -15
- package/dist/modules/labrinth/projects/v2.d.ts +0 -169
- package/dist/modules/labrinth/projects/v3.d.ts +0 -110
- package/dist/modules/labrinth/reports/v3.d.ts +0 -81
- package/dist/modules/labrinth/server-ping/internal.d.ts +0 -10
- package/dist/modules/labrinth/sessions/v2.d.ts +0 -17
- package/dist/modules/labrinth/state/index.d.ts +0 -17
- package/dist/modules/labrinth/tags/v2.d.ts +0 -19
- package/dist/modules/labrinth/teams/v2.d.ts +0 -57
- package/dist/modules/labrinth/teams/v3.d.ts +0 -18
- package/dist/modules/labrinth/tech-review/internal.d.ts +0 -77
- package/dist/modules/labrinth/threads/v3.d.ts +0 -57
- package/dist/modules/labrinth/types.d.ts +0 -2119
- package/dist/modules/labrinth/users/v2.d.ts +0 -101
- package/dist/modules/labrinth/users/v3.d.ts +0 -37
- package/dist/modules/labrinth/versions/v2.d.ts +0 -75
- package/dist/modules/labrinth/versions/v3.d.ts +0 -123
- package/dist/modules/launcher-meta/types.d.ts +0 -25
- package/dist/modules/launcher-meta/v0.d.ts +0 -17
- package/dist/modules/mclogs/insights/v1.d.ts +0 -6
- package/dist/modules/mclogs/logs/v1.d.ts +0 -6
- package/dist/modules/mclogs/types.d.ts +0 -60
- package/dist/modules/paper/types.d.ts +0 -22
- package/dist/modules/paper/v3.d.ts +0 -19
- package/dist/modules/purpur/types.d.ts +0 -15
- package/dist/modules/purpur/v2.d.ts +0 -16
- package/dist/modules/types.d.ts +0 -8
- package/dist/platform/generic.d.ts +0 -28
- package/dist/platform/nuxt.d.ts +0 -88
- package/dist/platform/sync-generic.d.ts +0 -16
- package/dist/platform/tauri.d.ts +0 -35
- package/dist/platform/websocket-generic.d.ts +0 -16
- package/dist/platform/xhr-upload-client.d.ts +0 -15
- package/dist/state/node-auth.d.ts +0 -36
- package/dist/types/client.d.ts +0 -70
- package/dist/types/errors.d.ts +0 -43
- package/dist/types/index.d.ts +0 -10
- package/dist/types/request.d.ts +0 -124
- package/dist/types/upload.d.ts +0 -92
- package/dist/utils/fetch.d.ts +0 -4
- package/dist/utils/jwt-retry.d.ts +0 -5
- package/dist/utils/node-url.d.ts +0 -2
- package/dist/utils/pingtest.d.ts +0 -8
- package/dist/utils/sse.d.ts +0 -24
- package/dist/utils/types.d.ts +0 -2
package/dist/platform/tauri.d.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { ModrinthApiError } from '../core/errors';
|
|
2
|
-
import type { ClientConfig } from '../types/client';
|
|
3
|
-
import type { RequestOptions } from '../types/request';
|
|
4
|
-
import { XHRUploadClient } from './xhr-upload-client';
|
|
5
|
-
/**
|
|
6
|
-
* Tauri-specific configuration
|
|
7
|
-
* TODO: extend into interface if needed.
|
|
8
|
-
*/
|
|
9
|
-
export type TauriClientConfig = ClientConfig;
|
|
10
|
-
/**
|
|
11
|
-
* Tauri platform client using Tauri v2 HTTP plugin
|
|
12
|
-
*
|
|
13
|
-
* Extends XHRUploadClient to provide upload with progress tracking.
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```typescript
|
|
17
|
-
* import { getVersion } from '@tauri-apps/api/app'
|
|
18
|
-
*
|
|
19
|
-
* const client = new TauriModrinthClient({
|
|
20
|
-
* userAgent: async () => `modrinth/theseus/${await getVersion()} (support@modrinth.com)`,
|
|
21
|
-
* features: [
|
|
22
|
-
* new AuthFeature({ token: async () => getOAuthToken() })
|
|
23
|
-
* ]
|
|
24
|
-
* })
|
|
25
|
-
*
|
|
26
|
-
* const project = await client.request('/project/sodium', { api: 'labrinth', version: 2 })
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
export declare class TauriModrinthClient extends XHRUploadClient {
|
|
30
|
-
protected config: TauriClientConfig;
|
|
31
|
-
constructor(config: TauriClientConfig);
|
|
32
|
-
protected executeRequest<T>(url: string, options: RequestOptions): Promise<T>;
|
|
33
|
-
protected executeStreamRequest(url: string, options: RequestOptions): Promise<ReadableStream<Uint8Array>>;
|
|
34
|
-
protected normalizeError(error: unknown): ModrinthApiError;
|
|
35
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { AbstractWebSocketClient } from '../core/abstract-websocket';
|
|
2
|
-
import type { Archon } from '../modules/archon/types';
|
|
3
|
-
type WSEventMap = {
|
|
4
|
-
[K in Archon.Websocket.v0.WSEvent as `${string}:${K['event']}`]: K;
|
|
5
|
-
};
|
|
6
|
-
export declare class GenericWebSocketClient extends AbstractWebSocketClient {
|
|
7
|
-
protected emitter: import("mitt").Emitter<WSEventMap>;
|
|
8
|
-
connect(serverId: string, auth: Archon.Websocket.v0.WSAuth): Promise<void>;
|
|
9
|
-
disconnect(serverId: string): void;
|
|
10
|
-
private closeConnection;
|
|
11
|
-
disconnectAll(): void;
|
|
12
|
-
send(serverId: string, message: Archon.Websocket.v0.WSOutgoingMessage): void;
|
|
13
|
-
private scheduleReconnect;
|
|
14
|
-
private handleAuthExpiring;
|
|
15
|
-
}
|
|
16
|
-
export {};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { AbstractModrinthClient } from '../core/abstract-client';
|
|
2
|
-
import { ModrinthApiError } from '../core/errors';
|
|
3
|
-
import type { RequestContext } from '../types/request';
|
|
4
|
-
import type { UploadHandle, UploadProgress, UploadRequestOptions } from '../types/upload';
|
|
5
|
-
/**
|
|
6
|
-
* Abstract client with XHR-based upload implementation
|
|
7
|
-
*
|
|
8
|
-
* Platform-specific clients should extend this instead of AbstractModrinthClient
|
|
9
|
-
* to inherit the XHR upload implementation.
|
|
10
|
-
*/
|
|
11
|
-
export declare abstract class XHRUploadClient extends AbstractModrinthClient {
|
|
12
|
-
upload<T = void>(path: string, options: UploadRequestOptions): UploadHandle<T>;
|
|
13
|
-
protected executeXHRUpload<T>(context: RequestContext, progressCallbacks: Array<(p: UploadProgress) => void>, abortController: AbortController): Promise<T>;
|
|
14
|
-
protected createUploadError(xhr: XMLHttpRequest): ModrinthApiError;
|
|
15
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { NodeAuth } from '../features/node-auth';
|
|
2
|
-
/**
|
|
3
|
-
* Global node auth state.
|
|
4
|
-
* Set by server management pages, read by NodeAuthFeature.
|
|
5
|
-
*/
|
|
6
|
-
export declare const nodeAuthState: {
|
|
7
|
-
getAuth: (() => NodeAuth | null) | null;
|
|
8
|
-
refreshAuth: (() => Promise<void>) | null;
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* Configure the node auth state. Call this when entering server management.
|
|
12
|
-
*
|
|
13
|
-
* @param getAuth - Function that returns current auth or null
|
|
14
|
-
* @param refreshAuth - Function to refresh the auth token
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```typescript
|
|
18
|
-
* // In server management page setup
|
|
19
|
-
* setNodeAuthState(
|
|
20
|
-
* () => fsAuth.value,
|
|
21
|
-
* refreshFsAuth,
|
|
22
|
-
* )
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
|
-
export declare function setNodeAuthState(getAuth: () => NodeAuth | null, refreshAuth: () => Promise<void>): void;
|
|
26
|
-
/**
|
|
27
|
-
* Clear the node auth state. Call this when leaving server management.
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* ```typescript
|
|
31
|
-
* onUnmounted(() => {
|
|
32
|
-
* clearNodeAuthState()
|
|
33
|
-
* })
|
|
34
|
-
* ```
|
|
35
|
-
*/
|
|
36
|
-
export declare function clearNodeAuthState(): void;
|
package/dist/types/client.d.ts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import type { AbstractFeature } from '../core/abstract-feature';
|
|
2
|
-
import type { RequestContext } from './request';
|
|
3
|
-
export type MaybePromise<T> = T | Promise<T>;
|
|
4
|
-
export type UserAgentProvider = string | (() => MaybePromise<string | undefined>);
|
|
5
|
-
export type BaseUrlConfig = string | (() => string);
|
|
6
|
-
/**
|
|
7
|
-
* Request lifecycle hooks
|
|
8
|
-
*/
|
|
9
|
-
export type RequestHooks = {
|
|
10
|
-
/**
|
|
11
|
-
* Called before request is sent (after all features have processed)
|
|
12
|
-
*/
|
|
13
|
-
onRequest?: (context: RequestContext) => void | Promise<void>;
|
|
14
|
-
/**
|
|
15
|
-
* Called after successful response (before features process response)
|
|
16
|
-
*/
|
|
17
|
-
onResponse?: <T>(data: T, context: RequestContext) => void | Promise<void>;
|
|
18
|
-
/**
|
|
19
|
-
* Called when request fails (after all features have processed error)
|
|
20
|
-
*/
|
|
21
|
-
onError?: (error: Error, context: RequestContext) => void | Promise<void>;
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* Client configuration
|
|
25
|
-
*/
|
|
26
|
-
export interface ClientConfig {
|
|
27
|
-
/**
|
|
28
|
-
* User agent string or provider for requests
|
|
29
|
-
* Should identify your application (e.g., 'my-app/1.0.0')
|
|
30
|
-
* If not provided, the platform's default user agent will be used
|
|
31
|
-
*/
|
|
32
|
-
userAgent?: UserAgentProvider;
|
|
33
|
-
/**
|
|
34
|
-
* Base URL for Labrinth API (main Modrinth API)
|
|
35
|
-
* @default 'https://api.modrinth.com'
|
|
36
|
-
*/
|
|
37
|
-
labrinthBaseUrl?: BaseUrlConfig;
|
|
38
|
-
/**
|
|
39
|
-
* Base URL for Archon API (Modrinth Hosting API)
|
|
40
|
-
* Can be a callback so apps can drive this from runtime feature flags.
|
|
41
|
-
*
|
|
42
|
-
* @default 'https://archon.modrinth.com'
|
|
43
|
-
*/
|
|
44
|
-
archonBaseUrl?: BaseUrlConfig;
|
|
45
|
-
/**
|
|
46
|
-
* Default request timeout in milliseconds
|
|
47
|
-
* @default 10000
|
|
48
|
-
*/
|
|
49
|
-
timeout?: number;
|
|
50
|
-
/**
|
|
51
|
-
* Additional default headers to include in all requests
|
|
52
|
-
*/
|
|
53
|
-
headers?: Record<string, string>;
|
|
54
|
-
/**
|
|
55
|
-
* Whether to attach `modrinth-sentry-capture: 1` to Archon requests.
|
|
56
|
-
* Can be a callback so apps can drive this from runtime feature flags.
|
|
57
|
-
*
|
|
58
|
-
* @default false
|
|
59
|
-
*/
|
|
60
|
-
archonSentryCapture?: boolean | (() => boolean);
|
|
61
|
-
/**
|
|
62
|
-
* Features to enable for this client
|
|
63
|
-
* Features are applied in the order they appear in this array
|
|
64
|
-
*/
|
|
65
|
-
features?: AbstractFeature[];
|
|
66
|
-
/**
|
|
67
|
-
* Request lifecycle hooks
|
|
68
|
-
*/
|
|
69
|
-
hooks?: RequestHooks;
|
|
70
|
-
}
|
package/dist/types/errors.d.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Data for API errors
|
|
3
|
-
*/
|
|
4
|
-
export type ApiErrorData = {
|
|
5
|
-
/**
|
|
6
|
-
* HTTP status code (if available)
|
|
7
|
-
*/
|
|
8
|
-
statusCode?: number;
|
|
9
|
-
/**
|
|
10
|
-
* Original error that was caught
|
|
11
|
-
*/
|
|
12
|
-
originalError?: Error;
|
|
13
|
-
/**
|
|
14
|
-
* Response data from the API (if available)
|
|
15
|
-
*/
|
|
16
|
-
responseData?: unknown;
|
|
17
|
-
/**
|
|
18
|
-
* Error context (e.g., module name, operation being performed)
|
|
19
|
-
*/
|
|
20
|
-
context?: string;
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* Modrinth V1 error response format
|
|
24
|
-
* Used by kyros + archon APIs
|
|
25
|
-
*/
|
|
26
|
-
export type ModrinthErrorResponse = {
|
|
27
|
-
/**
|
|
28
|
-
* Error code/identifier
|
|
29
|
-
*/
|
|
30
|
-
error: string;
|
|
31
|
-
/**
|
|
32
|
-
* Human-readable error description
|
|
33
|
-
*/
|
|
34
|
-
description: string;
|
|
35
|
-
/**
|
|
36
|
-
* Optional context about where the error occurred
|
|
37
|
-
*/
|
|
38
|
-
context?: string;
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* Type guard to check if an object is a ModrinthErrorResponse
|
|
42
|
-
*/
|
|
43
|
-
export declare function isModrinthErrorResponse(obj: unknown): obj is ModrinthErrorResponse;
|
package/dist/types/index.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export type { FeatureConfig } from '../core/abstract-feature';
|
|
2
|
-
export type { AuthConfig } from '../features/auth';
|
|
3
|
-
export type { CircuitBreakerConfig, CircuitBreakerState, CircuitBreakerStorage, } from '../features/circuit-breaker';
|
|
4
|
-
export type { BackoffStrategy, RetryConfig } from '../features/retry';
|
|
5
|
-
export type { Archon } from '../modules/archon/types';
|
|
6
|
-
export type { BaseUrlConfig, ClientConfig, RequestHooks } from './client';
|
|
7
|
-
export type { ApiErrorData, ModrinthErrorResponse } from './errors';
|
|
8
|
-
export { isModrinthErrorResponse } from './errors';
|
|
9
|
-
export type { HttpMethod, RequestContext, RequestOptions, ResponseData } from './request';
|
|
10
|
-
export type { UploadHandle, UploadMetadata, UploadProgress, UploadRequestOptions, UploadState, } from './upload';
|
package/dist/types/request.d.ts
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HTTP method types
|
|
3
|
-
*/
|
|
4
|
-
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
5
|
-
/**
|
|
6
|
-
* Options for making a request
|
|
7
|
-
*/
|
|
8
|
-
export type RequestOptions = {
|
|
9
|
-
/**
|
|
10
|
-
* API to use for this request
|
|
11
|
-
* - 'labrinth': Main Modrinth API (resolves to labrinthBaseUrl)
|
|
12
|
-
* - 'archon': Modrinth Hosting API (resolves to archonBaseUrl)
|
|
13
|
-
* - string: Custom base URL (e.g., 'https://custom-api.com')
|
|
14
|
-
*/
|
|
15
|
-
api: 'labrinth' | 'archon' | string;
|
|
16
|
-
/**
|
|
17
|
-
* API version to use
|
|
18
|
-
* - number: version number (e.g., 2 for v2, 3 for v3)
|
|
19
|
-
* - 'internal': use internal API
|
|
20
|
-
*/
|
|
21
|
-
version: number | 'internal' | string;
|
|
22
|
-
/**
|
|
23
|
-
* HTTP method to use
|
|
24
|
-
* @default 'GET'
|
|
25
|
-
*/
|
|
26
|
-
method?: HttpMethod;
|
|
27
|
-
/**
|
|
28
|
-
* Request headers
|
|
29
|
-
*/
|
|
30
|
-
headers?: Record<string, string>;
|
|
31
|
-
/**
|
|
32
|
-
* Request body (will be JSON stringified if object)
|
|
33
|
-
*/
|
|
34
|
-
body?: unknown;
|
|
35
|
-
/**
|
|
36
|
-
* URL query parameters
|
|
37
|
-
*/
|
|
38
|
-
params?: Record<string, unknown>;
|
|
39
|
-
/**
|
|
40
|
-
* Request timeout in milliseconds
|
|
41
|
-
*/
|
|
42
|
-
timeout?: number;
|
|
43
|
-
/**
|
|
44
|
-
* Abort signal for cancelling requests
|
|
45
|
-
*/
|
|
46
|
-
signal?: AbortSignal;
|
|
47
|
-
/**
|
|
48
|
-
* Retry configuration for this specific request
|
|
49
|
-
* - false: no retries
|
|
50
|
-
* - true: use default retry config
|
|
51
|
-
* - number: max retry attempts
|
|
52
|
-
*/
|
|
53
|
-
retry?: boolean | number;
|
|
54
|
-
/**
|
|
55
|
-
* Circuit breaker configuration for this specific request
|
|
56
|
-
* - false: disable circuit breaker
|
|
57
|
-
* - true: use default circuit breaker config
|
|
58
|
-
*/
|
|
59
|
-
circuitBreaker?: boolean;
|
|
60
|
-
/**
|
|
61
|
-
* Whether to skip authentication for this request
|
|
62
|
-
* @default false
|
|
63
|
-
*/
|
|
64
|
-
skipAuth?: boolean;
|
|
65
|
-
/**
|
|
66
|
-
* Use node authentication for this request.
|
|
67
|
-
* When true, NodeAuthFeature will handle auth injection and URL building.
|
|
68
|
-
* @default false
|
|
69
|
-
*/
|
|
70
|
-
useNodeAuth?: boolean;
|
|
71
|
-
};
|
|
72
|
-
/**
|
|
73
|
-
* Full context passed to features during request execution
|
|
74
|
-
*/
|
|
75
|
-
export type RequestContext = {
|
|
76
|
-
/**
|
|
77
|
-
* Full URL being requested (with base URL and versioning applied)
|
|
78
|
-
*/
|
|
79
|
-
url: string;
|
|
80
|
-
/**
|
|
81
|
-
* Original path (before base URL and versioning)
|
|
82
|
-
*/
|
|
83
|
-
path: string;
|
|
84
|
-
/**
|
|
85
|
-
* Request options
|
|
86
|
-
*/
|
|
87
|
-
options: RequestOptions;
|
|
88
|
-
/**
|
|
89
|
-
* Current attempt number (1-indexed)
|
|
90
|
-
*/
|
|
91
|
-
attempt: number;
|
|
92
|
-
/**
|
|
93
|
-
* Timestamp when request started
|
|
94
|
-
*/
|
|
95
|
-
startTime: number;
|
|
96
|
-
/**
|
|
97
|
-
* Additional metadata that features can attach
|
|
98
|
-
*
|
|
99
|
-
* For uploads, this contains:
|
|
100
|
-
* - isUpload: true
|
|
101
|
-
* - file: File | Blob being uploaded
|
|
102
|
-
* - onProgress: progress callback (if provided)
|
|
103
|
-
*
|
|
104
|
-
* Features can check `context.metadata?.isUpload` to detect uploads.
|
|
105
|
-
*/
|
|
106
|
-
metadata?: Record<string, unknown>;
|
|
107
|
-
};
|
|
108
|
-
/**
|
|
109
|
-
* Generic response wrapper
|
|
110
|
-
*/
|
|
111
|
-
export type ResponseData<T = unknown> = {
|
|
112
|
-
/**
|
|
113
|
-
* Response data
|
|
114
|
-
*/
|
|
115
|
-
data: T;
|
|
116
|
-
/**
|
|
117
|
-
* HTTP status code
|
|
118
|
-
*/
|
|
119
|
-
status: number;
|
|
120
|
-
/**
|
|
121
|
-
* Response headers
|
|
122
|
-
*/
|
|
123
|
-
headers: Record<string, string>;
|
|
124
|
-
};
|
package/dist/types/upload.d.ts
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import type { RequestOptions } from './request';
|
|
2
|
-
/**
|
|
3
|
-
* Progress information for file uploads
|
|
4
|
-
*/
|
|
5
|
-
export interface UploadProgress {
|
|
6
|
-
/** Bytes uploaded so far */
|
|
7
|
-
loaded: number;
|
|
8
|
-
/** Total bytes to upload */
|
|
9
|
-
total: number;
|
|
10
|
-
/** Progress as a decimal (0-1) */
|
|
11
|
-
progress: number;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Base options for upload requests
|
|
15
|
-
*/
|
|
16
|
-
interface BaseUploadRequestOptions extends Omit<RequestOptions, 'body' | 'method'> {
|
|
17
|
-
/** Callback for progress updates */
|
|
18
|
-
onProgress?: (progress: UploadProgress) => void;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Options for single file upload requests
|
|
22
|
-
*/
|
|
23
|
-
export interface FileUploadRequestOptions extends BaseUploadRequestOptions {
|
|
24
|
-
/** File or Blob to upload */
|
|
25
|
-
file: File | Blob;
|
|
26
|
-
formData?: never;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Options for FormData upload requests
|
|
30
|
-
*
|
|
31
|
-
* Used for multipart uploads (e.g., version file uploads) that need
|
|
32
|
-
* to send metadata alongside files.
|
|
33
|
-
*/
|
|
34
|
-
export interface FormDataUploadRequestOptions extends BaseUploadRequestOptions {
|
|
35
|
-
/** FormData containing files and metadata */
|
|
36
|
-
formData: FormData;
|
|
37
|
-
file?: never;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Options for upload requests - either a single file or FormData
|
|
41
|
-
*/
|
|
42
|
-
export type UploadRequestOptions = FileUploadRequestOptions | FormDataUploadRequestOptions;
|
|
43
|
-
/**
|
|
44
|
-
* Metadata attached to file upload contexts
|
|
45
|
-
*
|
|
46
|
-
* Features can check `context.metadata?.isUpload` to detect uploads.
|
|
47
|
-
*/
|
|
48
|
-
export interface FileUploadMetadata extends Record<string, unknown> {
|
|
49
|
-
isUpload: true;
|
|
50
|
-
file: File | Blob;
|
|
51
|
-
formData?: never;
|
|
52
|
-
onProgress?: (progress: UploadProgress) => void;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Metadata attached to FormData upload contexts
|
|
56
|
-
*/
|
|
57
|
-
export interface FormDataUploadMetadata extends Record<string, unknown> {
|
|
58
|
-
isUpload: true;
|
|
59
|
-
formData: FormData;
|
|
60
|
-
file?: never;
|
|
61
|
-
onProgress?: (progress: UploadProgress) => void;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Metadata attached to upload contexts - either file or FormData
|
|
65
|
-
*/
|
|
66
|
-
export type UploadMetadata = FileUploadMetadata | FormDataUploadMetadata;
|
|
67
|
-
/**
|
|
68
|
-
* Handle returned from upload operations
|
|
69
|
-
*
|
|
70
|
-
* Provides the upload promise, progress subscription, and cancellation.
|
|
71
|
-
*/
|
|
72
|
-
export interface UploadHandle<T> {
|
|
73
|
-
/** Promise that resolves when upload completes */
|
|
74
|
-
promise: Promise<T>;
|
|
75
|
-
/** Subscribe to progress updates (chainable) */
|
|
76
|
-
onProgress: (callback: (progress: UploadProgress) => void) => UploadHandle<T>;
|
|
77
|
-
/** Cancel the upload */
|
|
78
|
-
cancel: () => void;
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* State of a batch file upload operation
|
|
82
|
-
*/
|
|
83
|
-
export interface UploadState {
|
|
84
|
-
isUploading: boolean;
|
|
85
|
-
currentFileName: string | null;
|
|
86
|
-
currentFileProgress: number;
|
|
87
|
-
uploadedBytes: number;
|
|
88
|
-
totalBytes: number;
|
|
89
|
-
completedFiles: number;
|
|
90
|
-
totalFiles: number;
|
|
91
|
-
}
|
|
92
|
-
export {};
|
package/dist/utils/fetch.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { RequestOptions } from '../types/request';
|
|
2
|
-
export declare function appendRequestParams(url: string, params?: RequestOptions['params']): string;
|
|
3
|
-
export declare function toFetchBody(body: unknown): BodyInit | null | undefined;
|
|
4
|
-
export declare function parseResponseErrorData(response: Response): Promise<unknown>;
|
package/dist/utils/node-url.d.ts
DELETED
package/dist/utils/pingtest.d.ts
DELETED
package/dist/utils/sse.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { Archon } from '../modules/archon/types';
|
|
2
|
-
export type ParsedSseEvent = {
|
|
3
|
-
kind: 'event';
|
|
4
|
-
id?: string;
|
|
5
|
-
event?: string;
|
|
6
|
-
data: string;
|
|
7
|
-
};
|
|
8
|
-
export type ParsedSseRetry = {
|
|
9
|
-
kind: 'retry';
|
|
10
|
-
retry: number;
|
|
11
|
-
};
|
|
12
|
-
export type ParsedSseItem = ParsedSseEvent | ParsedSseRetry;
|
|
13
|
-
export declare class SseParser {
|
|
14
|
-
private buffer;
|
|
15
|
-
private eventName;
|
|
16
|
-
private data;
|
|
17
|
-
private id;
|
|
18
|
-
feed(chunk: string): ParsedSseItem[];
|
|
19
|
-
end(): ParsedSseItem[];
|
|
20
|
-
private findLineEnd;
|
|
21
|
-
private processLine;
|
|
22
|
-
private dispatch;
|
|
23
|
-
}
|
|
24
|
-
export declare function parseSyncEventData(data: string): Archon.Sync.v1.SyncEvent | null;
|
package/dist/utils/types.d.ts
DELETED