@reservation-studio/electron-types
Version:
TypeScript типове за ReservationStudioElectron
266 lines (202 loc) • 5.07 kB
Markdown
# @reservation-studio/electron-types
TypeScript type definitions for the Reservation.Studio Electron application.
## Installation
```bash
npm install @reservation-studio/electron-types
```
## Overview
This package provides TypeScript type definitions for the Reservation.Studio Electron application. It includes interfaces and enums for working with:
- Certificate management
- XML signing
- HTTP requests
- Fiscal device operations
- Application environment and version information
## API Reference
### ReservationStudioElectron
The main API object exposed by the Electron application. It's available in the renderer process as `window.ReservationStudioElectron`.
```typescript
import { ReservationStudioElectron } from '@reservation-studio/electron-types';
// Example usage
const version = await ReservationStudioElectron.version();
```
### Certificates
Methods for working with certificates:
```typescript
// List all available certificates
const certificates = await ReservationStudioElectron.certificates.list();
// Validate a certificate PIN
const isValid = await ReservationStudioElectron.certificates.isValidPin(
slot,
pin
);
```
### XML Signing
Methods for signing XML documents:
```typescript
// Sign an XML document
const signedXml = await ReservationStudioElectron.xml.sign(xml, slot, pin);
```
### HTTP Requests
Methods for making HTTP requests:
```typescript
// Make a GET request
const response = await ReservationStudioElectron.http.get(url, {
headers: { 'Content-Type': 'application/json' },
timeout: 5000,
params: { key: 'value' }
});
// Make a POST request
const response = await ReservationStudioElectron.http.post(url, data, {
headers: { 'Content-Type': 'application/json' }
});
```
### Application Information
Methods for getting application information:
```typescript
// Get application version
const version = await ReservationStudioElectron.version();
// Get application environment
const environment = await ReservationStudioElectron.environment();
// Reload the application window
await ReservationStudioElectron.reload();
```
### Fiscal Devices
Methods for working with fiscal devices:
```typescript
// List all available fiscal devices
const devices = await ReservationStudioElectron.fiscalDevices.list();
// Set the active fiscal device
await ReservationStudioElectron.fiscalDevices.setActiveDevice(serialNumber);
// Get the active fiscal device
const activeDevice =
await ReservationStudioElectron.fiscalDevices.getActiveDevice();
// Print a fiscal receipt
const receiptNumber =
await ReservationStudioElectron.fiscalDevices.printReceipt({
operatorNumber: 1,
operatorPassword: '1',
items: [
{
name: 'Product 1',
price: 10.0,
quantity: 1,
vatGroup: 'A'
}
],
payments: [
{
type: 'cash',
amount: 10.0
}
]
});
// Print non-fiscal text
await ReservationStudioElectron.fiscalDevices.printText('Hello, World!');
// Get the last fiscal memory record
const lastRecord =
await ReservationStudioElectron.fiscalDevices.getLastFiscalRecord();
// Get the fiscal device status
const status = await ReservationStudioElectron.fiscalDevices.getStatus();
```
## Interfaces
### ApiInterface
The main interface that defines the structure of the ReservationStudioElectron object.
### CertificateInfo
```typescript
interface CertificateInfo {
slot: number;
name: string;
serialNumber: string;
}
```
### HttpResponse
```typescript
interface HttpResponse {
status: number;
headers: Record<string, string>;
data: any;
error: boolean;
}
```
### HttpOptions
```typescript
interface HttpOptions {
headers?: Record<string, string>;
timeout?: number;
params?: Record<string, string>;
}
```
### FiscalReceipt
```typescript
interface FiscalReceipt {
operatorNumber: number;
operatorPassword: string;
uniqueSaleNumber?: string;
items: FiscalReceiptItem[];
payments: FiscalPayment[];
client?: FiscalClient;
}
```
### FiscalReceiptItem
```typescript
interface FiscalReceiptItem {
name: string;
price: number;
quantity: number;
vatGroup: string;
discount?: number;
}
```
### FiscalPayment
```typescript
interface FiscalPayment {
type: FiscalPaymentType;
amount: number;
}
```
### FiscalPaymentType
```typescript
enum FiscalPaymentType {
CASH = 'cash',
CARD = 'card',
CHECK = 'check',
TRANSFER = 'transfer'
}
```
### FiscalClient
```typescript
interface FiscalClient {
name: string;
address?: string;
taxNumber?: string;
vatNumber?: string;
}
```
### FiscalMemoryRecord
```typescript
interface FiscalMemoryRecord {
number: string;
date: Date;
total: number;
}
```
### FiscalDeviceStatus
```typescript
interface FiscalDeviceStatus {
connected: boolean;
hasPaper: boolean;
fiscalMemoryFull: boolean;
errorCode?: number;
errorMessage?: string;
}
```
### EnvironmentEnum
```typescript
enum EnvironmentEnum {
LOCAL = 'local',
STAGING = 'staging',
PRODUCTION = 'production'
}
```
## License
Proprietary - Reservation.Studio