@tossplace/pos-plugin-sdk 0.0.2 → 0.0.4
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.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/sdk.d.ts +1006 -0
- package/package.json +2 -2
- package/types/index.d.ts +1006 -13
package/types/index.d.ts
CHANGED
|
@@ -1,13 +1,1006 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
declare type AlertElements = {
|
|
2
|
+
type: 'alert';
|
|
3
|
+
title: string;
|
|
4
|
+
description: string;
|
|
5
|
+
image: string;
|
|
6
|
+
cta: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
declare type AlertResponse = {
|
|
10
|
+
type: 'alert';
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
declare type AllPaymentCreateDto = PluginCardDto | PluginCashDto | PluginExternalDto;
|
|
14
|
+
|
|
15
|
+
declare type AllPopupElements = AlertElements | BarcodeElements;
|
|
16
|
+
|
|
17
|
+
declare type AllPopupResponse = AlertResponse | BarcodeResponse;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @publicApi
|
|
21
|
+
*/
|
|
22
|
+
declare type AllPopupType = AllPopupElements['type'];
|
|
23
|
+
|
|
24
|
+
declare const AvailableLanguageCodes: {
|
|
25
|
+
readonly Korean: "ko-KR";
|
|
26
|
+
readonly English: "en-US";
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
*/
|
|
31
|
+
declare type BarcodeElements = {
|
|
32
|
+
type: 'barcode';
|
|
33
|
+
productName: string;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
declare type BarcodeResponse = {
|
|
37
|
+
type: 'barcode';
|
|
38
|
+
complete: true;
|
|
39
|
+
data: {
|
|
40
|
+
barcode: string;
|
|
41
|
+
result: 'SUCCESS';
|
|
42
|
+
} | {
|
|
43
|
+
result: 'CANCELLED';
|
|
44
|
+
};
|
|
45
|
+
} | {
|
|
46
|
+
type: 'barcode';
|
|
47
|
+
complete: false;
|
|
48
|
+
errorMessage: string;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
declare type CancelCallback = (order: PluginOrder, payment: PluginPayment) => Promise<PluginCancelledPaymentDto | undefined>;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @publicApi
|
|
55
|
+
*/
|
|
56
|
+
export declare type CashReceipt = {
|
|
57
|
+
/** 현금영수증이 발행 된 order id입니다 */
|
|
58
|
+
orderId: string;
|
|
59
|
+
/** 현금영수증 발행 금액입니다 */
|
|
60
|
+
amount: number;
|
|
61
|
+
/** 현금영수증 발행 날짜입니다 yyyyMMddHHmmss */
|
|
62
|
+
issueDate: string;
|
|
63
|
+
/** 현금영수증 발행 번호입니다 */
|
|
64
|
+
issueNumber: string;
|
|
65
|
+
/** 현금영수증 발행 카드 번호입니다 */
|
|
66
|
+
cardNumber: string;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
declare interface CashReceiptTypes {
|
|
70
|
+
add: (receipt: CashReceipt) => Promise<void>;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @publicApi
|
|
75
|
+
*/
|
|
76
|
+
export declare type CatalogItemOptionChoiceState = 'ON_SALE' | 'SOLD_OUT';
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @publicApi
|
|
80
|
+
*/
|
|
81
|
+
export declare interface CatalogTypes {
|
|
82
|
+
getCatalogs: () => Promise<PluginCatalogItem[]>;
|
|
83
|
+
on: (event: 'sold-out' | 'on-sale', callback: (menu: PluginCatalogItem) => void) => void;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* @publicApi
|
|
88
|
+
*/
|
|
89
|
+
export declare interface CategoryTypes {
|
|
90
|
+
getCategories: () => Promise<PluginCatalogCategory[]>;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
declare type Digit = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9';
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* @publicApi
|
|
97
|
+
*/
|
|
98
|
+
export declare type ExternalPaymentMethodResponse = PaymentMethodResponse & {
|
|
99
|
+
sourceType: 'EXTERNAL';
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* @publicApi
|
|
104
|
+
*/
|
|
105
|
+
declare type FFIAbiType = '__stdcall';
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* @publicApi
|
|
109
|
+
*/
|
|
110
|
+
declare interface FFIApi extends FFIFunction {
|
|
111
|
+
name: string;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* @publicApi
|
|
116
|
+
*/
|
|
117
|
+
declare interface FFIFunction {
|
|
118
|
+
params?: FFIFunctionParam[];
|
|
119
|
+
return: FFIFunctionReturn;
|
|
120
|
+
options?: FFIFunctionOptions;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* @publicApi
|
|
125
|
+
*/
|
|
126
|
+
declare interface FFIFunctionOptions {
|
|
127
|
+
/**
|
|
128
|
+
* Application Binary Interface
|
|
129
|
+
* - 응용 프로그램 바이너리 인터페이스: 컴파일된 프로그램 모듈들이 바이너리 수준에서 상호작용하는 방식을 정의하는 인터페이스
|
|
130
|
+
*/
|
|
131
|
+
abi?: FFIAbiType;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* @publicApi
|
|
136
|
+
*/
|
|
137
|
+
declare type FFIFunctionParam = {
|
|
138
|
+
type: 'str';
|
|
139
|
+
} | {
|
|
140
|
+
type: 'int';
|
|
141
|
+
} | {
|
|
142
|
+
type: 'bool';
|
|
143
|
+
} | {
|
|
144
|
+
type: 'wchar *';
|
|
145
|
+
} | {
|
|
146
|
+
type: 'callback';
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* @publicApi
|
|
151
|
+
*/
|
|
152
|
+
declare type FFIFunctionReturn = 'void' | 'str' | 'int' | 'bool' | 'wchar *' | 'void *';
|
|
153
|
+
|
|
154
|
+
declare interface FFITypes {
|
|
155
|
+
download: (downloadUrl: string, filePath: string) => Promise<void>;
|
|
156
|
+
load: (filePath: string, apis: FFIApi[]) => Promise<void>;
|
|
157
|
+
unload: (filePath: string) => Promise<void>;
|
|
158
|
+
invoke: (filePath: string, apiName: string, params?: any[]) => Promise<any>;
|
|
159
|
+
registerCallback: (filePath: string, signature: FFIFunction, callback: (...args: any[]) => any) => Promise<{
|
|
160
|
+
ffiCallbackId: string;
|
|
161
|
+
}>;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* @publicApi
|
|
166
|
+
*/
|
|
167
|
+
export declare type HttpMethod = 'GET' | 'POST' | 'DELETE' | 'HEAD' | 'OPTIONS' | 'PUT' | 'PATCH';
|
|
168
|
+
|
|
169
|
+
declare interface HttpRequest {
|
|
170
|
+
method: HttpMethod;
|
|
171
|
+
payload?: string;
|
|
172
|
+
headers: [string, string][];
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* @publicApi
|
|
177
|
+
*/
|
|
178
|
+
export declare interface HttpTypes {
|
|
179
|
+
get: (url: string, headers?: [string, string][]) => Promise<PluginHttpResponse>;
|
|
180
|
+
post: (url: string, payload: any, headers?: [string, string][]) => Promise<PluginHttpResponse>;
|
|
181
|
+
delete: (url: string, headers?: [string, string][]) => Promise<PluginHttpResponse>;
|
|
182
|
+
head: (url: string, headers?: [string, string][]) => Promise<PluginHttpResponse>;
|
|
183
|
+
options: (url: string, headers?: [string, string][]) => Promise<PluginHttpResponse>;
|
|
184
|
+
put: (url: string, payload: any, headers?: [string, string][]) => Promise<PluginHttpResponse>;
|
|
185
|
+
patch: (url: string, payload: any, headers?: [string, string][]) => Promise<PluginHttpResponse>;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
declare type Join<T extends string, U extends string> = `${T}${U}` | '0';
|
|
189
|
+
|
|
190
|
+
declare type Languages = Record<PluginLanguageCode, string>;
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* @publicApi
|
|
194
|
+
*/
|
|
195
|
+
export declare interface MenuOptionTypes {
|
|
196
|
+
getOptions: () => Promise<PluginCatalogItemOption[]>;
|
|
197
|
+
on: (event: 'sold-out' | 'on-sale', callback: (option: PluginCatalogItemOption) => void) => void;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* @publicApi
|
|
202
|
+
*/
|
|
203
|
+
export declare interface MerchantTypes {
|
|
204
|
+
getMerchant: () => Promise<TossMerchant>;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
declare type OrderItemType = 'ITEM' | 'DELIVERY_FEE' | 'PREPAID_CARD';
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* @publicApi
|
|
211
|
+
*/
|
|
212
|
+
export declare interface OrderTypes {
|
|
213
|
+
getOrder: (id: string) => Promise<PluginOrder>;
|
|
214
|
+
/**
|
|
215
|
+
* 토스 포스에서 카드결제를 취소하면 무조건 카드리딩해야함 그래서 on cancel은 늘 환불까지 된 상태임
|
|
216
|
+
*/
|
|
217
|
+
on: (event: 'cancel', callback: (order: PluginOrder) => void) => void;
|
|
218
|
+
cancel: (id: string) => Promise<void>;
|
|
219
|
+
add: (order: PluginOrderDto) => Promise<PluginOrder>;
|
|
220
|
+
/**
|
|
221
|
+
* 새로 추가 된 메뉴만 order에 넣으세요
|
|
222
|
+
*/
|
|
223
|
+
addMenu: (orderId: string, order: PluginOrderDto) => Promise<PluginOrder>;
|
|
224
|
+
complete: (id: string) => Promise<PluginOrder>;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
declare type PayCallback = (order: PluginOrder, price: PluginPrice) => Promise<PaymentMethodResponse | undefined>;
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* @publicApi
|
|
231
|
+
* @description 포스에 원장이 생기는 payment
|
|
232
|
+
* @see https://tossteam.slack.com/archives/C037HM4QJ0L/p1740547954237879?thread_ts=1740500512.811309&cid=C037HM4QJ0L
|
|
233
|
+
*/
|
|
234
|
+
export declare type PaymentMethodResponse = {
|
|
235
|
+
/**
|
|
236
|
+
* 승인일시
|
|
237
|
+
* @example 2022-01-27T11:42:33
|
|
238
|
+
*/
|
|
239
|
+
approvedAt: string;
|
|
240
|
+
approvedNo: string;
|
|
241
|
+
paymentKey: string;
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
declare type PaymentMethodType = {
|
|
245
|
+
add: (payload: {
|
|
246
|
+
data: {
|
|
247
|
+
/**
|
|
248
|
+
* @description 결제수단의 id (unique)
|
|
249
|
+
* @description 결제수단이 여러개인 경우 필요하 것 같아 추가함
|
|
250
|
+
*/
|
|
251
|
+
id: string;
|
|
252
|
+
paymentName: string;
|
|
253
|
+
/**
|
|
254
|
+
* @description 결제수단의 이미지 url
|
|
255
|
+
* @description 30x30
|
|
256
|
+
*/
|
|
257
|
+
image: string;
|
|
258
|
+
};
|
|
259
|
+
payCallback: PayCallback;
|
|
260
|
+
cancelCallback: CancelCallback;
|
|
261
|
+
}) => void;
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
declare interface PaymentTypes {
|
|
265
|
+
on: (event: 'cancel' | 'paid', callback: (payload: PluginPaymentOf<'CASH'> | PluginPaymentOf<'CARD'> | PluginPaymentOf<'EXTERNAL'>) => void) => void;
|
|
266
|
+
cancel: (order: {
|
|
267
|
+
id: string;
|
|
268
|
+
}, payment: {
|
|
269
|
+
id: string;
|
|
270
|
+
}) => Promise<void>;
|
|
271
|
+
add: (order: {
|
|
272
|
+
id: string;
|
|
273
|
+
}, paymentDto: PluginPaymentDto) => Promise<PluginPaymentOf<'CARD'> | PluginPaymentOf<'CASH'> | PluginPaymentOf<'EXTERNAL'>>;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* @publicApi
|
|
278
|
+
*/
|
|
279
|
+
export declare type PluginCancelledPaymentDto = {
|
|
280
|
+
cancelledAt: string;
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
declare interface PluginCardDto extends PluginPaymentDtoBase {
|
|
284
|
+
sourceType: 'CARD';
|
|
285
|
+
cardDetails: PluginPaymentOf<'CARD'>['cardDetails'];
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* @publicApi
|
|
290
|
+
*/
|
|
291
|
+
export declare interface PluginCardPayment extends PluginPaymentBase {
|
|
292
|
+
sourceType: 'CARD';
|
|
293
|
+
cardDetails: {
|
|
294
|
+
installmentMonth: PluginPaymentInstallment;
|
|
295
|
+
cardType: PluginPaymentCardType;
|
|
296
|
+
/** 발급사명 */
|
|
297
|
+
cardBrand: string;
|
|
298
|
+
/** 발급사 코드 */
|
|
299
|
+
cardBrandId?: string;
|
|
300
|
+
/** 카드번호 */
|
|
301
|
+
cardNo: string;
|
|
302
|
+
/** 매입사명 */
|
|
303
|
+
source?: string;
|
|
304
|
+
/** 매입사 코드 */
|
|
305
|
+
sourceId?: string;
|
|
306
|
+
/** 선불카드일 때 잔액 */
|
|
307
|
+
balance?: number;
|
|
308
|
+
/** VAN사 */
|
|
309
|
+
van?: VanType;
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
declare interface PluginCashDto extends PluginPaymentDtoBase {
|
|
314
|
+
sourceType: 'CASH';
|
|
315
|
+
cashReceipt?: PluginCashReceipt;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* @publicApi
|
|
320
|
+
*/
|
|
321
|
+
export declare interface PluginCashPayment extends PluginPaymentBase {
|
|
322
|
+
sourceType: 'CASH';
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* @publicApi
|
|
327
|
+
* 현금영수증
|
|
328
|
+
*/
|
|
329
|
+
export declare interface PluginCashReceipt {
|
|
330
|
+
/** 현금영수증 식별번호 */
|
|
331
|
+
identityNumber: string;
|
|
332
|
+
issuerType: PluginCashReceiptIssuerType;
|
|
333
|
+
issuanceType: PluginCashReceiptIssuanceType;
|
|
334
|
+
/** 자진 발급 여부 */
|
|
335
|
+
selfIssuance: boolean;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* @publicApi
|
|
340
|
+
* 현금영수증 발행 유형
|
|
341
|
+
* PHONE: 휴대폰번호
|
|
342
|
+
* BUSINESS_NUMBER: 사업자번호
|
|
343
|
+
* CARD: 현금영수증 카드
|
|
344
|
+
*/
|
|
345
|
+
export declare type PluginCashReceiptIssuanceType = 'PHONE' | 'BUSINESS_NUMBER' | 'CARD';
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* @publicApi
|
|
349
|
+
* 현금영수증 발급 유형
|
|
350
|
+
* CONSUMER: 개인
|
|
351
|
+
* BUSINESSES: 사업자
|
|
352
|
+
*/
|
|
353
|
+
export declare type PluginCashReceiptIssuerType = 'CONSUMER' | 'BUSINESSES';
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* @publicApi
|
|
357
|
+
*/
|
|
358
|
+
export declare interface PluginCatalogCategory {
|
|
359
|
+
id: number;
|
|
360
|
+
title: string;
|
|
361
|
+
titleI18n?: PluginLanguagePack;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* @publicApi
|
|
366
|
+
* response
|
|
367
|
+
* 포스에 있는 메뉴를 조회할 때
|
|
368
|
+
*/
|
|
369
|
+
export declare interface PluginCatalogItem {
|
|
370
|
+
/**
|
|
371
|
+
* @description 토스 포스에 등록된 메뉴의 고유 아이디
|
|
372
|
+
*/
|
|
373
|
+
id: number;
|
|
374
|
+
/**
|
|
375
|
+
* @description 포스 내에서 보여주는 타이틀
|
|
376
|
+
* @description 사장님께만 보입니다
|
|
377
|
+
*/
|
|
378
|
+
title: string;
|
|
379
|
+
/**
|
|
380
|
+
* @description 다국어지원을 위해 추가된 필드입니다
|
|
381
|
+
*/
|
|
382
|
+
titleI18n?: PluginLanguagePack;
|
|
383
|
+
/**
|
|
384
|
+
* @description 메뉴의 상태입니다
|
|
385
|
+
* @description ON_SALE: 현재 판매중
|
|
386
|
+
* @description SOLD_OUT: 품절
|
|
387
|
+
* @description UNAVAILABLE: 기타 판매불가
|
|
388
|
+
* @description DELETED: 제거됨
|
|
389
|
+
*/
|
|
390
|
+
state: PluginCatalogItemState;
|
|
391
|
+
description?: string;
|
|
392
|
+
descriptionI18n?: PluginLanguagePack;
|
|
393
|
+
/**
|
|
394
|
+
* @description 메뉴의 카테고리입니다
|
|
395
|
+
*/
|
|
396
|
+
category: PluginCatalogCategory;
|
|
397
|
+
/**
|
|
398
|
+
* @description 메뉴에 달린 벳지입니다
|
|
399
|
+
*/
|
|
400
|
+
labels: PluginCatalogItemLabel[];
|
|
401
|
+
imageUrl: string | null;
|
|
402
|
+
/**
|
|
403
|
+
* @description 상품의 가격정보
|
|
404
|
+
*/
|
|
405
|
+
price: PluginCatalogItemPrice;
|
|
406
|
+
/**
|
|
407
|
+
* @description 상품에서 사용가능한 옵션 리스트
|
|
408
|
+
*/
|
|
409
|
+
options: PluginCatalogItemOption[];
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* @publicApi
|
|
414
|
+
* request
|
|
415
|
+
* 포스에 메뉴를 만들때 update아니다 생성할 때만 사용한다
|
|
416
|
+
* update할때는 다른 api 사용하시라
|
|
417
|
+
* 생성할 때 state는 무조건 on_sale
|
|
418
|
+
*/
|
|
419
|
+
export declare interface PluginCatalogItemDto {
|
|
420
|
+
title: string;
|
|
421
|
+
titleI18n?: PluginLanguagePack;
|
|
422
|
+
description?: string;
|
|
423
|
+
descriptionI18n?: PluginLanguagePack;
|
|
424
|
+
categoryId: number;
|
|
425
|
+
price: PluginCatalogItemPrice;
|
|
426
|
+
labels: PluginCatalogItemLabel[];
|
|
427
|
+
imageUrl: string | null;
|
|
428
|
+
/**
|
|
429
|
+
* @description 옵션을 먼저 만들고 id를 넣어달라
|
|
430
|
+
*/
|
|
431
|
+
options: Pick<PluginCatalogItemOption, 'id'>[];
|
|
432
|
+
kioskTitle?: string;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* @publicApi
|
|
437
|
+
* @description 메뉴에 인기/신규/쿠폰 등의 뱃지를 단다
|
|
438
|
+
*/
|
|
439
|
+
export declare interface PluginCatalogItemLabel {
|
|
440
|
+
title: string;
|
|
441
|
+
color: string;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* @publicApi
|
|
446
|
+
* @description 아직 dto는 정의되지 않았음
|
|
447
|
+
* @todo option dto 만들어야함
|
|
448
|
+
*/
|
|
449
|
+
export declare interface PluginCatalogItemOption {
|
|
450
|
+
id: number;
|
|
451
|
+
title: string;
|
|
452
|
+
titleI18n?: PluginLanguagePack;
|
|
453
|
+
isRequired: boolean;
|
|
454
|
+
minChoices: number;
|
|
455
|
+
/**
|
|
456
|
+
* 최대로 선택가능한 선택 수
|
|
457
|
+
* -1인 경우 무제한 선택이 가능합니다.
|
|
458
|
+
*/
|
|
459
|
+
maxChoices: number;
|
|
460
|
+
choices: PluginCatalogItemOptionChoice[];
|
|
461
|
+
/**
|
|
462
|
+
* 기본으로 선택되어 있는 CatalogItemOptionChoice['id'] 리스트
|
|
463
|
+
* 기본값이 없다면 빈 배열입니다.
|
|
464
|
+
*/
|
|
465
|
+
defaultChoices: number[];
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* @publicApi
|
|
470
|
+
*/
|
|
471
|
+
export declare interface PluginCatalogItemOptionChoice {
|
|
472
|
+
id: number;
|
|
473
|
+
title: string;
|
|
474
|
+
titleI18n?: PluginLanguagePack;
|
|
475
|
+
/** 옵션에 딸린 가격이 없는 경우 0 */
|
|
476
|
+
priceValue: number;
|
|
477
|
+
/** 키오스크에서 표시되는 아이콘 URL */
|
|
478
|
+
imageUrl?: string | null;
|
|
479
|
+
state: CatalogItemOptionChoiceState;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
/**
|
|
483
|
+
* @publicApi
|
|
484
|
+
*/
|
|
485
|
+
export declare interface PluginCatalogItemPrice {
|
|
486
|
+
id: number;
|
|
487
|
+
/** 상품 가격명 */
|
|
488
|
+
title: string;
|
|
489
|
+
/** 기본 가격 여부 */
|
|
490
|
+
isDefault: boolean;
|
|
491
|
+
/** 상품 가격 상태 */
|
|
492
|
+
state: PluginCatalogItemState;
|
|
493
|
+
/**
|
|
494
|
+
* 재고 관리 코드
|
|
495
|
+
* @see https://en.wikipedia.org/wiki/Stock_keeping_unit
|
|
496
|
+
*/
|
|
497
|
+
sku: string | null;
|
|
498
|
+
/** 상품 가격의 바코드 정보 */
|
|
499
|
+
barcode: string | null;
|
|
500
|
+
/** 가격 유형 */
|
|
501
|
+
priceType: PluginCatalogItemPriceType;
|
|
502
|
+
/** 가격의 기본 개수 */
|
|
503
|
+
priceUnit: number;
|
|
504
|
+
/**
|
|
505
|
+
* 부가가치세(VAT)가 포함된 가격
|
|
506
|
+
*/
|
|
507
|
+
priceValue: number;
|
|
508
|
+
/** 비과세 여부 */
|
|
509
|
+
isTaxFree: boolean;
|
|
510
|
+
/** 재고 관리여부 */
|
|
511
|
+
isStockable: boolean;
|
|
512
|
+
/** 현재 남아있는 재고 수 */
|
|
513
|
+
stockQuantity: {
|
|
514
|
+
remainQuantity: number;
|
|
515
|
+
lastChangeDateTime: string;
|
|
516
|
+
} | null;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
* @publicApi
|
|
521
|
+
* FIXED: 고정 가격
|
|
522
|
+
* VARIABLE: 시가(예: 수산시장 방어회)
|
|
523
|
+
*/
|
|
524
|
+
export declare type PluginCatalogItemPriceType = 'FIXED' | 'VARIABLE';
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* 상품 상태
|
|
528
|
+
* ON_SALE: 현재 판매중
|
|
529
|
+
* SOLD_OUT: 품절
|
|
530
|
+
* UNAVAILABLE: 기타 판매불가
|
|
531
|
+
* DELETED: 제거됨
|
|
532
|
+
*/
|
|
533
|
+
declare type PluginCatalogItemState = 'ON_SALE' | 'SOLD_OUT' | 'UNAVAILABLE' | 'DELETED';
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* @publicApi
|
|
537
|
+
* 할인 정보
|
|
538
|
+
* */
|
|
539
|
+
export declare interface PluginDiscount {
|
|
540
|
+
/**
|
|
541
|
+
* 할인 금액
|
|
542
|
+
* 퍼센티지 할인인 경우 계산된 금액 입니다.
|
|
543
|
+
*/
|
|
544
|
+
amountMoney: {
|
|
545
|
+
value: number;
|
|
546
|
+
};
|
|
547
|
+
/** 할인 명칭 */
|
|
548
|
+
title: string;
|
|
549
|
+
titleI18n?: PluginLanguagePack;
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
declare interface PluginExternalDto extends PluginPaymentDtoBase {
|
|
553
|
+
sourceType: 'EXTERNAL';
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
* @publicApi
|
|
558
|
+
*/
|
|
559
|
+
export declare interface PluginExternalPayment extends PluginPaymentBase {
|
|
560
|
+
sourceType: 'EXTERNAL';
|
|
561
|
+
externalDetails: {
|
|
562
|
+
/**
|
|
563
|
+
* 기타 결제 수단의 소스
|
|
564
|
+
*/
|
|
565
|
+
source?: string;
|
|
566
|
+
sourceId?: string;
|
|
567
|
+
};
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
/**
|
|
571
|
+
* @publicApi
|
|
572
|
+
* 테이블이 놓여진 공간
|
|
573
|
+
* */
|
|
574
|
+
export declare interface PluginHall {
|
|
575
|
+
id: number;
|
|
576
|
+
title: string;
|
|
577
|
+
/** 순서값. 오름차순 정렬 합니다. */
|
|
578
|
+
order: number;
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
/**
|
|
582
|
+
* @publicApi
|
|
583
|
+
*/
|
|
584
|
+
export declare interface PluginHttpRequest extends HttpRequest {
|
|
585
|
+
url: string;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
/**
|
|
589
|
+
* @publicApi
|
|
590
|
+
*/
|
|
591
|
+
export declare type PluginHttpResponse = {
|
|
592
|
+
body: string;
|
|
593
|
+
headers: [string, string][];
|
|
594
|
+
code: number;
|
|
595
|
+
};
|
|
596
|
+
|
|
597
|
+
declare type PluginLanguageCode = ValueOf<typeof AvailableLanguageCodes>;
|
|
598
|
+
|
|
599
|
+
/**
|
|
600
|
+
* @publicApi
|
|
601
|
+
*/
|
|
602
|
+
export declare interface PluginLanguagePack {
|
|
603
|
+
key?: string;
|
|
604
|
+
languages: Partial<Languages>;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
/**
|
|
608
|
+
* @publicApi
|
|
609
|
+
* @description pluginOrder orderDto를 서버에 저장 후 가공해서 내려 준 값
|
|
610
|
+
*/
|
|
611
|
+
export declare interface PluginOrder {
|
|
612
|
+
id: string;
|
|
613
|
+
/** 테이블 주문. */
|
|
614
|
+
tableId?: number;
|
|
615
|
+
table?: PluginTable;
|
|
616
|
+
orderKey: string;
|
|
617
|
+
state: PluginOrderState;
|
|
618
|
+
lineItems: PluginOrderItem[];
|
|
619
|
+
discounts?: PluginDiscount[];
|
|
620
|
+
payments: PluginPayment[];
|
|
621
|
+
chargePrice: PluginOrderChargePrice;
|
|
622
|
+
paymentPrice: PluginOrderPaymentPrice;
|
|
623
|
+
requestedInfo?: PluginOrderRequestInfo;
|
|
624
|
+
source: string;
|
|
625
|
+
memo?: string;
|
|
626
|
+
/**
|
|
627
|
+
* 해당값이 있다면 createdAt 대신 사용해주세요.
|
|
628
|
+
*/
|
|
629
|
+
openedAt?: string;
|
|
630
|
+
createdAt: string;
|
|
631
|
+
updatedAt?: string;
|
|
632
|
+
cancelledAt?: string;
|
|
633
|
+
completedAt?: string;
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
declare interface PluginOrderChargePrice {
|
|
637
|
+
/** 청구 할인 금액 = 할인 금액 + 할인 취소 금액 */
|
|
638
|
+
chargeDiscountValue: number;
|
|
639
|
+
/** 청구 원주문 금액 = 원주문 금액 + 환불 원주문 금액 */
|
|
640
|
+
chargeListPriceValue: number;
|
|
641
|
+
/**
|
|
642
|
+
* 청구 금액 = 청구 원주문 금액 + 청구 할인 금액 + 청구 봉사료
|
|
643
|
+
*/
|
|
644
|
+
chargePriceValue: number;
|
|
645
|
+
/** 청구 공급 가액 = 청구 금액 - 청구 세액 */
|
|
646
|
+
chargeSupplyValue: number;
|
|
647
|
+
/**
|
|
648
|
+
* 청구 세액(부가가치세) = 청구 금액 / (1+VAT)
|
|
649
|
+
* VAT=10
|
|
650
|
+
*/
|
|
651
|
+
chargeTaxValue: number;
|
|
652
|
+
/** 청구 봉사료 = 봉사료 + 환불 봉사료 */
|
|
653
|
+
chargeTipValue: number;
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
/**
|
|
657
|
+
* @publicApi
|
|
658
|
+
* HERE: 매장내
|
|
659
|
+
* TOGO: 포장
|
|
660
|
+
* DELIVERY: 배달
|
|
661
|
+
* PICKUP: 픽업
|
|
662
|
+
*/
|
|
663
|
+
export declare type PluginOrderDiningOption = 'HERE' | 'TOGO' | 'DELIVERY' | 'PICKUP';
|
|
664
|
+
|
|
665
|
+
/**
|
|
666
|
+
* @publicApi
|
|
667
|
+
* @description order를 만들기 위한 dto
|
|
668
|
+
*/
|
|
669
|
+
export declare type PluginOrderDto = {
|
|
670
|
+
memo?: string;
|
|
671
|
+
discounts: PluginDiscount[];
|
|
672
|
+
tableId?: number;
|
|
673
|
+
lineItems: Omit<PluginOrderItem, 'id' | 'orderId'>[];
|
|
674
|
+
};
|
|
675
|
+
|
|
676
|
+
/**
|
|
677
|
+
* @publicApi
|
|
678
|
+
*/
|
|
679
|
+
export declare interface PluginOrderItem {
|
|
680
|
+
id: string;
|
|
681
|
+
orderId: string;
|
|
682
|
+
diningOption: PluginOrderDiningOption;
|
|
683
|
+
item: Pick<PluginCatalogItem, 'id' | 'title' | 'category'> & {
|
|
684
|
+
type: OrderItemType;
|
|
685
|
+
};
|
|
686
|
+
quantity: {
|
|
687
|
+
value: number;
|
|
688
|
+
};
|
|
689
|
+
/**
|
|
690
|
+
* @description 실제 고객이 결제하는 금액에 대한 정보입니다.
|
|
691
|
+
*/
|
|
692
|
+
chargePrice: {
|
|
693
|
+
value: number;
|
|
694
|
+
};
|
|
695
|
+
optionChoices: PluginCatalogItemOptionChoice[];
|
|
696
|
+
discounts?: PluginDiscount[];
|
|
697
|
+
memo?: string;
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
declare interface PluginOrderPaymentPrice {
|
|
701
|
+
/** 미납 결제 금액 */
|
|
702
|
+
paymentUnpaidValue: number;
|
|
703
|
+
/** 완납 결제 금액 */
|
|
704
|
+
paymentPaidValue: number;
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
declare interface PluginOrderRequestInfo {
|
|
708
|
+
/** 요청 시간 */
|
|
709
|
+
requestAt: string;
|
|
710
|
+
/** 만료 시간 */
|
|
711
|
+
expiredAt: string;
|
|
712
|
+
/** 픽업 시간 */
|
|
713
|
+
expectedReadyAt: string;
|
|
714
|
+
/** 예상 완료 시간 */
|
|
715
|
+
estimatedReadyAt?: string;
|
|
716
|
+
/** 접수 시간 */
|
|
717
|
+
acceptedAt?: string;
|
|
718
|
+
/** 거부 시간 */
|
|
719
|
+
declinedAt?: string;
|
|
720
|
+
/** 거부 사유 */
|
|
721
|
+
declinedReason?: string;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
/**
|
|
725
|
+
* @publicApi
|
|
726
|
+
* 주문 상태
|
|
727
|
+
* 상태 전이 규칙은 아래 문서를 참조해주세요.
|
|
728
|
+
* https://www.notion.so/tossteam/1affab9356d24d2d9256ca21be2db473
|
|
729
|
+
*
|
|
730
|
+
* OPENED: 주문시작
|
|
731
|
+
* PAID: 분할결제 중
|
|
732
|
+
* CANCELLED: 주문취소
|
|
733
|
+
* COMPLETED: 주문완료. 결제까지 완료된 상태
|
|
734
|
+
* REFUNDED: 환불
|
|
735
|
+
*/
|
|
736
|
+
export declare type PluginOrderState = 'OPENED' | 'PAID' | 'CANCELLED' | 'COMPLETED' | 'REFUNDED';
|
|
737
|
+
|
|
738
|
+
/**
|
|
739
|
+
* @publicApi
|
|
740
|
+
*/
|
|
741
|
+
export declare type PluginPayment = (PluginCardPayment | PluginCashPayment | PluginExternalPayment) & {
|
|
742
|
+
paymentKey: string;
|
|
743
|
+
};
|
|
744
|
+
|
|
745
|
+
/**
|
|
746
|
+
* @publicApi
|
|
747
|
+
*/
|
|
748
|
+
export declare interface PluginPaymentBase {
|
|
749
|
+
id: string;
|
|
750
|
+
orderId: string;
|
|
751
|
+
/** 결제상태 */
|
|
752
|
+
state: PluginPaymentState;
|
|
753
|
+
/** 결제수단 */
|
|
754
|
+
sourceType: PluginPaymentSourceType;
|
|
755
|
+
/** 지불액 */
|
|
756
|
+
amountMoney: number;
|
|
757
|
+
/** 부가가치세 */
|
|
758
|
+
taxMoney: number;
|
|
759
|
+
/** 공급가액 */
|
|
760
|
+
supplyMoney: number;
|
|
761
|
+
/** 봉사료 */
|
|
762
|
+
tipMoney: number;
|
|
763
|
+
/** 면세 금액. 값을 지정하지 않으면 기본으로 0원이 지정됨 */
|
|
764
|
+
taxExemptMoney?: number;
|
|
765
|
+
/** 승인번호 */
|
|
766
|
+
approvedNo: string;
|
|
767
|
+
/**
|
|
768
|
+
* 승인일시
|
|
769
|
+
* @example 2022-01-27T11:42:35
|
|
770
|
+
*/
|
|
771
|
+
approvedAt: string;
|
|
772
|
+
/**
|
|
773
|
+
* 취소일시
|
|
774
|
+
* 취소거래인 경우에만 값 존재
|
|
775
|
+
*/
|
|
776
|
+
cancelledAt?: string;
|
|
777
|
+
/** 현금영수증 정보
|
|
778
|
+
* 계좌이체가 추가되면서 현금 결제가 아니어도 현금영수증 발행이 가능함
|
|
779
|
+
* */
|
|
780
|
+
cashReceipt?: PluginCashReceipt;
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
/**
|
|
784
|
+
* @publicApi
|
|
785
|
+
* CREDIT: 신용카드
|
|
786
|
+
* DEBIT: 체크카드
|
|
787
|
+
* PREPAID: 선불카드
|
|
788
|
+
* FOREIGN: 해외카드
|
|
789
|
+
*/
|
|
790
|
+
export declare type PluginPaymentCardType = 'CREDIT' | 'DEBIT' | 'PREPAID' | 'FOREIGN';
|
|
791
|
+
|
|
792
|
+
/**
|
|
793
|
+
* @publicApi
|
|
794
|
+
* @description 파트너사에 원장이 생기는 payment
|
|
795
|
+
*/
|
|
796
|
+
export declare type PluginPaymentDto<S extends PluginPaymentSourceType = PluginPaymentSourceType> = Extract<AllPaymentCreateDto, {
|
|
797
|
+
sourceType: S;
|
|
798
|
+
}>;
|
|
799
|
+
|
|
800
|
+
declare type PluginPaymentDtoBase = Pick<PluginPayment,
|
|
801
|
+
/**
|
|
802
|
+
* orderId 그냥 열어두면 이상한 값 넣을가봐 걱정... 방어코드 필요
|
|
803
|
+
*/
|
|
804
|
+
'orderId' | 'sourceType' | 'amountMoney' | 'taxMoney' | 'approvedNo' | 'approvedAt' | 'paymentKey' | 'supplyMoney' | 'tipMoney' | 'taxExemptMoney'>;
|
|
805
|
+
|
|
806
|
+
/**
|
|
807
|
+
* @publicApi
|
|
808
|
+
* 할부개월 수
|
|
809
|
+
* 00: 일시불. 현금IC의 경우 일반거래
|
|
810
|
+
* 01: 현금IC의 경우 간소화 거래(비밀번호 입력생략)
|
|
811
|
+
*/
|
|
812
|
+
export declare type PluginPaymentInstallment = Join<Digit, Digit>;
|
|
813
|
+
|
|
814
|
+
/**
|
|
815
|
+
* @publicApi
|
|
816
|
+
*/
|
|
817
|
+
export declare type PluginPaymentOf<S extends PluginPaymentSourceType> = Extract<PluginPayment, {
|
|
818
|
+
sourceType: S;
|
|
819
|
+
}>;
|
|
820
|
+
|
|
821
|
+
/**
|
|
822
|
+
* @publicApi
|
|
823
|
+
* CARD: 신용카드
|
|
824
|
+
* CASH: 현금
|
|
825
|
+
* BARCODE: 바코드/QR을 사용하는 간편결제
|
|
826
|
+
* EXTERNAL: 기타결제(쿠폰, 외상 등)
|
|
827
|
+
*/
|
|
828
|
+
export declare type PluginPaymentSourceType = 'CARD' | 'CASH' | 'EXTERNAL';
|
|
829
|
+
|
|
830
|
+
/**
|
|
831
|
+
* @publicApi
|
|
832
|
+
*/
|
|
833
|
+
export declare type PluginPaymentState = 'APPROVED' | 'COMPLETED' | 'CANCELLED';
|
|
834
|
+
|
|
835
|
+
/**
|
|
836
|
+
* @publicApi
|
|
837
|
+
*/
|
|
838
|
+
export declare type PluginPrice = {
|
|
839
|
+
/** 지불액 */
|
|
840
|
+
amountMoney: number;
|
|
841
|
+
/** 부가가치세 */
|
|
842
|
+
taxMoney: number;
|
|
843
|
+
/** 공급가액 */
|
|
844
|
+
supplyMoney: number;
|
|
845
|
+
/** 봉사료 */
|
|
846
|
+
tipMoney: number;
|
|
847
|
+
/** 면세금액 */
|
|
848
|
+
taxExemptMoney: number;
|
|
849
|
+
};
|
|
850
|
+
|
|
851
|
+
/**
|
|
852
|
+
* @publicApi
|
|
853
|
+
*/
|
|
854
|
+
export declare interface PluginTable {
|
|
855
|
+
id: number;
|
|
856
|
+
/** 테이블이 놓여진 공간 id */
|
|
857
|
+
hallId: number;
|
|
858
|
+
/** 테이블명 */
|
|
859
|
+
title: string;
|
|
860
|
+
group?: PluginTableGroup;
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
/**
|
|
864
|
+
* @publicApi
|
|
865
|
+
*/
|
|
866
|
+
export declare interface PluginTableGroup {
|
|
867
|
+
id: number;
|
|
868
|
+
color: string;
|
|
869
|
+
merchantId: number;
|
|
870
|
+
/** 공간에 속한 테이블 리스트 */
|
|
871
|
+
tableIds: number[];
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
/**
|
|
875
|
+
* @publicApi
|
|
876
|
+
*/
|
|
877
|
+
export declare type PopupActionResponse<T extends AllPopupType> = Extract<AllPopupResponse, {
|
|
878
|
+
type: T;
|
|
879
|
+
}>;
|
|
880
|
+
|
|
881
|
+
/**
|
|
882
|
+
* @publicApi
|
|
883
|
+
*/
|
|
884
|
+
export declare type PopupElements<T extends AllPopupType> = Extract<AllPopupElements, {
|
|
885
|
+
type: T;
|
|
886
|
+
}>;
|
|
887
|
+
|
|
888
|
+
/**
|
|
889
|
+
* @publicApi
|
|
890
|
+
*/
|
|
891
|
+
export declare const pos: Sdk;
|
|
892
|
+
|
|
893
|
+
/**
|
|
894
|
+
* @publicApi
|
|
895
|
+
*/
|
|
896
|
+
export declare class PosPluginSdkError extends Error {
|
|
897
|
+
constructor(message: string);
|
|
898
|
+
static isPosPluginSdkError(error: unknown): error is PosPluginSdkError;
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
/**
|
|
902
|
+
* @publicApi
|
|
903
|
+
*/
|
|
904
|
+
export declare type Sdk = {
|
|
905
|
+
table: TableTypes;
|
|
906
|
+
category: CategoryTypes;
|
|
907
|
+
catalog: CatalogTypes;
|
|
908
|
+
option: MenuOptionTypes;
|
|
909
|
+
storage: StorageTypes;
|
|
910
|
+
cashReceipt: CashReceiptTypes;
|
|
911
|
+
order: OrderTypes;
|
|
912
|
+
payment: PaymentTypes;
|
|
913
|
+
http: HttpTypes;
|
|
914
|
+
toast: ToastTypes;
|
|
915
|
+
merchant: MerchantTypes;
|
|
916
|
+
ui: UiType;
|
|
917
|
+
paymentMethod: PaymentMethodType;
|
|
918
|
+
websocket: WebsocketTypes;
|
|
919
|
+
ffi: FFITypes;
|
|
920
|
+
};
|
|
921
|
+
|
|
922
|
+
/**
|
|
923
|
+
* @publicApi
|
|
924
|
+
*/
|
|
925
|
+
export declare interface StorageTypes {
|
|
926
|
+
get: (key: string) => Promise<string | undefined>;
|
|
927
|
+
set: (key: string, value: string) => Promise<void>;
|
|
928
|
+
del: (key: string) => Promise<void>;
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
declare interface TableTypes {
|
|
932
|
+
getTables: () => Promise<{
|
|
933
|
+
table: PluginTable;
|
|
934
|
+
order?: PluginOrder;
|
|
935
|
+
}[]>;
|
|
936
|
+
on(event: 'order-update' | 'add' | 'clear', callback: (table: PluginTable) => void): void;
|
|
937
|
+
on(event: 'swap' | 'move' | 'merge', callback: (before: PluginTable, after: PluginTable) => void): void;
|
|
938
|
+
clearTable: (payload: {
|
|
939
|
+
table: PluginTable;
|
|
940
|
+
order?: PluginOrder;
|
|
941
|
+
}) => Promise<void>;
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
declare type ToastTypes = {
|
|
945
|
+
open(message: string): void;
|
|
946
|
+
};
|
|
947
|
+
|
|
948
|
+
/**
|
|
949
|
+
* @publicApi
|
|
950
|
+
* @description 추후에 필요한 정보 더 추가될 예정
|
|
951
|
+
*/
|
|
952
|
+
export declare type TossMerchant = {
|
|
953
|
+
name: string;
|
|
954
|
+
id: number;
|
|
955
|
+
serialNumber: string;
|
|
956
|
+
franchiseId?: string;
|
|
957
|
+
franchiseName?: string;
|
|
958
|
+
};
|
|
959
|
+
|
|
960
|
+
declare type UiType = {
|
|
961
|
+
openPopup<T extends AllPopupType>(message: PopupElements<T>): Promise<PopupActionResponse<T>>;
|
|
962
|
+
};
|
|
963
|
+
|
|
964
|
+
declare type ValueOf<ObjectType, ValueType extends keyof ObjectType = keyof ObjectType> = ObjectType[ValueType];
|
|
965
|
+
|
|
966
|
+
/**
|
|
967
|
+
* @publicApi
|
|
968
|
+
*/
|
|
969
|
+
export declare type VanType = 'NICE' | 'KIS' | 'SMARTRO' | 'KOVAN';
|
|
970
|
+
|
|
971
|
+
declare class Websocket {
|
|
972
|
+
private readonly url;
|
|
973
|
+
private readonly headers;
|
|
974
|
+
private readonly options?;
|
|
975
|
+
onMessageCallback: ((message: string) => void) | undefined;
|
|
976
|
+
onErrorCallback: ((errorName?: string, errorMessage?: string) => void) | undefined;
|
|
977
|
+
onCloseCallback: ((code: string) => void) | undefined;
|
|
978
|
+
onOpenCallback: (() => void) | undefined;
|
|
979
|
+
constructor(url: string, headers: Record<string, string>, options?: {
|
|
980
|
+
rejectUnauthorized?: boolean | undefined;
|
|
981
|
+
followRedirects?: boolean | undefined;
|
|
982
|
+
timeout?: number | undefined;
|
|
983
|
+
} | undefined);
|
|
984
|
+
connect(): Promise<void>;
|
|
985
|
+
disconnect(): Promise<void>;
|
|
986
|
+
send(data: {
|
|
987
|
+
data: string;
|
|
988
|
+
option?: {
|
|
989
|
+
mask?: boolean;
|
|
990
|
+
};
|
|
991
|
+
}): void;
|
|
992
|
+
onMessage(callback: (message: string) => void): void;
|
|
993
|
+
onError(callback: (errorName?: string, errorMessage?: string) => void): void;
|
|
994
|
+
onClose(callback: (code: string) => void): void;
|
|
995
|
+
onOpen(callback: () => void): void;
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
declare type WebsocketTypes = {
|
|
999
|
+
create: (url: string, headers: Record<string, string>, options?: {
|
|
1000
|
+
rejectUnauthorized?: boolean;
|
|
1001
|
+
followRedirects?: boolean;
|
|
1002
|
+
timeout?: number;
|
|
1003
|
+
}) => Promise<Websocket>;
|
|
1004
|
+
};
|
|
1005
|
+
|
|
1006
|
+
export { }
|