@tossplace/pos-plugin-sdk 0.0.4 → 0.0.5

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
@@ -1,20 +1,8 @@
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
1
  declare type AllPaymentCreateDto = PluginCardDto | PluginCashDto | PluginExternalDto;
14
2
 
15
- declare type AllPopupElements = AlertElements | BarcodeElements;
3
+ declare type AllPopupElements = BarcodeElements;
16
4
 
17
- declare type AllPopupResponse = AlertResponse | BarcodeResponse;
5
+ declare type AllPopupResponse = BarcodeResponse;
18
6
 
19
7
  /**
20
8
  * @publicApi
@@ -48,9 +36,16 @@ declare type BarcodeResponse = {
48
36
  errorMessage: string;
49
37
  };
50
38
 
39
+ declare type BaseInput = {
40
+ label: string;
41
+ required: boolean;
42
+ id: string;
43
+ };
44
+
51
45
  declare type CancelCallback = (order: PluginOrder, payment: PluginPayment) => Promise<PluginCancelledPaymentDto | undefined>;
52
46
 
53
47
  /**
48
+ * @schema
54
49
  * @publicApi
55
50
  */
56
51
  export declare type CashReceipt = {
@@ -73,31 +68,61 @@ declare interface CashReceiptTypes {
73
68
  /**
74
69
  * @publicApi
75
70
  */
76
- export declare type CatalogItemOptionChoiceState = 'ON_SALE' | 'SOLD_OUT';
71
+ export declare interface Catalog {
72
+ getCatalogs: () => Promise<PluginCatalogItem[]>;
73
+ on: (event: 'sold-out' | 'on-sale' | 'update' | 'add' | 'delete', callback: (menu: PluginCatalogItem) => void) => void;
74
+ }
77
75
 
78
76
  /**
79
77
  * @publicApi
80
78
  */
81
- export declare interface CatalogTypes {
82
- getCatalogs: () => Promise<PluginCatalogItem[]>;
83
- on: (event: 'sold-out' | 'on-sale', callback: (menu: PluginCatalogItem) => void) => void;
84
- }
79
+ export declare type CatalogItemOptionChoiceState = 'ON_SALE' | 'SOLD_OUT';
85
80
 
86
81
  /**
87
82
  * @publicApi
88
83
  */
89
84
  export declare interface CategoryTypes {
90
85
  getCategories: () => Promise<PluginCatalogCategory[]>;
86
+ on: (event: 'update' | 'add' | 'delete', callback: (category: PluginCatalogCategory) => void) => void;
91
87
  }
92
88
 
93
- declare type Digit = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9';
89
+ /**
90
+ * @return 선택된 values id의 배열 string[]
91
+ * @example ['option1', 'option2']
92
+ */
93
+ declare type CheckBoxInput = Omit<BaseInput, 'placeholder'> & {
94
+ type: 'checkbox';
95
+ /**
96
+ * @description 선택된 value의 id의 배열
97
+ */
98
+ default: string[];
99
+ values: InputValue[];
100
+ };
101
+
102
+ declare type DeliveryOrder = Order & {
103
+ type: 'DELIVERY';
104
+ /**
105
+ * 배달 주체
106
+ */
107
+ deliveryBy: 'DELIVERY_COMPANY' | 'STORE' | 'AGENCY';
108
+ memo: {
109
+ store?: string;
110
+ delivery?: string;
111
+ };
112
+ address: {
113
+ road?: string;
114
+ lot?: string;
115
+ };
116
+ phone?: string;
117
+ status: DeliveryStatus;
118
+ };
94
119
 
95
120
  /**
96
121
  * @publicApi
97
122
  */
98
- export declare type ExternalPaymentMethodResponse = PaymentMethodResponse & {
99
- sourceType: 'EXTERNAL';
100
- };
123
+ declare type DeliveryStatus = 'NEW' | 'ACCEPTED' | 'REJECTED' | 'PARTIALLY_CANCELLED' | 'CANCELLED' | 'RIDER_ASSIGNED' | 'RIDER_ARRIVE_SOON' | 'RIDER_PICKUP_COMPLETED' | 'DONE';
124
+
125
+ declare type Digit = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9';
101
126
 
102
127
  /**
103
128
  * @publicApi
@@ -111,6 +136,8 @@ declare interface FFIApi extends FFIFunction {
111
136
  name: string;
112
137
  }
113
138
 
139
+ /* Excluded from this release type: FFIDownloadInfo */
140
+
114
141
  /**
115
142
  * @publicApi
116
143
  */
@@ -118,6 +145,7 @@ declare interface FFIFunction {
118
145
  params?: FFIFunctionParam[];
119
146
  return: FFIFunctionReturn;
120
147
  options?: FFIFunctionOptions;
148
+ returnData?: any;
121
149
  }
122
150
 
123
151
  /**
@@ -152,15 +180,35 @@ declare type FFIFunctionParam = {
152
180
  declare type FFIFunctionReturn = 'void' | 'str' | 'int' | 'bool' | 'wchar *' | 'void *';
153
181
 
154
182
  declare interface FFITypes {
155
- download: (downloadUrl: string, filePath: string) => Promise<void>;
183
+ download: (downloadInfo: FFIDownloadInfo) => Promise<{
184
+ platform: keyof FFIDownloadInfo;
185
+ }>;
156
186
  load: (filePath: string, apis: FFIApi[]) => Promise<void>;
157
187
  unload: (filePath: string) => Promise<void>;
158
188
  invoke: (filePath: string, apiName: string, params?: any[]) => Promise<any>;
159
189
  registerCallback: (filePath: string, signature: FFIFunction, callback: (...args: any[]) => any) => Promise<{
160
190
  ffiCallbackId: string;
161
191
  }>;
192
+ unregisterCallback: (filePath: string, callbackId: string) => Promise<void>;
193
+ addCallbackErrorHandler: (filePath: string, handler: (error: Error) => void) => void;
162
194
  }
163
195
 
196
+ declare function getPluginInfo(): Promise<{
197
+ name: string;
198
+ version: string;
199
+ }>;
200
+
201
+ declare function getValues<T extends Record<string, number | string | string[] | boolean | undefined>>(): Promise<T>;
202
+
203
+ declare type HereOrder = Order & {
204
+ type: 'HERE';
205
+ memo: {
206
+ store?: string;
207
+ };
208
+ phone?: string;
209
+ status: StoreStatus;
210
+ };
211
+
164
212
  /**
165
213
  * @publicApi
166
214
  */
@@ -185,6 +233,11 @@ export declare interface HttpTypes {
185
233
  patch: (url: string, payload: any, headers?: [string, string][]) => Promise<PluginHttpResponse>;
186
234
  }
187
235
 
236
+ declare type InputValue = {
237
+ id: string;
238
+ label: string;
239
+ };
240
+
188
241
  declare type Join<T extends string, U extends string> = `${T}${U}` | '0';
189
242
 
190
243
  declare type Languages = Record<PluginLanguageCode, string>;
@@ -192,9 +245,9 @@ declare type Languages = Record<PluginLanguageCode, string>;
192
245
  /**
193
246
  * @publicApi
194
247
  */
195
- export declare interface MenuOptionTypes {
248
+ export declare interface MenuOption {
196
249
  getOptions: () => Promise<PluginCatalogItemOption[]>;
197
- on: (event: 'sold-out' | 'on-sale', callback: (option: PluginCatalogItemOption) => void) => void;
250
+ on: (event: 'sold-out' | 'on-sale' | 'update' | 'add' | 'delete', callback: (option: PluginCatalogItemOption) => void) => void;
198
251
  }
199
252
 
200
253
  /**
@@ -204,7 +257,51 @@ export declare interface MerchantTypes {
204
257
  getMerchant: () => Promise<TossMerchant>;
205
258
  }
206
259
 
207
- declare type OrderItemType = 'ITEM' | 'DELIVERY_FEE' | 'PREPAID_CARD';
260
+ declare function on(event: 'close', callback: () => Promise<void>): void;
261
+
262
+ declare type Order = {
263
+ /**
264
+ * 포스(사장님)에게 보여줄 주문유형
265
+ * @example 가게배달, 장보기/쇼핑, 픽업, 배민1 등등
266
+ */
267
+ serviceName: string;
268
+ /**
269
+ * 주문서에서 라이더에게 보여줄 배달 타입 (배민1, 배달의민족)
270
+ */
271
+ deliveryName: string;
272
+ /**
273
+ * @description 주문 시간 (yyyy-MM-dd'T'HH:mm:ss)
274
+ * @example 2025-04-08T16:11:13.000+09:00
275
+ */
276
+ orderAt: string;
277
+ /**
278
+ * @description 아이콘 url
279
+ */
280
+ icon: string;
281
+ /**
282
+ * @description 준비시간(분)
283
+ */
284
+ preparationTimeMin?: number;
285
+ /**
286
+ * 픽업/배달이 실행될 예약주문 시간 (yyyy-MM-dd'T'HH:mm:ss)
287
+ * @description 예약주문인 경우에만 값이 존재
288
+ * @example 2025-04-08T16:11:13.000+09:00
289
+ */
290
+ reservedDateTime?: string;
291
+ deliveryId: string;
292
+ origin?: string;
293
+ shop: {
294
+ id: string;
295
+ name: string;
296
+ };
297
+ paymentMethod: '결제완료' | '만나서 카드결제' | '만나서 현금결제' | '선불결제' | '기타결제';
298
+ /**
299
+ * @description 고객이 결제한 금액
300
+ */
301
+ customerChargedPrice: number;
302
+ };
303
+
304
+ declare type OrderItemType = 'ITEM' | 'DELIVERY_FEE' | 'PREPAID_CARD' | 'MULTI_USE_TICKET';
208
305
 
209
306
  /**
210
307
  * @publicApi
@@ -224,6 +321,15 @@ export declare interface OrderTypes {
224
321
  complete: (id: string) => Promise<PluginOrder>;
225
322
  }
226
323
 
324
+ /**
325
+ * @return string
326
+ */
327
+ declare type PasswordInput = BaseInput & {
328
+ type: 'password';
329
+ default: string;
330
+ placeholder?: string;
331
+ };
332
+
227
333
  declare type PayCallback = (order: PluginOrder, price: PluginPrice) => Promise<PaymentMethodResponse | undefined>;
228
334
 
229
335
  /**
@@ -237,7 +343,6 @@ export declare type PaymentMethodResponse = {
237
343
  * @example 2022-01-27T11:42:33
238
344
  */
239
345
  approvedAt: string;
240
- approvedNo: string;
241
346
  paymentKey: string;
242
347
  };
243
348
 
@@ -262,7 +367,7 @@ declare type PaymentMethodType = {
262
367
  };
263
368
 
264
369
  declare interface PaymentTypes {
265
- on: (event: 'cancel' | 'paid', callback: (payload: PluginPaymentOf<'CASH'> | PluginPaymentOf<'CARD'> | PluginPaymentOf<'EXTERNAL'>) => void) => void;
370
+ on: (event: 'cancel', callback: (payload: PluginPaymentOf<'CASH'> | PluginPaymentOf<'CARD'> | PluginPaymentOf<'EXTERNAL'>) => void) => void;
266
371
  cancel: (order: {
267
372
  id: string;
268
373
  }, payment: {
@@ -273,6 +378,20 @@ declare interface PaymentTypes {
273
378
  }, paymentDto: PluginPaymentDto) => Promise<PluginPaymentOf<'CARD'> | PluginPaymentOf<'CASH'> | PluginPaymentOf<'EXTERNAL'>>;
274
379
  }
275
380
 
381
+ declare type PickupOrder = Order & {
382
+ type: 'PICKUP';
383
+ memo: {
384
+ store?: string;
385
+ };
386
+ phone?: string;
387
+ status: StoreStatus;
388
+ };
389
+
390
+ declare const plugin: {
391
+ on: typeof on;
392
+ getPluginInfo: typeof getPluginInfo;
393
+ };
394
+
276
395
  /**
277
396
  * @publicApi
278
397
  */
@@ -520,8 +639,9 @@ export declare interface PluginCatalogItemPrice {
520
639
  * @publicApi
521
640
  * FIXED: 고정 가격
522
641
  * VARIABLE: 시가(예: 수산시장 방어회)
642
+ * UNIT: 단위 가격(예: 1kg당 가격, 1L당 가격 등)
523
643
  */
524
- export declare type PluginCatalogItemPriceType = 'FIXED' | 'VARIABLE';
644
+ export declare type PluginCatalogItemPriceType = 'FIXED' | 'VARIABLE' | 'UNIT';
525
645
 
526
646
  /**
527
647
  * 상품 상태
@@ -532,6 +652,13 @@ export declare type PluginCatalogItemPriceType = 'FIXED' | 'VARIABLE';
532
652
  */
533
653
  declare type PluginCatalogItemState = 'ON_SALE' | 'SOLD_OUT' | 'UNAVAILABLE' | 'DELETED';
534
654
 
655
+ /**
656
+ * @publicApi
657
+ */
658
+ export declare type PluginDelivery<T extends 'PICKUP' | 'HERE' | 'DELIVERY'> = Extract<DeliveryOrder | PickupOrder | HereOrder, {
659
+ type: T;
660
+ }>;
661
+
535
662
  /**
536
663
  * @publicApi
537
664
  * 할인 정보
@@ -594,6 +721,19 @@ export declare type PluginHttpResponse = {
594
721
  code: number;
595
722
  };
596
723
 
724
+ /**
725
+ * @publicApi
726
+ * @see https://deus.toss.im/projects/1057/pages/8gKjmG0l@1
727
+ */
728
+ export declare type PluginInputs<T extends PluginInputType = any> = Extract<TextInput | PasswordInput | RadioInput | CheckBoxInput | ToggleInput | SliderInput, {
729
+ type: T;
730
+ }>;
731
+
732
+ /**
733
+ * @publicApi
734
+ */
735
+ declare type PluginInputType = PluginInputs['type'];
736
+
597
737
  declare type PluginLanguageCode = ValueOf<typeof AvailableLanguageCodes>;
598
738
 
599
739
  /**
@@ -614,7 +754,14 @@ export declare interface PluginOrder {
614
754
  tableId?: number;
615
755
  table?: PluginTable;
616
756
  orderKey: string;
617
- state: PluginOrderState;
757
+ /**
758
+ * 결제상태
759
+ */
760
+ paymentState: PluginOrderPaymentState;
761
+ /**
762
+ * 주문상태
763
+ */
764
+ orderState: PluginOrderState;
618
765
  lineItems: PluginOrderItem[];
619
766
  discounts?: PluginDiscount[];
620
767
  payments: PluginPayment[];
@@ -704,6 +851,22 @@ declare interface PluginOrderPaymentPrice {
704
851
  paymentPaidValue: number;
705
852
  }
706
853
 
854
+ /**
855
+ * @publicApi
856
+ * 주문의 결제상태
857
+ * 상태 전이 규칙은 아래 문서를 참조해주세요. (22.09)
858
+ * https://www.notion.so/tossteam/1affab9356d24d2d9256ca21be2db473
859
+ * 또다른 문서도 있어요. (25.03)
860
+ * https://www.notion.so/tossteam/1c3a360d33e380979d4df2a1ba3bfd31
861
+ *
862
+ * OPENED: 결제 전 (초기 상태)
863
+ * PAID: 부분 결제 (일부 금액만 결제된 상태)
864
+ * CANCELLED: 취소
865
+ * COMPLETED: 결제 완료 (주문 금액이 모두 결제된 경우)
866
+ * REFUNDED: 환불 (모든 결제가 취소된 상태)
867
+ */
868
+ declare type PluginOrderPaymentState = 'OPENED' | 'PAID' | 'CANCELLED' | 'COMPLETED' | 'REFUNDED';
869
+
707
870
  declare interface PluginOrderRequestInfo {
708
871
  /** 요청 시간 */
709
872
  requestAt: string;
@@ -724,16 +887,13 @@ declare interface PluginOrderRequestInfo {
724
887
  /**
725
888
  * @publicApi
726
889
  * 주문 상태
727
- * 상태 전이 규칙은 아래 문서를 참조해주세요.
728
- * https://www.notion.so/tossteam/1affab9356d24d2d9256ca21be2db473
729
890
  *
730
- * OPENED: 주문시작
731
- * PAID: 분할결제
732
- * CANCELLED: 주문취소
733
- * COMPLETED: 주문완료. 결제까지 완료된 상태
734
- * REFUNDED: 환불
891
+ * - REQUEST: 주문 접수 (requestedInfo가 있는 주문의 초기 상태)
892
+ * - OPENED: 주문 진행중 (포스 등 일반적인 환경에서 주문의 초기 상태)
893
+ * - COMPLETED: 주문 완료
894
+ * - CANCELLED: 주문 취소
735
895
  */
736
- export declare type PluginOrderState = 'OPENED' | 'PAID' | 'CANCELLED' | 'COMPLETED' | 'REFUNDED';
896
+ export declare type PluginOrderState = 'REQUESTED' | 'OPENED' | 'COMPLETED' | 'CANCELLED';
737
897
 
738
898
  /**
739
899
  * @publicApi
@@ -871,6 +1031,8 @@ export declare interface PluginTableGroup {
871
1031
  tableIds: number[];
872
1032
  }
873
1033
 
1034
+ declare type PluginTypes = typeof plugin;
1035
+
874
1036
  /**
875
1037
  * @publicApi
876
1038
  */
@@ -888,24 +1050,11 @@ export declare type PopupElements<T extends AllPopupType> = Extract<AllPopupElem
888
1050
  /**
889
1051
  * @publicApi
890
1052
  */
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;
1053
+ export declare type PosPluginSdk = {
1054
+ table: Table;
906
1055
  category: CategoryTypes;
907
- catalog: CatalogTypes;
908
- option: MenuOptionTypes;
1056
+ catalog: Catalog;
1057
+ option: MenuOption;
909
1058
  storage: StorageTypes;
910
1059
  cashReceipt: CashReceiptTypes;
911
1060
  order: OrderTypes;
@@ -917,6 +1066,53 @@ export declare type Sdk = {
917
1066
  paymentMethod: PaymentMethodType;
918
1067
  websocket: WebsocketTypes;
919
1068
  ffi: FFITypes;
1069
+ plugin: PluginTypes;
1070
+ setting: SettingTypes;
1071
+ };
1072
+
1073
+ /**
1074
+ * @publicApi
1075
+ */
1076
+ export declare const posPluginSdk: PosPluginSdk;
1077
+
1078
+ /**
1079
+ * @publicApi
1080
+ */
1081
+ export declare class PosPluginSdkError extends Error {
1082
+ constructor(message: string);
1083
+ static isPosPluginSdkError(error: unknown): error is PosPluginSdkError;
1084
+ }
1085
+
1086
+ /**
1087
+ * @return string values.id
1088
+ */
1089
+ declare type RadioInput = Omit<BaseInput, 'placeholder'> & {
1090
+ type: 'radio';
1091
+ /**
1092
+ * @desciption 선택된 value의 id
1093
+ */
1094
+ default: string;
1095
+ values: InputValue[];
1096
+ };
1097
+
1098
+ declare function setInputs(inputs: Array<PluginInputs>): void;
1099
+
1100
+ declare const setting: {
1101
+ setInputs: typeof setInputs;
1102
+ getValues: typeof getValues;
1103
+ };
1104
+
1105
+ declare type SettingTypes = typeof setting;
1106
+
1107
+ /**
1108
+ * @return number 0 25 50 75 100
1109
+ */
1110
+ declare type SliderInput = Omit<BaseInput, 'placeholder'> & {
1111
+ type: 'slider';
1112
+ default: number;
1113
+ min: number;
1114
+ max: number;
1115
+ step: number;
920
1116
  };
921
1117
 
922
1118
  /**
@@ -928,12 +1124,22 @@ export declare interface StorageTypes {
928
1124
  del: (key: string) => Promise<void>;
929
1125
  }
930
1126
 
931
- declare interface TableTypes {
1127
+ /**
1128
+ * @publicApi
1129
+ */
1130
+ declare type StoreStatus = 'NEW' | 'ACCEPTED' | 'REJECTED' | 'PARTIALLY_CANCELLED' | 'CANCELLED'
1131
+ /**
1132
+ * 손님이 가져감
1133
+ */
1134
+ | 'DONE';
1135
+
1136
+ declare interface Table {
932
1137
  getTables: () => Promise<{
933
1138
  table: PluginTable;
934
1139
  order?: PluginOrder;
935
1140
  }[]>;
936
- on(event: 'order-update' | 'add' | 'clear', callback: (table: PluginTable) => void): void;
1141
+ on(event: 'order-update' | 'order-add', callback: (order: PluginOrder) => void): void;
1142
+ on(event: 'clear' | 'add' | 'delete' | 'update', callback: (table: PluginTable) => void): void;
937
1143
  on(event: 'swap' | 'move' | 'merge', callback: (before: PluginTable, after: PluginTable) => void): void;
938
1144
  clearTable: (payload: {
939
1145
  table: PluginTable;
@@ -941,10 +1147,27 @@ declare interface TableTypes {
941
1147
  }) => Promise<void>;
942
1148
  }
943
1149
 
1150
+ /**
1151
+ * @return string
1152
+ */
1153
+ declare type TextInput = BaseInput & {
1154
+ type: 'text';
1155
+ default: string;
1156
+ placeholder?: string;
1157
+ };
1158
+
944
1159
  declare type ToastTypes = {
945
1160
  open(message: string): void;
946
1161
  };
947
1162
 
1163
+ /**
1164
+ * @return boolean
1165
+ */
1166
+ declare type ToggleInput = Omit<BaseInput, 'placeholder'> & {
1167
+ type: 'toggle';
1168
+ default: boolean;
1169
+ };
1170
+
948
1171
  /**
949
1172
  * @publicApi
950
1173
  * @description 추후에 필요한 정보 더 추가될 예정
@@ -952,9 +1175,12 @@ declare type ToastTypes = {
952
1175
  export declare type TossMerchant = {
953
1176
  name: string;
954
1177
  id: number;
1178
+ businessNumber: string;
955
1179
  serialNumber: string;
956
- franchiseId?: string;
957
- franchiseName?: string;
1180
+ franchise?: {
1181
+ id: string;
1182
+ name: string;
1183
+ };
958
1184
  };
959
1185
 
960
1186
  declare type UiType = {