@tossplace/pos-plugin-sdk 0.0.0

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.
@@ -0,0 +1,9 @@
1
+ import { TossMerchant } from '@tossplace-nexus/plugin-types';
2
+ export declare function getMerchant(): Promise<TossMerchant>;
3
+ /**
4
+ * @publicApi
5
+ */
6
+ export interface MerchantTypes {
7
+ getMerchant: () => Promise<TossMerchant>;
8
+ }
9
+ export declare const merchant: MerchantTypes;
@@ -0,0 +1,9 @@
1
+ import { PluginCatalogItemOption } from '@tossplace-nexus/plugin-types';
2
+ /**
3
+ * @publicApi
4
+ */
5
+ export interface MenuOptionTypes {
6
+ getOptions: () => Promise<PluginCatalogItemOption[]>;
7
+ on: (event: 'sold-out' | 'on-sale', callback: (option: PluginCatalogItemOption) => void) => void;
8
+ }
9
+ export declare const option: MenuOptionTypes;
@@ -0,0 +1,19 @@
1
+ import { PluginOrder, PluginOrderDto } from '@tossplace-nexus/plugin-types';
2
+ /**
3
+ * @publicApi
4
+ */
5
+ export interface OrderTypes {
6
+ getOrder: (id: string) => Promise<PluginOrder>;
7
+ /**
8
+ * 토스포스에서 카드결제를 취소하면 무조건 카드리딩해야함 그래서 on cancel은 늘 환불까지 된 상태임
9
+ */
10
+ on: (event: 'cancel', callback: (order: PluginOrder) => void) => void;
11
+ cancel: (id: string) => Promise<void>;
12
+ add: (order: PluginOrderDto) => Promise<PluginOrder>;
13
+ /**
14
+ * 새로 추가 된 메뉴만 order에 넣으세요
15
+ */
16
+ addMenu: (orderId: string, order: PluginOrderDto) => Promise<PluginOrder>;
17
+ complete: (id: string) => Promise<PluginOrder>;
18
+ }
19
+ export declare const order: OrderTypes;
@@ -0,0 +1,2 @@
1
+ import { PluginPaymentDto } from '@tossplace-nexus/plugin-types';
2
+ export declare function assertPayment(paymentDto: PluginPaymentDto): void;
@@ -0,0 +1,13 @@
1
+ import { PluginPaymentDto, PluginPaymentOf } from '@tossplace-nexus/plugin-types';
2
+ export interface PaymentTypes {
3
+ on: (event: 'cancel' | 'paid', callback: (payload: PluginPaymentOf<'CASH'> | PluginPaymentOf<'CARD'> | PluginPaymentOf<'EXTERNAL'>) => void) => void;
4
+ cancel: (order: {
5
+ id: string;
6
+ }, payment: {
7
+ id: string;
8
+ }) => Promise<void>;
9
+ add: (order: {
10
+ id: string;
11
+ }, paymentDto: PluginPaymentDto) => Promise<PluginPaymentOf<'CARD'> | PluginPaymentOf<'CASH'> | PluginPaymentOf<'EXTERNAL'>>;
12
+ }
13
+ export declare const payment: PaymentTypes;
@@ -0,0 +1,12 @@
1
+ import { PaymentMethodResponse, PluginCancelledPaymentDto, PluginMessage, PluginOrder, PluginPayment, PluginPrice } from '@tossplace-nexus/plugin-types';
2
+ declare type PayCallback = (order: PluginOrder, price: PluginPrice) => Promise<PaymentMethodResponse | undefined>;
3
+ declare type CancelCallback = (order: PluginOrder, payment: PluginPayment) => Promise<PluginCancelledPaymentDto | undefined>;
4
+ export declare type PaymentMethodType = {
5
+ add: (payload: {
6
+ data: PluginMessage<'payment.method.add'>['data'];
7
+ payCallback: PayCallback;
8
+ cancelCallback: CancelCallback;
9
+ }) => void;
10
+ };
11
+ export declare const paymentMethod: PaymentMethodType;
12
+ export {};
@@ -0,0 +1,37 @@
1
+ import { CashReceiptTypes } from '../cash-receipt/cash-receipt';
2
+ import { StorageTypes } from '../storage/storage';
3
+ import { TableTypes } from '../table/table';
4
+ import { CategoryTypes } from '../category/category';
5
+ import { CatalogTypes } from '../catalog/catalog';
6
+ import { MenuOptionTypes } from '../option/option';
7
+ import { OrderTypes } from '../order/order';
8
+ import { HttpTypes } from '../http/http';
9
+ import { PaymentTypes } from '../payment/payment';
10
+ import { ToastTypes } from '../toast/toast';
11
+ import { MerchantTypes } from '../merchant/merchant';
12
+ import { UiType } from '../ui/ui';
13
+ import { PaymentMethodType } from '../payment-method/payment-method';
14
+ import { WebsocketTypes } from '../websocket/websocket';
15
+ /**
16
+ * @publicApi
17
+ */
18
+ export declare type Sdk = {
19
+ table: TableTypes;
20
+ category: CategoryTypes;
21
+ catalog: CatalogTypes;
22
+ option: MenuOptionTypes;
23
+ storage: StorageTypes;
24
+ cashReceipt: CashReceiptTypes;
25
+ order: OrderTypes;
26
+ payment: PaymentTypes;
27
+ http: HttpTypes;
28
+ toast: ToastTypes;
29
+ merchant: MerchantTypes;
30
+ ui: UiType;
31
+ paymentMethod: PaymentMethodType;
32
+ websocket: WebsocketTypes;
33
+ };
34
+ /**
35
+ * @publicApi
36
+ */
37
+ export declare const pos: Sdk;
@@ -0,0 +1,5 @@
1
+ import { PluginOrder, PluginTable } from '@tossplace-nexus/plugin-types';
2
+ export interface PrinterTypes {
3
+ print: (order: PluginOrder, previousOrder?: PluginOrder, table?: PluginTable) => Promise<void>;
4
+ }
5
+ export declare const printer: PrinterTypes;
@@ -0,0 +1,17 @@
1
+ declare function get(key: string): Promise<string | undefined>;
2
+ declare function set(key: string, value: any): Promise<void>;
3
+ declare function del(key: string): Promise<void>;
4
+ /**
5
+ * @publicApi
6
+ */
7
+ export interface StorageTypes {
8
+ get: (key: string) => Promise<string | undefined>;
9
+ set: (key: string, value: string) => Promise<void>;
10
+ del: (key: string) => Promise<void>;
11
+ }
12
+ export declare const storage: {
13
+ get: typeof get;
14
+ set: typeof set;
15
+ del: typeof del;
16
+ };
17
+ export {};
@@ -0,0 +1,14 @@
1
+ import { PluginOrder, PluginTable } from '@tossplace-nexus/plugin-types';
2
+ export interface TableTypes {
3
+ getTables: () => Promise<{
4
+ table: PluginTable;
5
+ order?: PluginOrder;
6
+ }[]>;
7
+ on(event: 'order-update' | 'add' | 'clear', callback: (table: PluginTable) => void): void;
8
+ on(event: 'swap' | 'move' | 'merge', callback: (before: PluginTable, after: PluginTable) => void): void;
9
+ clearTable: (payload: {
10
+ table: PluginTable;
11
+ order?: PluginOrder;
12
+ }) => Promise<void>;
13
+ }
14
+ export declare const table: TableTypes;
@@ -0,0 +1,8 @@
1
+ declare function open(message: string): void;
2
+ export declare type ToastTypes = {
3
+ open(message: string): void;
4
+ };
5
+ export declare const toast: {
6
+ open: typeof open;
7
+ };
8
+ export {};
@@ -0,0 +1,2 @@
1
+ import { AllPopupType, PopupActionResponse, PopupElements } from '@tossplace-nexus/plugin-types';
2
+ export declare function openPopup<T extends AllPopupType>(data: PopupElements<T>): Promise<PopupActionResponse<T>>;
@@ -0,0 +1,5 @@
1
+ import { AllPopupType, PopupActionResponse, PopupElements } from '@tossplace-nexus/plugin-types/src/ui/popup';
2
+ export declare type UiType = {
3
+ openPopup<T extends AllPopupType>(message: PopupElements<T>): Promise<PopupActionResponse<T>>;
4
+ };
5
+ export declare const ui: UiType;
@@ -0,0 +1,34 @@
1
+ export declare class Websocket {
2
+ private readonly url;
3
+ private readonly headers;
4
+ private readonly options?;
5
+ onMessageCallback: ((message: string) => void) | undefined;
6
+ onErrorCallback: ((errorName?: string, errorMessage?: string) => void) | undefined;
7
+ onCloseCallback: ((code: string) => void) | undefined;
8
+ onOpenCallback: (() => void) | undefined;
9
+ constructor(url: string, headers: Record<string, string>, options?: {
10
+ rejectUnauthorized?: boolean | undefined;
11
+ followRedirects?: boolean | undefined;
12
+ timeout?: number | undefined;
13
+ } | undefined);
14
+ connect(): Promise<void>;
15
+ disconnect(): Promise<void>;
16
+ send(data: {
17
+ data: string;
18
+ option?: {
19
+ mask?: boolean;
20
+ };
21
+ }): void;
22
+ onMessage(callback: (message: string) => void): void;
23
+ onError(callback: (errorName?: string, errorMessage?: string) => void): void;
24
+ onClose(callback: (code: string) => void): void;
25
+ onOpen(callback: () => void): void;
26
+ }
27
+ export declare type WebsocketTypes = {
28
+ create: (url: string, headers: Record<string, string>, options?: {
29
+ rejectUnauthorized?: boolean;
30
+ followRedirects?: boolean;
31
+ timeout?: number;
32
+ }) => Promise<Websocket>;
33
+ };
34
+ export declare const websocket: WebsocketTypes;