@posx/core 5.5.393 → 5.5.396
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/build/index.d.ts +9 -0
- package/build/index.js +1 -1
- package/dev/escpos/receipt.bin +0 -0
- package/dev/escpos/receipt.hex +1 -0
- package/dev/escpos/receipt.json +1 -0
- package/dev/escpos-cli-usage.md +103 -0
- package/dev/px-cli.md +99 -0
- package/dev/tmp/xpos_product_import(1).csv +338 -0
- package/dev/tmp/xpos_product_import_fixed.csv +338 -0
- package/package.json +1 -1
- package/package.publish.json +3 -2
- package/px/.env.example +3 -0
- package/px/commands/category.ts +47 -0
- package/px/commands/product.ts +51 -0
- package/px/http.ts +40 -0
- package/px/index.ts +35 -0
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
1B401B45001B34001B2D000A1B45011B61011D2111204861707079205468616920466F6F64202D20566963746F727920380A1D21001B45001B34001B2D000A1B45011B610138204A616C616E204C6567756E6469202330312D313020566963746F727920380A1B45001B34001B2D000A1B45011B610154656C3A2036373134363638320A1B45001B34001B2D000A1B45011B610044696E652D496E0A1B45001B34001B2D000A1B45011B6100232030313236303231303030303030313437320A1B45001B34001B2D000A1B45011B61001D21115461626C653A31350A1D21001B45001B34001B2D000A1B45011B61001D21114F52444552204E4F2E3A203437320A1D21001B45001B34001B2D000A1B45011B61005365727665642042793A61646D696E0A1B45001B34001B2D000A1B45011B6100446174653A323032362D4665622D31302031333A34313A35340A1B45001B34001B2D000A1B45001B34001B2D002D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D0A1B45014954454D20202020202020202020202020202020202020202020202051545920202020414D542020202020202020200A1B45001B34001B2D002D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D0A1B45011B61004D332E204761726C696320467269656420506F726B20202020202020783120202020202431332E39302020202020200A1B45011B61005445352E20436869636B656E204F6D656C65747465202020202020207831202020202024372E3930202020202020200A1B45011B61004E44322E20506861642073656520457720284B7761792054202020207831202020202024392E3930202020202020200A656F772920536561666F6F6420202020202020202020202020202020202020202020202020202020202020202020200A1B45011B610041342E205468616920507261776E2043616B65202834205020202020783120202020202431332E39302020202020200A69656365732920202020202020202020202020202020202020202020202020202020202020202020202020202020200A1B45011B6100445231312E2054686169204D696C6B205465612020202020202020207831202020202024342E3530202020202020200A1B45011B61004452372E204C656D6F6E6772617373204472696E6B202020202020207831202020202024332E3930202020202020200A1B45001B34001B2D001B61002D2020436F6C642020202020202020202020202020202020202020207B7B7D7D2020202020202020202020202020200A1B45001B34001B2D000A1B45001B34001B2D002D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D0A1B45011B6100535542544F54414C202020202020202020202020202020202020202020202020202020202435342E30302020202020200A1B450131302520534552564943452043484152474520202020202020202020202020202020202024352E3430202020202020200A1B4501544F54414C202020202020202020202020202020202020202020202020202020202020202435392E34302020202020200A1B45001B34001B2D002D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D0A1B45015041594D454E542042593A466975752020202020202020202020202020202020202020202435392E34302020202020200A1B45001B34001B2D002D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D0A1B45015041594D454E5420545950452020202020202020202020204D41535445524341524420202020202020202020202020200A1B45015245462020202020202020202020202020202020202020203334383732363039343320202020202020202020202020200A1B450143415244204E554D202020202020202020202020202020202A2A2A2A202A2A2A2A202A2A2A2A203130343020202020200A1B4501435553544F4D45522054454C2020202020202020202020202020202020202020202020202B36352A2A2A2A34383436200A1B450143617368204261636B20202020202020202020202020202020202020202020202020202024312E3738202020202020200A1B45014372656469742042616C616E63652020202020202020202020202020202020202020202024312E3738202020202020200A1B4501506F696E742042616C616E636520202020202020202020202020202020202020202020207074202020202020202020200A1B45001B34001B2D002D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D0A1B45011B610138204A616C616E204C6567756E6469202330312D313020566963746F727920380A1B45001B34001B2D000A0A0A0A0A1B45001B34001B2D000A1B45001B34001B2D000A1B45001B34001B2D000A1B45001B34001B2D001D5600
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"uid": "pjb_I8RJcR0Hm6iMsYSzmIDRd", "updated_at": "2026-02-10T05:41:54.209Z", "created_at": "2026-02-10T05:41:54.356Z", "created_at_timestamp": 1770702114356, "deleted_at": null, "name_translations": {}, "printer_name": "Receipt Printer", "driver_printer_name": "Receipt Printer", "printer_ip": "0.0.0.0", "printer_uid": "prt_eJ5yITaByzBnAXSz1IvhF", "printer_type": "receipt_printer", "protocol": "ESC/POS", "connection_type": "WINDOWS_DRIVER", "data": {"codepage": "cp936", "items": [{"type": "newline", "repeat": 1}, {"type": "text", "align": "center", "style": "bold", "item": {"size": "custom", "width": 1, "height": 1, "text": " Happy Thai Food - Victory 8"}}, {"type": "newline", "repeat": 1}, {"type": "text", "align": "center", "style": "bold", "item": {"text": "8 Jalan Legundi #01-10 Victory 8"}}, {"type": "newline", "repeat": 1}, {"type": "text", "align": "center", "style": "bold", "item": {"text": "Tel: 67146682"}}, {"type": "newline", "repeat": 1}, {"type": "text", "align": "left", "style": "bold", "item": {"text": "Dine-In"}}, {"type": "newline", "repeat": 1}, {"type": "text", "align": "left", "style": "bold", "item": {"text": "# 01260210000001472"}}, {"type": "newline", "repeat": 1}, {"type": "text", "align": "left", "style": "bold", "item": {"size": "custom", "width": 1, "height": 1, "text": "Table:15"}}, {"type": "newline", "repeat": 1}, {"type": "text", "align": "left", "style": "bold", "item": {"size": "custom", "width": 1, "height": 1, "text": "ORDER NO.: 472"}}, {"type": "newline", "repeat": 1}, {"type": "text", "align": "left", "style": "bold", "item": {"text": "Served By:admin"}}, {"type": "newline", "repeat": 1}, {"type": "text", "align": "left", "style": "bold", "item": {"text": "Date:2026-Feb-10 13:41:54"}}, {"type": "newline", "repeat": 1}, {"type": "line"}, {"type": "table", "style": "bold", "table": {"items": [{"text": "ITEM", "column_width": 50}, {"text": "", "column_width": 10}, {"text": "QTY", "column_width": 15}, {"text": "AMT", "column_width": 25}]}}, {"type": "line"}, {"type": "table", "align": "left", "style": "bold", "table": {"items": [{"text": "M3. Garlic Fried Pork ", "column_width": 50}, {"text": "", "column_width": 10}, {"text": "x1", "column_width": 15}, {"text": "$13.90", "column_width": 25}]}}, {"type": "table", "align": "left", "style": "bold", "table": {"items": [{"text": "TE5. Chicken Omelette ", "column_width": 50}, {"text": "", "column_width": 10}, {"text": "x1", "column_width": 15}, {"text": "$7.90", "column_width": 25}]}}, {"type": "table", "align": "left", "style": "bold", "table": {"items": [{"text": "ND2. Phad see Ew (Kway Teow) Seafood ", "column_width": 50}, {"text": "", "column_width": 10}, {"text": "x1", "column_width": 15}, {"text": "$9.90", "column_width": 25}]}}, {"type": "table", "align": "left", "style": "bold", "table": {"items": [{"text": "A4. Thai Prawn Cake (4 Pieces) ", "column_width": 50}, {"text": "", "column_width": 10}, {"text": "x1", "column_width": 15}, {"text": "$13.90", "column_width": 25}]}}, {"type": "table", "align": "left", "style": "bold", "table": {"items": [{"text": "DR11. Thai Milk Tea ", "column_width": 50}, {"text": "", "column_width": 10}, {"text": "x1", "column_width": 15}, {"text": "$4.50", "column_width": 25}]}}, {"type": "table", "align": "left", "style": "bold", "table": {"items": [{"text": "DR7. Lemongrass Drink ", "column_width": 50}, {"text": "", "column_width": 10}, {"text": "x1", "column_width": 15}, {"text": "$3.90", "column_width": 25}]}}, {"type": "table", "align": "left", "table": {"items": [{"text": "- Cold ", "column_width": 50}, {"text": "", "column_width": 10}, {"text": "{{}}", "column_width": 15}, {"text": "", "column_width": 25}]}}, {"type": "newline", "repeat": 1}, {"type": "line"}, {"codepage": "cp437", "type": "table", "align": "left", "style": "bold", "table": {"items": [{"text": "SUBTOTAL", "column_width": 50}, {"text": "", "column_width": 25}, {"text": "$54.00", "column_width": 25}]}}, {"codepage": "cp437", "type": "table", "style": "bold", "table": {"items": [{"text": "10% SERVICE CHARGE", "column_width": 50}, {"text": "", "column_width": 25}, {"text": "$5.40", "column_width": 25}]}}, {"codepage": "cp437", "type": "table", "style": "bold", "size": "custom", "width": 1, "height": 1, "table": {"items": [{"text": "TOTAL", "column_width": 50}, {"text": "", "column_width": 25}, {"text": "$59.40", "column_width": 25}]}}, {"type": "line"}, {"codepage": "cp437", "type": "table", "style": "bold", "table": {"items": [{"text": "PAYMENT BY:Fiuu", "column_width": 50}, {"text": "", "column_width": 25}, {"text": "$59.40", "column_width": 25}]}}, {"type": "line"}, {"codepage": "cp437", "type": "table", "style": "bold", "table": {"items": [{"text": "PAYMENT TYPE", "column_width": 50}, {"text": "MASTERCARD", "column_width": 50}]}}, {"codepage": "cp437", "type": "table", "style": "bold", "table": {"items": [{"text": "REF", "column_width": 50}, {"text": "3487260943", "column_width": 50}]}}, {"codepage": "cp437", "type": "table", "style": "bold", "table": {"items": [{"text": "CARD NUM", "column_width": 50}, {"text": "**** **** **** 1040", "column_width": 50}]}}, {"type": "table", "style": "bold", "table": {"items": [{"text": "CUSTOMER TEL", "column_width": 50}, {"text": "", "column_width": 25}, {"text": "\u002B65****4846", "column_width": 25}]}}, {"type": "table", "style": "bold", "table": {"items": [{"text": "Cash Back", "column_width": 50}, {"text": "", "column_width": 25}, {"text": "$1.78", "column_width": 25}]}}, {"type": "table", "style": "bold", "table": {"items": [{"text": "Credit Balance", "column_width": 50}, {"text": "", "column_width": 25}, {"text": "$1.78", "column_width": 25}]}}, {"type": "table", "style": "bold", "table": {"items": [{"text": "Point Balance", "column_width": 50}, {"text": "", "column_width": 25}, {"text": "pt", "column_width": 25}]}}, {"type": "line"}, {"type": "text", "align": "center", "style": "bold", "item": {"text": "8 Jalan Legundi #01-10 Victory 8"}}, {"type": "newline", "repeat": 5}, {"type": "newline", "repeat": 1}, {"type": "newline", "repeat": 1}, {"type": "newline", "repeat": 1}, {"type": "cut"}]}, "status": "printed", "retries": 0, "commands": "", "save_only": false, "print_times": 1, "printed": 1, "device_uid_to_print": "", "designated_table_section_uids": [], "job_id": 0, "print_sequence": 0, "meta": {}, "id_in_server": 1044494, "_timestamp": 1770702115370025}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# ESC/POS CLI Tool Usage Manual
|
|
2
|
+
|
|
3
|
+
Generate ESC/POS byte files from print job JSON definitions.
|
|
4
|
+
|
|
5
|
+
## Files
|
|
6
|
+
|
|
7
|
+
- `scripts/generate-escpos-bytes.mjs` - ESC/POS byte generator with built-in encoder
|
|
8
|
+
- `scripts/example-print-job.json` - Example print job for testing
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm run escpos -- <input.json> <output.bin>
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Example
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm run escpos -- ./scripts/example-print-job.json ./receipt.bin
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Supported Features
|
|
23
|
+
|
|
24
|
+
| Feature | Description |
|
|
25
|
+
|---------|-------------|
|
|
26
|
+
| Text | With size, bold, italic, underline, alignment |
|
|
27
|
+
| Tables | With column widths and text wrapping |
|
|
28
|
+
| Lines | Separators |
|
|
29
|
+
| QR codes | Model, size, error level configurable |
|
|
30
|
+
| Barcodes | EAN13, UPC-A, UPC-E, EAN8, Code39, ITF, Codabar |
|
|
31
|
+
| Newlines | With repeat count |
|
|
32
|
+
| Cut | Full or partial |
|
|
33
|
+
| Beeper | Audible alert |
|
|
34
|
+
| Cash drawer | Open cash drawer command |
|
|
35
|
+
| VISCII codepage | Vietnamese support |
|
|
36
|
+
| Multiple codepages | cp437, cp850, cp936, etc. |
|
|
37
|
+
|
|
38
|
+
## Not Supported
|
|
39
|
+
|
|
40
|
+
- **Image printing** - Requires browser APIs, not available in CLI mode
|
|
41
|
+
|
|
42
|
+
## Print Job JSON Format
|
|
43
|
+
|
|
44
|
+
```json
|
|
45
|
+
{
|
|
46
|
+
"codepage": "cp936",
|
|
47
|
+
"items": [
|
|
48
|
+
{
|
|
49
|
+
"type": "text",
|
|
50
|
+
"align": "center",
|
|
51
|
+
"style": "bold",
|
|
52
|
+
"item": {
|
|
53
|
+
"text": "RECEIPT",
|
|
54
|
+
"size": "normal",
|
|
55
|
+
"line_width": 48
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"type": "table",
|
|
60
|
+
"table": {
|
|
61
|
+
"size": "normal",
|
|
62
|
+
"line_width": 48,
|
|
63
|
+
"items": [
|
|
64
|
+
{ "text": "Item", "column_width": 50 },
|
|
65
|
+
{ "text": "Qty", "column_width": 20 },
|
|
66
|
+
{ "text": "Price", "column_width": 30 }
|
|
67
|
+
]
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"type": "qrcode",
|
|
72
|
+
"align": "center",
|
|
73
|
+
"qrcode": {
|
|
74
|
+
"data": "https://example.com",
|
|
75
|
+
"model": 2,
|
|
76
|
+
"size": 6,
|
|
77
|
+
"errorlevel": "m"
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"type": "cut"
|
|
82
|
+
}
|
|
83
|
+
]
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Available Types
|
|
88
|
+
|
|
89
|
+
| Type | Properties |
|
|
90
|
+
|------|------------|
|
|
91
|
+
| `text` | `item.text`, `item.size`, `item.line_width`, `item.width`, `item.height` |
|
|
92
|
+
| `table` | `table.items[]`, `table.size`, `table.line_width` |
|
|
93
|
+
| `line` | `item.text` (character to repeat) |
|
|
94
|
+
| `newline` | `repeat` (number of lines) |
|
|
95
|
+
| `qrcode` | `qrcode.data`, `qrcode.model`, `qrcode.size`, `qrcode.errorlevel` |
|
|
96
|
+
| `barcode` | `barcode.data`, `barcode.symbology`, `barcode.height` |
|
|
97
|
+
| `cut` | `item.text` ("full" or "partial") |
|
|
98
|
+
| `beeper` | - |
|
|
99
|
+
| `open_cash_drawer` | - |
|
|
100
|
+
|
|
101
|
+
## Available Codepages
|
|
102
|
+
|
|
103
|
+
`cp437`, `cp850`, `cp860`, `cp863`, `cp865`, `cp857`, `cp737`, `cp866`, `cp862`, `cp864`, `cp874`, `cp936`, `cp949`, `cp950`, `shiftjis`, `windows1252`, `69` (VISCII)
|
package/dev/px-cli.md
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# px-cli
|
|
2
|
+
|
|
3
|
+
Bun CLI project to interact with server using x-api-key method
|
|
4
|
+
|
|
5
|
+
## Setup
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
cd px
|
|
9
|
+
bun install
|
|
10
|
+
cp .env.example .env # fill in PX_BASE_URL, PX_API_KEY, PX_MERCHANT_UID
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Structure
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
px/
|
|
17
|
+
├── package.json # bun project, depends on @posx/core
|
|
18
|
+
├── tsconfig.json
|
|
19
|
+
├── .env.example
|
|
20
|
+
├── index.ts # entry point & router (cac)
|
|
21
|
+
├── http.ts # HTTP client with x-api-key auth
|
|
22
|
+
├── .changes.json # staged CUD changes (auto-generated)
|
|
23
|
+
└── commands/
|
|
24
|
+
├── category.ts # Category CRUD (types: ICategory)
|
|
25
|
+
└── product.ts # Product CRUD (types: IItem)
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Dependencies
|
|
29
|
+
|
|
30
|
+
- `@posx/core` — import types only (no service layer — no Dexie/IndexedDB in Bun):
|
|
31
|
+
- `IServiceOptions` — config typing in `http.ts`
|
|
32
|
+
- `ICategory` — category request/response typing
|
|
33
|
+
- `IItem` — product request/response typing
|
|
34
|
+
- `@litepos/autoquery` — `QueryBuilder` for `list` action (autoquery via `sapi` endpoint)
|
|
35
|
+
- `cac` — lightweight CLI framework (arg parsing, help text, subcommands)
|
|
36
|
+
|
|
37
|
+
## Usage
|
|
38
|
+
|
|
39
|
+
### Read (immediate)
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
# List via autoquery (sapi)
|
|
43
|
+
px category list
|
|
44
|
+
px category list --nameContains Drinks --take 10
|
|
45
|
+
px product list
|
|
46
|
+
px product list --nameContains Latte --take 10
|
|
47
|
+
|
|
48
|
+
# Get by ID
|
|
49
|
+
px category get --id 123
|
|
50
|
+
px product get --id 456
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### CUD — two-step workflow (stage → commit)
|
|
54
|
+
|
|
55
|
+
CUD operations stage changes locally before applying to server.
|
|
56
|
+
|
|
57
|
+
**Step 1: Stage changes** — fetches latest data, displays diff, saves to `.changes.json`
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
# Add (shows new record fields)
|
|
61
|
+
px category add --name "Drinks" --type product --color "#ff0000" --icon "🍹"
|
|
62
|
+
|
|
63
|
+
# Update (fetches current record, shows old → new diff)
|
|
64
|
+
# Pattern: GET → merge changes → PATCH
|
|
65
|
+
px category update --id 123 --name "Beverages"
|
|
66
|
+
px product update --id 456 --price 6.00
|
|
67
|
+
|
|
68
|
+
# Delete (fetches current record, shows record to be removed)
|
|
69
|
+
px category delete --id 123
|
|
70
|
+
px product delete --id 456
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
**Step 2: Review & apply**
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
px status # show all staged changes
|
|
77
|
+
px commit # apply all staged changes to server
|
|
78
|
+
px reset # discard all staged changes
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## API
|
|
82
|
+
|
|
83
|
+
- **Base**: `https://lite-dev.posx.ai`
|
|
84
|
+
- **Auth**: `x-api-key` header
|
|
85
|
+
|
|
86
|
+
| Method | Route | Action |
|
|
87
|
+
|----------|-----------------------------------------------------|------------------|
|
|
88
|
+
| `GET` | `sapi/v5/merchants/{merchant_uid}/{module}` | list (autoquery) |
|
|
89
|
+
| `GET` | `api/v5/merchants/{merchant_uid}/{module}/{id}` | get |
|
|
90
|
+
| `PUT` | `api/v5/merchants/{merchant_uid}/{module}/{method}` | add |
|
|
91
|
+
| `PATCH` | `api/v5/merchants/{merchant_uid}/{module}/{id}` | update |
|
|
92
|
+
| `DELETE` | `api/v5/merchants/{merchant_uid}/{module}/{id}` | delete |
|
|
93
|
+
|
|
94
|
+
## Ref
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
curl -H "x-api-key: p8Hwl4A7ewynszODOOc05SJcqSP6YZDo2pevtZ" \
|
|
98
|
+
"https://lite-dev.posx.ai/api/v5/merchants/by-whatsapp-jid/6590992059@s.whatsapp.net"
|
|
99
|
+
```
|