connectbase-client 3.1.0 → 3.2.1
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/CHANGELOG.md +54 -0
- package/README.md +83 -0
- package/dist/connect-base.umd.js +3 -3
- package/dist/index.d.mts +83 -1
- package/dist/index.d.ts +83 -1
- package/dist/index.js +135 -2
- package/dist/index.mjs +135 -2
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -6771,6 +6771,70 @@ declare class EndpointAPI {
|
|
|
6771
6771
|
* @param init - fetch() 의 RequestInit + path. path 는 사용자 모델 서버의 엔드포인트 경로 (예: "/prompt", "/v1/chat/completions").
|
|
6772
6772
|
*/
|
|
6773
6773
|
call(label: string, init: EndpointCallInit): Promise<Response>;
|
|
6774
|
+
/**
|
|
6775
|
+
* 라벨 + path 의 최종 호출 URL `${baseUrl}/v1/proxy/${label}${path}` 을 조립해서
|
|
6776
|
+
* 반환. URL 을 다른 시스템 (Service Worker, 백엔드 워커, 로깅) 에 넘기거나
|
|
6777
|
+
* 디버깅 용도일 때 사용.
|
|
6778
|
+
*
|
|
6779
|
+
* ⚠️ **`<img src>` / 네이티브 `WebSocket` / `<script src>` / `EventSource` 처럼
|
|
6780
|
+
* 커스텀 헤더를 못 보내는 브라우저 API 에 직접 넘기면 401 입니다.** ConnectBase
|
|
6781
|
+
* 프록시는 모든 요청에 `X-Public-Key` 헤더를 요구하고, 쿼리 파라미터 폴백은
|
|
6782
|
+
* 제공하지 않습니다. 그런 경우엔 `call()` 로 받아서 Blob URL 로 변환하세요.
|
|
6783
|
+
*
|
|
6784
|
+
* @example URL 을 워커로 넘겨 호출 (✅)
|
|
6785
|
+
* ```typescript
|
|
6786
|
+
* sw.postMessage({
|
|
6787
|
+
* url: cb.endpoint.url("comfyui-main", "/prompt"),
|
|
6788
|
+
* key: publicKey, // 워커가 X-Public-Key 헤더로 부착
|
|
6789
|
+
* })
|
|
6790
|
+
* ```
|
|
6791
|
+
*
|
|
6792
|
+
* @example 이미지 렌더링은 call() + Blob URL 패턴으로 (✅)
|
|
6793
|
+
* ```typescript
|
|
6794
|
+
* const res = await cb.endpoint.call("comfyui-main", {
|
|
6795
|
+
* path: `/view?filename=${encodeURIComponent(name)}`,
|
|
6796
|
+
* })
|
|
6797
|
+
* img.src = URL.createObjectURL(await res.blob())
|
|
6798
|
+
* // 나중에 URL.revokeObjectURL(img.src)
|
|
6799
|
+
* ```
|
|
6800
|
+
*/
|
|
6801
|
+
url(label: string, path: string): string;
|
|
6802
|
+
/**
|
|
6803
|
+
* 같은 endpoint 호출을 `predicate` 가 값을 반환할 때까지 주기적으로 반복.
|
|
6804
|
+
* ComfyUI `/history/{id}`, A1111 `/sdapi/v1/progress`, 자체 큐 API 처럼
|
|
6805
|
+
* "작업 제출 → 폴링" 패턴을 한 줄로 처리하기 위한 헬퍼.
|
|
6806
|
+
*
|
|
6807
|
+
* 동작:
|
|
6808
|
+
* - `call(label, init)` → predicate(response) 호출
|
|
6809
|
+
* - predicate 가 `undefined` 면 `intervalMs` 만큼 대기 후 재시도
|
|
6810
|
+
* - predicate 가 값을 반환하면 그 값을 즉시 resolve
|
|
6811
|
+
* - `timeoutMs` 초과 또는 `signal` abort 시 reject
|
|
6812
|
+
* - HTTP 5xx/네트워크 오류는 재시도, 4xx 는 즉시 reject (작업 자체가 잘못된 경우)
|
|
6813
|
+
*
|
|
6814
|
+
* predicate 는 같은 Response 를 한 번만 읽을 수 있으므로, 헬퍼 내부에서
|
|
6815
|
+
* `res.clone().json()` 형태로 안전하게 파싱한 뒤 호출자에게 전달.
|
|
6816
|
+
*
|
|
6817
|
+
* @example ComfyUI 결과 폴링
|
|
6818
|
+
* ```typescript
|
|
6819
|
+
* type Hist = Record<string, { outputs: Record<string, { images?: { filename: string }[] }> }>
|
|
6820
|
+
*
|
|
6821
|
+
* const filename = await cb.endpoint.pollUntil<string>(
|
|
6822
|
+
* "comfyui-main",
|
|
6823
|
+
* { path: `/history/${promptId}` },
|
|
6824
|
+
* (data: Hist) => {
|
|
6825
|
+
* const entry = data[promptId]
|
|
6826
|
+
* if (!entry) return undefined // 아직 큐에 있음
|
|
6827
|
+
* for (const out of Object.values(entry.outputs)) {
|
|
6828
|
+
* const img = out.images?.[0]
|
|
6829
|
+
* if (img) return img.filename
|
|
6830
|
+
* }
|
|
6831
|
+
* return undefined
|
|
6832
|
+
* },
|
|
6833
|
+
* { intervalMs: 1000, timeoutMs: 5 * 60_000 },
|
|
6834
|
+
* )
|
|
6835
|
+
* ```
|
|
6836
|
+
*/
|
|
6837
|
+
pollUntil<T>(label: string, init: EndpointCallInit, predicate: (body: any, res: Response) => T | undefined | Promise<T | undefined>, opts?: PollUntilOptions): Promise<T>;
|
|
6774
6838
|
}
|
|
6775
6839
|
/**
|
|
6776
6840
|
* EndpointAPI.call 의 init 인자.
|
|
@@ -6792,6 +6856,24 @@ interface EndpointCallInit {
|
|
|
6792
6856
|
/** 취소 신호. */
|
|
6793
6857
|
signal?: AbortSignal;
|
|
6794
6858
|
}
|
|
6859
|
+
/**
|
|
6860
|
+
* EndpointAPI.pollUntil 옵션.
|
|
6861
|
+
*/
|
|
6862
|
+
interface PollUntilOptions {
|
|
6863
|
+
/** 폴링 간격 (ms). 기본 1500. */
|
|
6864
|
+
intervalMs?: number;
|
|
6865
|
+
/** 전체 timeout (ms). 기본 300000 (5분). */
|
|
6866
|
+
timeoutMs?: number;
|
|
6867
|
+
/**
|
|
6868
|
+
* 응답 본문 파싱 방식.
|
|
6869
|
+
* - `"json"` (기본) — `res.json()`. 파싱 실패 시 predicate 에 `undefined` 전달.
|
|
6870
|
+
* - `"text"` — 문자열 그대로.
|
|
6871
|
+
* - `"none"` — 본문 사용 안 함 (예: 헤더 / status 만 보고 판단).
|
|
6872
|
+
*/
|
|
6873
|
+
parse?: "json" | "text" | "none";
|
|
6874
|
+
/** 외부 취소 신호. abort 시 즉시 reject. */
|
|
6875
|
+
signal?: AbortSignal;
|
|
6876
|
+
}
|
|
6795
6877
|
|
|
6796
6878
|
interface PublishMessageRequest {
|
|
6797
6879
|
body: unknown;
|
|
@@ -7288,4 +7370,4 @@ declare class ConnectBase {
|
|
|
7288
7370
|
updateConfig(config: Partial<ConnectBaseConfig>): void;
|
|
7289
7371
|
}
|
|
7290
7372
|
|
|
7291
|
-
export { AIAPI, type AIChatRequest, type AIChatResponse, type AIMessage, type AISource, type AIStreamChunk, type AITool, type AIToolCall, type AIToolEvent, type AckMessagesRequest, type AdMobDailyReport, type AdMobReportResponse, type AdMobReportSummary, type AdReportResponse, type AdReportSummary, type AdmobConnectionInfo, AdsAPI, type AdsenseConnectionInfo, type AggregateResult, type AggregateStage, type AnalyticsConfig, type AnalyticsEvent, ApiError, type ApiErrorDetail, type AppStatsResponse, type ArchivePolicy, type AtomicOperator, type AtomicOperatorType, AuthError, type AuthSettingsResponse, type BackupInfo, type BatchOperation, type BatchSetPageMetaRequest, type BillingCycle, type BillingKeyResponse, type BiometricInfo, type BiometricResult, type BulkCreateResponse, type BulkError, type CPUInfo, type CancelPaymentRequest, type CancelPaymentResponse, type CancelSubscriptionRequest, type CategoryInfo, type Channel, type ChannelMembership, type ChargeWithBillingKeyRequest, type ChargeWithBillingKeyResponse, type ChatMessage, type ClientMessage, type ColumnSchema, type CommentListResponse, type CompleteUploadRequest, type CompleteUploadResponse, type ConfirmBillingKeyRequest, type ConfirmPaymentRequest, type ConfirmPaymentResponse, ConnectBase, type ConnectBaseConfig, type ConnectedData, type ConnectionState, type ConsentOptions, type ConsumeMessagesResponse, type ConsumeOptions, type CopyTableRequest, type CopyTableResponse, type CreateBackupRequest, type CreateChannelRequest, type CreateCheckoutSessionRequest, type CreateCheckoutSessionResponse, type CreateColumnRequest, type CreateDataRequest, type CreateDocumentRequest, type CreateFolderRequest, type CreateFolderResponse, type CreateGeoIndexRequest, type CreateIndexRequest, type CreateLobbyRequest, type CreatePlaylistRequest, type CreatePublicKeyRequest, type CreatePublicKeyResponse, type CreateRelationRequest, type CreateSearchIndexRequest, type CreateSecurityRuleRequest, type CreateSubscriptionRequest, type CreateTableRequest, type CreateTriggerRequest, type CreateVideoStorageRequest, type DailyReport, type DataItem, type DataType, type DatabaseChange, type DatabaseChangeMessage, type DatabaseChangeType, type DatabaseRealtimeConnectOptions, type DatabaseRealtimeFilter, type DatabaseRealtimeHandlers, type DatabaseRealtimeSubscription, type DatabaseSnapshot, type DatabaseSnapshotMessage, type DatabaseSubscribeOptions, type DeleteWhereResponse, type DeviceInfo, type DocumentResponse, type EnabledProviderInfo, type EnabledProvidersResponse, EndpointAPI, type EndpointCallInit, type ErrorHandler, type ErrorMessage, type ErrorReport, type ErrorTrackerConfig, type ErrorType, type ExportDataRequest, type ExportDataResponse, type FetchDataResponse, type FetchFilesResponse, type FetchPublicKeysResponse, type FileItem, type FileStats, GameAPI, type GameAction, type GameClientConfig, type GameConnectionState, type GameConnectionStatus, type GameDelta, type GameEventHandlers, type GamePlayer, GameRoom, type GameRoomConfig, type GameRoomInfo, GameRoomTransport, type GameServerMessage, type GameServerMessageType, type GameState, type GameTransportConfig, type GenerateUploadURLByPathRequest, type GenerateUploadURLRequest, type GenerateUploadURLResponse, type GeoIndex, type GeoNear, type GeoPoint, type GeoPolygon, type GeoQuery, type GeoResponse, type GeoResult, type GeoWithin, type GetAuthorizationURLResponse, type GetFileByPathResponse, type GoogleConnectionStatus, type GuestMemberSignInResponse, type HistoryResponse, type ICEServer, type ICEServersResponse, type ImageResult, type ImportDataRequest, type ImportDataResponse, type IndexAnalysis, type IndexRecommendation, type InitUploadResponse, type InvokeFunctionRequest, type InvokeFunctionResponse, type IssueBillingKeyRequest, type IssueBillingKeyResponse, type JoinQueueRequest, type JoinRoomRequest, type JoinRoomResponse, type KnowledgeSearchRequest, type KnowledgeSearchResponse, type KnowledgeSearchResult, type LeaderboardEntry, type LeaderboardListResponse, type LeaderboardScoreEntry, type LifecyclePolicy, type ListBillingKeysResponse, type ListDocumentsResponse, type ListPageMetasOptions, type ListPageMetasResponse, type ListSubscriptionPaymentsRequest, type ListSubscriptionPaymentsResponse, type ListSubscriptionsRequest, type ListSubscriptionsResponse, type LobbyInfo, type LobbyInvite, type LobbyMember, type LobbyVisibility, type MatchResult, type MatchmakingTicket, type MatchqueueListResponse, type MatchqueueTicket, type MemberInfoResponse, type MemberSignInRequest, type MemberSignInResponse, type MemberSignUpRequest, type MemberSignUpResponse, type MembershipTier, type MemoryInfo, type MessageHandler, type MigrateDataRequest, type MigrateDataResponse, type MoveFileRequest, type NackMessageRequest, NativeAPI, type OAuthCallbackResponse, type OAuthProvider, type OpenDialogOptions, type OpenDialogResult, type PageMetaResponse, type PartyInfo, type PartyInvite, type PartyMember, type PauseSubscriptionRequest, type PaymentDetail, type PaymentProvider, type PaymentStatus, type PeerInfo, type Platform, type PlayerEvent, type PlayerStats, type Playlist, type PlaylistItem, type PongMessage, type PopulateOption, type Position, type PreparePaymentRequest, type PreparePaymentResponse, type PresenceChangeHandler, type PresenceInfo, type PresenceSetOptions, type PresenceStatus, type PresenceStatusResult, type PublicKeyItem, type PublishBatchRequest, type PublishBatchResponse, type PublishMessageRequest, type PublishMessageResponse, type PushPlatform, type QualityProgress, type QueryOptions, type QueueInfoResponse, type QueueMessage, type ReadReceiptHandler, type ReadReceiptInfo, type RealtimeConnectOptions, type RealtimeMessage, type RegisterDeviceRequest, type RelationType, type RenameFileRequest, type RenameFileResponse, type ReplayHighlight, type ReplayInfo, type ReplayPlayerInfo, type RestoreBackupRequest, type RestoreBackupResponse, type RetentionPolicy, type RoomInfo, type RoomStats, type RoomsResponse, type SaveDialogOptions, type SaveDialogResult, type ScriptDetailResponse, type ScriptListResponse, type ScriptMeta, type ScriptVersion, type ScriptVersionListResponse, type SearchIndex, type SearchOptions, type SearchResponse, type SearchResult, type SecurityRule, type SendOptions, type ServerMessage, SessionManager, type SetPageMetaRequest, type Shorts, type ShortsListResponse, type SignalingMessage, type SignalingMessageType, type SlowQueryInfo, type SpectatorInfo, type SpectatorPlayerState, type SpectatorState, type StateChange, type StateChangeHandler, type StorageUploadOptions, type StreamDoneCallback, type StreamDoneData, type StreamErrorCallback, type StreamHandlers, type StreamMessage, type StreamOptions, type StreamSession, type StreamTokenCallback, type StreamToolCallCallback, type StreamToolResultCallback, type StreamURLResponse, type SubscribeOptions, type SubscribeTopicRequest, type SubscribedData, type Subscription, type SubscriptionPaymentResponse, type SubscriptionPaymentStatus, type SubscriptionResponse, type SubscriptionStatus, type SuperChat, type SystemInfo, type TTLConfig, type TableAccessLevel, type TableColumnDef, type TableIndex, type TableRelation, type TableSchema, type TableSchemaDefinition, type TokenPersistence, type TransactionRead, type TransactionWrite, type TranscodeStatus, type TransportType, type Trigger, type TriggerEvent, type TriggerHandlerType, type TypingChangeHandler, type TypingInfo, type UpdateBillingKeyRequest, type UpdateChannelRequest, type UpdateColumnRequest, type UpdateCustomDataRequest, type UpdateCustomDataResponse, type UpdateDataRequest, type UpdateLobbyRequest, type UpdatePublicKeyRequest, type UpdatePublicKeyResponse, type UpdateSecurityRuleRequest, type UpdateSubscriptionRequest, type UpdateTriggerRequest, type UpdateVideoRequest, type UpdateVideoStorageRequest, type UploadByPathOptions, type UploadFileResponse, type UploadOptions, type UploadProgress, type VAPIDPublicKeyResponse, type ValidateResponse, type ValidationSchema, type ValidationSchemaField, type ValidationStateTransitions, type Video, type VideoComment, type VideoListOptions, type VideoListResponse, VideoProcessingError, type VideoQuality, type VideoStatus, type VideoStorage, type VideoStorageListResponse, type VideoVisibility, type VoiceChannel, type VoiceMember, type WaitOptions, type WatchHistoryItem, type WebPushSubscription, type WebRTCConnectOptions, type WebRTCConnectionState, type WebRTCMode, type WhereCondition, type WhereOperator, ConnectBase as default, isWebTransportSupported };
|
|
7373
|
+
export { AIAPI, type AIChatRequest, type AIChatResponse, type AIMessage, type AISource, type AIStreamChunk, type AITool, type AIToolCall, type AIToolEvent, type AckMessagesRequest, type AdMobDailyReport, type AdMobReportResponse, type AdMobReportSummary, type AdReportResponse, type AdReportSummary, type AdmobConnectionInfo, AdsAPI, type AdsenseConnectionInfo, type AggregateResult, type AggregateStage, type AnalyticsConfig, type AnalyticsEvent, ApiError, type ApiErrorDetail, type AppStatsResponse, type ArchivePolicy, type AtomicOperator, type AtomicOperatorType, AuthError, type AuthSettingsResponse, type BackupInfo, type BatchOperation, type BatchSetPageMetaRequest, type BillingCycle, type BillingKeyResponse, type BiometricInfo, type BiometricResult, type BulkCreateResponse, type BulkError, type CPUInfo, type CancelPaymentRequest, type CancelPaymentResponse, type CancelSubscriptionRequest, type CategoryInfo, type Channel, type ChannelMembership, type ChargeWithBillingKeyRequest, type ChargeWithBillingKeyResponse, type ChatMessage, type ClientMessage, type ColumnSchema, type CommentListResponse, type CompleteUploadRequest, type CompleteUploadResponse, type ConfirmBillingKeyRequest, type ConfirmPaymentRequest, type ConfirmPaymentResponse, ConnectBase, type ConnectBaseConfig, type ConnectedData, type ConnectionState, type ConsentOptions, type ConsumeMessagesResponse, type ConsumeOptions, type CopyTableRequest, type CopyTableResponse, type CreateBackupRequest, type CreateChannelRequest, type CreateCheckoutSessionRequest, type CreateCheckoutSessionResponse, type CreateColumnRequest, type CreateDataRequest, type CreateDocumentRequest, type CreateFolderRequest, type CreateFolderResponse, type CreateGeoIndexRequest, type CreateIndexRequest, type CreateLobbyRequest, type CreatePlaylistRequest, type CreatePublicKeyRequest, type CreatePublicKeyResponse, type CreateRelationRequest, type CreateSearchIndexRequest, type CreateSecurityRuleRequest, type CreateSubscriptionRequest, type CreateTableRequest, type CreateTriggerRequest, type CreateVideoStorageRequest, type DailyReport, type DataItem, type DataType, type DatabaseChange, type DatabaseChangeMessage, type DatabaseChangeType, type DatabaseRealtimeConnectOptions, type DatabaseRealtimeFilter, type DatabaseRealtimeHandlers, type DatabaseRealtimeSubscription, type DatabaseSnapshot, type DatabaseSnapshotMessage, type DatabaseSubscribeOptions, type DeleteWhereResponse, type DeviceInfo, type DocumentResponse, type EnabledProviderInfo, type EnabledProvidersResponse, EndpointAPI, type EndpointCallInit, type ErrorHandler, type ErrorMessage, type ErrorReport, type ErrorTrackerConfig, type ErrorType, type ExportDataRequest, type ExportDataResponse, type FetchDataResponse, type FetchFilesResponse, type FetchPublicKeysResponse, type FileItem, type FileStats, GameAPI, type GameAction, type GameClientConfig, type GameConnectionState, type GameConnectionStatus, type GameDelta, type GameEventHandlers, type GamePlayer, GameRoom, type GameRoomConfig, type GameRoomInfo, GameRoomTransport, type GameServerMessage, type GameServerMessageType, type GameState, type GameTransportConfig, type GenerateUploadURLByPathRequest, type GenerateUploadURLRequest, type GenerateUploadURLResponse, type GeoIndex, type GeoNear, type GeoPoint, type GeoPolygon, type GeoQuery, type GeoResponse, type GeoResult, type GeoWithin, type GetAuthorizationURLResponse, type GetFileByPathResponse, type GoogleConnectionStatus, type GuestMemberSignInResponse, type HistoryResponse, type ICEServer, type ICEServersResponse, type ImageResult, type ImportDataRequest, type ImportDataResponse, type IndexAnalysis, type IndexRecommendation, type InitUploadResponse, type InvokeFunctionRequest, type InvokeFunctionResponse, type IssueBillingKeyRequest, type IssueBillingKeyResponse, type JoinQueueRequest, type JoinRoomRequest, type JoinRoomResponse, type KnowledgeSearchRequest, type KnowledgeSearchResponse, type KnowledgeSearchResult, type LeaderboardEntry, type LeaderboardListResponse, type LeaderboardScoreEntry, type LifecyclePolicy, type ListBillingKeysResponse, type ListDocumentsResponse, type ListPageMetasOptions, type ListPageMetasResponse, type ListSubscriptionPaymentsRequest, type ListSubscriptionPaymentsResponse, type ListSubscriptionsRequest, type ListSubscriptionsResponse, type LobbyInfo, type LobbyInvite, type LobbyMember, type LobbyVisibility, type MatchResult, type MatchmakingTicket, type MatchqueueListResponse, type MatchqueueTicket, type MemberInfoResponse, type MemberSignInRequest, type MemberSignInResponse, type MemberSignUpRequest, type MemberSignUpResponse, type MembershipTier, type MemoryInfo, type MessageHandler, type MigrateDataRequest, type MigrateDataResponse, type MoveFileRequest, type NackMessageRequest, NativeAPI, type OAuthCallbackResponse, type OAuthProvider, type OpenDialogOptions, type OpenDialogResult, type PageMetaResponse, type PartyInfo, type PartyInvite, type PartyMember, type PauseSubscriptionRequest, type PaymentDetail, type PaymentProvider, type PaymentStatus, type PeerInfo, type Platform, type PlayerEvent, type PlayerStats, type Playlist, type PlaylistItem, type PollUntilOptions, type PongMessage, type PopulateOption, type Position, type PreparePaymentRequest, type PreparePaymentResponse, type PresenceChangeHandler, type PresenceInfo, type PresenceSetOptions, type PresenceStatus, type PresenceStatusResult, type PublicKeyItem, type PublishBatchRequest, type PublishBatchResponse, type PublishMessageRequest, type PublishMessageResponse, type PushPlatform, type QualityProgress, type QueryOptions, type QueueInfoResponse, type QueueMessage, type ReadReceiptHandler, type ReadReceiptInfo, type RealtimeConnectOptions, type RealtimeMessage, type RegisterDeviceRequest, type RelationType, type RenameFileRequest, type RenameFileResponse, type ReplayHighlight, type ReplayInfo, type ReplayPlayerInfo, type RestoreBackupRequest, type RestoreBackupResponse, type RetentionPolicy, type RoomInfo, type RoomStats, type RoomsResponse, type SaveDialogOptions, type SaveDialogResult, type ScriptDetailResponse, type ScriptListResponse, type ScriptMeta, type ScriptVersion, type ScriptVersionListResponse, type SearchIndex, type SearchOptions, type SearchResponse, type SearchResult, type SecurityRule, type SendOptions, type ServerMessage, SessionManager, type SetPageMetaRequest, type Shorts, type ShortsListResponse, type SignalingMessage, type SignalingMessageType, type SlowQueryInfo, type SpectatorInfo, type SpectatorPlayerState, type SpectatorState, type StateChange, type StateChangeHandler, type StorageUploadOptions, type StreamDoneCallback, type StreamDoneData, type StreamErrorCallback, type StreamHandlers, type StreamMessage, type StreamOptions, type StreamSession, type StreamTokenCallback, type StreamToolCallCallback, type StreamToolResultCallback, type StreamURLResponse, type SubscribeOptions, type SubscribeTopicRequest, type SubscribedData, type Subscription, type SubscriptionPaymentResponse, type SubscriptionPaymentStatus, type SubscriptionResponse, type SubscriptionStatus, type SuperChat, type SystemInfo, type TTLConfig, type TableAccessLevel, type TableColumnDef, type TableIndex, type TableRelation, type TableSchema, type TableSchemaDefinition, type TokenPersistence, type TransactionRead, type TransactionWrite, type TranscodeStatus, type TransportType, type Trigger, type TriggerEvent, type TriggerHandlerType, type TypingChangeHandler, type TypingInfo, type UpdateBillingKeyRequest, type UpdateChannelRequest, type UpdateColumnRequest, type UpdateCustomDataRequest, type UpdateCustomDataResponse, type UpdateDataRequest, type UpdateLobbyRequest, type UpdatePublicKeyRequest, type UpdatePublicKeyResponse, type UpdateSecurityRuleRequest, type UpdateSubscriptionRequest, type UpdateTriggerRequest, type UpdateVideoRequest, type UpdateVideoStorageRequest, type UploadByPathOptions, type UploadFileResponse, type UploadOptions, type UploadProgress, type VAPIDPublicKeyResponse, type ValidateResponse, type ValidationSchema, type ValidationSchemaField, type ValidationStateTransitions, type Video, type VideoComment, type VideoListOptions, type VideoListResponse, VideoProcessingError, type VideoQuality, type VideoStatus, type VideoStorage, type VideoStorageListResponse, type VideoVisibility, type VoiceChannel, type VoiceMember, type WaitOptions, type WatchHistoryItem, type WebPushSubscription, type WebRTCConnectOptions, type WebRTCConnectionState, type WebRTCMode, type WhereCondition, type WhereOperator, ConnectBase as default, isWebTransportSupported };
|
package/dist/index.d.ts
CHANGED
|
@@ -6771,6 +6771,70 @@ declare class EndpointAPI {
|
|
|
6771
6771
|
* @param init - fetch() 의 RequestInit + path. path 는 사용자 모델 서버의 엔드포인트 경로 (예: "/prompt", "/v1/chat/completions").
|
|
6772
6772
|
*/
|
|
6773
6773
|
call(label: string, init: EndpointCallInit): Promise<Response>;
|
|
6774
|
+
/**
|
|
6775
|
+
* 라벨 + path 의 최종 호출 URL `${baseUrl}/v1/proxy/${label}${path}` 을 조립해서
|
|
6776
|
+
* 반환. URL 을 다른 시스템 (Service Worker, 백엔드 워커, 로깅) 에 넘기거나
|
|
6777
|
+
* 디버깅 용도일 때 사용.
|
|
6778
|
+
*
|
|
6779
|
+
* ⚠️ **`<img src>` / 네이티브 `WebSocket` / `<script src>` / `EventSource` 처럼
|
|
6780
|
+
* 커스텀 헤더를 못 보내는 브라우저 API 에 직접 넘기면 401 입니다.** ConnectBase
|
|
6781
|
+
* 프록시는 모든 요청에 `X-Public-Key` 헤더를 요구하고, 쿼리 파라미터 폴백은
|
|
6782
|
+
* 제공하지 않습니다. 그런 경우엔 `call()` 로 받아서 Blob URL 로 변환하세요.
|
|
6783
|
+
*
|
|
6784
|
+
* @example URL 을 워커로 넘겨 호출 (✅)
|
|
6785
|
+
* ```typescript
|
|
6786
|
+
* sw.postMessage({
|
|
6787
|
+
* url: cb.endpoint.url("comfyui-main", "/prompt"),
|
|
6788
|
+
* key: publicKey, // 워커가 X-Public-Key 헤더로 부착
|
|
6789
|
+
* })
|
|
6790
|
+
* ```
|
|
6791
|
+
*
|
|
6792
|
+
* @example 이미지 렌더링은 call() + Blob URL 패턴으로 (✅)
|
|
6793
|
+
* ```typescript
|
|
6794
|
+
* const res = await cb.endpoint.call("comfyui-main", {
|
|
6795
|
+
* path: `/view?filename=${encodeURIComponent(name)}`,
|
|
6796
|
+
* })
|
|
6797
|
+
* img.src = URL.createObjectURL(await res.blob())
|
|
6798
|
+
* // 나중에 URL.revokeObjectURL(img.src)
|
|
6799
|
+
* ```
|
|
6800
|
+
*/
|
|
6801
|
+
url(label: string, path: string): string;
|
|
6802
|
+
/**
|
|
6803
|
+
* 같은 endpoint 호출을 `predicate` 가 값을 반환할 때까지 주기적으로 반복.
|
|
6804
|
+
* ComfyUI `/history/{id}`, A1111 `/sdapi/v1/progress`, 자체 큐 API 처럼
|
|
6805
|
+
* "작업 제출 → 폴링" 패턴을 한 줄로 처리하기 위한 헬퍼.
|
|
6806
|
+
*
|
|
6807
|
+
* 동작:
|
|
6808
|
+
* - `call(label, init)` → predicate(response) 호출
|
|
6809
|
+
* - predicate 가 `undefined` 면 `intervalMs` 만큼 대기 후 재시도
|
|
6810
|
+
* - predicate 가 값을 반환하면 그 값을 즉시 resolve
|
|
6811
|
+
* - `timeoutMs` 초과 또는 `signal` abort 시 reject
|
|
6812
|
+
* - HTTP 5xx/네트워크 오류는 재시도, 4xx 는 즉시 reject (작업 자체가 잘못된 경우)
|
|
6813
|
+
*
|
|
6814
|
+
* predicate 는 같은 Response 를 한 번만 읽을 수 있으므로, 헬퍼 내부에서
|
|
6815
|
+
* `res.clone().json()` 형태로 안전하게 파싱한 뒤 호출자에게 전달.
|
|
6816
|
+
*
|
|
6817
|
+
* @example ComfyUI 결과 폴링
|
|
6818
|
+
* ```typescript
|
|
6819
|
+
* type Hist = Record<string, { outputs: Record<string, { images?: { filename: string }[] }> }>
|
|
6820
|
+
*
|
|
6821
|
+
* const filename = await cb.endpoint.pollUntil<string>(
|
|
6822
|
+
* "comfyui-main",
|
|
6823
|
+
* { path: `/history/${promptId}` },
|
|
6824
|
+
* (data: Hist) => {
|
|
6825
|
+
* const entry = data[promptId]
|
|
6826
|
+
* if (!entry) return undefined // 아직 큐에 있음
|
|
6827
|
+
* for (const out of Object.values(entry.outputs)) {
|
|
6828
|
+
* const img = out.images?.[0]
|
|
6829
|
+
* if (img) return img.filename
|
|
6830
|
+
* }
|
|
6831
|
+
* return undefined
|
|
6832
|
+
* },
|
|
6833
|
+
* { intervalMs: 1000, timeoutMs: 5 * 60_000 },
|
|
6834
|
+
* )
|
|
6835
|
+
* ```
|
|
6836
|
+
*/
|
|
6837
|
+
pollUntil<T>(label: string, init: EndpointCallInit, predicate: (body: any, res: Response) => T | undefined | Promise<T | undefined>, opts?: PollUntilOptions): Promise<T>;
|
|
6774
6838
|
}
|
|
6775
6839
|
/**
|
|
6776
6840
|
* EndpointAPI.call 의 init 인자.
|
|
@@ -6792,6 +6856,24 @@ interface EndpointCallInit {
|
|
|
6792
6856
|
/** 취소 신호. */
|
|
6793
6857
|
signal?: AbortSignal;
|
|
6794
6858
|
}
|
|
6859
|
+
/**
|
|
6860
|
+
* EndpointAPI.pollUntil 옵션.
|
|
6861
|
+
*/
|
|
6862
|
+
interface PollUntilOptions {
|
|
6863
|
+
/** 폴링 간격 (ms). 기본 1500. */
|
|
6864
|
+
intervalMs?: number;
|
|
6865
|
+
/** 전체 timeout (ms). 기본 300000 (5분). */
|
|
6866
|
+
timeoutMs?: number;
|
|
6867
|
+
/**
|
|
6868
|
+
* 응답 본문 파싱 방식.
|
|
6869
|
+
* - `"json"` (기본) — `res.json()`. 파싱 실패 시 predicate 에 `undefined` 전달.
|
|
6870
|
+
* - `"text"` — 문자열 그대로.
|
|
6871
|
+
* - `"none"` — 본문 사용 안 함 (예: 헤더 / status 만 보고 판단).
|
|
6872
|
+
*/
|
|
6873
|
+
parse?: "json" | "text" | "none";
|
|
6874
|
+
/** 외부 취소 신호. abort 시 즉시 reject. */
|
|
6875
|
+
signal?: AbortSignal;
|
|
6876
|
+
}
|
|
6795
6877
|
|
|
6796
6878
|
interface PublishMessageRequest {
|
|
6797
6879
|
body: unknown;
|
|
@@ -7288,4 +7370,4 @@ declare class ConnectBase {
|
|
|
7288
7370
|
updateConfig(config: Partial<ConnectBaseConfig>): void;
|
|
7289
7371
|
}
|
|
7290
7372
|
|
|
7291
|
-
export { AIAPI, type AIChatRequest, type AIChatResponse, type AIMessage, type AISource, type AIStreamChunk, type AITool, type AIToolCall, type AIToolEvent, type AckMessagesRequest, type AdMobDailyReport, type AdMobReportResponse, type AdMobReportSummary, type AdReportResponse, type AdReportSummary, type AdmobConnectionInfo, AdsAPI, type AdsenseConnectionInfo, type AggregateResult, type AggregateStage, type AnalyticsConfig, type AnalyticsEvent, ApiError, type ApiErrorDetail, type AppStatsResponse, type ArchivePolicy, type AtomicOperator, type AtomicOperatorType, AuthError, type AuthSettingsResponse, type BackupInfo, type BatchOperation, type BatchSetPageMetaRequest, type BillingCycle, type BillingKeyResponse, type BiometricInfo, type BiometricResult, type BulkCreateResponse, type BulkError, type CPUInfo, type CancelPaymentRequest, type CancelPaymentResponse, type CancelSubscriptionRequest, type CategoryInfo, type Channel, type ChannelMembership, type ChargeWithBillingKeyRequest, type ChargeWithBillingKeyResponse, type ChatMessage, type ClientMessage, type ColumnSchema, type CommentListResponse, type CompleteUploadRequest, type CompleteUploadResponse, type ConfirmBillingKeyRequest, type ConfirmPaymentRequest, type ConfirmPaymentResponse, ConnectBase, type ConnectBaseConfig, type ConnectedData, type ConnectionState, type ConsentOptions, type ConsumeMessagesResponse, type ConsumeOptions, type CopyTableRequest, type CopyTableResponse, type CreateBackupRequest, type CreateChannelRequest, type CreateCheckoutSessionRequest, type CreateCheckoutSessionResponse, type CreateColumnRequest, type CreateDataRequest, type CreateDocumentRequest, type CreateFolderRequest, type CreateFolderResponse, type CreateGeoIndexRequest, type CreateIndexRequest, type CreateLobbyRequest, type CreatePlaylistRequest, type CreatePublicKeyRequest, type CreatePublicKeyResponse, type CreateRelationRequest, type CreateSearchIndexRequest, type CreateSecurityRuleRequest, type CreateSubscriptionRequest, type CreateTableRequest, type CreateTriggerRequest, type CreateVideoStorageRequest, type DailyReport, type DataItem, type DataType, type DatabaseChange, type DatabaseChangeMessage, type DatabaseChangeType, type DatabaseRealtimeConnectOptions, type DatabaseRealtimeFilter, type DatabaseRealtimeHandlers, type DatabaseRealtimeSubscription, type DatabaseSnapshot, type DatabaseSnapshotMessage, type DatabaseSubscribeOptions, type DeleteWhereResponse, type DeviceInfo, type DocumentResponse, type EnabledProviderInfo, type EnabledProvidersResponse, EndpointAPI, type EndpointCallInit, type ErrorHandler, type ErrorMessage, type ErrorReport, type ErrorTrackerConfig, type ErrorType, type ExportDataRequest, type ExportDataResponse, type FetchDataResponse, type FetchFilesResponse, type FetchPublicKeysResponse, type FileItem, type FileStats, GameAPI, type GameAction, type GameClientConfig, type GameConnectionState, type GameConnectionStatus, type GameDelta, type GameEventHandlers, type GamePlayer, GameRoom, type GameRoomConfig, type GameRoomInfo, GameRoomTransport, type GameServerMessage, type GameServerMessageType, type GameState, type GameTransportConfig, type GenerateUploadURLByPathRequest, type GenerateUploadURLRequest, type GenerateUploadURLResponse, type GeoIndex, type GeoNear, type GeoPoint, type GeoPolygon, type GeoQuery, type GeoResponse, type GeoResult, type GeoWithin, type GetAuthorizationURLResponse, type GetFileByPathResponse, type GoogleConnectionStatus, type GuestMemberSignInResponse, type HistoryResponse, type ICEServer, type ICEServersResponse, type ImageResult, type ImportDataRequest, type ImportDataResponse, type IndexAnalysis, type IndexRecommendation, type InitUploadResponse, type InvokeFunctionRequest, type InvokeFunctionResponse, type IssueBillingKeyRequest, type IssueBillingKeyResponse, type JoinQueueRequest, type JoinRoomRequest, type JoinRoomResponse, type KnowledgeSearchRequest, type KnowledgeSearchResponse, type KnowledgeSearchResult, type LeaderboardEntry, type LeaderboardListResponse, type LeaderboardScoreEntry, type LifecyclePolicy, type ListBillingKeysResponse, type ListDocumentsResponse, type ListPageMetasOptions, type ListPageMetasResponse, type ListSubscriptionPaymentsRequest, type ListSubscriptionPaymentsResponse, type ListSubscriptionsRequest, type ListSubscriptionsResponse, type LobbyInfo, type LobbyInvite, type LobbyMember, type LobbyVisibility, type MatchResult, type MatchmakingTicket, type MatchqueueListResponse, type MatchqueueTicket, type MemberInfoResponse, type MemberSignInRequest, type MemberSignInResponse, type MemberSignUpRequest, type MemberSignUpResponse, type MembershipTier, type MemoryInfo, type MessageHandler, type MigrateDataRequest, type MigrateDataResponse, type MoveFileRequest, type NackMessageRequest, NativeAPI, type OAuthCallbackResponse, type OAuthProvider, type OpenDialogOptions, type OpenDialogResult, type PageMetaResponse, type PartyInfo, type PartyInvite, type PartyMember, type PauseSubscriptionRequest, type PaymentDetail, type PaymentProvider, type PaymentStatus, type PeerInfo, type Platform, type PlayerEvent, type PlayerStats, type Playlist, type PlaylistItem, type PongMessage, type PopulateOption, type Position, type PreparePaymentRequest, type PreparePaymentResponse, type PresenceChangeHandler, type PresenceInfo, type PresenceSetOptions, type PresenceStatus, type PresenceStatusResult, type PublicKeyItem, type PublishBatchRequest, type PublishBatchResponse, type PublishMessageRequest, type PublishMessageResponse, type PushPlatform, type QualityProgress, type QueryOptions, type QueueInfoResponse, type QueueMessage, type ReadReceiptHandler, type ReadReceiptInfo, type RealtimeConnectOptions, type RealtimeMessage, type RegisterDeviceRequest, type RelationType, type RenameFileRequest, type RenameFileResponse, type ReplayHighlight, type ReplayInfo, type ReplayPlayerInfo, type RestoreBackupRequest, type RestoreBackupResponse, type RetentionPolicy, type RoomInfo, type RoomStats, type RoomsResponse, type SaveDialogOptions, type SaveDialogResult, type ScriptDetailResponse, type ScriptListResponse, type ScriptMeta, type ScriptVersion, type ScriptVersionListResponse, type SearchIndex, type SearchOptions, type SearchResponse, type SearchResult, type SecurityRule, type SendOptions, type ServerMessage, SessionManager, type SetPageMetaRequest, type Shorts, type ShortsListResponse, type SignalingMessage, type SignalingMessageType, type SlowQueryInfo, type SpectatorInfo, type SpectatorPlayerState, type SpectatorState, type StateChange, type StateChangeHandler, type StorageUploadOptions, type StreamDoneCallback, type StreamDoneData, type StreamErrorCallback, type StreamHandlers, type StreamMessage, type StreamOptions, type StreamSession, type StreamTokenCallback, type StreamToolCallCallback, type StreamToolResultCallback, type StreamURLResponse, type SubscribeOptions, type SubscribeTopicRequest, type SubscribedData, type Subscription, type SubscriptionPaymentResponse, type SubscriptionPaymentStatus, type SubscriptionResponse, type SubscriptionStatus, type SuperChat, type SystemInfo, type TTLConfig, type TableAccessLevel, type TableColumnDef, type TableIndex, type TableRelation, type TableSchema, type TableSchemaDefinition, type TokenPersistence, type TransactionRead, type TransactionWrite, type TranscodeStatus, type TransportType, type Trigger, type TriggerEvent, type TriggerHandlerType, type TypingChangeHandler, type TypingInfo, type UpdateBillingKeyRequest, type UpdateChannelRequest, type UpdateColumnRequest, type UpdateCustomDataRequest, type UpdateCustomDataResponse, type UpdateDataRequest, type UpdateLobbyRequest, type UpdatePublicKeyRequest, type UpdatePublicKeyResponse, type UpdateSecurityRuleRequest, type UpdateSubscriptionRequest, type UpdateTriggerRequest, type UpdateVideoRequest, type UpdateVideoStorageRequest, type UploadByPathOptions, type UploadFileResponse, type UploadOptions, type UploadProgress, type VAPIDPublicKeyResponse, type ValidateResponse, type ValidationSchema, type ValidationSchemaField, type ValidationStateTransitions, type Video, type VideoComment, type VideoListOptions, type VideoListResponse, VideoProcessingError, type VideoQuality, type VideoStatus, type VideoStorage, type VideoStorageListResponse, type VideoVisibility, type VoiceChannel, type VoiceMember, type WaitOptions, type WatchHistoryItem, type WebPushSubscription, type WebRTCConnectOptions, type WebRTCConnectionState, type WebRTCMode, type WhereCondition, type WhereOperator, ConnectBase as default, isWebTransportSupported };
|
|
7373
|
+
export { AIAPI, type AIChatRequest, type AIChatResponse, type AIMessage, type AISource, type AIStreamChunk, type AITool, type AIToolCall, type AIToolEvent, type AckMessagesRequest, type AdMobDailyReport, type AdMobReportResponse, type AdMobReportSummary, type AdReportResponse, type AdReportSummary, type AdmobConnectionInfo, AdsAPI, type AdsenseConnectionInfo, type AggregateResult, type AggregateStage, type AnalyticsConfig, type AnalyticsEvent, ApiError, type ApiErrorDetail, type AppStatsResponse, type ArchivePolicy, type AtomicOperator, type AtomicOperatorType, AuthError, type AuthSettingsResponse, type BackupInfo, type BatchOperation, type BatchSetPageMetaRequest, type BillingCycle, type BillingKeyResponse, type BiometricInfo, type BiometricResult, type BulkCreateResponse, type BulkError, type CPUInfo, type CancelPaymentRequest, type CancelPaymentResponse, type CancelSubscriptionRequest, type CategoryInfo, type Channel, type ChannelMembership, type ChargeWithBillingKeyRequest, type ChargeWithBillingKeyResponse, type ChatMessage, type ClientMessage, type ColumnSchema, type CommentListResponse, type CompleteUploadRequest, type CompleteUploadResponse, type ConfirmBillingKeyRequest, type ConfirmPaymentRequest, type ConfirmPaymentResponse, ConnectBase, type ConnectBaseConfig, type ConnectedData, type ConnectionState, type ConsentOptions, type ConsumeMessagesResponse, type ConsumeOptions, type CopyTableRequest, type CopyTableResponse, type CreateBackupRequest, type CreateChannelRequest, type CreateCheckoutSessionRequest, type CreateCheckoutSessionResponse, type CreateColumnRequest, type CreateDataRequest, type CreateDocumentRequest, type CreateFolderRequest, type CreateFolderResponse, type CreateGeoIndexRequest, type CreateIndexRequest, type CreateLobbyRequest, type CreatePlaylistRequest, type CreatePublicKeyRequest, type CreatePublicKeyResponse, type CreateRelationRequest, type CreateSearchIndexRequest, type CreateSecurityRuleRequest, type CreateSubscriptionRequest, type CreateTableRequest, type CreateTriggerRequest, type CreateVideoStorageRequest, type DailyReport, type DataItem, type DataType, type DatabaseChange, type DatabaseChangeMessage, type DatabaseChangeType, type DatabaseRealtimeConnectOptions, type DatabaseRealtimeFilter, type DatabaseRealtimeHandlers, type DatabaseRealtimeSubscription, type DatabaseSnapshot, type DatabaseSnapshotMessage, type DatabaseSubscribeOptions, type DeleteWhereResponse, type DeviceInfo, type DocumentResponse, type EnabledProviderInfo, type EnabledProvidersResponse, EndpointAPI, type EndpointCallInit, type ErrorHandler, type ErrorMessage, type ErrorReport, type ErrorTrackerConfig, type ErrorType, type ExportDataRequest, type ExportDataResponse, type FetchDataResponse, type FetchFilesResponse, type FetchPublicKeysResponse, type FileItem, type FileStats, GameAPI, type GameAction, type GameClientConfig, type GameConnectionState, type GameConnectionStatus, type GameDelta, type GameEventHandlers, type GamePlayer, GameRoom, type GameRoomConfig, type GameRoomInfo, GameRoomTransport, type GameServerMessage, type GameServerMessageType, type GameState, type GameTransportConfig, type GenerateUploadURLByPathRequest, type GenerateUploadURLRequest, type GenerateUploadURLResponse, type GeoIndex, type GeoNear, type GeoPoint, type GeoPolygon, type GeoQuery, type GeoResponse, type GeoResult, type GeoWithin, type GetAuthorizationURLResponse, type GetFileByPathResponse, type GoogleConnectionStatus, type GuestMemberSignInResponse, type HistoryResponse, type ICEServer, type ICEServersResponse, type ImageResult, type ImportDataRequest, type ImportDataResponse, type IndexAnalysis, type IndexRecommendation, type InitUploadResponse, type InvokeFunctionRequest, type InvokeFunctionResponse, type IssueBillingKeyRequest, type IssueBillingKeyResponse, type JoinQueueRequest, type JoinRoomRequest, type JoinRoomResponse, type KnowledgeSearchRequest, type KnowledgeSearchResponse, type KnowledgeSearchResult, type LeaderboardEntry, type LeaderboardListResponse, type LeaderboardScoreEntry, type LifecyclePolicy, type ListBillingKeysResponse, type ListDocumentsResponse, type ListPageMetasOptions, type ListPageMetasResponse, type ListSubscriptionPaymentsRequest, type ListSubscriptionPaymentsResponse, type ListSubscriptionsRequest, type ListSubscriptionsResponse, type LobbyInfo, type LobbyInvite, type LobbyMember, type LobbyVisibility, type MatchResult, type MatchmakingTicket, type MatchqueueListResponse, type MatchqueueTicket, type MemberInfoResponse, type MemberSignInRequest, type MemberSignInResponse, type MemberSignUpRequest, type MemberSignUpResponse, type MembershipTier, type MemoryInfo, type MessageHandler, type MigrateDataRequest, type MigrateDataResponse, type MoveFileRequest, type NackMessageRequest, NativeAPI, type OAuthCallbackResponse, type OAuthProvider, type OpenDialogOptions, type OpenDialogResult, type PageMetaResponse, type PartyInfo, type PartyInvite, type PartyMember, type PauseSubscriptionRequest, type PaymentDetail, type PaymentProvider, type PaymentStatus, type PeerInfo, type Platform, type PlayerEvent, type PlayerStats, type Playlist, type PlaylistItem, type PollUntilOptions, type PongMessage, type PopulateOption, type Position, type PreparePaymentRequest, type PreparePaymentResponse, type PresenceChangeHandler, type PresenceInfo, type PresenceSetOptions, type PresenceStatus, type PresenceStatusResult, type PublicKeyItem, type PublishBatchRequest, type PublishBatchResponse, type PublishMessageRequest, type PublishMessageResponse, type PushPlatform, type QualityProgress, type QueryOptions, type QueueInfoResponse, type QueueMessage, type ReadReceiptHandler, type ReadReceiptInfo, type RealtimeConnectOptions, type RealtimeMessage, type RegisterDeviceRequest, type RelationType, type RenameFileRequest, type RenameFileResponse, type ReplayHighlight, type ReplayInfo, type ReplayPlayerInfo, type RestoreBackupRequest, type RestoreBackupResponse, type RetentionPolicy, type RoomInfo, type RoomStats, type RoomsResponse, type SaveDialogOptions, type SaveDialogResult, type ScriptDetailResponse, type ScriptListResponse, type ScriptMeta, type ScriptVersion, type ScriptVersionListResponse, type SearchIndex, type SearchOptions, type SearchResponse, type SearchResult, type SecurityRule, type SendOptions, type ServerMessage, SessionManager, type SetPageMetaRequest, type Shorts, type ShortsListResponse, type SignalingMessage, type SignalingMessageType, type SlowQueryInfo, type SpectatorInfo, type SpectatorPlayerState, type SpectatorState, type StateChange, type StateChangeHandler, type StorageUploadOptions, type StreamDoneCallback, type StreamDoneData, type StreamErrorCallback, type StreamHandlers, type StreamMessage, type StreamOptions, type StreamSession, type StreamTokenCallback, type StreamToolCallCallback, type StreamToolResultCallback, type StreamURLResponse, type SubscribeOptions, type SubscribeTopicRequest, type SubscribedData, type Subscription, type SubscriptionPaymentResponse, type SubscriptionPaymentStatus, type SubscriptionResponse, type SubscriptionStatus, type SuperChat, type SystemInfo, type TTLConfig, type TableAccessLevel, type TableColumnDef, type TableIndex, type TableRelation, type TableSchema, type TableSchemaDefinition, type TokenPersistence, type TransactionRead, type TransactionWrite, type TranscodeStatus, type TransportType, type Trigger, type TriggerEvent, type TriggerHandlerType, type TypingChangeHandler, type TypingInfo, type UpdateBillingKeyRequest, type UpdateChannelRequest, type UpdateColumnRequest, type UpdateCustomDataRequest, type UpdateCustomDataResponse, type UpdateDataRequest, type UpdateLobbyRequest, type UpdatePublicKeyRequest, type UpdatePublicKeyResponse, type UpdateSecurityRuleRequest, type UpdateSubscriptionRequest, type UpdateTriggerRequest, type UpdateVideoRequest, type UpdateVideoStorageRequest, type UploadByPathOptions, type UploadFileResponse, type UploadOptions, type UploadProgress, type VAPIDPublicKeyResponse, type ValidateResponse, type ValidationSchema, type ValidationSchemaField, type ValidationStateTransitions, type Video, type VideoComment, type VideoListOptions, type VideoListResponse, VideoProcessingError, type VideoQuality, type VideoStatus, type VideoStorage, type VideoStorageListResponse, type VideoVisibility, type VoiceChannel, type VoiceMember, type WaitOptions, type WatchHistoryItem, type WebPushSubscription, type WebRTCConnectOptions, type WebRTCConnectionState, type WebRTCMode, type WhereCondition, type WhereOperator, ConnectBase as default, isWebTransportSupported };
|
package/dist/index.js
CHANGED
|
@@ -7697,8 +7697,7 @@ var EndpointAPI = class {
|
|
|
7697
7697
|
`EndpointAPI.call: path must start with '/', got ${JSON.stringify(init.path)}`
|
|
7698
7698
|
);
|
|
7699
7699
|
}
|
|
7700
|
-
const
|
|
7701
|
-
const url = `${baseUrl}/v1/proxy/${encodeURIComponent(label)}${init.path}`;
|
|
7700
|
+
const url = this.url(label, init.path);
|
|
7702
7701
|
const headers = new Headers(init.headers ?? {});
|
|
7703
7702
|
if (!headers.has("X-Public-Key")) {
|
|
7704
7703
|
const pk = this.http.getPublicKey();
|
|
@@ -7718,7 +7717,141 @@ var EndpointAPI = class {
|
|
|
7718
7717
|
redirect: "follow"
|
|
7719
7718
|
});
|
|
7720
7719
|
}
|
|
7720
|
+
/**
|
|
7721
|
+
* 라벨 + path 의 최종 호출 URL `${baseUrl}/v1/proxy/${label}${path}` 을 조립해서
|
|
7722
|
+
* 반환. URL 을 다른 시스템 (Service Worker, 백엔드 워커, 로깅) 에 넘기거나
|
|
7723
|
+
* 디버깅 용도일 때 사용.
|
|
7724
|
+
*
|
|
7725
|
+
* ⚠️ **`<img src>` / 네이티브 `WebSocket` / `<script src>` / `EventSource` 처럼
|
|
7726
|
+
* 커스텀 헤더를 못 보내는 브라우저 API 에 직접 넘기면 401 입니다.** ConnectBase
|
|
7727
|
+
* 프록시는 모든 요청에 `X-Public-Key` 헤더를 요구하고, 쿼리 파라미터 폴백은
|
|
7728
|
+
* 제공하지 않습니다. 그런 경우엔 `call()` 로 받아서 Blob URL 로 변환하세요.
|
|
7729
|
+
*
|
|
7730
|
+
* @example URL 을 워커로 넘겨 호출 (✅)
|
|
7731
|
+
* ```typescript
|
|
7732
|
+
* sw.postMessage({
|
|
7733
|
+
* url: cb.endpoint.url("comfyui-main", "/prompt"),
|
|
7734
|
+
* key: publicKey, // 워커가 X-Public-Key 헤더로 부착
|
|
7735
|
+
* })
|
|
7736
|
+
* ```
|
|
7737
|
+
*
|
|
7738
|
+
* @example 이미지 렌더링은 call() + Blob URL 패턴으로 (✅)
|
|
7739
|
+
* ```typescript
|
|
7740
|
+
* const res = await cb.endpoint.call("comfyui-main", {
|
|
7741
|
+
* path: `/view?filename=${encodeURIComponent(name)}`,
|
|
7742
|
+
* })
|
|
7743
|
+
* img.src = URL.createObjectURL(await res.blob())
|
|
7744
|
+
* // 나중에 URL.revokeObjectURL(img.src)
|
|
7745
|
+
* ```
|
|
7746
|
+
*/
|
|
7747
|
+
url(label, path) {
|
|
7748
|
+
if (!label) throw new Error("EndpointAPI.url: label required");
|
|
7749
|
+
if (!path || !path.startsWith("/")) {
|
|
7750
|
+
throw new Error(
|
|
7751
|
+
`EndpointAPI.url: path must start with '/', got ${JSON.stringify(path)}`
|
|
7752
|
+
);
|
|
7753
|
+
}
|
|
7754
|
+
const baseUrl = this.http.getBaseUrl().replace(/\/+$/, "");
|
|
7755
|
+
return `${baseUrl}/v1/proxy/${encodeURIComponent(label)}${path}`;
|
|
7756
|
+
}
|
|
7757
|
+
/**
|
|
7758
|
+
* 같은 endpoint 호출을 `predicate` 가 값을 반환할 때까지 주기적으로 반복.
|
|
7759
|
+
* ComfyUI `/history/{id}`, A1111 `/sdapi/v1/progress`, 자체 큐 API 처럼
|
|
7760
|
+
* "작업 제출 → 폴링" 패턴을 한 줄로 처리하기 위한 헬퍼.
|
|
7761
|
+
*
|
|
7762
|
+
* 동작:
|
|
7763
|
+
* - `call(label, init)` → predicate(response) 호출
|
|
7764
|
+
* - predicate 가 `undefined` 면 `intervalMs` 만큼 대기 후 재시도
|
|
7765
|
+
* - predicate 가 값을 반환하면 그 값을 즉시 resolve
|
|
7766
|
+
* - `timeoutMs` 초과 또는 `signal` abort 시 reject
|
|
7767
|
+
* - HTTP 5xx/네트워크 오류는 재시도, 4xx 는 즉시 reject (작업 자체가 잘못된 경우)
|
|
7768
|
+
*
|
|
7769
|
+
* predicate 는 같은 Response 를 한 번만 읽을 수 있으므로, 헬퍼 내부에서
|
|
7770
|
+
* `res.clone().json()` 형태로 안전하게 파싱한 뒤 호출자에게 전달.
|
|
7771
|
+
*
|
|
7772
|
+
* @example ComfyUI 결과 폴링
|
|
7773
|
+
* ```typescript
|
|
7774
|
+
* type Hist = Record<string, { outputs: Record<string, { images?: { filename: string }[] }> }>
|
|
7775
|
+
*
|
|
7776
|
+
* const filename = await cb.endpoint.pollUntil<string>(
|
|
7777
|
+
* "comfyui-main",
|
|
7778
|
+
* { path: `/history/${promptId}` },
|
|
7779
|
+
* (data: Hist) => {
|
|
7780
|
+
* const entry = data[promptId]
|
|
7781
|
+
* if (!entry) return undefined // 아직 큐에 있음
|
|
7782
|
+
* for (const out of Object.values(entry.outputs)) {
|
|
7783
|
+
* const img = out.images?.[0]
|
|
7784
|
+
* if (img) return img.filename
|
|
7785
|
+
* }
|
|
7786
|
+
* return undefined
|
|
7787
|
+
* },
|
|
7788
|
+
* { intervalMs: 1000, timeoutMs: 5 * 60_000 },
|
|
7789
|
+
* )
|
|
7790
|
+
* ```
|
|
7791
|
+
*/
|
|
7792
|
+
async pollUntil(label, init, predicate, opts = {}) {
|
|
7793
|
+
const intervalMs = opts.intervalMs ?? 1500;
|
|
7794
|
+
const timeoutMs = opts.timeoutMs ?? 5 * 6e4;
|
|
7795
|
+
const parser = opts.parse ?? "json";
|
|
7796
|
+
const start = Date.now();
|
|
7797
|
+
while (true) {
|
|
7798
|
+
if (opts.signal?.aborted) {
|
|
7799
|
+
throw new DOMException("aborted", "AbortError");
|
|
7800
|
+
}
|
|
7801
|
+
if (Date.now() - start > timeoutMs) {
|
|
7802
|
+
throw new Error(
|
|
7803
|
+
`EndpointAPI.pollUntil: timeout after ${timeoutMs}ms (label=${label}, path=${init.path})`
|
|
7804
|
+
);
|
|
7805
|
+
}
|
|
7806
|
+
let res;
|
|
7807
|
+
try {
|
|
7808
|
+
res = await this.call(label, { ...init, signal: opts.signal });
|
|
7809
|
+
} catch (err) {
|
|
7810
|
+
if (err.name === "AbortError") throw err;
|
|
7811
|
+
await sleep(intervalMs, opts.signal);
|
|
7812
|
+
continue;
|
|
7813
|
+
}
|
|
7814
|
+
if (res.status >= 500) {
|
|
7815
|
+
await drainBody(res);
|
|
7816
|
+
await sleep(intervalMs, opts.signal);
|
|
7817
|
+
continue;
|
|
7818
|
+
}
|
|
7819
|
+
if (res.status >= 400) {
|
|
7820
|
+
const text = await res.text().catch(() => "");
|
|
7821
|
+
throw new Error(
|
|
7822
|
+
`EndpointAPI.pollUntil: ${res.status} ${res.statusText} (label=${label}, path=${init.path})${text ? ` \u2014 ${text.slice(0, 200)}` : ""}`
|
|
7823
|
+
);
|
|
7824
|
+
}
|
|
7825
|
+
let body;
|
|
7826
|
+
if (parser === "text") body = await res.text();
|
|
7827
|
+
else if (parser === "none") body = void 0;
|
|
7828
|
+
else body = await res.json().catch(() => void 0);
|
|
7829
|
+
const result = await predicate(body, res);
|
|
7830
|
+
if (result !== void 0) return result;
|
|
7831
|
+
await sleep(intervalMs, opts.signal);
|
|
7832
|
+
}
|
|
7833
|
+
}
|
|
7721
7834
|
};
|
|
7835
|
+
async function sleep(ms, signal) {
|
|
7836
|
+
if (signal?.aborted) throw new DOMException("aborted", "AbortError");
|
|
7837
|
+
return new Promise((resolve, reject) => {
|
|
7838
|
+
const t = setTimeout(() => {
|
|
7839
|
+
signal?.removeEventListener("abort", onAbort);
|
|
7840
|
+
resolve();
|
|
7841
|
+
}, ms);
|
|
7842
|
+
const onAbort = () => {
|
|
7843
|
+
clearTimeout(t);
|
|
7844
|
+
reject(new DOMException("aborted", "AbortError"));
|
|
7845
|
+
};
|
|
7846
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
7847
|
+
});
|
|
7848
|
+
}
|
|
7849
|
+
async function drainBody(res) {
|
|
7850
|
+
try {
|
|
7851
|
+
await res.text();
|
|
7852
|
+
} catch {
|
|
7853
|
+
}
|
|
7854
|
+
}
|
|
7722
7855
|
|
|
7723
7856
|
// src/api/queue.ts
|
|
7724
7857
|
var QueueAPI = class {
|
package/dist/index.mjs
CHANGED
|
@@ -7658,8 +7658,7 @@ var EndpointAPI = class {
|
|
|
7658
7658
|
`EndpointAPI.call: path must start with '/', got ${JSON.stringify(init.path)}`
|
|
7659
7659
|
);
|
|
7660
7660
|
}
|
|
7661
|
-
const
|
|
7662
|
-
const url = `${baseUrl}/v1/proxy/${encodeURIComponent(label)}${init.path}`;
|
|
7661
|
+
const url = this.url(label, init.path);
|
|
7663
7662
|
const headers = new Headers(init.headers ?? {});
|
|
7664
7663
|
if (!headers.has("X-Public-Key")) {
|
|
7665
7664
|
const pk = this.http.getPublicKey();
|
|
@@ -7679,7 +7678,141 @@ var EndpointAPI = class {
|
|
|
7679
7678
|
redirect: "follow"
|
|
7680
7679
|
});
|
|
7681
7680
|
}
|
|
7681
|
+
/**
|
|
7682
|
+
* 라벨 + path 의 최종 호출 URL `${baseUrl}/v1/proxy/${label}${path}` 을 조립해서
|
|
7683
|
+
* 반환. URL 을 다른 시스템 (Service Worker, 백엔드 워커, 로깅) 에 넘기거나
|
|
7684
|
+
* 디버깅 용도일 때 사용.
|
|
7685
|
+
*
|
|
7686
|
+
* ⚠️ **`<img src>` / 네이티브 `WebSocket` / `<script src>` / `EventSource` 처럼
|
|
7687
|
+
* 커스텀 헤더를 못 보내는 브라우저 API 에 직접 넘기면 401 입니다.** ConnectBase
|
|
7688
|
+
* 프록시는 모든 요청에 `X-Public-Key` 헤더를 요구하고, 쿼리 파라미터 폴백은
|
|
7689
|
+
* 제공하지 않습니다. 그런 경우엔 `call()` 로 받아서 Blob URL 로 변환하세요.
|
|
7690
|
+
*
|
|
7691
|
+
* @example URL 을 워커로 넘겨 호출 (✅)
|
|
7692
|
+
* ```typescript
|
|
7693
|
+
* sw.postMessage({
|
|
7694
|
+
* url: cb.endpoint.url("comfyui-main", "/prompt"),
|
|
7695
|
+
* key: publicKey, // 워커가 X-Public-Key 헤더로 부착
|
|
7696
|
+
* })
|
|
7697
|
+
* ```
|
|
7698
|
+
*
|
|
7699
|
+
* @example 이미지 렌더링은 call() + Blob URL 패턴으로 (✅)
|
|
7700
|
+
* ```typescript
|
|
7701
|
+
* const res = await cb.endpoint.call("comfyui-main", {
|
|
7702
|
+
* path: `/view?filename=${encodeURIComponent(name)}`,
|
|
7703
|
+
* })
|
|
7704
|
+
* img.src = URL.createObjectURL(await res.blob())
|
|
7705
|
+
* // 나중에 URL.revokeObjectURL(img.src)
|
|
7706
|
+
* ```
|
|
7707
|
+
*/
|
|
7708
|
+
url(label, path) {
|
|
7709
|
+
if (!label) throw new Error("EndpointAPI.url: label required");
|
|
7710
|
+
if (!path || !path.startsWith("/")) {
|
|
7711
|
+
throw new Error(
|
|
7712
|
+
`EndpointAPI.url: path must start with '/', got ${JSON.stringify(path)}`
|
|
7713
|
+
);
|
|
7714
|
+
}
|
|
7715
|
+
const baseUrl = this.http.getBaseUrl().replace(/\/+$/, "");
|
|
7716
|
+
return `${baseUrl}/v1/proxy/${encodeURIComponent(label)}${path}`;
|
|
7717
|
+
}
|
|
7718
|
+
/**
|
|
7719
|
+
* 같은 endpoint 호출을 `predicate` 가 값을 반환할 때까지 주기적으로 반복.
|
|
7720
|
+
* ComfyUI `/history/{id}`, A1111 `/sdapi/v1/progress`, 자체 큐 API 처럼
|
|
7721
|
+
* "작업 제출 → 폴링" 패턴을 한 줄로 처리하기 위한 헬퍼.
|
|
7722
|
+
*
|
|
7723
|
+
* 동작:
|
|
7724
|
+
* - `call(label, init)` → predicate(response) 호출
|
|
7725
|
+
* - predicate 가 `undefined` 면 `intervalMs` 만큼 대기 후 재시도
|
|
7726
|
+
* - predicate 가 값을 반환하면 그 값을 즉시 resolve
|
|
7727
|
+
* - `timeoutMs` 초과 또는 `signal` abort 시 reject
|
|
7728
|
+
* - HTTP 5xx/네트워크 오류는 재시도, 4xx 는 즉시 reject (작업 자체가 잘못된 경우)
|
|
7729
|
+
*
|
|
7730
|
+
* predicate 는 같은 Response 를 한 번만 읽을 수 있으므로, 헬퍼 내부에서
|
|
7731
|
+
* `res.clone().json()` 형태로 안전하게 파싱한 뒤 호출자에게 전달.
|
|
7732
|
+
*
|
|
7733
|
+
* @example ComfyUI 결과 폴링
|
|
7734
|
+
* ```typescript
|
|
7735
|
+
* type Hist = Record<string, { outputs: Record<string, { images?: { filename: string }[] }> }>
|
|
7736
|
+
*
|
|
7737
|
+
* const filename = await cb.endpoint.pollUntil<string>(
|
|
7738
|
+
* "comfyui-main",
|
|
7739
|
+
* { path: `/history/${promptId}` },
|
|
7740
|
+
* (data: Hist) => {
|
|
7741
|
+
* const entry = data[promptId]
|
|
7742
|
+
* if (!entry) return undefined // 아직 큐에 있음
|
|
7743
|
+
* for (const out of Object.values(entry.outputs)) {
|
|
7744
|
+
* const img = out.images?.[0]
|
|
7745
|
+
* if (img) return img.filename
|
|
7746
|
+
* }
|
|
7747
|
+
* return undefined
|
|
7748
|
+
* },
|
|
7749
|
+
* { intervalMs: 1000, timeoutMs: 5 * 60_000 },
|
|
7750
|
+
* )
|
|
7751
|
+
* ```
|
|
7752
|
+
*/
|
|
7753
|
+
async pollUntil(label, init, predicate, opts = {}) {
|
|
7754
|
+
const intervalMs = opts.intervalMs ?? 1500;
|
|
7755
|
+
const timeoutMs = opts.timeoutMs ?? 5 * 6e4;
|
|
7756
|
+
const parser = opts.parse ?? "json";
|
|
7757
|
+
const start = Date.now();
|
|
7758
|
+
while (true) {
|
|
7759
|
+
if (opts.signal?.aborted) {
|
|
7760
|
+
throw new DOMException("aborted", "AbortError");
|
|
7761
|
+
}
|
|
7762
|
+
if (Date.now() - start > timeoutMs) {
|
|
7763
|
+
throw new Error(
|
|
7764
|
+
`EndpointAPI.pollUntil: timeout after ${timeoutMs}ms (label=${label}, path=${init.path})`
|
|
7765
|
+
);
|
|
7766
|
+
}
|
|
7767
|
+
let res;
|
|
7768
|
+
try {
|
|
7769
|
+
res = await this.call(label, { ...init, signal: opts.signal });
|
|
7770
|
+
} catch (err) {
|
|
7771
|
+
if (err.name === "AbortError") throw err;
|
|
7772
|
+
await sleep(intervalMs, opts.signal);
|
|
7773
|
+
continue;
|
|
7774
|
+
}
|
|
7775
|
+
if (res.status >= 500) {
|
|
7776
|
+
await drainBody(res);
|
|
7777
|
+
await sleep(intervalMs, opts.signal);
|
|
7778
|
+
continue;
|
|
7779
|
+
}
|
|
7780
|
+
if (res.status >= 400) {
|
|
7781
|
+
const text = await res.text().catch(() => "");
|
|
7782
|
+
throw new Error(
|
|
7783
|
+
`EndpointAPI.pollUntil: ${res.status} ${res.statusText} (label=${label}, path=${init.path})${text ? ` \u2014 ${text.slice(0, 200)}` : ""}`
|
|
7784
|
+
);
|
|
7785
|
+
}
|
|
7786
|
+
let body;
|
|
7787
|
+
if (parser === "text") body = await res.text();
|
|
7788
|
+
else if (parser === "none") body = void 0;
|
|
7789
|
+
else body = await res.json().catch(() => void 0);
|
|
7790
|
+
const result = await predicate(body, res);
|
|
7791
|
+
if (result !== void 0) return result;
|
|
7792
|
+
await sleep(intervalMs, opts.signal);
|
|
7793
|
+
}
|
|
7794
|
+
}
|
|
7682
7795
|
};
|
|
7796
|
+
async function sleep(ms, signal) {
|
|
7797
|
+
if (signal?.aborted) throw new DOMException("aborted", "AbortError");
|
|
7798
|
+
return new Promise((resolve, reject) => {
|
|
7799
|
+
const t = setTimeout(() => {
|
|
7800
|
+
signal?.removeEventListener("abort", onAbort);
|
|
7801
|
+
resolve();
|
|
7802
|
+
}, ms);
|
|
7803
|
+
const onAbort = () => {
|
|
7804
|
+
clearTimeout(t);
|
|
7805
|
+
reject(new DOMException("aborted", "AbortError"));
|
|
7806
|
+
};
|
|
7807
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
7808
|
+
});
|
|
7809
|
+
}
|
|
7810
|
+
async function drainBody(res) {
|
|
7811
|
+
try {
|
|
7812
|
+
await res.text();
|
|
7813
|
+
} catch {
|
|
7814
|
+
}
|
|
7815
|
+
}
|
|
7683
7816
|
|
|
7684
7817
|
// src/api/queue.ts
|
|
7685
7818
|
var QueueAPI = class {
|