@tossplace/pos-plugin-sdk 0.0.6 → 0.0.8

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/sdk.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: {
@@ -379,32 +375,30 @@ declare type InputResponse = {
379
375
  errorMessage: string;
380
376
  };
381
377
 
378
+ /**
379
+ * @publicApi
380
+ */
382
381
  declare type InputValue = {
383
382
  id: string;
384
383
  label: string;
385
384
  };
386
385
 
387
- declare type InputValue_2 = {
388
- id: string;
389
- label: string;
390
- };
391
-
392
386
  declare type Join<T extends string, U extends string> = `${T}${U}` | '0';
393
387
 
394
388
  declare type Languages = Record<PluginLanguageCode, string>;
395
389
 
396
- /**
397
- * @publicApi
398
- * @deprecated
399
- */
400
- declare type LegacyPluginInputType = PluginInputsLegacy['type'];
401
-
402
390
  /**
403
391
  * @publicApi
404
392
  */
405
393
  export declare interface MenuOption {
406
394
  getOptions: () => Promise<PluginCatalogItemOption[]>;
407
- on: (event: 'sold-out' | 'on-sale' | 'update' | 'add' | 'delete', callback: (option: PluginCatalogItemOption) => void) => void;
395
+ getOption: (optionId: number) => Promise<PluginCatalogItemOption>;
396
+ /**
397
+ * @deprecated 다음 버전에서 제거 예정입니다
398
+ */
399
+ on(event: 'sold-out' | 'on-sale', callback: (option: PluginCatalogItemOption) => void): void;
400
+ on(event: 'update' | 'add' | 'delete', callback: (option: PluginCatalogItemOption) => void): void;
401
+ on(event: 'sold-out' | 'on-sale' | 'update' | 'add' | 'delete', callback: (option: PluginCatalogItemOption) => void): void;
408
402
  }
409
403
 
410
404
  /**
@@ -437,6 +431,7 @@ export declare class NavigationImpl implements Navigation {
437
431
  }
438
432
 
439
433
  /**
434
+ * @publicApi
440
435
  * @return number
441
436
  */
442
437
  declare type NumberInput = BaseInput & {
@@ -460,8 +455,8 @@ declare type NumberInput = BaseInput & {
460
455
  export declare interface Order {
461
456
  getOrder: (id: string) => Promise<PluginOrder>;
462
457
  /**
463
- * @param start yyyyMMdd
464
- * @param end yyyyMMdd
458
+ * @param start yyyy-MM-dd
459
+ * @param end yyyy-MM-dd
465
460
  * @description createdAt 기준으로 주문을 조회합니다
466
461
  */
467
462
  getOrders: (range: {
@@ -469,9 +464,9 @@ export declare interface Order {
469
464
  end: string;
470
465
  }) => Promise<PluginOrder[]>;
471
466
  /**
472
- * 토스 포스에서 카드결제를 취소하면 무조건 카드리딩해야함 그래서 on cancel은 늘 환불까지 된 상태임
467
+ * @deprecated
473
468
  */
474
- on: (event: 'cancel', callback: (order: PluginOrder) => void) => void;
469
+ on(event: 'cancel', callback: (order: PluginOrder) => void): void;
475
470
  cancel: (id: string) => Promise<void>;
476
471
  add: (order: PluginOrderDto) => Promise<PluginOrder>;
477
472
  /**
@@ -526,6 +521,7 @@ declare type Order_2 = {
526
521
  declare type OrderItemType = 'ITEM' | 'DELIVERY_FEE' | 'PREPAID_CARD' | 'MULTI_USE_TICKET';
527
522
 
528
523
  /**
524
+ * @publicApi
529
525
  * @return string
530
526
  */
531
527
  declare type PasswordInput = BaseInput & {
@@ -534,15 +530,6 @@ declare type PasswordInput = BaseInput & {
534
530
  placeholder?: string;
535
531
  };
536
532
 
537
- /**
538
- * @return string
539
- */
540
- declare type PasswordInput_2 = BaseInput_2 & {
541
- type: 'password';
542
- default: string;
543
- placeholder?: string;
544
- };
545
-
546
533
  declare type PayCallback = (order: PluginOrder, price: PluginPrice, ui: Ui) => Promise<PaymentMethodResponse | undefined>;
547
534
 
548
535
  /**
@@ -558,9 +545,10 @@ export declare interface Payment {
558
545
  add: (order: {
559
546
  id: string;
560
547
  }, paymentDto: PluginPaymentDto) => Promise<PluginPaymentOf<'CARD'> | PluginPaymentOf<'CASH'> | PluginPaymentOf<'EXTERNAL'>>;
548
+ getPayment: (paymentId: PluginPayment['id']) => Promise<PluginPayment>;
561
549
  }
562
550
 
563
- declare type PaymentCallback = (payment: PluginPayment, order: PluginOrder) => void;
551
+ declare type PaymentCallback = (payment: PluginPayment) => void;
564
552
 
565
553
  /**
566
554
  * @publicApi
@@ -895,7 +883,6 @@ export declare interface PluginCatalogItemOptionChoice {
895
883
  * @publicApi
896
884
  */
897
885
  export declare interface PluginCatalogItemPrice {
898
- id: number;
899
886
  /** 상품 가격명 */
900
887
  title: string;
901
888
  /** 기본 가격 여부 */
@@ -972,6 +959,34 @@ export declare type PluginDelivery<T extends 'PICKUP' | 'HERE' | 'DELIVERY'> = E
972
959
  type: T;
973
960
  }>;
974
961
 
962
+ /**
963
+ * @publicApi
964
+ * */
965
+ export declare interface PluginDeliveryDiscount extends PluginDiscount {
966
+ discountBy: 'OWNER' | 'PLATFORM';
967
+ }
968
+
969
+ /**
970
+ * @publicApi
971
+ * @description order를 만들기 위한 dto
972
+ */
973
+ export declare type PluginDeliveryOrderDto = Omit<PluginOrderDto, 'lineItems' | 'discounts'> & {
974
+ cancelled: boolean;
975
+ delivery: PluginDelivery<'DELIVERY' | 'PICKUP' | 'HERE'>;
976
+ discounts: Array<PluginDeliveryDiscount>;
977
+ lineItems: Array<Omit<PluginOrderItem, 'id' | 'orderId' | 'item' | 'optionChoices' | 'discounts'> & {
978
+ item: {
979
+ title: string;
980
+ type: 'ITEM' | 'DELIVERY_FEE';
981
+ };
982
+ optionChoices: Array<{
983
+ title: string;
984
+ priceValue: number;
985
+ }>;
986
+ discounts?: Array<PluginDeliveryDiscount>;
987
+ }>;
988
+ };
989
+
975
990
  /**
976
991
  * @publicApi
977
992
  * 할인 정보
@@ -1011,6 +1026,8 @@ export declare interface PluginDraftOrder {
1011
1026
  * 기본값은 false입니다.
1012
1027
  */
1013
1028
  ignorePrint: boolean;
1029
+ /** 해당 주문의 테이블 인원 수 */
1030
+ numGuests?: number;
1014
1031
  }
1015
1032
 
1016
1033
  /**
@@ -1026,7 +1043,7 @@ export declare interface PluginDraftOrderItem {
1026
1043
  type: OrderItemType;
1027
1044
  };
1028
1045
  /** 상품 가격 정보 */
1029
- itemPrice: Pick<PluginCatalogItemPrice, 'id' | 'isTaxFree' | 'priceType' | 'priceUnit' | 'priceValue' | 'sku' | 'title'>;
1046
+ itemPrice: Pick<PluginCatalogItemPrice, 'isTaxFree' | 'priceType' | 'priceUnit' | 'priceValue' | 'sku' | 'title'>;
1030
1047
  /** 적용된 할인 목록 */
1031
1048
  discount: PluginDiscount[];
1032
1049
  /** 요청사항 */
@@ -1135,6 +1152,7 @@ export declare type PluginHttpResponse = {
1135
1152
 
1136
1153
  declare class PluginImpl implements Plugin_2 {
1137
1154
  private readonly webview;
1155
+ private plugin;
1138
1156
  private pluginCallbacks;
1139
1157
  constructor(webview: WebView);
1140
1158
  private initializePlugin;
@@ -1151,15 +1169,6 @@ declare class PluginImpl implements Plugin_2 {
1151
1169
  */
1152
1170
  export declare type PluginInputs = TextInput | PasswordInput | RadioInput | CheckBoxInput | ToggleInput | SliderInput | NumberInput;
1153
1171
 
1154
- /**
1155
- * @publicApi
1156
- * @deprecated
1157
- * @see https://deus.toss.im/projects/1057/pages/8gKjmG0l@1
1158
- */
1159
- declare type PluginInputsLegacy<T extends LegacyPluginInputType = any> = Extract<TextInput_2 | PasswordInput_2 | RadioInput_2 | CheckBoxInput_2 | ToggleInput_2 | SliderInput_2, {
1160
- type: T;
1161
- }>;
1162
-
1163
1172
  declare type PluginLanguageCode = ValueOf<typeof AvailableLanguageCodes>;
1164
1173
 
1165
1174
  /**
@@ -1215,6 +1224,8 @@ export declare interface PluginOrder {
1215
1224
  paymentPrice: PluginOrderPaymentPrice;
1216
1225
  requestedInfo?: PluginOrderRequestInfo;
1217
1226
  source: string;
1227
+ /** 해당 주문의 테이블 인원 수 */
1228
+ numGuests?: number;
1218
1229
  memo?: string;
1219
1230
  /**
1220
1231
  * @description 주문시각
@@ -1407,11 +1418,18 @@ export declare type PluginPaymentDto<S extends PluginPaymentSourceType = PluginP
1407
1418
  sourceType: S;
1408
1419
  }>;
1409
1420
 
1410
- declare type PluginPaymentDtoBase = Pick<PluginPayment,
1421
+ declare interface PluginPaymentDtoBase extends Pick<PluginPayment,
1411
1422
  /**
1412
1423
  * orderId 그냥 열어두면 이상한 값 넣을가봐 걱정... 방어코드 필요
1413
1424
  */
1414
- 'orderId' | 'sourceType' | 'amountMoney' | 'taxMoney' | 'approvedNo' | 'approvedAt' | 'paymentKey' | 'supplyMoney' | 'tipMoney' | 'taxExemptMoney'>;
1425
+ 'orderId' | 'sourceType' | 'amountMoney' | 'taxMoney' | 'approvedNo' | 'approvedAt' | 'paymentKey' | 'supplyMoney' | 'tipMoney' | 'taxExemptMoney'> {
1426
+ /**
1427
+ * default: true
1428
+ * false로 설정 시, 결제 등록 후 자동으로 주문이 완료되지 않습니다.
1429
+ * 테이블의 주문인 경우 autocomplete를 false로 설정하면, 테이블이 비워지지 않습니다
1430
+ */
1431
+ autocomplete?: boolean;
1432
+ }
1415
1433
 
1416
1434
  /**
1417
1435
  * @publicApi
@@ -1463,6 +1481,15 @@ export declare type PluginPrice = {
1463
1481
  taxExemptMoney: number;
1464
1482
  };
1465
1483
 
1484
+ /**
1485
+ * @publicApi
1486
+ * @internal
1487
+ */
1488
+ export declare interface PluginServerOnHttpRequest extends HttpRequest {
1489
+ path: string;
1490
+ port: number;
1491
+ }
1492
+
1466
1493
  /**
1467
1494
  * @publicApi
1468
1495
  */
@@ -1472,6 +1499,8 @@ export declare interface PluginTable {
1472
1499
  hallId: number;
1473
1500
  /** 테이블명 */
1474
1501
  title: string;
1502
+ /** 인원수 */
1503
+ capacity?: number;
1475
1504
  group?: PluginTableGroup;
1476
1505
  }
1477
1506
 
@@ -1525,6 +1554,7 @@ export declare type PosPluginSdk = {
1525
1554
  paymentMethod: PaymentMethodType;
1526
1555
  websocket: WebsocketTypes;
1527
1556
  ffi: FFITypes;
1557
+ barcode: Barcode;
1528
1558
  plugin: Plugin_2;
1529
1559
  pluginMessenger: PluginMessenger;
1530
1560
  setting: SettingTypes;
@@ -1546,32 +1576,29 @@ export declare class PosPluginSdkError extends Error {
1546
1576
  }
1547
1577
 
1548
1578
  /**
1549
- * @return string values.id
1579
+ * @publicApi
1550
1580
  */
1551
- declare type RadioInput = Omit<BaseInput, 'placeholder'> & {
1552
- type: 'radio';
1553
- /**
1554
- * @desciption 선택된 value의 id
1555
- */
1556
- default: string;
1557
- values: InputValue[];
1558
- };
1581
+ export declare class PosPluginSdkRateLimitError extends PosPluginSdkError {
1582
+ constructor(message: string);
1583
+ static isPosPluginSdkRateLimitError(error: unknown): error is PosPluginSdkRateLimitError;
1584
+ }
1559
1585
 
1560
1586
  /**
1587
+ * @publicApi
1561
1588
  * @return string values.id
1562
1589
  */
1563
- declare type RadioInput_2 = Omit<BaseInput_2, 'placeholder'> & {
1590
+ declare type RadioInput = Omit<BaseInput, 'placeholder'> & {
1564
1591
  type: 'radio';
1565
1592
  /**
1566
1593
  * @desciption 선택된 value의 id
1567
1594
  */
1568
1595
  default: string;
1569
- values: InputValue_2[];
1596
+ values: InputValue[];
1570
1597
  };
1571
1598
 
1572
1599
  declare type Response_2 = BarcodeResponse | InputResponse;
1573
1600
 
1574
- declare function setInputs(inputs: Array<PluginInputsLegacy>): void;
1601
+ declare function setInputs(inputs: Array<PluginInputs>): void;
1575
1602
 
1576
1603
  declare const setting: {
1577
1604
  setInputs: typeof setInputs;
@@ -1584,6 +1611,7 @@ declare const setting: {
1584
1611
  export declare type SettingTypes = typeof setting;
1585
1612
 
1586
1613
  /**
1614
+ * @publicApi
1587
1615
  * @return number 0 25 50 75 100
1588
1616
  */
1589
1617
  declare type SliderInput = Omit<BaseInput, 'placeholder'> & {
@@ -1594,17 +1622,6 @@ declare type SliderInput = Omit<BaseInput, 'placeholder'> & {
1594
1622
  step: number;
1595
1623
  };
1596
1624
 
1597
- /**
1598
- * @return number 0 25 50 75 100
1599
- */
1600
- declare type SliderInput_2 = Omit<BaseInput_2, 'placeholder'> & {
1601
- type: 'slider';
1602
- default: number;
1603
- min: number;
1604
- max: number;
1605
- step: number;
1606
- };
1607
-
1608
1625
  /**
1609
1626
  * @publicApi
1610
1627
  */
@@ -1627,20 +1644,22 @@ declare type StoreStatus = 'NEW' | 'ACCEPTED' | 'REJECTED' | 'PARTIALLY_CANCELLE
1627
1644
  * @publicApi
1628
1645
  */
1629
1646
  export declare interface Table {
1630
- getTables: () => Promise<{
1631
- table: PluginTable;
1632
- order?: PluginOrder;
1633
- }[]>;
1647
+ getTables: () => Promise<PluginTable[]>;
1648
+ getTable: (tableId: number) => Promise<PluginTable>;
1649
+ /**
1650
+ * @deprecated 다음버전에서 제거 예정. order.on 사용 권장
1651
+ */
1634
1652
  on(event: 'order-update' | 'order-add', callback: (order: PluginOrder) => void): void;
1635
1653
  on(event: 'clear' | 'add' | 'delete' | 'update', callback: (table: PluginTable) => void): void;
1636
- on(event: 'swap' | 'move' | 'merge', callback: (before: PluginTable, after: PluginTable) => void): void;
1637
- clearTable: (payload: {
1654
+ on(event: 'move', callback: (before: PluginTable, after: PluginTable) => void): void;
1655
+ clearTable: ({ table, order }: {
1638
1656
  table: PluginTable;
1639
1657
  order?: PluginOrder;
1640
1658
  }) => Promise<void>;
1641
1659
  }
1642
1660
 
1643
1661
  /**
1662
+ * @publicApi
1644
1663
  * @return string
1645
1664
  */
1646
1665
  declare type TextInput = BaseInput & {
@@ -1658,15 +1677,6 @@ declare type TextInput = BaseInput & {
1658
1677
  }[];
1659
1678
  };
1660
1679
 
1661
- /**
1662
- * @return string
1663
- */
1664
- declare type TextInput_2 = BaseInput_2 & {
1665
- type: 'text';
1666
- default: string;
1667
- placeholder?: string;
1668
- };
1669
-
1670
1680
  /**
1671
1681
  * @publicApi
1672
1682
  */
@@ -1675,6 +1685,7 @@ export declare type ToastTypes = {
1675
1685
  };
1676
1686
 
1677
1687
  /**
1688
+ * @publicApi
1678
1689
  * @return boolean
1679
1690
  */
1680
1691
  declare type ToggleInput = Omit<BaseInput, 'placeholder'> & {
@@ -1682,14 +1693,6 @@ declare type ToggleInput = Omit<BaseInput, 'placeholder'> & {
1682
1693
  default: boolean;
1683
1694
  };
1684
1695
 
1685
- /**
1686
- * @return boolean
1687
- */
1688
- declare type ToggleInput_2 = Omit<BaseInput_2, 'placeholder'> & {
1689
- type: 'toggle';
1690
- default: boolean;
1691
- };
1692
-
1693
1696
  /**
1694
1697
  * @publicApi
1695
1698
  * @description 추후에 필요한 정보 더 추가될 예정
@@ -1698,11 +1701,6 @@ export declare type TossMerchant = {
1698
1701
  name: string;
1699
1702
  id: number;
1700
1703
  businessNumber: string;
1701
- /**
1702
- * @deprecated
1703
- * @see DeviceInfo.serialNumber
1704
- */
1705
- serialNumber: string;
1706
1704
  franchise?: {
1707
1705
  id: string;
1708
1706
  name: string;
@@ -1717,6 +1715,18 @@ export declare type Ui = {
1717
1715
  openInputModal(message: Omit<PopupElement<'input'>, 'type'>): Promise<PopupActionResponse<'input'>>;
1718
1716
  };
1719
1717
 
1718
+ /**
1719
+ * @publicApi
1720
+ */
1721
+ export declare const ui: UiImpl;
1722
+
1723
+ declare class UiImpl implements Ui {
1724
+ openBarcode(data: {
1725
+ productName: string;
1726
+ }): Promise<PopupActionResponse<'barcode'>>;
1727
+ openInputModal(data: Omit<PopupElement<'input'>, 'type'>): Promise<PopupActionResponse<'input'>>;
1728
+ }
1729
+
1720
1730
  declare type ValueOf<ObjectType, ValueType extends keyof ObjectType = keyof ObjectType> = ObjectType[ValueType];
1721
1731
 
1722
1732
  /**
@@ -1724,7 +1734,10 @@ declare type ValueOf<ObjectType, ValueType extends keyof ObjectType = keyof Obje
1724
1734
  */
1725
1735
  export declare type VanType = 'NICE' | 'KIS' | 'SMARTRO' | 'KOVAN';
1726
1736
 
1727
- declare class Websocket {
1737
+ /**
1738
+ * @publicApi
1739
+ */
1740
+ export declare class Websocket {
1728
1741
  private readonly url;
1729
1742
  private readonly headers;
1730
1743
  private readonly options?;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tossplace/pos-plugin-sdk",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "포스 플러그인 sdk",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",