@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/dist/sdk.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,21 @@ declare interface FFIApi extends FFIFunction {
111
136
  name: string;
112
137
  }
113
138
 
139
+ /**
140
+ * @internal
141
+ * @publicApi
142
+ */
143
+ declare interface FFIDownloadInfo {
144
+ win32: {
145
+ filePath: string;
146
+ downloadUrl: string;
147
+ };
148
+ win64: {
149
+ filePath: string;
150
+ downloadUrl: string;
151
+ };
152
+ }
153
+
114
154
  /**
115
155
  * @publicApi
116
156
  */
@@ -118,6 +158,7 @@ declare interface FFIFunction {
118
158
  params?: FFIFunctionParam[];
119
159
  return: FFIFunctionReturn;
120
160
  options?: FFIFunctionOptions;
161
+ returnData?: any;
121
162
  }
122
163
 
123
164
  /**
@@ -152,15 +193,35 @@ declare type FFIFunctionParam = {
152
193
  declare type FFIFunctionReturn = 'void' | 'str' | 'int' | 'bool' | 'wchar *' | 'void *';
153
194
 
154
195
  declare interface FFITypes {
155
- download: (downloadUrl: string, filePath: string) => Promise<void>;
196
+ download: (downloadInfo: FFIDownloadInfo) => Promise<{
197
+ platform: keyof FFIDownloadInfo;
198
+ }>;
156
199
  load: (filePath: string, apis: FFIApi[]) => Promise<void>;
157
200
  unload: (filePath: string) => Promise<void>;
158
201
  invoke: (filePath: string, apiName: string, params?: any[]) => Promise<any>;
159
202
  registerCallback: (filePath: string, signature: FFIFunction, callback: (...args: any[]) => any) => Promise<{
160
203
  ffiCallbackId: string;
161
204
  }>;
205
+ unregisterCallback: (filePath: string, callbackId: string) => Promise<void>;
206
+ addCallbackErrorHandler: (filePath: string, handler: (error: Error) => void) => void;
162
207
  }
163
208
 
209
+ declare function getPluginInfo(): Promise<{
210
+ name: string;
211
+ version: string;
212
+ }>;
213
+
214
+ declare function getValues<T extends Record<string, number | string | string[] | boolean | undefined>>(): Promise<T>;
215
+
216
+ declare type HereOrder = Order & {
217
+ type: 'HERE';
218
+ memo: {
219
+ store?: string;
220
+ };
221
+ phone?: string;
222
+ status: StoreStatus;
223
+ };
224
+
164
225
  /**
165
226
  * @publicApi
166
227
  */
@@ -185,6 +246,11 @@ export declare interface HttpTypes {
185
246
  patch: (url: string, payload: any, headers?: [string, string][]) => Promise<PluginHttpResponse>;
186
247
  }
187
248
 
249
+ declare type InputValue = {
250
+ id: string;
251
+ label: string;
252
+ };
253
+
188
254
  declare type Join<T extends string, U extends string> = `${T}${U}` | '0';
189
255
 
190
256
  declare type Languages = Record<PluginLanguageCode, string>;
@@ -192,9 +258,9 @@ declare type Languages = Record<PluginLanguageCode, string>;
192
258
  /**
193
259
  * @publicApi
194
260
  */
195
- export declare interface MenuOptionTypes {
261
+ export declare interface MenuOption {
196
262
  getOptions: () => Promise<PluginCatalogItemOption[]>;
197
- on: (event: 'sold-out' | 'on-sale', callback: (option: PluginCatalogItemOption) => void) => void;
263
+ on: (event: 'sold-out' | 'on-sale' | 'update' | 'add' | 'delete', callback: (option: PluginCatalogItemOption) => void) => void;
198
264
  }
199
265
 
200
266
  /**
@@ -204,7 +270,51 @@ export declare interface MerchantTypes {
204
270
  getMerchant: () => Promise<TossMerchant>;
205
271
  }
206
272
 
207
- declare type OrderItemType = 'ITEM' | 'DELIVERY_FEE' | 'PREPAID_CARD';
273
+ declare function on(event: 'close', callback: () => Promise<void>): void;
274
+
275
+ declare type Order = {
276
+ /**
277
+ * 포스(사장님)에게 보여줄 주문유형
278
+ * @example 가게배달, 장보기/쇼핑, 픽업, 배민1 등등
279
+ */
280
+ serviceName: string;
281
+ /**
282
+ * 주문서에서 라이더에게 보여줄 배달 타입 (배민1, 배달의민족)
283
+ */
284
+ deliveryName: string;
285
+ /**
286
+ * @description 주문 시간 (yyyy-MM-dd'T'HH:mm:ss)
287
+ * @example 2025-04-08T16:11:13.000+09:00
288
+ */
289
+ orderAt: string;
290
+ /**
291
+ * @description 아이콘 url
292
+ */
293
+ icon: string;
294
+ /**
295
+ * @description 준비시간(분)
296
+ */
297
+ preparationTimeMin?: number;
298
+ /**
299
+ * 픽업/배달이 실행될 예약주문 시간 (yyyy-MM-dd'T'HH:mm:ss)
300
+ * @description 예약주문인 경우에만 값이 존재
301
+ * @example 2025-04-08T16:11:13.000+09:00
302
+ */
303
+ reservedDateTime?: string;
304
+ deliveryId: string;
305
+ origin?: string;
306
+ shop: {
307
+ id: string;
308
+ name: string;
309
+ };
310
+ paymentMethod: '결제완료' | '만나서 카드결제' | '만나서 현금결제' | '선불결제' | '기타결제';
311
+ /**
312
+ * @description 고객이 결제한 금액
313
+ */
314
+ customerChargedPrice: number;
315
+ };
316
+
317
+ declare type OrderItemType = 'ITEM' | 'DELIVERY_FEE' | 'PREPAID_CARD' | 'MULTI_USE_TICKET';
208
318
 
