@tossplace/pos-plugin-sdk 0.0.6 → 0.0.7

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/types/index.d.ts CHANGED
@@ -7,6 +7,13 @@ declare const AvailableLanguageCodes: {
7
7
  readonly English: "en-US";
8
8
  };
9
9
 
10
+ declare interface Barcode {
11
+ send(barcode: string): Promise<void>;
12
+ on(event: 'scan', callback: (barcode: string) => void): void;
13
+ useBarcodeScan(): void;
14
+ unUseBarcodeScan(): void;
15
+ }
16
+
10
17
  /**
11
18
  */
12
19
  declare type BarcodeElements = {
@@ -35,12 +42,6 @@ declare type BaseInput = {
35
42
  required: boolean;
36
43
  };
37
44
 
38
- declare type BaseInput_2 = {
39
- label: string;
40
- required: boolean;
41
- id: string;
42
- };
43
-
44
45
  declare type CancelCallback = (order: PluginOrder, payment: PluginPayment, ui: Ui) => Promise<PluginCancelledPaymentDto | undefined>;
45
46
 
46
47
  /**
@@ -71,9 +72,14 @@ export declare interface CashReceiptTypes {
71
72
  * @publicApi
72
73
  */
73
74
  export declare interface Catalog {
75
+ getCatalog: (catalogId: number) => Promise<PluginCatalogItem>;
74
76
  getCatalogs: () => Promise<PluginCatalogItem[]>;
77
+ on(event: 'update' | 'add' | 'delete', callback: CatalogEventCallback): void;
78
+ /**
79
+ * @deprecated 다음 버전에서 제거 예정입니다
80
+ */
81
+ on(event: 'sold-out' | 'on-sale', callback: CatalogEventCallback): void;
75
82
  on(event: 'sold-out' | 'on-sale' | 'update' | 'add' | 'delete', callback: CatalogEventCallback): void;
76
- on(event: 'before-add', callback: CatalogRequiredResponseEventCallback): void;
77
83
  }
78
84
 
79
85
  declare type CatalogEventCallback = (catalog: PluginCatalogItem) => void;
@@ -83,22 +89,17 @@ declare type CatalogEventCallback = (catalog: PluginCatalogItem) => void;
83
89
  */
84
90
  export declare type CatalogItemOptionChoiceState = 'ON_SALE' | 'SOLD_OUT';
85
91
 
86
- declare type CatalogRequiredResponseEventCallback = (payload: {
87
- payload: Partial<PluginCatalogItemDto>;
88
- ui: Ui;
89
- }) => Promise<{
90
- initialValue?: PluginCatalogItemDto;
91
- }>;
92
-
93
92
  /**
94
93
  * @publicApi
95
94
  */
96
95
  export declare interface CategoryTypes {
97
96
  getCategories: () => Promise<PluginCatalogCategory[]>;
97
+ getCategory: (categoryId: number) => Promise<PluginCatalogCategory>;
98
98
  on: (event: 'update' | 'add' | 'delete', callback: (category: PluginCatalogCategory) => void) => void;
99
99
  }
100
100
 
101
101
  /**
102
+ * @publicApi
102
103
  * @return 선택된 values id의 배열 string[]
103
104
  * @example ['option1', 'option2']
104
105
  */
@@ -112,25 +113,20 @@ declare type CheckBoxInput = Omit<BaseInput, 'placeholder'> & {
112
113
  };
113
114
 
114
115
  /**
115
- * @return 선택된 values id의 배열 string[]
116
- * @example ['option1', 'option2']
116
+ * @publicApi
117
117
  */
118
- declare type CheckBoxInput_2 = Omit<BaseInput_2, 'placeholder'> & {
119
- type: 'checkbox';
120
- /**
121
- * @description 선택된 value의 id의 배열
122
- */
123
- default: string[];
124
- values: InputValue_2[];
125
- };
126
-
127
118
  declare type CtaInput = {
128
119
  type: 'cta';
129
120
  id: string;
130
121
  text: string;
131
- ctaType: 'primary' | 'danger' | 'weak';
122
+ ctaType: 'primary' | 'danger' | 'dark';
132
123
  };
133
124
 
125
+ /**
126
+ * @publicApi
127
+ */
128
+ export declare type DeliveryConnectionStatusErrorCode = 'NOT_RUNNING' | 'NOT_LOGGED_IN' | 'UNKNOWN' | 'BAEMIN_NOT_SELECTED_PROGRAM';
129
+
134
130
  declare type DeliveryOrder = Order_2 & {
135
131
  type: 'DELIVERY';
136
132
  /**
@@ -181,7 +177,7 @@ export declare type DeviceInfo = {
181
177
  osVersion?: string;
182
178
  businessType: {
183
179
  business: {
184
- type: 'CARE' | 'RESTAURANT';
180
+ type: 'CAFE' | 'RESTAURANT';
185
181
  };
186
182
  operation: {
187
183
  payment: {
@@ -366,32 +362,30 @@ declare type InputResponse = {
366
362
  errorMessage: string;
367
363
  };
368
364
 
365
+ /**
366
+ * @publicApi
367
+ */
369
368
  declare type InputValue = {
370
369
  id: string;
371
370
  label: string;
372
371
  };
373
372
 
374
- declare type InputValue_2 = {
375
- id: string;
376
- label: string;
377
- };
378
-
379
373
  declare type Join<T extends string, U extends string> = `${T}${U}` | '0';
380
374
 
381
375
  declare type Languages = Record<PluginLanguageCode, string>;
382
376
 
383
- /**
384
- * @publicApi
385
- * @deprecated
386
- */
387
- declare type LegacyPluginInputType = PluginInputsLegacy['type'];
388
-
389
377
  /**
390
378
  * @publicApi
391
379
  */
392
380
  export declare interface MenuOption {
393
381
  getOptions: () => Promise<PluginCatalogItemOption[]>;
394
- on: (event: 'sold-out' | 'on-sale' | 'update' | 'add' | 'delete', callback: (option: PluginCatalogItemOption) => void) => void;
382
+ getOption: (optionId: number) => Promise<PluginCatalogItemOption>;
383
+ /**
384
+ * @deprecated 다음 버전에서 제거 예정입니다
385
+ */
386
+ on(event: 'sold-out' | 'on-sale', callback: (option: PluginCatalogItemOption) => void): void;
387
+ on(event: 'update' | 'add' | 'delete', callback: (option: PluginCatalogItemOption) => void): void;
388
+ on(event: 'sold-out' | 'on-sale' | 'update' | 'add' | 'delete', callback: (option: PluginCatalogItemOption) => void): void;
395
389
  }
396
390
 
397
391
  /**
@@ -424,6 +418,7 @@ export declare class NavigationImpl implements Navigation {
424
418
  }
425
419
 
426
420
  /**
421
+ * @publicApi
427
422
  * @return number
428
423
  */
429
424
  declare type NumberInput = BaseInput & {
@@ -447,8 +442,8 @@ declare type NumberInput = BaseInput & {
447
442
  export declare interface Order {
448
443
  getOrder: (id: string) => Promise<PluginOrder>;
449
444
  /**
450
- * @param start yyyyMMdd
451
- * @param end yyyyMMdd
445
+ * @param start yyyy-MM-dd
446
+ * @param end yyyy-MM-dd
452
447
  * @description createdAt 기준으로 주문을 조회합니다
453
448
  */
454
449
  getOrders: (range: {
@@ -456,9 +451,9 @@ export declare interface Order {
456
451
  end: string;
457
452
  }) => Promise<PluginOrder[]>;
458
453
  /**
459
- * 토스 포스에서 카드결제를 취소하면 무조건 카드리딩해야함 그래서 on cancel은 늘 환불까지 된 상태임
454
+ * @deprecated
460
455
  */
461
- on: (event: 'cancel', callback: (order: PluginOrder) => void) => void;
456
+ on(event: 'cancel', callback: (order: PluginOrder) => void): void;
462
457
  cancel: (id: string) => Promise<void>;
463
458
  add: (order: PluginOrderDto) => Promise<PluginOrder>;
464
459
  /**
@@ -513,6 +508,7 @@ declare type Order_2 = {
513
508
  declare type OrderItemType = 'ITEM' | 'DELIVERY_FEE' | 'PREPAID_CARD' | 'MULTI_USE_TICKET';
514
509
 
515
510
  /**
511
+ * @publicApi
516
512
  * @return string
517
513
  */
518
514
  declare type PasswordInput = BaseInput & {
@@ -521,15 +517,6 @@ declare type PasswordInput = BaseInput & {
521
517
  placeholder?: string;
522
518
  };
523
519
 
524
- /**
525
- * @return string
526
- */
527
- declare type PasswordInput_2 = BaseInput_2 & {
528
- type: 'password';
529
- default: string;
530
- placeholder?: string;
531
- };
532
-
533
520
  declare type PayCallback = (order: PluginOrder, price: PluginPrice, ui: Ui) => Promise<PaymentMethodResponse | undefined>;
534
521
 
535
522
  /**
@@ -545,9 +532,10 @@ export declare interface Payment {
545
532
  add: (order: {
546
533
  id: string;
547
534
  }, paymentDto: PluginPaymentDto) => Promise<PluginPaymentOf<'CARD'> | PluginPaymentOf<'CASH'> | PluginPaymentOf<'EXTERNAL'>>;
535
+ getPayment: (paymentId: PluginPayment['id']) => Promise<PluginPayment>;
548
536
  }
549
537
 
550
- declare type PaymentCallback = (payment: PluginPayment, order: PluginOrder) => void;
538
+ declare type PaymentCallback = (payment: PluginPayment) => void;
551
539
 
552
540
  /**
553
541
  * @publicApi
@@ -882,7 +870,6 @@ export declare interface PluginCatalogItemOptionChoice {
882
870
  * @publicApi
883
871
  */
884
872
  export declare interface PluginCatalogItemPrice {
885
- id: number;
886
873
  /** 상품 가격명 */
887
874
  title: string;
888
875
  /** 기본 가격 여부 */
@@ -959,6 +946,34 @@ export declare type PluginDelivery<T extends 'PICKUP' | 'HERE' | 'DELIVERY'> = E
959
946
  type: T;
960
947
  }>;
961
948
 
949
+ /**
950
+ * @publicApi
951
+ * */
952
+ export declare interface PluginDeliveryDiscount extends PluginDiscount {
953
+ discountBy: 'OWNER' | 'PLATFORM';
954
+ }
955
+
956
+ /**
957
+ * @publicApi
958
+ * @description order를 만들기 위한 dto
959
+ */
960
+ export declare type PluginDeliveryOrderDto = Omit<PluginOrderDto, 'lineItems' | 'discounts'> & {
961
+ cancelled: boolean;
962
+ delivery: PluginDelivery<'DELIVERY' | 'PICKUP' | 'HERE'>;
963
+ discounts: Array<PluginDeliveryDiscount>;
964
+ lineItems: Array<Omit<PluginOrderItem, 'id' | 'orderId' | 'item' | 'optionChoices' | 'discounts'> & {
965
+ item: {
966
+ title: string;
967
+ type: 'ITEM' | 'DELIVERY_FEE';
968
+ };
969
+ optionChoices: Array<{
970
+ title: string;
971
+ priceValue: number;
972
+ }>;
973
+ discounts?: Array<PluginDeliveryDiscount>;
974
+ }>;
975
+ };
976
+
962
977
  /**
963
978
  * @publicApi
964
979
  * 할인 정보
@@ -998,6 +1013,8 @@ export declare interface PluginDraftOrder {
998
1013
  * 기본값은 false입니다.
999
1014
  */
1000
1015
  ignorePrint: boolean;
1016
+ /** 해당 주문의 테이블 인원 수 */
1017
+ numGuests?: number;
1001
1018
  }
1002
1019
 
1003
1020
  /**
@@ -1013,7 +1030,7 @@ export declare interface PluginDraftOrderItem {
1013
1030
  type: OrderItemType;
1014
1031
  };
1015
1032
  /** 상품 가격 정보 */
1016
- itemPrice: Pick<PluginCatalogItemPrice, 'id' | 'isTaxFree' | 'priceType' | 'priceUnit' | 'priceValue' | 'sku' | 'title'>;
1033
+ itemPrice: Pick<PluginCatalogItemPrice, 'isTaxFree' | 'priceType' | 'priceUnit' | 'priceValue' | 'sku' | 'title'>;
1017
1034
  /** 적용된 할인 목록 */
1018
1035
  discount: PluginDiscount[];
1019
1036
  /** 요청사항 */
@@ -1138,15 +1155,6 @@ declare class PluginImpl implements Plugin_2 {
1138
1155
  */
1139
1156
  export declare type PluginInputs = TextInput | PasswordInput | RadioInput | CheckBoxInput | ToggleInput | SliderInput | NumberInput;
1140
1157
 
1141
- /**
1142
- * @publicApi
1143
- * @deprecated
1144
- * @see https://deus.toss.im/projects/1057/pages/8gKjmG0l@1
1145
- */
1146
- declare type PluginInputsLegacy<T extends LegacyPluginInputType = any> = Extract<TextInput_2 | PasswordInput_2 | RadioInput_2 | CheckBoxInput_2 | ToggleInput_2 | SliderInput_2, {
1147
- type: T;
1148
- }>;
1149
-
1150
1158
  declare type PluginLanguageCode = ValueOf<typeof AvailableLanguageCodes>;
1151
1159
 
1152
1160
  /**
@@ -1202,6 +1210,8 @@ export declare interface PluginOrder {
1202
1210
  paymentPrice: PluginOrderPaymentPrice;
1203
1211
  requestedInfo?: PluginOrderRequestInfo;
1204
1212
  source: string;
1213
+ /** 해당 주문의 테이블 인원 수 */
1214
+ numGuests?: number;
1205
1215
  memo?: string;
1206
1216
  /**
1207
1217
  * @description 주문시각
@@ -1394,11 +1404,18 @@ export declare type PluginPaymentDto<S extends PluginPaymentSourceType = PluginP
1394
1404
  sourceType: S;
1395
1405
  }>;
1396
1406
 
1397
- declare type PluginPaymentDtoBase = Pick<PluginPayment,
1407
+ declare interface PluginPaymentDtoBase extends Pick<PluginPayment,
1398
1408
  /**
1399
1409
  * orderId 그냥 열어두면 이상한 값 넣을가봐 걱정... 방어코드 필요
1400
1410
  */
1401
- 'orderId' | 'sourceType' | 'amountMoney' | 'taxMoney' | 'approvedNo' | 'approvedAt' | 'paymentKey' | 'supplyMoney' | 'tipMoney' | 'taxExemptMoney'>;
1411
+ 'orderId' | 'sourceType' | 'amountMoney' | 'taxMoney' | 'approvedNo' | 'approvedAt' | 'paymentKey' | 'supplyMoney' | 'tipMoney' | 'taxExemptMoney'> {
1412
+ /**
1413
+ * default: true
1414
+ * false로 설정 시, 결제 등록 후 자동으로 주문이 완료되지 않습니다.
1415
+ * 테이블의 주문인 경우 autocomplete를 false로 설정하면, 테이블이 비워지지 않습니다
1416
+ */
1417
+ autocomplete?: boolean;
1418
+ }
1402
1419
 
1403
1420
  /**
1404
1421
  * @publicApi
@@ -1450,6 +1467,8 @@ export declare type PluginPrice = {
1450
1467
  taxExemptMoney: number;
1451
1468
  };
1452
1469
 
1470
+ /* Excluded from this release type: PluginServerOnHttpRequest */
1471
+
1453
1472
  /**
1454
1473
  * @publicApi
1455
1474
  */
@@ -1459,6 +1478,8 @@ export declare interface PluginTable {
1459
1478
  hallId: number;
1460
1479
  /** 테이블명 */
1461
1480
  title: string;
1481
+ /** 인원수 */
1482
+ capacity?: number;
1462
1483
  group?: PluginTableGroup;
1463
1484
  }
1464
1485
 
@@ -1512,6 +1533,7 @@ export declare type PosPluginSdk = {
1512
1533
  paymentMethod: PaymentMethodType;
1513
1534
  websocket: WebsocketTypes;
1514
1535
  ffi: FFITypes;
1536
+ barcode: Barcode;
1515
1537
  plugin: Plugin_2;
1516
1538
  pluginMessenger: PluginMessenger;
1517
1539
  setting: SettingTypes;
@@ -1533,32 +1555,29 @@ export declare class PosPluginSdkError extends Error {
1533
1555
  }
1534
1556
 
1535
1557
  /**
1536
- * @return string values.id
1558
+ * @publicApi
1537
1559
  */
1538
- declare type RadioInput = Omit<BaseInput, 'placeholder'> & {
1539
- type: 'radio';
1540
- /**
1541
- * @desciption 선택된 value의 id
1542
- */
1543
- default: string;
1544
- values: InputValue[];
1545
- };
1560
+ export declare class PosPluginSdkRateLimitError extends PosPluginSdkError {
1561
+ constructor(message: string);
1562
+ static isPosPluginSdkRateLimitError(error: unknown): error is PosPluginSdkRateLimitError;
1563
+ }
1546
1564
 
1547
1565
  /**
1566
+ * @publicApi
1548
1567
  * @return string values.id
1549
1568
  */
1550
- declare type RadioInput_2 = Omit<BaseInput_2, 'placeholder'> & {
1569
+ declare type RadioInput = Omit<BaseInput, 'placeholder'> & {
1551
1570
  type: 'radio';
1552
1571
  /**
1553
1572
  * @desciption 선택된 value의 id
1554
1573
  */
1555
1574
  default: string;
1556
- values: InputValue_2[];
1575
+ values: InputValue[];
1557
1576
  };
1558
1577
 
1559
1578
  declare type Response_2 = BarcodeResponse | InputResponse;
1560
1579
 
1561
- declare function setInputs(inputs: Array<PluginInputsLegacy>): void;
1580
+ declare function setInputs(inputs: Array<PluginInputs>): void;
1562
1581
 
1563
1582
  declare const setting: {
1564
1583
  setInputs: typeof setInputs;
@@ -1571,6 +1590,7 @@ declare const setting: {
1571
1590
  export declare type SettingTypes = typeof setting;
1572
1591
 
1573
1592
  /**
1593
+ * @publicApi
1574
1594
  * @return number 0 25 50 75 100
1575
1595
  */
1576
1596
  declare type SliderInput = Omit<BaseInput, 'placeholder'> & {
@@ -1581,17 +1601,6 @@ declare type SliderInput = Omit<BaseInput, 'placeholder'> & {
1581
1601
  step: number;
1582
1602
  };
1583
1603
 
1584
- /**
1585
- * @return number 0 25 50 75 100
1586
- */
1587
- declare type SliderInput_2 = Omit<BaseInput_2, 'placeholder'> & {
1588
- type: 'slider';
1589
- default: number;
1590
- min: number;
1591
- max: number;
1592
- step: number;
1593
- };
1594
-
1595
1604
  /**
1596
1605
  * @publicApi
1597
1606
  */
@@ -1614,20 +1623,22 @@ declare type StoreStatus = 'NEW' | 'ACCEPTED' | 'REJECTED' | 'PARTIALLY_CANCELLE
1614
1623
  * @publicApi
1615
1624
  */
1616
1625
  export declare interface Table {
1617
- getTables: () => Promise<{
1618
- table: PluginTable;
1619
- order?: PluginOrder;
1620
- }[]>;
1626
+ getTables: () => Promise<PluginTable[]>;
1627
+ getTable: (tableId: number) => Promise<PluginTable>;
1628
+ /**
1629
+ * @deprecated 다음버전에서 제거 예정. order.on 사용 권장
1630
+ */
1621
1631
  on(event: 'order-update' | 'order-add', callback: (order: PluginOrder) => void): void;
1622
1632
  on(event: 'clear' | 'add' | 'delete' | 'update', callback: (table: PluginTable) => void): void;
1623
- on(event: 'swap' | 'move' | 'merge', callback: (before: PluginTable, after: PluginTable) => void): void;
1624
- clearTable: (payload: {
1633
+ on(event: 'move', callback: (before: PluginTable, after: PluginTable) => void): void;
1634
+ clearTable: ({ table, order }: {
1625
1635
  table: PluginTable;
1626
1636
  order?: PluginOrder;
1627
1637
  }) => Promise<void>;
1628
1638
  }
1629
1639
 
1630
1640
  /**
1641
+ * @publicApi
1631
1642
  * @return string
1632
1643
  */
1633
1644
  declare type TextInput = BaseInput & {
@@ -1645,15 +1656,6 @@ declare type TextInput = BaseInput & {
1645
1656
  }[];
1646
1657
  };
1647
1658
 
1648
- /**
1649
- * @return string
1650
- */
1651
- declare type TextInput_2 = BaseInput_2 & {
1652
- type: 'text';
1653
- default: string;
1654
- placeholder?: string;
1655
- };
1656
-
1657
1659
  /**
1658
1660
  * @publicApi
1659
1661
  */
@@ -1662,6 +1664,7 @@ export declare type ToastTypes = {
1662
1664
  };
1663
1665
 
1664
1666
  /**
1667
+ * @publicApi
1665
1668
  * @return boolean
1666
1669
  */
1667
1670
  declare type ToggleInput = Omit<BaseInput, 'placeholder'> & {
@@ -1669,14 +1672,6 @@ declare type ToggleInput = Omit<BaseInput, 'placeholder'> & {
1669
1672
  default: boolean;
1670
1673
  };
1671
1674
 
1672
- /**
1673
- * @return boolean
1674
- */
1675
- declare type ToggleInput_2 = Omit<BaseInput_2, 'placeholder'> & {
1676
- type: 'toggle';
1677
- default: boolean;
1678
- };
1679
-
1680
1675
  /**
1681
1676
  * @publicApi
1682
1677
  * @description 추후에 필요한 정보 더 추가될 예정
@@ -1685,11 +1680,6 @@ export declare type TossMerchant = {
1685
1680
  name: string;
1686
1681
  id: number;
1687
1682
  businessNumber: string;
1688
- /**
1689
- * @deprecated
1690
- * @see DeviceInfo.serialNumber
1691
- */
1692
- serialNumber: string;
1693
1683
  franchise?: {
1694
1684
  id: string;
1695
1685
  name: string;
@@ -1704,6 +1694,18 @@ export declare type Ui = {
1704
1694
  openInputModal(message: Omit<PopupElement<'input'>, 'type'>): Promise<PopupActionResponse<'input'>>;
1705
1695
  };
1706
1696
 
1697
+ /**
1698
+ * @publicApi
1699
+ */
1700
+ export declare const ui: UiImpl;
1701
+
1702
+ declare class UiImpl implements Ui {
1703
+ openBarcode(data: {
1704
+ productName: string;
1705
+ }): Promise<PopupActionResponse<'barcode'>>;
1706
+ openInputModal(data: Omit<PopupElement<'input'>, 'type'>): Promise<PopupActionResponse<'input'>>;
1707
+ }
1708
+
1707
1709
  declare type ValueOf<ObjectType, ValueType extends keyof ObjectType = keyof ObjectType> = ObjectType[ValueType];
1708
1710
 
1709
1711
  /**
@@ -1711,7 +1713,10 @@ declare type ValueOf<ObjectType, ValueType extends keyof ObjectType = keyof Obje
1711
1713
  */
1712
1714
  export declare type VanType = 'NICE' | 'KIS' | 'SMARTRO' | 'KOVAN';
1713
1715
 
1714
- declare class Websocket {
1716
+ /**
1717
+ * @publicApi
1718
+ */
1719
+ export declare class Websocket {
1715
1720
  private readonly url;
1716
1721
  private readonly headers;
1717
1722
  private readonly options?;