deliveryapi 0.1.4 → 0.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/dist/index.d.cts CHANGED
@@ -1,465 +1,444 @@
1
- // Generated by dts-bundle-generator v9.5.1
1
+ interface ApiResponse<T = unknown> {
2
+ isSuccess: boolean;
3
+ data?: T;
4
+ message?: string;
5
+ error?: string;
6
+ statusCode?: number;
7
+ errorCode?: string;
8
+ }
9
+ interface RequestVerificationParams {
10
+ email: string;
11
+ }
12
+ interface VerifyAndRegisterParams {
13
+ email: string;
14
+ code: string;
15
+ password: string;
16
+ displayName: string;
17
+ }
18
+ interface VerifyAndRegisterResult {
19
+ customToken: string;
20
+ }
21
+ interface EnsureUserResult {
22
+ uid: string;
23
+ email: string;
24
+ displayName: string;
25
+ isNewUser: boolean;
26
+ }
27
+ interface DashboardApiKey {
28
+ name: string;
29
+ status: string;
30
+ environment: string;
31
+ secretKeyCount: number;
32
+ usage: {
33
+ today: number;
34
+ thisMonth: number;
35
+ };
36
+ }
37
+ interface DashboardResult {
38
+ user: {
39
+ email: string;
40
+ displayName: string;
41
+ };
42
+ customer: {
43
+ totalRequests: number;
44
+ } | null;
45
+ apiKeys: DashboardApiKey[];
46
+ plan: {
47
+ name: string;
48
+ tier: string;
49
+ limits: {
50
+ requestsPerMinute: number;
51
+ requestsPerMonth: number;
52
+ };
53
+ };
54
+ }
55
+ interface IssueApiKeyResult {
56
+ apiKey: string;
57
+ secretKey: string;
58
+ emailSent: boolean;
59
+ }
60
+ interface Post {
61
+ id: string;
62
+ title: string;
63
+ content?: string;
64
+ authorUid: string;
65
+ authorName: string;
66
+ isSecret: boolean;
67
+ commentCount: number;
68
+ viewCount: number;
69
+ dateCreated: string | null;
70
+ dateModified?: string | null;
71
+ }
72
+ interface Comment {
73
+ id: string;
74
+ postId?: string;
75
+ content: string;
76
+ authorUid: string;
77
+ authorName: string;
78
+ isAdmin: boolean;
79
+ dateCreated: string | null;
80
+ }
81
+ interface ListPostsParams {
82
+ cursor?: string;
83
+ pageSize?: number;
84
+ }
85
+ interface ListPostsResult {
86
+ posts: Post[];
87
+ nextCursor: string | null;
88
+ hasMore: boolean;
89
+ }
90
+ interface CreatePostParams {
91
+ title: string;
92
+ content: string;
93
+ isSecret?: boolean;
94
+ }
95
+ interface UpdatePostParams {
96
+ title?: string;
97
+ content?: string;
98
+ isSecret?: boolean;
99
+ }
100
+ interface ListCommentsResult {
101
+ comments: Comment[];
102
+ }
103
+ interface CreateCommentParams {
104
+ content: string;
105
+ }
106
+ interface ContactInquiryParams {
107
+ name: string;
108
+ email: string;
109
+ phone?: string;
110
+ projectType: string;
111
+ budget?: string;
112
+ timeline?: string;
113
+ description: string;
114
+ }
115
+ interface PlanInfo {
116
+ tier: string;
117
+ name: string;
118
+ price: number;
119
+ limits: {
120
+ secretKey: {
121
+ maxRequestsPerMinute: number;
122
+ maxRequestsPerMonth: number;
123
+ };
124
+ };
125
+ }
126
+ interface SecretPreset {
127
+ id: string;
128
+ name: string;
129
+ description: string;
130
+ }
131
+ interface AdminStats {
132
+ totalHpUsers: number;
133
+ totalCustomers: number;
134
+ totalApiKeys: number;
135
+ totalRequests: number;
136
+ todaySignups: number;
137
+ planCounts: Record<string, number>;
138
+ }
139
+ interface DailySignup {
140
+ date: string;
141
+ count: number;
142
+ }
143
+ interface AdminUser {
144
+ uid: string;
145
+ email: string;
146
+ displayName: string;
147
+ provider: string;
148
+ currentPlan: string;
149
+ isAdmin: boolean;
150
+ dateCreated: string | null;
151
+ }
152
+ interface ListAdminUsersResult {
153
+ users: AdminUser[];
154
+ total: number;
155
+ }
156
+ interface UpdateAdminUserParams {
157
+ displayName?: string;
158
+ currentPlan?: string;
159
+ isAdmin?: boolean;
160
+ }
161
+ interface AdminSecretKeyDetail {
162
+ secretKeyHash: string;
163
+ name: string;
164
+ status: string;
165
+ usage: string;
166
+ limits: {
167
+ requestsPerMinute: number;
168
+ requestsPerHour: number;
169
+ requestsPerDay: number;
170
+ requestsPerMonth: number;
171
+ byOperation: {
172
+ total: {
173
+ requestsPerMinute: number;
174
+ requestsPerHour: number;
175
+ requestsPerDay: number;
176
+ requestsPerMonth: number;
177
+ };
178
+ read: {
179
+ requestsPerMinute: number;
180
+ requestsPerHour: number;
181
+ requestsPerDay: number;
182
+ requestsPerMonth: number;
183
+ };
184
+ write: {
185
+ requestsPerMinute: number;
186
+ requestsPerHour: number;
187
+ requestsPerDay: number;
188
+ requestsPerMonth: number;
189
+ };
190
+ } | null;
191
+ };
192
+ todayCount: number;
193
+ thisMonthCount: number;
194
+ }
195
+ interface AdminApiKeyDetail {
196
+ apiKeyHash: string;
197
+ apiKey: string;
198
+ name: string;
199
+ status: string;
200
+ environment: string;
201
+ planTier: string;
202
+ secretKeys: AdminSecretKeyDetail[];
203
+ usage: {
204
+ today: number;
205
+ thisMonth: number;
206
+ };
207
+ }
208
+ interface AdminUserDetail {
209
+ user: {
210
+ uid: string;
211
+ email: string;
212
+ displayName: string;
213
+ provider: string;
214
+ currentPlan: string;
215
+ isAdmin: boolean;
216
+ customerId: string | null;
217
+ dateCreated: string | null;
218
+ };
219
+ apiKeys: AdminApiKeyDetail[];
220
+ planLimits: {
221
+ name: string;
222
+ maxRequestsPerMinute: number;
223
+ maxRequestsPerHour: number;
224
+ maxRequestsPerDay: number;
225
+ maxRequestsPerMonth: number;
226
+ };
227
+ }
228
+ interface AdminCustomer {
229
+ id: string;
230
+ email: string;
231
+ currentPlan: string;
232
+ status: string;
233
+ activeApiKeys: number;
234
+ totalRequests: number;
235
+ dateCreated: string | null;
236
+ }
237
+ interface ListAdminCustomersResult {
238
+ customers: AdminCustomer[];
239
+ total: number;
240
+ }
241
+ interface AdminKeyItem {
242
+ apiKeyHash: string;
243
+ apiKey: string;
244
+ name: string;
245
+ status: string;
246
+ environment: string;
247
+ planTier: string;
248
+ customerEmail: string;
249
+ hpUserId: string | null;
250
+ secretKeyCount: number;
251
+ todayCount: number;
252
+ thisMonthCount: number;
253
+ dateCreated: string | null;
254
+ }
255
+ interface ListAdminKeysResult {
256
+ keys: AdminKeyItem[];
257
+ total: number;
258
+ }
259
+ interface UpdateKeyPlanParams {
260
+ planTier: string;
261
+ }
262
+ interface BulkUpdateKeyPlanParams {
263
+ apiKeyHashes: string[];
264
+ planTier: string;
265
+ }
266
+ interface KeyLimits {
267
+ requestsPerMinute?: number;
268
+ requestsPerHour?: number;
269
+ requestsPerDay?: number;
270
+ requestsPerMonth?: number;
271
+ byOperation?: {
272
+ total?: {
273
+ requestsPerMinute?: number;
274
+ requestsPerHour?: number;
275
+ requestsPerDay?: number;
276
+ requestsPerMonth?: number;
277
+ };
278
+ read?: {
279
+ requestsPerMinute?: number;
280
+ requestsPerHour?: number;
281
+ requestsPerDay?: number;
282
+ requestsPerMonth?: number;
283
+ };
284
+ write?: {
285
+ requestsPerMinute?: number;
286
+ requestsPerHour?: number;
287
+ requestsPerDay?: number;
288
+ requestsPerMonth?: number;
289
+ };
290
+ };
291
+ }
292
+ interface UpdateKeyLimitsParams {
293
+ secretKeyHash: string;
294
+ limits: KeyLimits;
295
+ }
296
+ interface AdminDemoKey {
297
+ apiKeyHash: string;
298
+ apiKey: string;
299
+ secretKey?: string;
300
+ name: string;
301
+ status: string;
302
+ environment: string;
303
+ planTier: string;
304
+ dateCreated: string | null;
305
+ }
306
+ interface CreateDemoKeyParams {
307
+ name?: string;
308
+ planTier?: string;
309
+ }
310
+ interface ListAdminDemoKeysResult {
311
+ keys: AdminDemoKey[];
312
+ }
313
+ interface TrackingLog {
314
+ id: string;
315
+ apiKeyHash: string;
316
+ customerEmail: string;
317
+ trackingNumber: string;
318
+ courierCode: string;
319
+ status: string;
320
+ dateCreated: string;
321
+ }
322
+ interface ListTrackingLogsResult {
323
+ logs: TrackingLog[];
324
+ total: number;
325
+ page: number;
326
+ totalPages: number;
327
+ }
328
+ interface HomepageClientOptions {
329
+ /** API base URL (e.g. 'https://api.deliveryapi.co.kr') */
330
+ baseUrl: string;
331
+ /** Returns Firebase ID Token for authenticated requests */
332
+ getToken?: () => Promise<string | null>;
333
+ }
334
+
335
+ declare class AuthResource {
336
+ private readonly baseUrl;
337
+ private readonly getToken;
338
+ constructor(baseUrl: string, getToken: () => Promise<string | null>);
339
+ /** Step 1: 이메일 인증 코드 요청 */
340
+ requestVerification(params: RequestVerificationParams): Promise<void>;
341
+ /** Step 2: 인증 코드 검증 + Firebase 계정 생성 → customToken 반환 */
342
+ verifyAndRegister(params: VerifyAndRegisterParams): Promise<VerifyAndRegisterResult>;
343
+ /** Google 로그인 후 HP 사용자 문서 확인/생성 */
344
+ ensureUser(): Promise<EnsureUserResult>;
345
+ }
346
+
347
+ declare class DashboardResource {
348
+ private readonly baseUrl;
349
+ private readonly getToken;
350
+ constructor(baseUrl: string, getToken: () => Promise<string | null>);
351
+ /** 대시보드 데이터 조회 (API 키 목록, 사용량, 플랜 정보) */
352
+ get(): Promise<DashboardResult>;
353
+ /** API 키 발급 */
354
+ issueKey(): Promise<IssueApiKeyResult>;
355
+ }
356
+
357
+ declare class QnaResource {
358
+ private readonly baseUrl;
359
+ private readonly getToken;
360
+ constructor(baseUrl: string, getToken: () => Promise<string | null>);
361
+ /** 게시글 목록 조회 (비회원도 공개글 열람 가능) */
362
+ listPosts(params?: ListPostsParams): Promise<ListPostsResult>;
363
+ /** 게시글 상세 조회 */
364
+ getPost(postId: string): Promise<Post>;
365
+ /** 게시글 작성 (로그인 필요) */
366
+ createPost(params: CreatePostParams): Promise<{
367
+ id: string;
368
+ }>;
369
+ /** 게시글 수정 (작성자/관리자만) */
370
+ updatePost(postId: string, params: UpdatePostParams): Promise<Post>;
371
+ /** 게시글 삭제 (작성자/관리자만) */
372
+ deletePost(postId: string): Promise<void>;
373
+ /** 댓글 목록 조회 */
374
+ listComments(postId: string): Promise<ListCommentsResult>;
375
+ /** 댓글 작성 (로그인 필요) */
376
+ createComment(postId: string, params: CreateCommentParams): Promise<Comment>;
377
+ /** 댓글 삭제 (작성자/관리자만) */
378
+ deleteComment(commentId: string): Promise<void>;
379
+ }
380
+
381
+ declare class AdminResource {
382
+ private readonly baseUrl;
383
+ private readonly getToken;
384
+ constructor(baseUrl: string, getToken: () => Promise<string | null>);
385
+ private token;
386
+ /** 전체 통계 조회 */
387
+ getStats(): Promise<AdminStats>;
388
+ /** 최근 14일 일별 가입자 수 */
389
+ getDailySignups(): Promise<DailySignup[]>;
390
+ /** 사용자 목록 조회 */
391
+ listUsers(): Promise<ListAdminUsersResult>;
392
+ /** 사용자 정보 수정 */
393
+ updateUser(uid: string, params: UpdateAdminUserParams): Promise<void>;
394
+ /** 사용자 상세 조회 (API 키 + 사용량 포함) */
395
+ getUserDetail(uid: string): Promise<AdminUserDetail>;
396
+ /** customers 목록 조회 */
397
+ listCustomers(): Promise<ListAdminCustomersResult>;
398
+ /** API 키 목록 조회 */
399
+ listKeys(): Promise<ListAdminKeysResult>;
400
+ /** API 키 플랜 변경 */
401
+ updateKeyPlan(apiKeyHash: string, params: UpdateKeyPlanParams): Promise<void>;
402
+ /** API 키 플랜 일괄 변경 */
403
+ bulkUpdateKeyPlan(params: BulkUpdateKeyPlanParams): Promise<void>;
404
+ /** Secret Key limits 수정 */
405
+ updateKeyLimits(apiKeyHash: string, params: UpdateKeyLimitsParams): Promise<void>;
406
+ /** 데모 키 생성 */
407
+ createDemoKey(params?: CreateDemoKeyParams): Promise<AdminDemoKey>;
408
+ /** 데모 키 목록 조회 */
409
+ listDemoKeys(): Promise<ListAdminDemoKeysResult>;
410
+ /** 데모 키 비활성화 */
411
+ deactivateDemoKey(apiKeyHash: string): Promise<void>;
412
+ /** 데모 키 활성화 */
413
+ activateDemoKey(apiKeyHash: string): Promise<void>;
414
+ /** 조회 로그 목록 */
415
+ listTrackingLogs(page?: number): Promise<ListTrackingLogsResult>;
416
+ }
2
417
 