209
319
  /**
210
320
  * @publicApi
@@ -224,6 +334,15 @@ export declare interface OrderTypes {
224
334
  complete: (id: string) => Promise<PluginOrder>;
225
335
  }
226
336
 
337
+ /**
338
+ * @return string
339
+ */
340
+ declare type PasswordInput = BaseInput & {
341
+ type: 'password';
342
+ default: string;
343
+ placeholder?: string;
344
+ };
345
+
227
346
  declare type PayCallback = (order: PluginOrder, price: PluginPrice) => Promise<PaymentMethodResponse | undefined>;
228
347
 
229
348
  /**
@@ -237,7 +356,6 @@ export declare type PaymentMethodResponse = {
237
356
  * @example 2022-01-27T11:42:33
238
357
  */
239
358
  approvedAt: string;
240
- approvedNo: string;
241
359
  paymentKey: string;
242
360
  };
243
361
 
@@ -262,7 +380,7 @@ declare type PaymentMethodType = {
262
380
  };
263
381
 
264
382
  declare interface PaymentTypes {
265
- on: (event: 'cancel' | 'paid', callback: (payload: PluginPaymentOf<'CASH'> | PluginPaymentOf<'CARD'> | PluginPaymentOf<'EXTERNAL'>) => void) => void;
383
+ on: (event: 'cancel', callback: (payload: PluginPaymentOf<'CASH'> | PluginPaymentOf<'CARD'> | PluginPaymentOf<'EXTERNAL'>) => void) => void;
266
384
  cancel: (order: {
267
385
  id: string;
268
386
  }, payment: {
@@ -273,6 +391,20 @@ declare interface PaymentTypes {
273
391
  }, paymentDto: PluginPaymentDto) => Promise<PluginPaymentOf<'CARD'> | PluginPaymentOf<'CASH'> | PluginPaymentOf<'EXTERNAL'>>;
274
392
  }
275
393
 
394
+ declare type PickupOrder = Order & {
395
+ type: 'PICKUP';
396
+ memo: {
397
+ store?: string;
398
+ };
399
+ phone?: string;
400
+ status: StoreStatus;
401
+ };
402
+
403
+ declare const plugin: {
404
+ on: typeof on;
405
+ getPluginInfo: typeof getPluginInfo;
406
+ };
407
+
276
408
  /**
277
409
  * @publicApi
278
410
  */
@@ -520,8 +652,9 @@ export declare interface PluginCatalogItemPrice {
520
652
  * @publicApi
521
653
  * FIXED: 고정 가격
522
654
  * VARIABLE: 시가(예: 수산시장 방어회)
655
+ * UNIT: 단위 가격(예: 1kg당 가격, 1L당 가격 등)
523
656
  */
524
- export declare type PluginCatalogItemPriceType = 'FIXED' | 'VARIABLE';
657
+ export declare type PluginCatalogItemPriceType = 'FIXED' | 'VARIABLE' | 'UNIT';
525
658
 
526
659
  /**
527
660
  * 상품 상태
@@ -532,6 +665,13 @@ export declare type PluginCatalogItemPriceType = 'FIXED' | 'VARIABLE';
532
665
  */
533
666
  declare type PluginCatalogItemState = 'ON_SALE' | 'SOLD_OUT' | 'UNAVAILABLE' | 'DELETED';
534
667
 
668
+ /**
669
+ * @publicApi
670
+ */
671
+ export declare type PluginDelivery<T extends 'PICKUP' | 'HERE' | 'DELIVERY'> = Extract<DeliveryOrder | PickupOrder | HereOrder, {
672
+ type: T;
673
+ }>;
674
+
535
675
  /**
536
676
  * @publicApi
537
677
  * 할인 정보
@@ -594,6 +734,19 @@ export declare type PluginHttpResponse = {
594
734
  code: number;
595
735
  };
596
736
 
737
+ /**
738
+ * @publicApi
739
+ * @see https://deus.toss.im/projects/1057/pages/8gKjmG0l@1
740
+ */
741
+ export declare type PluginInputs<T extends PluginInputType = any> = Extract<TextInput | PasswordInput | RadioInput | CheckBoxInput | ToggleInput | SliderInput, {
742
+ type: T;
743
+ }>;
744
+
745
+ /**
746
+ * @publicApi
747
+ */
748
+ declare type PluginInputType = PluginInputs['type'];
749
+
597
750
  declare type PluginLanguageCode = ValueOf<typeof AvailableLanguageCodes>;
598
751
 
599
752
  /**
@@ -614,7 +767,14 @@ export declare interface PluginOrder {
614
767
  tableId?: number;
615
768
  table?: PluginTable;
616
769
  orderKey: string;
617
- state: PluginOrderState;
770
+ /**
771
+ * 결제상태
772
+ */
773
+ paymentState: PluginOrderPaymentState;
774
+ /**
775
+ * 주문상태
776
+ */
777
+ orderState: PluginOrderState;
618
778
  lineItems: PluginOrderItem[];
619
779
  discounts?: PluginDiscount[];
620
780
  payments: PluginPayment[];
@@ -704,6 +864,22 @@ declare interface PluginOrderPaymentPrice {
704
864
  paymentPaidValue: number;
705
865
  }
706
866
 
867
+ /**
868
+ * @publicApi
869
+ * 주문의 결제상태
870
+ * 상태 전이 규칙은 아래 문서를 참조해주세요. (22.09)
871
+ * https://www.notion.so/tossteam/1affab9356d24d2d9256ca21be2db473
872
+ * 또다른 문서도 있어요. (25.03)
873
+ * https://www.notion.so/tossteam/1c3a360d33e380979d4df2a1ba3bfd31
874
+ *
875
+ * OPENED: 결제 전 (초기 상태)
876
+ * PAID: 부분 결제 (일부 금액만 결제된 상태)
877
+ * CANCELLED: 취소
878
+ * COMPLETED: 결제 완료 (주문 금액이 모두 결제된 경우)
879
+ * REFUNDED: 환불 (모든 결제가 취소된 상태)
880
+ */
881
+ declare type PluginOrderPaymentState = 'OPENED' | 'PAID' | 'CANCELLED' | 'COMPLETED' | 'REFUNDED';
882
+
707
883
  declare interface PluginOrderRequestInfo {
708
884
  /** 요청 시간 */
709
885
  requestAt: string;
@@ -724,16 +900,13 @@ declare interface PluginOrderRequestInfo {
724
900
  /**
725
901
  * @publicApi
726
902
  * 주문 상태
727
- * 상태 전이 규칙은 아래 문서를 참조해주세요.
728
- * https://www.notion.so/tossteam/1affab9356d24d2d9256ca21be2db473
729
903
  *
730
- * OPENED: 주문시작
731
- * PAID: 분할결제
732
- * CANCELLED: 주문취소
733
- * COMPLETED: 주문완료. 결제까지 완료된 상태
734
- * REFUNDED: 환불
904
+ * - REQUEST: 주문 접수 (requestedInfo가 있는 주문의 초기 상태)
905
+ * - OPENED: 주문 진행중 (포스 등 일반적인 환경에서 주문의 초기 상태)
906
+ * - COMPLETED: 주문 완료
907
+ * - CANCELLED: 주문 취소
735
908
  */
736
- export declare type PluginOrderState = 'OPENED' | 'PAID' | 'CANCELLED' | 'COMPLETED' | 'REFUNDED';
909
+ export declare type PluginOrderState = 'REQUESTED' | 'OPENED' | 'COMPLETED' | 'CANCELLED';
737
910
 
738
911
  /**
739
912
  * @publicApi
@@ -871,6 +1044,8 @@ export declare interface PluginTableGroup {
871
1044
  tableIds: number[];
872
1045
  }
873
1046
 
1047
+ declare type PluginTypes = typeof plugin;
1048
+
874
1049
  /**
875
1050
  * @publicApi
876
1051
  */
@@ -888,24 +1063,11 @@ export declare type PopupElements<T extends AllPopupType> = Extract<AllPopupElem
888
1063
  /**
889
1064
  * @publicApi
890
1065
  */
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;
1066
+ export declare type PosPluginSdk = {
1067
+ table: Table;
906
1068
  category: CategoryTypes;
907
- catalog: CatalogTypes;
908
- option: MenuOptionTypes;
1069
+ catalog: Catalog;
1070
+ option: MenuOption;
909
1071
  storage: StorageTypes;
910
1072
  cashReceipt: CashReceiptTypes;
911
1073
  order: OrderTypes;
@@ -917,6 +1079,53 @@ export declare type Sdk = {
917
1079
  paymentMethod: PaymentMethodType;
918
1080
  websocket: WebsocketTypes;
919
1081
  ffi: FFITypes;
1082
+ plugin: PluginTypes;
1083
+ setting: SettingTypes;
1084
+ };
1085
+
1086
+ /**
1087
+ * @publicApi
1088
+ */
1089
+ export declare const posPluginSdk: PosPluginSdk;
1090
+
1091
+ /**
1092
+ * @publicApi
1093
+ */
1094
+ export declare class PosPluginSdkError extends Error {
1095
+ constructor(message: string);
1096
+ static isPosPluginSdkError(error: unknown): error is PosPluginSdkError;
1097
+ }
1098
+
1099
+ /**
1100
+ * @return string values.id
1101
+ */
1102
+ declare type RadioInput = Omit<BaseInput, 'placeholder'> & {
1103
+ type: 'radio';
1104
+ /**
1105
+ * @desciption 선택된 value의 id
1106
+ */
1107
+ default: string;
1108
+ values: InputValue[];
1109
+ };
1110
+
1111
+ declare function setInputs(inputs: Array<PluginInputs>): void;
1112
+
1113
+ declare const setting: {
1114
+ setInputs: typeof setInputs;
1115
+ getValues: typeof getValues;
1116
+ };
1117
+
1118
+ declare type SettingTypes = typeof setting;
1119
+
1120
+ /**
1121
+ * @return number 0 25 50 75 100
1122
+ */
1123
+ declare type SliderInput = Omit<BaseInput, 'placeholder'> & {
1124
+ type: 'slider';
1125
+ default: number;
1126
+ min: number;
1127
+ max: number;
1128
+ step: number;
920
1129
  };
921
1130
 
922
1131
  /**
@@ -928,12 +1137,22 @@ export declare interface StorageTypes {
928
1137
  del: (key: string) => Promise<void>;
929
1138
  }
930
1139
 
931
- declare interface TableTypes {
1140
+ /**
1141
+ * @publicApi
1142
+ */
1143
+ declare type StoreStatus = 'NEW' | 'ACCEPTED' | 'REJECTED' | 'PARTIALLY_CANCELLED' | 'CANCELLED'
1144
+ /**
1145
+ * 손님이 가져감
1146
+ */
1147
+ | 'DONE';
1148
+
1149
+ declare interface Table {
932
1150
  getTables: () => Promise<{
933
1151
  table: PluginTable;
934
1152
  order?: PluginOrder;
935
1153
  }[]>;
936
- on(event: 'order-update' | 'add' | 'clear', callback: (table: PluginTable) => void): void;
1154
+ on(event: 'order-update' | 'order-add', callback: (order: PluginOrder) => void): void;
1155
+ on(event: 'clear' | 'add' | 'delete' | 'update', callback: (table: PluginTable) => void): void;
937
1156
  on(event: 'swap' | 'move' | 'merge', callback: (before: PluginTable, after: PluginTable) => void): void;
938
1157
  clearTable: (payload: {
939
1158
  table: PluginTable;
@@ -941,10 +1160,27 @@ declare interface TableTypes {
941
1160
  }) => Promise<void>;
942
1161
  }
943
1162
 
1163
+ /**
1164
+ * @return string
1165
+ */
1166
+ declare type TextInput = BaseInput & {
1167
+ type: 'text';
1168
+ default: string;
1169
+ placeholder?: string;
1170
+ };
1171
+
944
1172
  declare type ToastTypes = {
945
1173
  open(message: string): void;
946
1174
  };
947
1175
 
1176
+ /**
1177
+ * @return boolean
1178
+ */
1179
+ declare type ToggleInput = Omit<BaseInput, 'placeholder'> & {
1180
+ type: 'toggle';
1181
+ default: boolean;
1182
+ };
1183
+
948
1184
  /**
949
1185
  * @publicApi
950
1186
  * @description 추후에 필요한 정보 더 추가될 예정
@@ -952,9 +1188,12 @@ declare type ToastTypes = {
952
1188
  export declare type TossMerchant = {
953
1189
  name: string;
954
1190
  id: number;
1191
+ businessNumber: string;
955
1192
  serialNumber: string;
956
- franchiseId?: string;
957
- franchiseName?: string;
1193
+ franchise?: {
1194
+ id: string;
1195
+ name: string;
1196
+ };
958
1197
  };
959
1198
 
960
1199
  declare type UiType = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tossplace/pos-plugin-sdk",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "포스 플러그인 sdk",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",