connectbase-client 0.5.2 → 0.6.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/dist/index.d.mts CHANGED
@@ -276,6 +276,254 @@ interface BulkError {
276
276
  interface DeleteWhereResponse {
277
277
  deleted: number;
278
278
  }
279
+ interface SecurityRule {
280
+ id: string;
281
+ app_id: string;
282
+ table_name: string;
283
+ rules: Record<string, unknown>;
284
+ is_active: boolean;
285
+ priority: number;
286
+ created_at: string;
287
+ updated_at: string;
288
+ }
289
+ interface CreateSecurityRuleRequest {
290
+ table_name: string;
291
+ rules: Record<string, unknown>;
292
+ is_active?: boolean;
293
+ priority?: number;
294
+ }
295
+ interface UpdateSecurityRuleRequest {
296
+ rules?: Record<string, unknown>;
297
+ is_active?: boolean;
298
+ priority?: number;
299
+ }
300
+ interface TableIndex {
301
+ id: string;
302
+ name: string;
303
+ fields: string[];
304
+ unique: boolean;
305
+ sparse: boolean;
306
+ created_at: string;
307
+ }
308
+ interface CreateIndexRequest {
309
+ name: string;
310
+ fields: string[];
311
+ unique?: boolean;
312
+ sparse?: boolean;
313
+ }
314
+ interface IndexAnalysis {
315
+ recommendations: IndexRecommendation[];
316
+ slow_queries: SlowQueryInfo[];
317
+ existing_indexes: TableIndex[];
318
+ summary: {
319
+ total_queries: number;
320
+ slow_query_count: number;
321
+ avg_response_time: number;
322
+ index_utilization: number;
323
+ recommended_count: number;
324
+ };
325
+ }
326
+ interface IndexRecommendation {
327
+ fields: string[];
328
+ reason: string;
329
+ estimated_improvement: string;
330
+ priority: string;
331
+ query_count: number;
332
+ avg_query_time: number;
333
+ }
334
+ interface SlowQueryInfo {
335
+ pattern: string;
336
+ count: number;
337
+ avg_time: number;
338
+ }
339
+ type RelationType = 'one-to-one' | 'one-to-many' | 'many-to-many';
340
+ interface TableRelation {
341
+ id: string;
342
+ app_id: string;
343
+ source_table: string;
344
+ source_field: string;
345
+ target_table: string;
346
+ target_field: string;
347
+ relation_type: RelationType;
348
+ alias: string;
349
+ cascade_delete: boolean;
350
+ created_at: string;
351
+ updated_at: string;
352
+ }
353
+ interface CreateRelationRequest {
354
+ source_table: string;
355
+ source_field: string;
356
+ target_table: string;
357
+ target_field?: string;
358
+ relation_type: RelationType;
359
+ alias?: string;
360
+ cascade_delete?: boolean;
361
+ }
362
+ interface PopulateOption {
363
+ field: string;
364
+ from?: string;
365
+ as?: string;
366
+ select?: string[];
367
+ limit?: number;
368
+ orderBy?: string;
369
+ order?: 'asc' | 'desc';
370
+ populate?: PopulateOption[];
371
+ }
372
+ type TriggerEvent = 'create' | 'update' | 'delete' | 'all';
373
+ type TriggerHandlerType = 'function' | 'workflow' | 'webhook';
374
+ interface Trigger {
375
+ id: string;
376
+ app_id: string;
377
+ name: string;
378
+ table_name: string;
379
+ event: TriggerEvent;
380
+ condition?: Record<string, unknown>;
381
+ handler_type: TriggerHandlerType;
382
+ handler_id?: string;
383
+ handler_url?: string;
384
+ is_active: boolean;
385
+ order: number;
386
+ created_at: string;
387
+ updated_at: string;
388
+ }
389
+ interface CreateTriggerRequest {
390
+ name: string;
391
+ table_name: string;
392
+ event: TriggerEvent;
393
+ handler_type: TriggerHandlerType;
394
+ handler_id?: string;
395
+ handler_url?: string;
396
+ condition?: Record<string, unknown>;
397
+ is_active?: boolean;
398
+ order?: number;
399
+ }
400
+ interface UpdateTriggerRequest {
401
+ name?: string;
402
+ event?: TriggerEvent;
403
+ handler_type?: TriggerHandlerType;
404
+ handler_id?: string;
405
+ handler_url?: string;
406
+ condition?: Record<string, unknown>;
407
+ is_active?: boolean;
408
+ order?: number;
409
+ }
410
+ interface AggregateStage {
411
+ match?: Record<string, unknown>;
412
+ group?: {
413
+ _id: string | Record<string, unknown>;
414
+ [key: string]: unknown;
415
+ };
416
+ sort?: Record<string, 1 | -1>;
417
+ limit?: number;
418
+ skip?: number;
419
+ project?: Record<string, unknown>;
420
+ unwind?: string;
421
+ count?: string;
422
+ lookup?: {
423
+ from: string;
424
+ local_field: string;
425
+ foreign_field: string;
426
+ as: string;
427
+ };
428
+ }
429
+ interface AggregateResult {
430
+ results: Record<string, unknown>[];
431
+ total: number;
432
+ }
433
+ interface SearchOptions {
434
+ case_sensitive?: boolean;
435
+ whole_word?: boolean;
436
+ fuzzy?: boolean;
437
+ fuzzy_distance?: number;
438
+ highlight?: boolean;
439
+ limit?: number;
440
+ offset?: number;
441
+ min_score?: number;
442
+ }
443
+ interface SearchResult {
444
+ id: string;
445
+ data: Record<string, unknown>;
446
+ score: number;
447
+ highlights?: Record<string, string>;
448
+ }
449
+ interface SearchResponse {
450
+ results: SearchResult[];
451
+ total: number;
452
+ }
453
+ interface GeoPoint {
454
+ latitude: number;
455
+ longitude: number;
456
+ }
457
+ interface GeoNear {
458
+ center: GeoPoint;
459
+ max_distance: number;
460
+ min_distance?: number;
461
+ }
462
+ interface GeoWithin {
463
+ box: {
464
+ bottom_left: GeoPoint;
465
+ top_right: GeoPoint;
466
+ };
467
+ }
468
+ interface GeoPolygon {
469
+ points: GeoPoint[];
470
+ }
471
+ interface GeoQuery {
472
+ near?: GeoNear;
473
+ within?: GeoWithin;
474
+ polygon?: GeoPolygon;
475
+ }
476
+ interface GeoResult {
477
+ id: string;
478
+ data: Record<string, unknown>;
479
+ distance: number;
480
+ }
481
+ interface GeoResponse {
482
+ results: GeoResult[];
483
+ total: number;
484
+ }
485
+ type AtomicOperatorType = 'increment' | 'serverTimestamp' | 'deleteField' | 'arrayUnion' | 'arrayRemove' | 'arrayPush' | 'min' | 'max' | 'objectMerge' | 'objectSet' | 'geoPoint';
486
+ interface AtomicOperator {
487
+ type: AtomicOperatorType;
488
+ value?: unknown;
489
+ }
490
+ interface BatchOperation {
491
+ type: 'create' | 'update' | 'delete';
492
+ table: string;
493
+ doc_id?: string;
494
+ data?: Record<string, unknown>;
495
+ operators?: Record<string, AtomicOperator>;
496
+ }
497
+ interface TransactionRead {
498
+ table: string;
499
+ doc_id: string;
500
+ alias?: string;
501
+ }
502
+ interface TransactionWrite {
503
+ type: 'create' | 'update' | 'delete';
504
+ table: string;
505
+ doc_id?: string;
506
+ data?: Record<string, unknown>;
507
+ operators?: Record<string, AtomicOperator>;
508
+ precondition?: {
509
+ version?: number;
510
+ exists?: boolean;
511
+ };
512
+ }
513
+ interface TTLConfig {
514
+ table_name: string;
515
+ field: string;
516
+ enabled: boolean;
517
+ }
518
+ interface RetentionPolicy {
519
+ table_name: string;
520
+ retention_days: number;
521
+ date_field?: string;
522
+ action: 'delete' | 'archive';
523
+ archive_table?: string;
524
+ schedule?: string;
525
+ enabled: boolean;
526
+ }
279
527
 
280
528
  declare class DatabaseAPI {
281
529
  private http;
@@ -344,6 +592,121 @@ declare class DatabaseAPI {
344
592
  * 조건에 맞는 데이터 삭제
345
593
  */
346
594
  deleteWhere(tableId: string, where: WhereCondition): Promise<DeleteWhereResponse>;
595
+ /**
596
+ * 집계 파이프라인 실행 (MongoDB 스타일)
597
+ */
598
+ aggregate(tableId: string, pipeline: AggregateStage[]): Promise<AggregateResult>;
599
+ /**
600
+ * 전문 검색
601
+ */
602
+ search(tableId: string, query: string, fields: string[], options?: SearchOptions): Promise<SearchResponse>;
603
+ /**
604
+ * 자동완성 검색
605
+ */
606
+ autocomplete(tableId: string, query: string, field: string, options?: {
607
+ limit?: number;
608
+ }): Promise<SearchResponse>;
609
+ /**
610
+ * 지리 쿼리 (반경, 박스, 폴리곤)
611
+ */
612
+ geoQuery(tableId: string, field: string, query: GeoQuery, options?: {
613
+ limit?: number;
614
+ offset?: number;
615
+ }): Promise<GeoResponse>;
616
+ /**
617
+ * 배치 쓰기 (여러 테이블 다중 문서 원자적 처리)
618
+ */
619
+ batch(operations: BatchOperation[]): Promise<{
620
+ results: Record<string, unknown>[];
621
+ }>;
622
+ /**
623
+ * 트랜잭션 실행 (읽기 → 쓰기 ACID)
624
+ */
625
+ transaction(reads: TransactionRead[], writes: TransactionWrite[]): Promise<{
626
+ results: Record<string, unknown>;
627
+ }>;
628
+ /**
629
+ * 데이터 조회 시 릴레이션 로딩 (JOIN)
630
+ */
631
+ getDataWithPopulate(tableId: string, options: QueryOptions & {
632
+ populate: PopulateOption[];
633
+ }): Promise<FetchDataResponse>;
634
+ /**
635
+ * 보안 규칙 목록 조회
636
+ */
637
+ listSecurityRules(appId: string): Promise<SecurityRule[]>;
638
+ /**
639
+ * 보안 규칙 생성
640
+ */
641
+ createSecurityRule(appId: string, data: CreateSecurityRuleRequest): Promise<SecurityRule>;
642
+ /**
643
+ * 보안 규칙 수정
644
+ */
645
+ updateSecurityRule(appId: string, ruleId: string, data: UpdateSecurityRuleRequest): Promise<SecurityRule>;
646
+ /**
647
+ * 보안 규칙 삭제
648
+ */
649
+ deleteSecurityRule(appId: string, ruleId: string): Promise<void>;
650
+ /**
651
+ * 테이블 인덱스 목록 조회
652
+ */
653
+ listIndexes(appId: string, tableId: string): Promise<TableIndex[]>;
654
+ /**
655
+ * 인덱스 생성
656
+ */
657
+ createIndex(appId: string, tableId: string, data: CreateIndexRequest): Promise<TableIndex>;
658
+ /**
659
+ * 인덱스 삭제
660
+ */
661
+ deleteIndex(appId: string, tableId: string, indexId: string): Promise<void>;
662
+ /**
663
+ * 인덱스 분석 및 추천
664
+ */
665
+ analyzeIndexes(appId: string, tableId: string): Promise<IndexAnalysis>;
666
+ /**
667
+ * 테이블 릴레이션 목록 조회
668
+ */
669
+ listRelations(appId: string, tableId: string): Promise<TableRelation[]>;
670
+ /**
671
+ * 릴레이션 생성
672
+ */
673
+ createRelation(appId: string, tableId: string, data: CreateRelationRequest): Promise<TableRelation>;
674
+ /**
675
+ * 릴레이션 삭제
676
+ */
677
+ deleteRelation(appId: string, tableId: string, relationName: string): Promise<void>;
678
+ /**
679
+ * 트리거 목록 조회
680
+ */
681
+ listTriggers(appId: string): Promise<Trigger[]>;
682
+ /**
683
+ * 트리거 생성
684
+ */
685
+ createTrigger(appId: string, data: CreateTriggerRequest): Promise<Trigger>;
686
+ /**
687
+ * 트리거 수정
688
+ */
689
+ updateTrigger(appId: string, triggerId: string, data: UpdateTriggerRequest): Promise<Trigger>;
690
+ /**
691
+ * 트리거 삭제
692
+ */
693
+ deleteTrigger(appId: string, triggerId: string): Promise<void>;
694
+ /**
695
+ * TTL 정책 설정
696
+ */
697
+ setTTL(appId: string, config: TTLConfig): Promise<TTLConfig>;
698
+ /**
699
+ * TTL 정책 조회
700
+ */
701
+ getTTL(appId: string, tableName: string): Promise<TTLConfig>;
702
+ /**
703
+ * 보관 정책 설정
704
+ */
705
+ setRetentionPolicy(appId: string, policy: RetentionPolicy): Promise<RetentionPolicy>;
706
+ /**
707
+ * 보관 정책 조회
708
+ */
709
+ getRetentionPolicy(appId: string, tableName: string): Promise<RetentionPolicy>;
347
710
  }
348
711
 
349
712
  interface FileItem {
@@ -1063,11 +1426,14 @@ declare class RealtimeAPI {
1063
1426
  *
1064
1427
  * @example
1065
1428
  * ```typescript
1429
+ * // 브라우저에서 사용
1430
+ * const outputEl = document.getElementById('ai-output')
1431
+ *
1066
1432
  * const session = await client.realtime.stream(
1067
1433
  * [{ role: 'user', content: '안녕하세요' }],
1068
1434
  * {
1069
1435
  * onToken: (token) => {
1070
- * process.stdout.write(token) // 실시간 출력
1436
+ * outputEl.textContent += token // 실시간 출력
1071
1437
  * },
1072
1438
  * onDone: (result) => {
1073
1439
  * console.log('완료:', result.fullText)
@@ -1076,7 +1442,7 @@ declare class RealtimeAPI {
1076
1442
  * console.error('에러:', error)
1077
1443
  * }
1078
1444
  * },
1079
- * { model: 'gemini-2.0-flash', temperature: 0.7 }
1445
+ * { provider: 'gemini', model: 'gemini-2.0-flash', temperature: 0.7 }
1080
1446
  * )
1081
1447
  *
1082
1448
  * // 필요 시 중지
@@ -3629,4 +3995,4 @@ declare class ConnectBase {
3629
3995
  updateConfig(config: Partial<ConnectBaseConfig>): void;
3630
3996
  }
3631
3997
 
3632
- export { type AdReportResponse, type AdReportSummary, AdsAPI, ApiError, type ApiKeyItem, type AppStatsResponse, AuthError, type AuthSettingsResponse, type BatchSetPageMetaRequest, type BillingCycle, type BillingKeyResponse, type BulkCreateResponse, type BulkError, 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 ConfirmBillingKeyRequest, type ConfirmPaymentRequest, type ConfirmPaymentResponse, ConnectBase, type ConnectBaseConfig, type ConnectedData, type ConnectionState, type CreateApiKeyRequest, type CreateApiKeyResponse, type CreateChannelRequest, type CreateColumnRequest, type CreateDataRequest, type CreateFolderRequest, type CreateFolderResponse, type CreatePlaylistRequest, type CreateSubscriptionRequest, type CreateTableRequest, type DailyReport, type DataItem, type DataType, type DeleteWhereResponse, type DeviceInfo, type EnabledProviderInfo, type EnabledProvidersResponse, type ErrorHandler, type ErrorMessage, type ErrorReport, type ErrorTrackerConfig, type ErrorType, type FetchApiKeysResponse, type FetchDataResponse, type FetchFilesResponse, type FileItem, 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 GetAuthorizationURLResponse, type GetFileByPathResponse, type GoogleConnectionStatus, type GuestMemberSignInResponse, type HistoryResponse, type ICEServer, type ICEServersResponse, type InitUploadResponse, type InvokeFunctionRequest, type InvokeFunctionResponse, type IssueBillingKeyRequest, type IssueBillingKeyResponse, type JoinRoomRequest, type JoinRoomResponse, type ListBillingKeysResponse, type ListPageMetasResponse, type ListSubscriptionPaymentsRequest, type ListSubscriptionPaymentsResponse, type ListSubscriptionsRequest, type ListSubscriptionsResponse, type MemberSignInRequest, type MemberSignInResponse, type MemberSignUpRequest, type MemberSignUpResponse, type MembershipTier, type MessageHandler, type MoveFileRequest, type OAuthCallbackResponse, type OAuthProvider, type PageMetaResponse, type PauseSubscriptionRequest, type PaymentDetail, type PaymentStatus, type PeerInfo, type PlayerEvent, type Playlist, type PlaylistItem, type PongMessage, type PreparePaymentRequest, type PreparePaymentResponse, type PushPlatform, type QualityProgress, type QueryOptions, type RealtimeConnectOptions, type RealtimeMessage, type RegisterDeviceRequest, type RenameFileRequest, type RenameFileResponse, type RoomInfo, type RoomStats, type RoomsResponse, type SendOptions, type ServerMessage, type SetPageMetaRequest, type Shorts, type ShortsListResponse, type SignalingMessage, type SignalingMessageType, type StateChange, type StateChangeHandler, type StreamDoneCallback, type StreamDoneData, type StreamErrorCallback, type StreamHandlers, type StreamMessage, type StreamOptions, type StreamSession, type StreamTokenCallback, type StreamURLResponse, type SubscribeOptions, type SubscribeTopicRequest, type SubscribedData, type Subscription, type SubscriptionPaymentResponse, type SubscriptionPaymentStatus, type SubscriptionResponse, type SubscriptionStatus, type SuperChat, type TableSchema, type TranscodeStatus, type TransportType, type UpdateApiKeyRequest, type UpdateApiKeyResponse, type UpdateBillingKeyRequest, type UpdateChannelRequest, type UpdateColumnRequest, type UpdateDataRequest, type UpdateSubscriptionRequest, type UpdateVideoRequest, type UploadByPathOptions, type UploadFileResponse, type UploadOptions, type UploadProgress, type VAPIDPublicKeyResponse, type ValidateResponse, type Video, type VideoComment, type VideoListOptions, type VideoListResponse, VideoProcessingError, type VideoQuality, type VideoStatus, type VideoVisibility, type WaitOptions, type WatchHistoryItem, type WebPushSubscription, type WebRTCConnectOptions, type WebRTCConnectionState, type WebRTCMode, type WhereCondition, type WhereOperator, ConnectBase as default, isWebTransportSupported };
3998
+ export { type AdReportResponse, type AdReportSummary, AdsAPI, type AggregateResult, type AggregateStage, ApiError, type ApiKeyItem, type AppStatsResponse, type AtomicOperator, type AtomicOperatorType, AuthError, type AuthSettingsResponse, type BatchOperation, type BatchSetPageMetaRequest, type BillingCycle, type BillingKeyResponse, type BulkCreateResponse, type BulkError, 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 ConfirmBillingKeyRequest, type ConfirmPaymentRequest, type ConfirmPaymentResponse, ConnectBase, type ConnectBaseConfig, type ConnectedData, type ConnectionState, type CreateApiKeyRequest, type CreateApiKeyResponse, type CreateChannelRequest, type CreateColumnRequest, type CreateDataRequest, type CreateFolderRequest, type CreateFolderResponse, type CreateIndexRequest, type CreatePlaylistRequest, type CreateRelationRequest, type CreateSecurityRuleRequest, type CreateSubscriptionRequest, type CreateTableRequest, type CreateTriggerRequest, type DailyReport, type DataItem, type DataType, type DeleteWhereResponse, type DeviceInfo, type EnabledProviderInfo, type EnabledProvidersResponse, type ErrorHandler, type ErrorMessage, type ErrorReport, type ErrorTrackerConfig, type ErrorType, type FetchApiKeysResponse, type FetchDataResponse, type FetchFilesResponse, type FileItem, 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 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 IndexAnalysis, type IndexRecommendation, type InitUploadResponse, type InvokeFunctionRequest, type InvokeFunctionResponse, type IssueBillingKeyRequest, type IssueBillingKeyResponse, type JoinRoomRequest, type JoinRoomResponse, type ListBillingKeysResponse, type ListPageMetasResponse, type ListSubscriptionPaymentsRequest, type ListSubscriptionPaymentsResponse, type ListSubscriptionsRequest, type ListSubscriptionsResponse, type MemberSignInRequest, type MemberSignInResponse, type MemberSignUpRequest, type MemberSignUpResponse, type MembershipTier, type MessageHandler, type MoveFileRequest, type OAuthCallbackResponse, type OAuthProvider, type PageMetaResponse, type PauseSubscriptionRequest, type PaymentDetail, type PaymentStatus, type PeerInfo, type PlayerEvent, type Playlist, type PlaylistItem, type PongMessage, type PopulateOption, type PreparePaymentRequest, type PreparePaymentResponse, type PushPlatform, type QualityProgress, type QueryOptions, type RealtimeConnectOptions, type RealtimeMessage, type RegisterDeviceRequest, type RelationType, type RenameFileRequest, type RenameFileResponse, type RetentionPolicy, type RoomInfo, type RoomStats, type RoomsResponse, type SearchOptions, type SearchResponse, type SearchResult, type SecurityRule, type SendOptions, type ServerMessage, type SetPageMetaRequest, type Shorts, type ShortsListResponse, type SignalingMessage, type SignalingMessageType, type SlowQueryInfo, type StateChange, type StateChangeHandler, type StreamDoneCallback, type StreamDoneData, type StreamErrorCallback, type StreamHandlers, type StreamMessage, type StreamOptions, type StreamSession, type StreamTokenCallback, type StreamURLResponse, type SubscribeOptions, type SubscribeTopicRequest, type SubscribedData, type Subscription, type SubscriptionPaymentResponse, type SubscriptionPaymentStatus, type SubscriptionResponse, type SubscriptionStatus, type SuperChat, type TTLConfig, type TableIndex, type TableRelation, type TableSchema, type TransactionRead, type TransactionWrite, type TranscodeStatus, type TransportType, type Trigger, type TriggerEvent, type TriggerHandlerType, type UpdateApiKeyRequest, type UpdateApiKeyResponse, type UpdateBillingKeyRequest, type UpdateChannelRequest, type UpdateColumnRequest, type UpdateDataRequest, type UpdateSecurityRuleRequest, type UpdateSubscriptionRequest, type UpdateTriggerRequest, type UpdateVideoRequest, type UploadByPathOptions, type UploadFileResponse, type UploadOptions, type UploadProgress, type VAPIDPublicKeyResponse, type ValidateResponse, type Video, type VideoComment, type VideoListOptions, type VideoListResponse, VideoProcessingError, type VideoQuality, type VideoStatus, type VideoVisibility, type WaitOptions, type WatchHistoryItem, type WebPushSubscription, type WebRTCConnectOptions, type WebRTCConnectionState, type WebRTCMode, type WhereCondition, type WhereOperator, ConnectBase as default, isWebTransportSupported };