3
- declare class HttpClient {
4
- private readonly baseUrl;
5
- private readonly authHeader;
6
- constructor(apiKey: string, secretKey: string, baseUrl: string);
7
- get<T>(path: string, params?: Record<string, string>): Promise<T>;
8
- post<T>(path: string, body?: unknown): Promise<T>;
9
- put<T>(path: string, body?: unknown): Promise<T>;
10
- patch<T>(path: string, body?: unknown): Promise<T>;
11
- delete<T>(path: string): Promise<T>;
12
- private request;
13
- }
14
- /**
15
- * Firebase Timestamp 호환 인터페이스
16
- * firebase-admin/firestore 및 firebase/firestore의 Timestamp와 구조적으로 호환됨
17
- */
18
- export interface Timestamp {
19
- seconds: number;
20
- nanoseconds: number;
21
- toDate(): Date;
22
- toMillis(): number;
23
- isEqual(other: Timestamp): boolean;
24
- valueOf(): string;
25
- }
26
- /**
27
- * 통일된 API 응답 형식
28
- */
29
- export interface ApiResponse<T = unknown> {
30
- isSuccess: boolean;
31
- statusCode?: number;
32
- data?: T;
33
- error?: string;
34
- message?: string;
35
- }
36
- /**
37
- * 택배 배송 상태 열거형
38
- * 모든 택배사의 상태를 통합하여 정규화
39
- *
40
- * 📌 프로젝트별 차이점:
41
- * - delivery-saas-api-functions (이 프로젝트): enum만 정의 (데이터 반환용)
42
- * - farmsns-admin_new, farmsns-functions_new, farmfree-mobile:
43
- * → CourierDeliveryStatusLabels (한글 라벨)
44
- * → LotteStatusMapping, CJStatusMapping (택배사별 매핑)
45
- * → Helper 함수들 (mapCourierStatus, isDeliveryInProgress 등)
46
- *
47
- * 이유: delivery-saas-api는 외부 API 역할로 데이터 반환만 수행하므로
48
- * UI 표시용 라벨이나 변환 로직이 불필요
49
- */
50
- export declare enum CourierDeliveryStatus {
51
- PENDING = "PENDING",// 접수 대기
52
- REGISTERED = "REGISTERED",// 접수 완료
53
- PICKUP_READY = "PICKUP_READY",// 집하 준비
54
- PICKED_UP = "PICKED_UP",// 집하 완료
55
- IN_TRANSIT = "IN_TRANSIT",// 배송 중
56
- OUT_FOR_DELIVERY = "OUT_FOR_DELIVERY",// 배송 출발
57
- DELIVERED = "DELIVERED",// 배송 완료
58
- FAILED = "FAILED",// 배송 실패
59
- RETURNED = "RETURNED",// 반송
60
- CANCELLED = "CANCELLED",// 취소
61
- HOLD = "HOLD",// 보류
62
- UNKNOWN = "UNKNOWN"
63
- }
64
- declare const COURIER_CODES: {
65
- readonly LOTTE: "lotte";
66
- readonly CJ: "cj";
67
- readonly POST: "post";
68
- readonly HANJIN: "hanjin";
69
- readonly LOGEN: "logen";
70
- readonly GSPOSTBOX: "gspostbox";
71
- readonly ILYANG: "ilyang";
72
- readonly KYUNGDONG: "kyungdong";
73
- readonly DAESIN: "daesin";
74
- readonly HAPDONG: "hapdong";
75
- readonly COUPANG: "coupang";
76
- };
77
- export type CourierCode = (typeof COURIER_CODES)[keyof typeof COURIER_CODES];
78
- /**
79
- * 인증 방식 타입
80
- */
81
- export type AuthMethod = "2FA_SMS" | "2FA_EMAIL" | "2FA_KAKAO" | "2FA_OTP";
82
- /**
83
- * 인증 코드 타입
84
- */
85
- export type AuthCodeType = "NUMERIC" | "ALPHANUMERIC";
86
- /**
87
- * 택배사 정보 인터페이스
88
- */
89
- export interface CourierInfo {
90
- id: CourierCode;
91
- trackingApiCode: CourierCode;
92
- displayName: string;
93
- icon: string;
94
- supportsTracking: boolean;
95
- supportsAccount: boolean;
96
- adminUrl: string;
97
- trackingUrl: string;
98
- customerServicePhone: string;
99
- requires2FA: boolean;
100
- authMethod?: AuthMethod | null;
101
- authCodeLength?: number | null;
102
- authCodeType?: AuthCodeType | null;
103
- supportsAutoReauth: boolean;
104
- allowsMultipleSessions: boolean;
105
- reauthMessage: string;
106
- accessTokenDurationMinutes: number;
107
- maxInquiryDays: number;
108
- }
109
- /**
110
- * 개별 택배 조회 항목
111
- */
112
- export interface TrackingItem {
113
- id?: string;
114
- clientId?: string;
115
- courierCode: string;
116
- trackingNumber: string;
117
- }
118
- /**
119
- * 택배 진행 상황
120
- */
121
- export interface TrackingProgress {
122
- dateTime: string;
123
- location: string;
124
- status: string;
125
- statusCode?: CourierDeliveryStatus;
126
- description?: string;
127
- telno?: string;
128
- telno2?: string;
129
- }
130
- /**
131
- * 통합 택배 조회 응답
132
- */
133
- export interface UnifiedTrackingResponse {
134
- trackingNumber: string;
135
- courierCode: string;
136
- courierName: string;
137
- deliveryStatus: CourierDeliveryStatus;
138
- deliveryStatusText: string;
139
- isDelivered: boolean;
140
- senderName?: string;
141
- receiverName?: string;
142
- receiverAddress?: string;
143
- productName?: string;
144
- productQuantity?: number;
145
- dateDelivered?: string;
146
- dateEstimated?: string;
147
- dateLastProgress: string;
148
- progresses: TrackingProgress[];
149
- queriedAt: string;
150
- }
151
- /**
152
- * 택배 조회 에러 코드
153
- *
154
- * 과금 정책:
155
- * - NOT_FOUND만 과금 (택배사 API를 호출했으나 데이터 없음 = 사용자 책임)
156
- * - 나머지는 비과금 (요청 검증 실패 또는 시스템 오류)
157
- */
158
- export type TrackingErrorCode = "MISSING_PARAMS" | "INVALID_TRACKING_NUMBER" | "UNSUPPORTED_COURIER" | "NOT_FOUND" | "TRACKING_FAILED";
159
- /**
160
- * 택배 조회 오류
161
- */
162
- export interface TrackingError {
163
- code: TrackingErrorCode;
164
- message: string;
165
- courierCode?: string;
166
- trackingNumber?: string;
167
- details?: unknown;
168
- billable: boolean;
169
- }
170
- /**
171
- * 캐시 메타데이터
172
- */
173
- export interface TrackingCacheInfo {
174
- fromCache: boolean;
175
- cachedAt?: string;
176
- }
177
- /**
178
- * 개별 택배 조회 결과
179
- */
180
- export interface TrackingResult {
181
- id?: string;
182
- clientId?: string;
183
- success: boolean;
184
- data?: UnifiedTrackingResponse;
185
- error?: TrackingError;
186
- cache?: TrackingCacheInfo;
187
- }
188
- /**
189
- * 택배 조회 응답 (배열로 다건 응답)
190
- */
191
- export interface TrackingResponse {
192
- results: TrackingResult[];
193
- summary: {
194
- total: number;
195
- successful: number;
196
- failed: number;
197
- billable: number;
198
- };
199
- }
200
- /**
201
- * 웹훅 엔드포인트 (apiKeys 문서에 저장)
202
- * API Key당 최대 10개 등록 가능
203
- */
204
- export interface WebhookEndpoint {
205
- id: string;
206
- url: string;
207
- name?: string;
208
- webhookSecret: string;
209
- webhookSecretHash: string;
210
- status: "active" | "inactive";
211
- dateCreated: Timestamp;
212
- dateModified: Timestamp;
213
- }
214
- /**
215
- * 구독 상태
216
- */
217
- export type SubscriptionStatus = "active" | "completed" | "cancelled" | "failed";
218
- /**
219
- * 택배 조회 구독 (trackingSubscriptions 컬렉션)
220
- */
221
- export interface TrackingSubscription {
222
- id: string;
223
- clientId?: string;
224
- customerId: string;
225
- apiKeyHash: string;
226
- courierCode: string;
227
- trackingNumber: string;
228
- endpointId: string;
229
- subscribedStatuses: CourierDeliveryStatus[];
230
- currentStatus: CourierDeliveryStatus;
231
- lastPolledAt: Timestamp;
232
- nextPollAt: Timestamp;
233
- status: SubscriptionStatus;
234
- failureCount: number;
235
- metadata?: Record<string, string>;
236
- dateCreated: Timestamp;
237
- dateModified: Timestamp;
238
- }
239
- /**
240
- * 웹훅 페이로드
241
- */
242
- export interface WebhookPayload {
243
- event: "tracking.status_changed";
244
- subscriptionId: string;
245
- timestamp: string;
246
- data: {
247
- courierCode: string;
248
- trackingNumber: string;
249
- previousStatus?: CourierDeliveryStatus;
250
- currentStatus: CourierDeliveryStatus;
251
- tracking: UnifiedTrackingResponse;
252
- };
253
- metadata?: Record<string, string>;
254
- }
255
- export interface DeliverySaasClientConfig {
256
- /** API Key (발급받은 API Key) */
257
- apiKey: string;
258
- /** Secret Key (발급받은 Secret Key) */
259
- secretKey: string;
260
- /** API Base URL (기본값: https://api.deliveryapi.co.kr) */
261
- baseUrl?: string;
262
- }
263
- export interface TrackingRequestInput {
264
- items: TrackingItem[];
265
- includeProgresses?: boolean;
266
- }
267
- export interface SubscriptionCreateInput {
268
- courierCode: string;
269
- trackingNumber: string;
270
- endpointId: string;
271
- subscribedStatuses?: CourierDeliveryStatus[];
272
- id?: string;
273
- metadata?: Record<string, string>;
274
- }
275
- export interface SubscriptionCreateResult {
276
- id?: string;
277
- courierCode: string;
278
- trackingNumber: string;
279
- subscriptionId?: string;
280
- success: boolean;
281
- currentStatus?: CourierDeliveryStatus;
282
- error?: string;
283
- }
284
- export interface SubscriptionCreateBatchResult {
285
- results: SubscriptionCreateResult[];
286
- summary: {
287
- total: number;
288
- successful: number;
289
- failed: number;
290
- };
291
- }
292
- export interface SubscriptionListResult {
293
- subscriptions: {
294
- id: string;
295
- courierCode: string;
296
- trackingNumber: string;
297
- endpointId: string;
298
- subscribedStatuses: CourierDeliveryStatus[];
299
- currentStatus: CourierDeliveryStatus;
300
- status: "active" | "completed" | "cancelled" | "failed";
301
- metadata?: Record<string, string>;
302
- dateCreated: string;
303
- dateModified: string;
304
- }[];
305
- total: number;
306
- nextCursor?: string;
307
- }
308
- export interface WebhookCreateInput {
309
- url: string;
310
- name?: string;
311
- }
312
- export interface WebhookCreateResult {
313
- endpointId: string;
314
- url: string;
315
- name?: string;
316
- webhookSecret: string;
317
- dateCreated: string;
318
- }
319
- export interface WebhookUpdateInput {
320
- name: string;
321
- }
322
- export interface WebhookListResult {
323
- endpoints: WebhookEndpoint[];
324
- total: number;
325
- }
326
- export interface WebhookRotateSecretResult {
327
- webhookSecret: string;
328
- }
329
- export interface CourierListResult {
330
- couriers: CourierInfo[];
331
- }
332
- declare class TrackingResource {
333
- private readonly http;
334
- constructor(http: HttpClient);
335
- /**
336
- * 택배 조회 (공개 API, 계정 불필요)
337
- * @param items 조회할 택배 목록 (1건도 배열로)
338
- * @param includeProgresses 진행 내역 포함 여부 (기본값: true)
339
- */
340
- get(items: TrackingRequestInput["items"], includeProgresses?: boolean): Promise<TrackingResponse>;
341
- /**
342
- * 단건 택배 조회 (편의 메서드)
343
- */
344
- getOne(courierCode: string, trackingNumber: string, options?: {
345
- clientId?: string;
346
- includeProgresses?: boolean;
347
- }): Promise<TrackingResponse>;
348
- }
349
- declare class SubscriptionsResource {
350
- private readonly http;
351
- constructor(http: HttpClient);
352
- /**
353
- * 택배 구독 생성 (단건)
354
- * 상태 변경 시 등록된 웹훅 엔드포인트로 알림 전송
355
- */
356
- create(data: SubscriptionCreateInput): Promise<SubscriptionCreateBatchResult>;
357
- /**
358
- * 택배 구독 일괄 생성 (최대 100건)
359
- */
360
- createBatch(items: SubscriptionCreateInput[]): Promise<SubscriptionCreateBatchResult>;
361
- /**
362
- * 택배 구독 목록 조회
363
- */
364
- list(options?: {
365
- status?: "active" | "completed" | "cancelled" | "failed";
366
- limit?: number;
367
- cursor?: string;
368
- }): Promise<SubscriptionListResult>;
369
- /**
370
- * 택배 구독 상세 조회
371
- */
372
- retrieve(subscriptionId: string): Promise<SubscriptionListResult["subscriptions"][number]>;
373
- /**
374
- * 택배 구독 취소 (ID)
375
- */
376
- cancel(subscriptionId: string): Promise<void>;
377
- /**
378
- * 택배 구독 취소 (송장번호)
379
- */
380
- cancelByTracking(courierCode: string, trackingNumber: string): Promise<{
381
- cancelledCount: number;
382
- }>;
383
- }
384
- declare class WebhooksResource {
385
- private readonly http;
386
- constructor(http: HttpClient);
387
- /**
388
- * 웹훅 엔드포인트 등록
389
- */
390
- create(data: WebhookCreateInput): Promise<WebhookCreateResult>;
391
- /**
392
- * 웹훅 엔드포인트 목록 조회
393
- */
394
- list(): Promise<WebhookListResult>;
395
- /**
396
- * 웹훅 엔드포인트 이름 수정
397
- */
398
- update(endpointId: string, data: WebhookUpdateInput): Promise<void>;
399
- /**
400
- * 웹훅 엔드포인트 삭제
401
- */
402
- delete(endpointId: string): Promise<void>;
403
- /**
404
- * 웹훅 시크릿 재발급
405
- */
406
- rotateSecret(endpointId: string, webhookSecret?: string): Promise<WebhookRotateSecretResult>;
407
- }
408
- declare class CouriersResource {
409
- private readonly http;
410
- constructor(http: HttpClient);
411
- /**
412
- * 지원 택배사 목록 조회
413
- */
414
- list(): Promise<CourierListResult>;
415
- }
416
- /**
417
- * DeliverySaaS API Client
418
- *
419
- * @example
420
- * ```typescript
421
- * import { DeliverySaasClient } from 'deliveryapi'
422
- *
423
- * const client = new DeliverySaasClient({
424
- * apiKey: 'your-api-key',
425
- * secretKey: 'your-secret-key',
426
- * })
427
- *
428
- * // 택배 조회
429
- * const result = await client.tracking.getOne('LOTTE', '1234567890')
430
- *
431
- * // 구독 생성
432
- * const subscription = await client.subscriptions.create({
433
- * courierCode: 'LOTTE',
434
- * trackingNumber: '1234567890',
435
- * endpointId: 'ep_xxx',
436
- * })
437
- * ```
438
- */
439
- export declare class DeliverySaasClient {
440
- readonly tracking: TrackingResource;
441
- readonly subscriptions: SubscriptionsResource;
442
- readonly webhooks: WebhooksResource;
443
- readonly couriers: CouriersResource;
444
- constructor(config: DeliverySaasClientConfig);
445
- }
446
- export declare class DeliverySaasError extends Error {
447
- readonly statusCode: number;
448
- readonly code?: string | undefined;
449
- constructor(message: string, statusCode: number, code?: string | undefined);
450
- }
451
- export declare class AuthenticationError extends DeliverySaasError {
452
- constructor(message?: string);
453
- }
454
- export declare class RateLimitError extends DeliverySaasError {
455
- constructor(message?: string);
456
- }
457
- export declare class NotFoundError extends DeliverySaasError {
458
- constructor(message?: string);
418
+ declare class PublicResource {
419
+ private readonly baseUrl;
420
+ constructor(baseUrl: string);
421
+ /** 요금제 목록 조회 */
422
+ getPlans(): Promise<PlanInfo[]>;
423
+ /** Secret Key 프리셋 목록 조회 */
424
+ getSecretPresets(): Promise<SecretPreset[]>;
425
+ /** 개발 의뢰 문의 전송 */
426
+ sendContactInquiry(params: ContactInquiryParams): Promise<void>;
459
427
  }
460
428
 
461
- export {
462
- TrackingItem as TrackingResponseItem,
463
- };
429
+ declare class HomepageClient {
430
+ readonly auth: AuthResource;
431
+ readonly dashboard: DashboardResource;
432
+ readonly qna: QnaResource;
433
+ readonly admin: AdminResource;
434
+ readonly public: PublicResource;
435
+ constructor(options: HomepageClientOptions);
436
+ }
437
+
438
+ declare class ApiError extends Error {
439
+ readonly statusCode: number;
440
+ readonly errorCode: string | undefined;
441
+ constructor(statusCode: number, errorCode: string | undefined, message: string);
442
+ }
464
443
 
465
- export {};
444
+ export { type AdminApiKeyDetail, type AdminCustomer, type AdminDemoKey, type AdminKeyItem, type AdminSecretKeyDetail, type AdminStats, type AdminUser, type AdminUserDetail, ApiError, type ApiResponse, type BulkUpdateKeyPlanParams, type Comment, type ContactInquiryParams, type CreateCommentParams, type CreateDemoKeyParams, type CreatePostParams, type DailySignup, type DashboardApiKey, type DashboardResult, type EnsureUserResult, HomepageClient, type HomepageClientOptions, type IssueApiKeyResult, type KeyLimits, type ListAdminCustomersResult, type ListAdminDemoKeysResult, type ListAdminKeysResult, type ListAdminUsersResult, type ListCommentsResult, type ListPostsParams, type ListPostsResult, type ListTrackingLogsResult, type PlanInfo, type Post, type RequestVerificationParams, type SecretPreset, type TrackingLog, type UpdateAdminUserParams, type UpdateKeyLimitsParams, type UpdateKeyPlanParams, type UpdatePostParams, type VerifyAndRegisterParams, type VerifyAndRegisterResult };