labelinn 1.1.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.
- package/CHANGELOG.md +36 -0
- package/LICENSE +21 -0
- package/README.md +458 -0
- package/bin/cli.js +793 -0
- package/lib/index.d.ts +327 -0
- package/lib/index.js +556 -0
- package/package.json +61 -0
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript declarations for the LabelInn Node.js SDK
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
declare class LabelInn {
|
|
6
|
+
constructor(apiKey: string, opts?: LabelInn.ClientOptions);
|
|
7
|
+
|
|
8
|
+
readonly print: LabelInn.PrintResource;
|
|
9
|
+
readonly fleet: LabelInn.FleetResource;
|
|
10
|
+
readonly designs: LabelInn.DesignsResource;
|
|
11
|
+
readonly webhooks: LabelInn.WebhooksResource;
|
|
12
|
+
readonly isTestMode: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
declare namespace LabelInn {
|
|
16
|
+
interface ClientOptions {
|
|
17
|
+
baseUrl?: string;
|
|
18
|
+
timeout?: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// ── Rate Limit ──
|
|
22
|
+
|
|
23
|
+
interface RateLimitInfo {
|
|
24
|
+
limit: number;
|
|
25
|
+
remaining: number;
|
|
26
|
+
reset: number;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface ApiResponse {
|
|
30
|
+
_rateLimit?: RateLimitInfo;
|
|
31
|
+
_idempotent?: boolean;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// ── Print Jobs ──
|
|
35
|
+
|
|
36
|
+
interface CreateJobParams {
|
|
37
|
+
printer_id: string;
|
|
38
|
+
payload_type: 'zpl' | 'image' | 'template';
|
|
39
|
+
payload_data?: string;
|
|
40
|
+
image_url?: string;
|
|
41
|
+
design_id?: string;
|
|
42
|
+
data?: Record<string, string> | Record<string, string>[];
|
|
43
|
+
job_name?: string;
|
|
44
|
+
copies?: number;
|
|
45
|
+
media_width_mm?: number;
|
|
46
|
+
media_height_mm?: number;
|
|
47
|
+
priority?: 'low' | 'normal' | 'high' | 'urgent';
|
|
48
|
+
print_at?: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
interface CreateJobOpts {
|
|
52
|
+
idempotencyKey?: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
interface ListJobsQuery {
|
|
56
|
+
status?: 'queued' | 'processing' | 'completed' | 'failed' | 'cancelled';
|
|
57
|
+
printer_id?: string;
|
|
58
|
+
limit?: number;
|
|
59
|
+
page_token?: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
interface PrintJob extends ApiResponse {
|
|
63
|
+
id: string;
|
|
64
|
+
status: string;
|
|
65
|
+
printer_id: string;
|
|
66
|
+
payload_type: string;
|
|
67
|
+
job_name?: string;
|
|
68
|
+
copies: number;
|
|
69
|
+
priority?: string;
|
|
70
|
+
print_at?: string;
|
|
71
|
+
created_at: string;
|
|
72
|
+
updated_at: string;
|
|
73
|
+
completed_at?: string;
|
|
74
|
+
error_message?: string;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
interface PrintJobList extends ApiResponse {
|
|
78
|
+
jobs: PrintJob[];
|
|
79
|
+
next_page_token?: string;
|
|
80
|
+
total?: number;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
interface BatchResult extends ApiResponse {
|
|
84
|
+
jobs: PrintJob[];
|
|
85
|
+
errors?: Array<{ index: number; error: string }>;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
interface RetryParams {
|
|
89
|
+
printer_id?: string;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
class PrintResource {
|
|
93
|
+
create(params: CreateJobParams, opts?: CreateJobOpts): Promise<PrintJob>;
|
|
94
|
+
list(query?: ListJobsQuery): Promise<PrintJobList>;
|
|
95
|
+
get(jobId: string): Promise<PrintJob>;
|
|
96
|
+
cancel(jobId: string): Promise<ApiResponse>;
|
|
97
|
+
reprint(jobId: string, overrides?: Partial<CreateJobParams>): Promise<PrintJob>;
|
|
98
|
+
retry(jobId: string, params?: RetryParams): Promise<PrintJob>;
|
|
99
|
+
batch(jobs: CreateJobParams[]): Promise<BatchResult>;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// ── Fleet ──
|
|
103
|
+
|
|
104
|
+
interface Printer extends ApiResponse {
|
|
105
|
+
id: string;
|
|
106
|
+
name: string;
|
|
107
|
+
model?: string;
|
|
108
|
+
type?: string;
|
|
109
|
+
connection?: string;
|
|
110
|
+
status: string;
|
|
111
|
+
ip_address?: string;
|
|
112
|
+
serial_number?: string;
|
|
113
|
+
last_seen?: string;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
interface UpdatePrinterParams {
|
|
117
|
+
name?: string;
|
|
118
|
+
metadata?: Record<string, string>;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
interface MediaDefinitionParams {
|
|
122
|
+
width_mm: number;
|
|
123
|
+
height_mm: number;
|
|
124
|
+
media_type?: string;
|
|
125
|
+
gap_mm?: number;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
interface FleetGroup extends ApiResponse {
|
|
129
|
+
id: string;
|
|
130
|
+
name: string;
|
|
131
|
+
printer_ids?: string[];
|
|
132
|
+
metadata?: Record<string, string>;
|
|
133
|
+
created_at?: string;
|
|
134
|
+
updated_at?: string;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
interface FleetGroupList extends ApiResponse {
|
|
138
|
+
groups: FleetGroup[];
|
|
139
|
+
next_page_token?: string;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
interface CreateGroupParams {
|
|
143
|
+
name: string;
|
|
144
|
+
printer_ids?: string[];
|
|
145
|
+
metadata?: Record<string, string>;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
interface UpdateGroupParams {
|
|
149
|
+
name?: string;
|
|
150
|
+
printer_ids?: string[];
|
|
151
|
+
metadata?: Record<string, string>;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
interface PrinterList extends ApiResponse {
|
|
155
|
+
printers: Printer[];
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
interface PrinterStatus extends ApiResponse {
|
|
159
|
+
id: string;
|
|
160
|
+
status: string;
|
|
161
|
+
last_seen?: string;
|
|
162
|
+
paper_status?: string;
|
|
163
|
+
ribbon_status?: string;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
interface ListPrintersQuery {
|
|
167
|
+
status?: string;
|
|
168
|
+
type?: string;
|
|
169
|
+
connection?: string;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
class FleetGroupsResource {
|
|
173
|
+
create(params: CreateGroupParams): Promise<FleetGroup>;
|
|
174
|
+
list(query?: Record<string, string>): Promise<FleetGroupList>;
|
|
175
|
+
get(groupId: string): Promise<FleetGroup>;
|
|
176
|
+
update(groupId: string, params: UpdateGroupParams): Promise<FleetGroup>;
|
|
177
|
+
delete(groupId: string): Promise<ApiResponse>;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
class FleetResource {
|
|
181
|
+
readonly groups: FleetGroupsResource;
|
|
182
|
+
list(query?: ListPrintersQuery): Promise<PrinterList>;
|
|
183
|
+
get(printerId: string): Promise<Printer>;
|
|
184
|
+
status(printerId: string): Promise<PrinterStatus>;
|
|
185
|
+
update(printerId: string, params: UpdatePrinterParams): Promise<Printer>;
|
|
186
|
+
identify(printerId: string): Promise<ApiResponse>;
|
|
187
|
+
setMedia(printerId: string, params: MediaDefinitionParams): Promise<ApiResponse>;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// ── Designs ──
|
|
191
|
+
|
|
192
|
+
interface Design extends ApiResponse {
|
|
193
|
+
id: string;
|
|
194
|
+
name: string;
|
|
195
|
+
width_mm?: number;
|
|
196
|
+
height_mm?: number;
|
|
197
|
+
elements?: DesignElement[];
|
|
198
|
+
variables?: DesignVariable[];
|
|
199
|
+
created_at?: string;
|
|
200
|
+
updated_at?: string;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
interface DesignElement extends ApiResponse {
|
|
204
|
+
id: string;
|
|
205
|
+
type: string;
|
|
206
|
+
x: number;
|
|
207
|
+
y: number;
|
|
208
|
+
width?: number;
|
|
209
|
+
height?: number;
|
|
210
|
+
[key: string]: unknown;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
interface DesignVariable {
|
|
214
|
+
name: string;
|
|
215
|
+
type?: string;
|
|
216
|
+
default_value?: string;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
interface DesignList extends ApiResponse {
|
|
220
|
+
designs: Design[];
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
interface DesignRevision extends ApiResponse {
|
|
224
|
+
revision_id: string;
|
|
225
|
+
design_id: string;
|
|
226
|
+
created_at: string;
|
|
227
|
+
author?: string;
|
|
228
|
+
summary?: string;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
interface DesignRevisionList extends ApiResponse {
|
|
232
|
+
revisions: DesignRevision[];
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
class DesignsResource {
|
|
236
|
+
list(query?: Record<string, string>): Promise<DesignList>;
|
|
237
|
+
get(designId: string): Promise<Design>;
|
|
238
|
+
create(params: Partial<Design>): Promise<Design>;
|
|
239
|
+
update(designId: string, params: Partial<Design>): Promise<Design>;
|
|
240
|
+
delete(designId: string): Promise<ApiResponse>;
|
|
241
|
+
listElements(designId: string): Promise<{ elements: DesignElement[] } & ApiResponse>;
|
|
242
|
+
addElement(designId: string, params: Partial<DesignElement>): Promise<DesignElement>;
|
|
243
|
+
updateElement(designId: string, elementId: string, params: Partial<DesignElement>): Promise<DesignElement>;
|
|
244
|
+
deleteElement(designId: string, elementId: string): Promise<ApiResponse>;
|
|
245
|
+
listVariables(designId: string): Promise<{ variables: DesignVariable[] } & ApiResponse>;
|
|
246
|
+
clone(designId: string): Promise<Design>;
|
|
247
|
+
render(designId: string, params?: { data?: Record<string, string> }): Promise<ApiResponse>;
|
|
248
|
+
print(designId: string, params: { printer_id: string; data?: Record<string, string> | Record<string, string>[]; copies?: number }): Promise<PrintJob>;
|
|
249
|
+
revisions(designId: string, query?: { limit?: number }): Promise<DesignRevisionList>;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// ── Webhooks ──
|
|
253
|
+
|
|
254
|
+
type WebhookEvent =
|
|
255
|
+
| 'print.job.completed'
|
|
256
|
+
| 'print.job.failed'
|
|
257
|
+
| 'print.job.cancelled'
|
|
258
|
+
| 'print.job.created'
|
|
259
|
+
| 'printer.status.changed'
|
|
260
|
+
| 'printer.supply.low'
|
|
261
|
+
| 'design.updated'
|
|
262
|
+
| 'design.deleted';
|
|
263
|
+
|
|
264
|
+
interface Webhook extends ApiResponse {
|
|
265
|
+
id: string;
|
|
266
|
+
url: string;
|
|
267
|
+
events: WebhookEvent[];
|
|
268
|
+
description?: string;
|
|
269
|
+
enabled?: boolean;
|
|
270
|
+
signing_secret: string;
|
|
271
|
+
created_at: string;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
interface WebhookList extends ApiResponse {
|
|
275
|
+
webhooks: Webhook[];
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
interface CreateWebhookParams {
|
|
279
|
+
url: string;
|
|
280
|
+
events: WebhookEvent[];
|
|
281
|
+
description?: string;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
interface UpdateWebhookParams {
|
|
285
|
+
url?: string;
|
|
286
|
+
events?: WebhookEvent[];
|
|
287
|
+
description?: string;
|
|
288
|
+
enabled?: boolean;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
interface WebhookDelivery extends ApiResponse {
|
|
292
|
+
id: string;
|
|
293
|
+
webhook_id: string;
|
|
294
|
+
event: string;
|
|
295
|
+
status_code?: number;
|
|
296
|
+
success: boolean;
|
|
297
|
+
attempted_at: string;
|
|
298
|
+
response_time_ms?: number;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
interface WebhookDeliveryList extends ApiResponse {
|
|
302
|
+
deliveries: WebhookDelivery[];
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
class WebhooksResource {
|
|
306
|
+
create(params: CreateWebhookParams): Promise<Webhook>;
|
|
307
|
+
list(): Promise<WebhookList>;
|
|
308
|
+
delete(webhookId: string): Promise<ApiResponse>;
|
|
309
|
+
test(webhookId: string): Promise<ApiResponse>;
|
|
310
|
+
update(webhookId: string, params: UpdateWebhookParams): Promise<Webhook>;
|
|
311
|
+
deliveries(webhookId: string, query?: { limit?: number }): Promise<WebhookDeliveryList>;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// ── Errors ──
|
|
315
|
+
|
|
316
|
+
class LabelInnError extends Error {
|
|
317
|
+
status: number;
|
|
318
|
+
code: string;
|
|
319
|
+
raw: unknown;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
class LabelInnRateLimitError extends LabelInnError {
|
|
323
|
+
retryAfter: number;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
export = LabelInn;
|