@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/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
  /** 요청사항 */
@@ -1151,15 +1168,6 @@ declare class PluginImpl implements Plugin_2 {
1151
1168
  */
1152
1169
  export declare type PluginInputs = TextInput | PasswordInput | RadioInput | CheckBoxInput | ToggleInput | SliderInput | NumberInput;
1153
1170
 
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
1171
  declare type PluginLanguageCode = ValueOf<typeof AvailableLanguageCodes>;
1164
1172
 
1165
1173
  /**
@@ -1215,6 +1223,8 @@ export declare interface PluginOrder {
1215
1223
  paymentPrice: PluginOrderPaymentPrice;
1216
1224
  requestedInfo?: PluginOrderRequestInfo;
1217
1225
  source: string;
1226
+ /** 해당 주문의 테이블 인원 수 */
1227
+ numGuests?: number;
1218
1228
  memo?: string;
1219
1229
  /**
1220
1230
  * @description 주문시각
@@ -1407,11 +1417,18 @@ export declare type PluginPaymentDto<S extends PluginPaymentSourceType = PluginP
1407
1417
  sourceType: S;
1408
1418
  }>;
1409
1419
 
1410
- declare type PluginPaymentDtoBase = Pick<PluginPayment,
1420
+ declare interface PluginPaymentDtoBase extends Pick<PluginPayment,
1411
1421
  /**
1412
1422
  * orderId 그냥 열어두면 이상한 값 넣을가봐 걱정... 방어코드 필요
1413
1423
  */
1414
- 'orderId' | 'sourceType' | 'amountMoney' | 'taxMoney' | 'approvedNo' | 'approvedAt' | 'paymentKey' | 'supplyMoney' | 'tipMoney' | 'taxExemptMoney'>;
1424
+ 'orderId' | 'sourceType' | 'amountMoney' | 'taxMoney' | 'approvedNo' | 'approvedAt' | 'paymentKey' | 'supplyMoney' | 'tipMoney' | 'taxExemptMoney'> {
1425
+ /**
1426
+ * default: true
1427
+ * false로 설정 시, 결제 등록 후 자동으로 주문이 완료되지 않습니다.
1428
+ * 테이블의 주문인 경우 autocomplete를 false로 설정하면, 테이블이 비워지지 않습니다
1429
+ */
1430
+ autocomplete?: boolean;
1431
+ }
1415
1432
 
1416
1433
  /**
1417
1434
  * @publicApi
@@ -1463,6 +1480,15 @@ export declare type PluginPrice = {
1463
1480
  taxExemptMoney: number;
1464
1481
  };
1465
1482
 
1483
+ /**
1484
+ * @publicApi
1485
+ * @internal
1486
+ */
1487
+ export declare interface PluginServerOnHttpRequest extends HttpRequest {
1488
+ path: string;
1489
+ port: number;
1490
+ }
1491
+
1466
1492
  /**
1467
1493
  * @publicApi
1468
1494
  */
@@ -1472,6 +1498,8 @@ export declare interface PluginTable {
1472
1498
  hallId: number;
1473
1499
  /** 테이블명 */
1474
1500
  title: string;
1501
+ /** 인원수 */
1502
+ capacity?: number;
1475
1503
  group?: PluginTableGroup;
1476
1504
  }
1477
1505
 
@@ -1525,6 +1553,7 @@ export declare type PosPluginSdk = {
1525
1553
  paymentMethod: PaymentMethodType;
1526
1554
  websocket: WebsocketTypes;
1527
1555
  ffi: FFITypes;
1556
+ barcode: Barcode;
1528
1557
  plugin: Plugin_2;
1529
1558
  pluginMessenger: PluginMessenger;
1530
1559
  setting: SettingTypes;
@@ -1546,32 +1575,29 @@ export declare class PosPluginSdkError extends Error {
1546
1575
  }
1547
1576
 
1548
1577
  /**
1549
- * @return string values.id
1578
+ * @publicApi
1550
1579
  */
1551
- declare type RadioInput = Omit<BaseInput, 'placeholder'> & {
1552
- type: 'radio';
1553
- /**
1554
- * @desciption 선택된 value의 id
1555
- */
1556
- default: string;
1557
- values: InputValue[];
1558
- };
1580
+ export declare class PosPluginSdkRateLimitError extends PosPluginSdkError {
1581
+ constructor(message: string);
1582
+ static isPosPluginSdkRateLimitError(error: unknown): error is PosPluginSdkRateLimitError;
1583
+ }
1559
1584
 
1560
1585
  /**
1586
+ * @publicApi
1561
1587
  * @return string values.id
1562
1588
  */
1563
- declare type RadioInput_2 = Omit<BaseInput_2, 'placeholder'> & {
1589
+ declare type RadioInput = Omit<BaseInput, 'placeholder'> & {
1564
1590
  type: 'radio';
1565
1591
  /**
1566
1592
  * @desciption 선택된 value의 id
1567
1593
  */
1568
1594
  default: string;
1569
- values: InputValue_2[];
1595
+ values: InputValue[];
1570
1596
  };
1571
1597
 
1572
1598
  declare type Response_2 = BarcodeResponse | InputResponse;
1573
1599
 
1574
- declare function setInputs(inputs: Array<PluginInputsLegacy>): void;
1600
+ declare function setInputs(inputs: Array<PluginInputs>): void;
1575
1601
 
1576
1602
  declare const setting: {
1577
1603
  setInputs: typeof setInputs;
@@ -1584,6 +1610,7 @@ declare const setting: {
1584
1610
  export declare type SettingTypes = typeof setting;
1585
1611
 
1586
1612
  /**
1613
+ * @publicApi
1587
1614
  * @return number 0 25 50 75 100
1588
1615
  */
1589
1616
  declare type SliderInput = Omit<BaseInput, 'placeholder'> & {
@@ -1594,17 +1621,6 @@ declare type SliderInput = Omit<BaseInput, 'placeholder'> & {
1594
1621
  step: number;
1595
1622
  };
1596
1623
 
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
1624
  /**
1609
1625
  * @publicApi
1610
1626
  */
@@ -1627,20 +1643,22 @@ declare type StoreStatus = 'NEW' | 'ACCEPTED' | 'REJECTED' | 'PARTIALLY_CANCELLE
1627
1643
  * @publicApi
1628
1644
  */
1629
1645
  export declare interface Table {
1630
- getTables: () => Promise<{
1631
- table: PluginTable;
1632
- order?: PluginOrder;
1633
- }[]>;
1646
+ getTables: () => Promise<PluginTable[]>;
1647
+ getTable: (tableId: number) => Promise<PluginTable>;
1648
+ /**
1649
+ * @deprecated 다음버전에서 제거 예정. order.on 사용 권장
1650
+ */
1634
1651
  on(event: 'order-update' | 'order-add', callback: (order: PluginOrder) => void): void;
1635
1652
  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: {
1653
+ on(event: 'move', callback: (before: PluginTable, after: PluginTable) => void): void;
1654
+ clearTable: ({ table, order }: {
1638
1655
  table: PluginTable;
1639
1656
  order?: PluginOrder;
1640
1657
  }) => Promise<void>;
1641
1658
  }
1642
1659
 
1643
1660
  /**
1661
+ * @publicApi
1644
1662
  * @return string
1645
1663
  */
1646
1664
  declare type TextInput = BaseInput & {
@@ -1658,15 +1676,6 @@ declare type TextInput = BaseInput & {
1658
1676
  }[];
1659
1677
  };
1660
1678
 
1661
- /**
1662
- * @return string
1663
- */
1664
- declare type TextInput_2 = BaseInput_2 & {
1665
- type: 'text';
1666
- default: string;
1667
- placeholder?: string;
1668
- };
1669
-
1670
1679
  /**
1671
1680
  * @publicApi
1672
1681
  */
@@ -1675,6 +1684,7 @@ export declare type ToastTypes = {
1675
1684
  };
1676
1685
 
1677
1686
  /**
1687
+ * @publicApi
1678
1688
  * @return boolean
1679
1689
  */
1680
1690
  declare type ToggleInput = Omit<BaseInput, 'placeholder'> & {
@@ -1682,14 +1692,6 @@ declare type ToggleInput = Omit<BaseInput, 'placeholder'> & {
1682
1692
  default: boolean;
1683
1693
  };
1684
1694
 
1685
- /**
1686
- * @return boolean
1687
- */
1688
- declare type ToggleInput_2 = Omit<BaseInput_2, 'placeholder'> & {
1689
- type: 'toggle';
1690
- default: boolean;
1691
- };
1692
-
1693
1695
  /**
1694
1696
  * @publicApi
1695
1697
  * @description 추후에 필요한 정보 더 추가될 예정
@@ -1698,11 +1700,6 @@ export declare type TossMerchant = {
1698
1700
  name: string;
1699
1701
  id: number;
1700
1702
  businessNumber: string;
1701
- /**
1702
- * @deprecated
1703
- * @see DeviceInfo.serialNumber
1704
- */
1705
- serialNumber: string;
1706
1703
  franchise?: {
1707
1704
  id: string;
1708
1705
  name: string;
@@ -1717,6 +1714,18 @@ export declare type Ui = {
1717
1714
  openInputModal(message: Omit<PopupElement<'input'>, 'type'>): Promise<PopupActionResponse<'input'>>;
1718
1715
  };
1719
1716
 
1717
+ /**
1718
+ * @publicApi
1719
+ */
1720
+ export declare const ui: UiImpl;
1721
+
1722
+ declare class UiImpl implements Ui {
1723
+ openBarcode(data: {
1724
+ productName: string;
1725
+ }): Promise<PopupActionResponse<'barcode'>>;
1726
+ openInputModal(data: Omit<PopupElement<'input'>, 'type'>): Promise<PopupActionResponse<'input'>>;
1727
+ }
1728
+
1720
1729
  declare type ValueOf<ObjectType, ValueType extends keyof ObjectType = keyof ObjectType> = ObjectType[ValueType];
1721
1730
 
1722
1731
  /**
@@ -1724,7 +1733,10 @@ declare type ValueOf<ObjectType, ValueType extends keyof ObjectType = keyof Obje
1724
1733
  */
1725
1734
  export declare type VanType = 'NICE' | 'KIS' | 'SMARTRO' | 'KOVAN';
1726
1735
 
1727
- declare class Websocket {
1736
+ /**
1737
+ * @publicApi
1738
+ */
1739
+ export declare class Websocket {
1728
1740
  private readonly url;
1729
1741
  private readonly headers;
1730
1742
  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.7",
4
4
  "description": "포스 플러그인 sdk",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",