@reservation-studio/electron-types 0.0.9 → 0.0.11
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/README.md +259 -0
- package/dist/enums/actions.enum.d.ts +9 -1
- package/dist/enums/envirovment.enum.d.ts +17 -0
- package/dist/interfaces/api.interface.d.ts +107 -16
- package/dist/interfaces/certificate-info.interface.d.ts +26 -0
- package/dist/interfaces/fiscal-device.interface.d.ts +204 -0
- package/dist/interfaces/http.interface.d.ts +27 -0
- package/package.json +3 -3
- package/README.md +0 -1
package/README.md
ADDED
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
# @reservation-studio/electron-types
|
|
2
|
+
|
|
3
|
+
TypeScript type definitions for the Reservation.Studio Electron application.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @reservation-studio/electron-types
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
This package provides TypeScript type definitions for the Reservation.Studio Electron application. It includes interfaces and enums for working with:
|
|
14
|
+
|
|
15
|
+
- Certificate management
|
|
16
|
+
- XML signing
|
|
17
|
+
- HTTP requests
|
|
18
|
+
- Fiscal device operations
|
|
19
|
+
- Application environment and version information
|
|
20
|
+
|
|
21
|
+
## API Reference
|
|
22
|
+
|
|
23
|
+
### ReservationStudioElectron
|
|
24
|
+
|
|
25
|
+
The main API object exposed by the Electron application. It's available in the renderer process as `window.ReservationStudioElectron`.
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { ReservationStudioElectron } from '@reservation-studio/electron-types';
|
|
29
|
+
|
|
30
|
+
// Example usage
|
|
31
|
+
const version = await ReservationStudioElectron.version();
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Certificates
|
|
35
|
+
|
|
36
|
+
Methods for working with certificates:
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
// List all available certificates
|
|
40
|
+
const certificates = await ReservationStudioElectron.certificates.list();
|
|
41
|
+
|
|
42
|
+
// Validate a certificate PIN
|
|
43
|
+
const isValid = await ReservationStudioElectron.certificates.isValidPin(slot, pin);
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### XML Signing
|
|
47
|
+
|
|
48
|
+
Methods for signing XML documents:
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
// Sign an XML document
|
|
52
|
+
const signedXml = await ReservationStudioElectron.xml.sign(xml, slot, pin);
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### HTTP Requests
|
|
56
|
+
|
|
57
|
+
Methods for making HTTP requests:
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
// Make a GET request
|
|
61
|
+
const response = await ReservationStudioElectron.http.get(url, {
|
|
62
|
+
headers: { 'Content-Type': 'application/json' },
|
|
63
|
+
timeout: 5000,
|
|
64
|
+
params: { key: 'value' }
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
// Make a POST request
|
|
68
|
+
const response = await ReservationStudioElectron.http.post(url, data, {
|
|
69
|
+
headers: { 'Content-Type': 'application/json' }
|
|
70
|
+
});
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Application Information
|
|
74
|
+
|
|
75
|
+
Methods for getting application information:
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
// Get application version
|
|
79
|
+
const version = await ReservationStudioElectron.version();
|
|
80
|
+
|
|
81
|
+
// Get application environment
|
|
82
|
+
const environment = await ReservationStudioElectron.environment();
|
|
83
|
+
|
|
84
|
+
// Reload the application window
|
|
85
|
+
await ReservationStudioElectron.reload();
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Fiscal Devices
|
|
89
|
+
|
|
90
|
+
Methods for working with fiscal devices:
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
// List all available fiscal devices
|
|
94
|
+
const devices = await ReservationStudioElectron.fiscalDevices.list();
|
|
95
|
+
|
|
96
|
+
// Set the active fiscal device
|
|
97
|
+
await ReservationStudioElectron.fiscalDevices.setActiveDevice(serialNumber);
|
|
98
|
+
|
|
99
|
+
// Get the active fiscal device
|
|
100
|
+
const activeDevice = await ReservationStudioElectron.fiscalDevices.getActiveDevice();
|
|
101
|
+
|
|
102
|
+
// Print a fiscal receipt
|
|
103
|
+
const receiptNumber = await ReservationStudioElectron.fiscalDevices.printReceipt({
|
|
104
|
+
operatorNumber: 1,
|
|
105
|
+
operatorPassword: '1',
|
|
106
|
+
items: [
|
|
107
|
+
{
|
|
108
|
+
name: 'Product 1',
|
|
109
|
+
price: 10.00,
|
|
110
|
+
quantity: 1,
|
|
111
|
+
vatGroup: 'A'
|
|
112
|
+
}
|
|
113
|
+
],
|
|
114
|
+
payments: [
|
|
115
|
+
{
|
|
116
|
+
type: 'cash',
|
|
117
|
+
amount: 10.00
|
|
118
|
+
}
|
|
119
|
+
]
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
// Print non-fiscal text
|
|
123
|
+
await ReservationStudioElectron.fiscalDevices.printText('Hello, World!');
|
|
124
|
+
|
|
125
|
+
// Get the last fiscal memory record
|
|
126
|
+
const lastRecord = await ReservationStudioElectron.fiscalDevices.getLastFiscalRecord();
|
|
127
|
+
|
|
128
|
+
// Get the fiscal device status
|
|
129
|
+
const status = await ReservationStudioElectron.fiscalDevices.getStatus();
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Interfaces
|
|
133
|
+
|
|
134
|
+
### ApiInterface
|
|
135
|
+
|
|
136
|
+
The main interface that defines the structure of the ReservationStudioElectron object.
|
|
137
|
+
|
|
138
|
+
### CertificateInfo
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
interface CertificateInfo {
|
|
142
|
+
slot: number;
|
|
143
|
+
name: string;
|
|
144
|
+
serialNumber: string;
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### HttpResponse
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
interface HttpResponse {
|
|
152
|
+
status: number;
|
|
153
|
+
headers: Record<string, string>;
|
|
154
|
+
data: any;
|
|
155
|
+
error: boolean;
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### HttpOptions
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
interface HttpOptions {
|
|
163
|
+
headers?: Record<string, string>;
|
|
164
|
+
timeout?: number;
|
|
165
|
+
params?: Record<string, string>;
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### FiscalReceipt
|
|
170
|
+
|
|
171
|
+
```typescript
|
|
172
|
+
interface FiscalReceipt {
|
|
173
|
+
operatorNumber: number;
|
|
174
|
+
operatorPassword: string;
|
|
175
|
+
uniqueSaleNumber?: string;
|
|
176
|
+
items: FiscalReceiptItem[];
|
|
177
|
+
payments: FiscalPayment[];
|
|
178
|
+
client?: FiscalClient;
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### FiscalReceiptItem
|
|
183
|
+
|
|
184
|
+
```typescript
|
|
185
|
+
interface FiscalReceiptItem {
|
|
186
|
+
name: string;
|
|
187
|
+
price: number;
|
|
188
|
+
quantity: number;
|
|
189
|
+
vatGroup: string;
|
|
190
|
+
discount?: number;
|
|
191
|
+
}
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### FiscalPayment
|
|
195
|
+
|
|
196
|
+
```typescript
|
|
197
|
+
interface FiscalPayment {
|
|
198
|
+
type: FiscalPaymentType;
|
|
199
|
+
amount: number;
|
|
200
|
+
}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### FiscalPaymentType
|
|
204
|
+
|
|
205
|
+
```typescript
|
|
206
|
+
enum FiscalPaymentType {
|
|
207
|
+
CASH = 'cash',
|
|
208
|
+
CARD = 'card',
|
|
209
|
+
CHECK = 'check',
|
|
210
|
+
TRANSFER = 'transfer'
|
|
211
|
+
}
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### FiscalClient
|
|
215
|
+
|
|
216
|
+
```typescript
|
|
217
|
+
interface FiscalClient {
|
|
218
|
+
name: string;
|
|
219
|
+
address?: string;
|
|
220
|
+
taxNumber?: string;
|
|
221
|
+
vatNumber?: string;
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### FiscalMemoryRecord
|
|
226
|
+
|
|
227
|
+
```typescript
|
|
228
|
+
interface FiscalMemoryRecord {
|
|
229
|
+
number: string;
|
|
230
|
+
date: Date;
|
|
231
|
+
total: number;
|
|
232
|
+
}
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### FiscalDeviceStatus
|
|
236
|
+
|
|
237
|
+
```typescript
|
|
238
|
+
interface FiscalDeviceStatus {
|
|
239
|
+
connected: boolean;
|
|
240
|
+
hasPaper: boolean;
|
|
241
|
+
fiscalMemoryFull: boolean;
|
|
242
|
+
errorCode?: number;
|
|
243
|
+
errorMessage?: string;
|
|
244
|
+
}
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
### EnvironmentEnum
|
|
248
|
+
|
|
249
|
+
```typescript
|
|
250
|
+
enum EnvironmentEnum {
|
|
251
|
+
LOCAL = 'local',
|
|
252
|
+
STAGING = 'staging',
|
|
253
|
+
PRODUCTION = 'production'
|
|
254
|
+
}
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
## License
|
|
258
|
+
|
|
259
|
+
Proprietary - Reservation.Studio
|
|
@@ -4,6 +4,14 @@ export declare enum IpcActions {
|
|
|
4
4
|
XML_SIGN = "xml:sign",
|
|
5
5
|
GET_VERSION = "get-version",
|
|
6
6
|
RELOAD_WINDOW = "reload-window",
|
|
7
|
+
ENVIRONMENT = "environment:get",
|
|
7
8
|
HTTP_GET = "http:get",
|
|
8
|
-
HTTP_POST = "http:post"
|
|
9
|
+
HTTP_POST = "http:post",
|
|
10
|
+
FISCAL_LIST = "fiscal:list",
|
|
11
|
+
FISCAL_SET_ACTIVE = "fiscal:set-active",
|
|
12
|
+
FISCAL_GET_ACTIVE = "fiscal:get-active",
|
|
13
|
+
FISCAL_PRINT_RECEIPT = "fiscal:print-receipt",
|
|
14
|
+
FISCAL_PRINT_TEXT = "fiscal:print-text",
|
|
15
|
+
FISCAL_GET_LAST_RECORD = "fiscal:get-last-record",
|
|
16
|
+
FISCAL_GET_STATUS = "fiscal:get-status"
|
|
9
17
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enumeration representing different application environments.
|
|
3
|
+
*
|
|
4
|
+
* This enum is used to specify and manage various environments in which
|
|
5
|
+
* the application might run, such as local development, staging, and
|
|
6
|
+
* production environments.
|
|
7
|
+
*
|
|
8
|
+
* Members:
|
|
9
|
+
* - LOCAL: Represents the local development environment.
|
|
10
|
+
* - STAGING: Represents the staging environment.
|
|
11
|
+
* - PRODUCTION: Represents the production environment.
|
|
12
|
+
*/
|
|
13
|
+
export declare enum EnvironmentEnum {
|
|
14
|
+
LOCAL = "local",
|
|
15
|
+
STAGING = "staging",
|
|
16
|
+
PRODUCTION = "production"
|
|
17
|
+
}
|
|
@@ -1,37 +1,62 @@
|
|
|
1
1
|
import { CertificateInfo } from './certificate-info.interface';
|
|
2
2
|
import { HttpOptions, HttpResponse } from './http.interface';
|
|
3
|
+
import { EnvironmentEnum } from '../enums/envirovment.enum';
|
|
4
|
+
import { FiscalDeviceStatus, FiscalMemoryRecord, FiscalReceipt } from './fiscal-device.interface';
|
|
3
5
|
export interface ApiInterface {
|
|
4
6
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* @property {Function} list Retrieves a list of certificates.
|
|
8
|
-
* @returns {Promise<CertificateInfo[]>} A promise that resolves with an array of `CertificateInfo` objects containing details about each certificate.
|
|
7
|
+
* An object representing operations related to certificates.
|
|
9
8
|
*/
|
|
10
9
|
certificates: {
|
|
10
|
+
/**
|
|
11
|
+
* Retrieves a list of certificate information.
|
|
12
|
+
*
|
|
13
|
+
* @return {Promise<CertificateInfo[]>} A promise that resolves to an array of CertificateInfo objects.
|
|
14
|
+
*/
|
|
11
15
|
list(): Promise<CertificateInfo[]>;
|
|
16
|
+
/**
|
|
17
|
+
* Validates a PIN against a specific slot.
|
|
18
|
+
*
|
|
19
|
+
* @param {number} slot - The numerical identifier of the slot to validate the PIN against.
|
|
20
|
+
* @param {string} pin - The PIN to be validated.
|
|
21
|
+
* @return {Promise<boolean>} A promise that resolves to true if the PIN is valid, otherwise false.
|
|
22
|
+
*/
|
|
12
23
|
isValidPin(slot: number, pin: string): Promise<boolean>;
|
|
13
24
|
};
|
|
14
25
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* @property {function} sign - A function to sign an XML string using a specified slot and PIN.
|
|
18
|
-
* @param {string} xml - The XML string to be signed.
|
|
19
|
-
* @param {number} slot - The slot number to be used for signing.
|
|
20
|
-
* @param {string} pin - The PIN associated with the slot for authentication.
|
|
21
|
-
* @returns {Promise<string>} A promise that resolves to the signed XML string.
|
|
26
|
+
* Object representing XML-related operations.
|
|
22
27
|
*/
|
|
23
28
|
xml: {
|
|
29
|
+
/**
|
|
30
|
+
* Signs the provided XML data using the specified cryptographic token slot and PIN.
|
|
31
|
+
*
|
|
32
|
+
* @param {string} xml - The XML string to be digitally signed.
|
|
33
|
+
* @param {number} slot - The slot number of the cryptographic token to be used for signing.
|
|
34
|
+
* @param {string} pin - The personal identification number (PIN) for accessing the cryptographic token.
|
|
35
|
+
* @return {Promise<string>} - A promise that resolves to the signed XML string.
|
|
36
|
+
*/
|
|
24
37
|
sign(xml: string, slot: number, pin: string): Promise<string>;
|
|
25
38
|
};
|
|
26
39
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* @property {function} post - Sends an HTTP POST request to the specified URL with the provided data and optional configurations.
|
|
31
|
-
* @property {function} get - Sends an HTTP GET request to the specified URL with optional configurations.
|
|
40
|
+
* A utility object for making HTTP requests, providing methods for sending GET and POST requests.
|
|
41
|
+
* Supports configuration options such as headers, query parameters, and response handling.
|
|
32
42
|
*/
|
|
33
43
|
http: {
|
|
44
|
+
/**
|
|
45
|
+
* Sends an HTTP POST request to the specified URL with the provided data and options.
|
|
46
|
+
*
|
|
47
|
+
* @param {string} url - The URL to which the POST request is sent.
|
|
48
|
+
* @param {any} data - The payload to be sent in the body of the POST request.
|
|
49
|
+
* @param {HttpOptions} [options] - Optional configuration for the HTTP request, such as headers and parameters.
|
|
50
|
+
* @return {Promise<HttpResponse>} A promise that resolves to the HTTP response object containing status, headers, and data.
|
|
51
|
+
*/
|
|
34
52
|
post(url: string, data: any, options?: HttpOptions): Promise<HttpResponse>;
|
|
53
|
+
/**
|
|
54
|
+
* Sends an HTTP GET request to the specified URL with optional configuration settings.
|
|
55
|
+
*
|
|
56
|
+
* @param {string} url - The target URL to which the GET request will be sent.
|
|
57
|
+
* @param {HttpOptions} [options] - Optional settings to configure the HTTP request, such as headers, query parameters, and other request options.
|
|
58
|
+
* @return {Promise<HttpResponse>} A promise that resolves to the HTTP response containing the status, headers, and data of the response.
|
|
59
|
+
*/
|
|
35
60
|
get(url: string, options?: HttpOptions): Promise<HttpResponse>;
|
|
36
61
|
};
|
|
37
62
|
/**
|
|
@@ -48,4 +73,70 @@ export interface ApiInterface {
|
|
|
48
73
|
* @return {Promise<void>} A promise that resolves when the reload operation is complete.
|
|
49
74
|
*/
|
|
50
75
|
reload(): Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* Retrieves the current application environment.
|
|
78
|
+
*
|
|
79
|
+
* @return {Promise<EnvironmentEnum>} A promise that resolves to the enumeration representing the current environment.
|
|
80
|
+
*/
|
|
81
|
+
environment(): Promise<EnvironmentEnum>;
|
|
82
|
+
/**
|
|
83
|
+
* An object representing operations related to fiscal devices.
|
|
84
|
+
* All methods automatically initialize fiscal devices when needed.
|
|
85
|
+
*/
|
|
86
|
+
fiscalDevices: {
|
|
87
|
+
/**
|
|
88
|
+
* Gets a list of all detected fiscal devices.
|
|
89
|
+
* Automatically initializes fiscal devices if needed.
|
|
90
|
+
*
|
|
91
|
+
* @return {Promise<Array<{manufacturer: string, model: string, serialNumber: string}>>} A promise that resolves to an array of fiscal device information.
|
|
92
|
+
*/
|
|
93
|
+
list(): Promise<Array<{
|
|
94
|
+
manufacturer: string;
|
|
95
|
+
model: string;
|
|
96
|
+
serialNumber: string;
|
|
97
|
+
}>>;
|
|
98
|
+
/**
|
|
99
|
+
* Sets the active fiscal device.
|
|
100
|
+
*
|
|
101
|
+
* @param {string} serialNumber - The serial number of the device to set as active.
|
|
102
|
+
* @return {Promise<boolean>} A promise that resolves to true if the device was found and set as active.
|
|
103
|
+
*/
|
|
104
|
+
setActiveDevice(serialNumber: string): Promise<boolean>;
|
|
105
|
+
/**
|
|
106
|
+
* Gets the active fiscal device.
|
|
107
|
+
*
|
|
108
|
+
* @return {Promise<{manufacturer: string, model: string, serialNumber: string} | null>} A promise that resolves to the active fiscal device information or null if no device is active.
|
|
109
|
+
*/
|
|
110
|
+
getActiveDevice(): Promise<{
|
|
111
|
+
manufacturer: string;
|
|
112
|
+
model: string;
|
|
113
|
+
serialNumber: string;
|
|
114
|
+
} | null>;
|
|
115
|
+
/**
|
|
116
|
+
* Prints a fiscal receipt using the active device.
|
|
117
|
+
*
|
|
118
|
+
* @param {FiscalReceipt} receipt - The receipt to print.
|
|
119
|
+
* @return {Promise<string>} A promise that resolves to the receipt number.
|
|
120
|
+
*/
|
|
121
|
+
printReceipt(receipt: FiscalReceipt): Promise<string>;
|
|
122
|
+
/**
|
|
123
|
+
* Prints a non-fiscal text using the active device.
|
|
124
|
+
*
|
|
125
|
+
* @param {string} text - The text to print.
|
|
126
|
+
* @return {Promise<boolean>} A promise that resolves to true if printing was successful.
|
|
127
|
+
*/
|
|
128
|
+
printText(text: string): Promise<boolean>;
|
|
129
|
+
/**
|
|
130
|
+
* Gets the last fiscal memory record from the active device.
|
|
131
|
+
*
|
|
132
|
+
* @return {Promise<FiscalMemoryRecord>} A promise that resolves to the last fiscal memory record.
|
|
133
|
+
*/
|
|
134
|
+
getLastFiscalRecord(): Promise<FiscalMemoryRecord>;
|
|
135
|
+
/**
|
|
136
|
+
* Gets the status of the active device.
|
|
137
|
+
*
|
|
138
|
+
* @return {Promise<FiscalDeviceStatus>} A promise that resolves to the status of the active device.
|
|
139
|
+
*/
|
|
140
|
+
getStatus(): Promise<FiscalDeviceStatus>;
|
|
141
|
+
};
|
|
51
142
|
}
|
|
@@ -1,4 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents information about a certificate that includes the slot number and name.
|
|
3
|
+
*/
|
|
1
4
|
export interface CertificateInfo {
|
|
5
|
+
/**
|
|
6
|
+
* The slot number associated with the certificate.
|
|
7
|
+
*/
|
|
2
8
|
slot: number;
|
|
9
|
+
/**
|
|
10
|
+
* The name of the certificate.
|
|
11
|
+
*/
|
|
3
12
|
name: string;
|
|
13
|
+
/**
|
|
14
|
+
* The serial number of the certificate.
|
|
15
|
+
*/
|
|
16
|
+
serialNumber: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Interface representing a certificate-based authentication structure.
|
|
20
|
+
*/
|
|
21
|
+
export interface CertificateAuth {
|
|
22
|
+
/**
|
|
23
|
+
* Represents the serial number of an item.
|
|
24
|
+
*/
|
|
25
|
+
serialNumber: string;
|
|
26
|
+
/**
|
|
27
|
+
* Personal identification code.
|
|
28
|
+
*/
|
|
29
|
+
pin: string;
|
|
4
30
|
}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface for fiscal device operations
|
|
3
|
+
*/
|
|
4
|
+
export interface FiscalDeviceInterface {
|
|
5
|
+
/**
|
|
6
|
+
* The model name of the fiscal device
|
|
7
|
+
*/
|
|
8
|
+
readonly model: string;
|
|
9
|
+
/**
|
|
10
|
+
* The manufacturer of the fiscal device
|
|
11
|
+
*/
|
|
12
|
+
readonly manufacturer: string;
|
|
13
|
+
/**
|
|
14
|
+
* The serial number of the fiscal device
|
|
15
|
+
*/
|
|
16
|
+
readonly serialNumber: string;
|
|
17
|
+
/**
|
|
18
|
+
* The port path of the fiscal device
|
|
19
|
+
*/
|
|
20
|
+
readonly port: string;
|
|
21
|
+
/**
|
|
22
|
+
* Initializes the fiscal device
|
|
23
|
+
*
|
|
24
|
+
* @returns {Promise<boolean>} A promise that resolves to true if initialization was successful
|
|
25
|
+
*/
|
|
26
|
+
initialize(): Promise<boolean>;
|
|
27
|
+
/**
|
|
28
|
+
* Checks if the device is connected and responsive
|
|
29
|
+
*
|
|
30
|
+
* @returns {Promise<boolean>} A promise that resolves to true if the device is connected
|
|
31
|
+
*/
|
|
32
|
+
isConnected(): Promise<boolean>;
|
|
33
|
+
/**
|
|
34
|
+
* Prints a fiscal receipt
|
|
35
|
+
*
|
|
36
|
+
* @param {FiscalReceipt} receipt - The receipt to print
|
|
37
|
+
* @returns {Promise<string>} A promise that resolves to the receipt number
|
|
38
|
+
*/
|
|
39
|
+
printReceipt(receipt: FiscalReceipt): Promise<string>;
|
|
40
|
+
/**
|
|
41
|
+
* Prints a non-fiscal text
|
|
42
|
+
*
|
|
43
|
+
* @param {string} text - The text to print
|
|
44
|
+
* @returns {Promise<boolean>} A promise that resolves to true if printing was successful
|
|
45
|
+
*/
|
|
46
|
+
printText(text: string): Promise<boolean>;
|
|
47
|
+
/**
|
|
48
|
+
* Gets the last fiscal memory record
|
|
49
|
+
*
|
|
50
|
+
* @returns {Promise<FiscalMemoryRecord>} A promise that resolves to the last fiscal memory record
|
|
51
|
+
*/
|
|
52
|
+
getLastFiscalRecord(): Promise<FiscalMemoryRecord>;
|
|
53
|
+
/**
|
|
54
|
+
* Gets the status of the fiscal device
|
|
55
|
+
*
|
|
56
|
+
* @returns {Promise<FiscalDeviceStatus>} A promise that resolves to the status of the fiscal device
|
|
57
|
+
*/
|
|
58
|
+
getStatus(): Promise<FiscalDeviceStatus>;
|
|
59
|
+
/**
|
|
60
|
+
* Closes the connection to the fiscal device
|
|
61
|
+
*
|
|
62
|
+
* @returns {Promise<boolean>} A promise that resolves to true if closing was successful
|
|
63
|
+
*/
|
|
64
|
+
close(): Promise<boolean>;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Interface for fiscal receipt
|
|
68
|
+
*/
|
|
69
|
+
export interface FiscalReceipt {
|
|
70
|
+
/**
|
|
71
|
+
* The operator number
|
|
72
|
+
*/
|
|
73
|
+
operatorNumber: number;
|
|
74
|
+
/**
|
|
75
|
+
* The operator password
|
|
76
|
+
*/
|
|
77
|
+
operatorPassword: string;
|
|
78
|
+
/**
|
|
79
|
+
* The unique sale number
|
|
80
|
+
*/
|
|
81
|
+
uniqueSaleNumber?: string;
|
|
82
|
+
/**
|
|
83
|
+
* The items in the receipt
|
|
84
|
+
*/
|
|
85
|
+
items: FiscalReceiptItem[];
|
|
86
|
+
/**
|
|
87
|
+
* The payments in the receipt
|
|
88
|
+
*/
|
|
89
|
+
payments: FiscalPayment[];
|
|
90
|
+
/**
|
|
91
|
+
* The client information (for invoice receipts)
|
|
92
|
+
*/
|
|
93
|
+
client?: FiscalClient;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Interface for fiscal receipt item
|
|
97
|
+
*/
|
|
98
|
+
export interface FiscalReceiptItem {
|
|
99
|
+
/**
|
|
100
|
+
* The name of the item
|
|
101
|
+
*/
|
|
102
|
+
name: string;
|
|
103
|
+
/**
|
|
104
|
+
* The price of the item
|
|
105
|
+
*/
|
|
106
|
+
price: number;
|
|
107
|
+
/**
|
|
108
|
+
* The quantity of the item
|
|
109
|
+
*/
|
|
110
|
+
quantity: number;
|
|
111
|
+
/**
|
|
112
|
+
* The VAT group of the item
|
|
113
|
+
*/
|
|
114
|
+
vatGroup: string;
|
|
115
|
+
/**
|
|
116
|
+
* The discount percentage (optional)
|
|
117
|
+
*/
|
|
118
|
+
discount?: number;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Interface for fiscal payment
|
|
122
|
+
*/
|
|
123
|
+
export interface FiscalPayment {
|
|
124
|
+
/**
|
|
125
|
+
* The payment type
|
|
126
|
+
*/
|
|
127
|
+
type: FiscalPaymentType;
|
|
128
|
+
/**
|
|
129
|
+
* The amount of the payment
|
|
130
|
+
*/
|
|
131
|
+
amount: number;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Enum for fiscal payment types
|
|
135
|
+
*/
|
|
136
|
+
export declare enum FiscalPaymentType {
|
|
137
|
+
CASH = "cash",
|
|
138
|
+
CARD = "card",
|
|
139
|
+
CHECK = "check",
|
|
140
|
+
TRANSFER = "transfer"
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Interface for fiscal client information
|
|
144
|
+
*/
|
|
145
|
+
export interface FiscalClient {
|
|
146
|
+
/**
|
|
147
|
+
* The name of the client
|
|
148
|
+
*/
|
|
149
|
+
name: string;
|
|
150
|
+
/**
|
|
151
|
+
* The address of the client
|
|
152
|
+
*/
|
|
153
|
+
address?: string;
|
|
154
|
+
/**
|
|
155
|
+
* The tax number of the client
|
|
156
|
+
*/
|
|
157
|
+
taxNumber?: string;
|
|
158
|
+
/**
|
|
159
|
+
* The VAT number of the client
|
|
160
|
+
*/
|
|
161
|
+
vatNumber?: string;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Interface for fiscal memory record
|
|
165
|
+
*/
|
|
166
|
+
export interface FiscalMemoryRecord {
|
|
167
|
+
/**
|
|
168
|
+
* The number of the record
|
|
169
|
+
*/
|
|
170
|
+
number: string;
|
|
171
|
+
/**
|
|
172
|
+
* The date of the record
|
|
173
|
+
*/
|
|
174
|
+
date: Date;
|
|
175
|
+
/**
|
|
176
|
+
* The total amount of the record
|
|
177
|
+
*/
|
|
178
|
+
total: number;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Interface for fiscal device status
|
|
182
|
+
*/
|
|
183
|
+
export interface FiscalDeviceStatus {
|
|
184
|
+
/**
|
|
185
|
+
* Whether the device is connected
|
|
186
|
+
*/
|
|
187
|
+
connected: boolean;
|
|
188
|
+
/**
|
|
189
|
+
* Whether the device has paper
|
|
190
|
+
*/
|
|
191
|
+
hasPaper: boolean;
|
|
192
|
+
/**
|
|
193
|
+
* Whether the fiscal memory is full
|
|
194
|
+
*/
|
|
195
|
+
fiscalMemoryFull: boolean;
|
|
196
|
+
/**
|
|
197
|
+
* The error code if any
|
|
198
|
+
*/
|
|
199
|
+
errorCode?: number;
|
|
200
|
+
/**
|
|
201
|
+
* The error message if any
|
|
202
|
+
*/
|
|
203
|
+
errorMessage?: string;
|
|
204
|
+
}
|
|
@@ -1,11 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface representing an HTTP response.
|
|
3
|
+
*/
|
|
1
4
|
export interface HttpResponse {
|
|
5
|
+
/**
|
|
6
|
+
* The HTTP status code of the response.
|
|
7
|
+
*/
|
|
2
8
|
status: number;
|
|
9
|
+
/**
|
|
10
|
+
* The headers returned in the HTTP response as key-value pairs.
|
|
11
|
+
*/
|
|
3
12
|
headers: Record<string, string>;
|
|
13
|
+
/**
|
|
14
|
+
* The response data, which can be any type depending on the request.
|
|
15
|
+
*/
|
|
4
16
|
data: any;
|
|
17
|
+
/**
|
|
18
|
+
* Flag indicating whether an error occurred during the HTTP request.
|
|
19
|
+
*/
|
|
5
20
|
error: boolean;
|
|
6
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Interface representing options for an HTTP request.
|
|
24
|
+
*/
|
|
7
25
|
export interface HttpOptions {
|
|
26
|
+
/**
|
|
27
|
+
* Optional headers to include in the HTTP request, represented as key-value pairs.
|
|
28
|
+
*/
|
|
8
29
|
headers?: Record<string, string>;
|
|
30
|
+
/**
|
|
31
|
+
* Optional timeout for the HTTP request, specified in milliseconds.
|
|
32
|
+
*/
|
|
9
33
|
timeout?: number;
|
|
34
|
+
/**
|
|
35
|
+
* Optional query parameters to include in the HTTP request, represented as key-value pairs.
|
|
36
|
+
*/
|
|
10
37
|
params?: Record<string, string>;
|
|
11
38
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reservation-studio/electron-types",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"description": "TypeScript типове за ReservationStudioElectron",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "tsc",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
"author": "Venelin Iliev",
|
|
17
17
|
"license": "Proprietary - Reservation.Studio",
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"
|
|
20
|
-
"
|
|
19
|
+
"@types/node": "^22.16.0",
|
|
20
|
+
"typescript": "^5.2.0"
|
|
21
21
|
},
|
|
22
22
|
"files": [
|
|
23
23
|
"dist"
|
package/README.md
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
# @reservation-studio/electron-types
|