@pelygo/janus 0.1.1
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 +264 -0
- package/dist/index.d.ts +1037 -0
- package/dist/index.js +257 -0
- package/package.json +57 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1037 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @pelygo/janus
|
|
3
|
+
*
|
|
4
|
+
* TypeScript API client for JANUS endpoints with full type safety.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { AuthApi } from '@pelygo/auth/core';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Data for adding a return reason to a client
|
|
13
|
+
*/
|
|
14
|
+
export declare interface AddClientReturnReasonRequest {
|
|
15
|
+
/** Client object with ID */
|
|
16
|
+
client: {
|
|
17
|
+
id: number;
|
|
18
|
+
};
|
|
19
|
+
/** Return reason object with ID */
|
|
20
|
+
return_reason: {
|
|
21
|
+
id: number;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Data for adding a comment to a return
|
|
27
|
+
*/
|
|
28
|
+
export declare interface AddReturnCommentRequest {
|
|
29
|
+
/** Comment text */
|
|
30
|
+
comment: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Data for adding a status to a return
|
|
35
|
+
*/
|
|
36
|
+
export declare interface AddReturnStatusRequest {
|
|
37
|
+
/** Return object with ID */
|
|
38
|
+
return: {
|
|
39
|
+
id: number;
|
|
40
|
+
};
|
|
41
|
+
/** Return status object with ID */
|
|
42
|
+
return_status: {
|
|
43
|
+
id: number;
|
|
44
|
+
};
|
|
45
|
+
/** Created by user object with ID */
|
|
46
|
+
created_by?: {
|
|
47
|
+
id: number;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Approval status for returns
|
|
53
|
+
*/
|
|
54
|
+
export declare type ApprovalStatus = 'pending' | 'approved' | 'rejected';
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Base Entity Interface
|
|
58
|
+
*
|
|
59
|
+
* All JANUS entities extend from this base type.
|
|
60
|
+
*/
|
|
61
|
+
export declare interface BaseEntity {
|
|
62
|
+
/** Unique identifier */
|
|
63
|
+
id: number;
|
|
64
|
+
/** User ID who created this record */
|
|
65
|
+
created_by?: number;
|
|
66
|
+
/** User ID who last updated this record */
|
|
67
|
+
updated_by?: number;
|
|
68
|
+
/** Creation timestamp */
|
|
69
|
+
created_ts?: string;
|
|
70
|
+
/** Last update timestamp */
|
|
71
|
+
updated_ts?: string;
|
|
72
|
+
/** Partition ID for multi-tenancy */
|
|
73
|
+
partition_id?: number;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Filter Types for API Queries
|
|
78
|
+
* @module types/filters
|
|
79
|
+
*/
|
|
80
|
+
/**
|
|
81
|
+
* Base filter options common to most queries
|
|
82
|
+
*/
|
|
83
|
+
export declare interface BaseFilters {
|
|
84
|
+
/** Page number for pagination */
|
|
85
|
+
page?: number;
|
|
86
|
+
/** Page size for pagination */
|
|
87
|
+
pageSize?: number;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Build a query string from a filter object.
|
|
92
|
+
*
|
|
93
|
+
* Handles undefined/null values by omitting them.
|
|
94
|
+
* Properly encodes special characters.
|
|
95
|
+
*
|
|
96
|
+
* @param filters - Object containing filter key-value pairs
|
|
97
|
+
* @returns Query string (without leading '?')
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```typescript
|
|
101
|
+
* const query = buildQueryString({ clientId: 5, status: 'active' });
|
|
102
|
+
* // Returns: "clientId=5&status=active"
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
export declare function buildQueryString(filters: FilterObject): string;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Build a full URL with query parameters.
|
|
109
|
+
*
|
|
110
|
+
* @param baseUrl - Base URL (may already include query params)
|
|
111
|
+
* @param filters - Filter object to append
|
|
112
|
+
* @returns Full URL with query parameters
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```typescript
|
|
116
|
+
* const url = buildUrl('/returns', { clientId: 5 });
|
|
117
|
+
* // Returns: "/returns?clientId=5"
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
export declare function buildUrl(baseUrl: string, filters?: FilterObject): string;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Client Entity
|
|
124
|
+
*
|
|
125
|
+
* Represents a customer/client in the JANUS system.
|
|
126
|
+
*/
|
|
127
|
+
export declare interface Client extends BaseEntity {
|
|
128
|
+
/** Client name */
|
|
129
|
+
name: string;
|
|
130
|
+
/** Short name / code */
|
|
131
|
+
short_name?: string;
|
|
132
|
+
/** Contact email */
|
|
133
|
+
email?: string;
|
|
134
|
+
/** Contact phone */
|
|
135
|
+
phone?: string;
|
|
136
|
+
/** Operational status */
|
|
137
|
+
operational_status?: ClientOperationalStatus;
|
|
138
|
+
/** Client-specific settings */
|
|
139
|
+
settings?: ClientSettings;
|
|
140
|
+
/** Whether returns require approval */
|
|
141
|
+
requires_approval?: boolean;
|
|
142
|
+
/** Default courier service ID */
|
|
143
|
+
default_courier_service_id?: number;
|
|
144
|
+
/** Whether client is active */
|
|
145
|
+
active?: boolean;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Client Courier Service
|
|
150
|
+
*
|
|
151
|
+
* Represents a courier service configured for a specific client.
|
|
152
|
+
*/
|
|
153
|
+
export declare interface ClientCourierService extends BaseEntity {
|
|
154
|
+
/** Client ID */
|
|
155
|
+
client_id?: number;
|
|
156
|
+
/** Courier service ID */
|
|
157
|
+
courier_service_id?: number;
|
|
158
|
+
/** Courier service */
|
|
159
|
+
courier_service?: CourierService;
|
|
160
|
+
/** Whether this is the default service */
|
|
161
|
+
is_default?: boolean;
|
|
162
|
+
/** Client-specific price override */
|
|
163
|
+
price?: number;
|
|
164
|
+
/** Whether service is active for this client */
|
|
165
|
+
active?: boolean;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Operational status for a client
|
|
170
|
+
*/
|
|
171
|
+
export declare type ClientOperationalStatus = 'active' | 'inactive' | 'onboarding' | 'offboarding';
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Client settings structure
|
|
175
|
+
*/
|
|
176
|
+
export declare interface ClientSettings {
|
|
177
|
+
/** Logo URL */
|
|
178
|
+
logo_url?: string;
|
|
179
|
+
/** Primary brand color */
|
|
180
|
+
primary_color?: string;
|
|
181
|
+
/** Secondary brand color */
|
|
182
|
+
secondary_color?: string;
|
|
183
|
+
/** Support email address */
|
|
184
|
+
support_email?: string;
|
|
185
|
+
/** Support phone number */
|
|
186
|
+
support_phone?: string;
|
|
187
|
+
/** Custom CSS for portal */
|
|
188
|
+
custom_css?: string;
|
|
189
|
+
/** Additional settings as key-value pairs */
|
|
190
|
+
[key: string]: unknown;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Client settings public response (no auth required)
|
|
195
|
+
*/
|
|
196
|
+
export declare interface ClientSettingsPublicResponse {
|
|
197
|
+
/** Client ID */
|
|
198
|
+
id: number;
|
|
199
|
+
/** Client name */
|
|
200
|
+
name: string;
|
|
201
|
+
/** Settings */
|
|
202
|
+
settings?: Record<string, unknown>;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Clients resource interface
|
|
207
|
+
*/
|
|
208
|
+
export declare interface ClientsResource {
|
|
209
|
+
/** Get all clients accessible to the current user */
|
|
210
|
+
getAll(): Promise<Client[]>;
|
|
211
|
+
/** Get a client by ID */
|
|
212
|
+
getById(id: number): Promise<Client>;
|
|
213
|
+
/** Update a client */
|
|
214
|
+
update(id: number, data: UpdateClientRequest): Promise<Client>;
|
|
215
|
+
/** Get courier services for a client */
|
|
216
|
+
getCourierServices(clientId: number): Promise<ClientCourierService[]>;
|
|
217
|
+
/** Get a specific courier service for a client */
|
|
218
|
+
getCourierServiceById(clientId: number, serviceId: number): Promise<ClientCourierService>;
|
|
219
|
+
/** Update a courier service for a client */
|
|
220
|
+
updateCourierService(clientId: number, service: Partial<ClientCourierService>): Promise<ClientCourierService>;
|
|
221
|
+
/** Get order by reference for a client */
|
|
222
|
+
getOrderByRef(clientId: number, orderRef: string): Promise<unknown>;
|
|
223
|
+
/** Add a return reason to a client */
|
|
224
|
+
addReturnReason(clientId: number, returnReasonId: number): Promise<unknown>;
|
|
225
|
+
/** Remove a return reason from a client */
|
|
226
|
+
removeReturnReason(clientId: number, returnReasonId: number): Promise<void>;
|
|
227
|
+
/** Upload a file for a client */
|
|
228
|
+
uploadFile(clientId: number, filename: string, data: UploadFileRequest): Promise<UploadFileResponse>;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Courier Entity
|
|
233
|
+
*
|
|
234
|
+
* Represents a courier/carrier company.
|
|
235
|
+
*/
|
|
236
|
+
export declare interface Courier extends BaseEntity {
|
|
237
|
+
/** Courier name */
|
|
238
|
+
name: string;
|
|
239
|
+
/** Courier code */
|
|
240
|
+
code?: string;
|
|
241
|
+
/** Whether courier is active */
|
|
242
|
+
active?: boolean;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Courier Service Entity
|
|
247
|
+
*
|
|
248
|
+
* Represents a specific service offered by a courier.
|
|
249
|
+
*/
|
|
250
|
+
export declare interface CourierService extends BaseEntity {
|
|
251
|
+
/** Service name */
|
|
252
|
+
name: string;
|
|
253
|
+
/** Service code */
|
|
254
|
+
code?: string;
|
|
255
|
+
/** Parent courier ID */
|
|
256
|
+
courier_id?: number;
|
|
257
|
+
/** Parent courier */
|
|
258
|
+
courier?: Courier;
|
|
259
|
+
/** Whether service is active */
|
|
260
|
+
active?: boolean;
|
|
261
|
+
/** Service cost */
|
|
262
|
+
cost?: number;
|
|
263
|
+
/** Client-specific price */
|
|
264
|
+
price?: number;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Create a JANUS API client.
|
|
269
|
+
*
|
|
270
|
+
* The client automatically handles authentication using @pelygo/auth
|
|
271
|
+
* and provides typed methods for all JANUS endpoints.
|
|
272
|
+
*
|
|
273
|
+
* @param options - Configuration options
|
|
274
|
+
* @returns JanusApi instance
|
|
275
|
+
*
|
|
276
|
+
* @example
|
|
277
|
+
* ```typescript
|
|
278
|
+
* import { createJanusApi } from '@pelygo/janus';
|
|
279
|
+
*
|
|
280
|
+
* // Create client with defaults (uses localStorage token)
|
|
281
|
+
* const janus = createJanusApi();
|
|
282
|
+
*
|
|
283
|
+
* // Fetch all clients
|
|
284
|
+
* const clients = await janus.clients.getAll();
|
|
285
|
+
*
|
|
286
|
+
* // Query returns with filters
|
|
287
|
+
* const returns = await janus.returns.query({
|
|
288
|
+
* clientId: 5,
|
|
289
|
+
* created_at: '2024-01-01',
|
|
290
|
+
* });
|
|
291
|
+
*
|
|
292
|
+
* // Get public client settings (no auth required)
|
|
293
|
+
* const settings = await janus.helpers.getClientSettingsByName('acme');
|
|
294
|
+
* ```
|
|
295
|
+
*
|
|
296
|
+
* @example
|
|
297
|
+
* ```typescript
|
|
298
|
+
* // With custom configuration
|
|
299
|
+
* const janus = createJanusApi({
|
|
300
|
+
* baseUrl: 'https://api.janus.dev.pelygo.com',
|
|
301
|
+
* onUnauthorized: () => {
|
|
302
|
+
* // Redirect to login
|
|
303
|
+
* window.location.href = '/login';
|
|
304
|
+
* },
|
|
305
|
+
* });
|
|
306
|
+
* ```
|
|
307
|
+
*/
|
|
308
|
+
export declare function createJanusApi(options?: JanusApiOptions): JanusApi;
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Data for a return item in create request
|
|
312
|
+
*/
|
|
313
|
+
export declare interface CreateReturnItemRequest {
|
|
314
|
+
/** Product SKU */
|
|
315
|
+
sku: string;
|
|
316
|
+
/** Product name */
|
|
317
|
+
name?: string;
|
|
318
|
+
/** Quantity */
|
|
319
|
+
qty: number;
|
|
320
|
+
/** Return reason ID */
|
|
321
|
+
reason_id?: number;
|
|
322
|
+
/** Customer note */
|
|
323
|
+
note?: string;
|
|
324
|
+
/** Price paid */
|
|
325
|
+
price_paid?: number;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Request Types for API Operations
|
|
330
|
+
* @module types/requests
|
|
331
|
+
*/
|
|
332
|
+
/**
|
|
333
|
+
* Data for creating a new return
|
|
334
|
+
*/
|
|
335
|
+
export declare interface CreateReturnRequest {
|
|
336
|
+
/** Client ID */
|
|
337
|
+
client_id: number;
|
|
338
|
+
/** Order reference */
|
|
339
|
+
order_ref?: string;
|
|
340
|
+
/** Customer forename */
|
|
341
|
+
forename?: string;
|
|
342
|
+
/** Customer surname */
|
|
343
|
+
surname?: string;
|
|
344
|
+
/** Customer email */
|
|
345
|
+
email?: string;
|
|
346
|
+
/** Company name */
|
|
347
|
+
company?: string;
|
|
348
|
+
/** Address line 1 */
|
|
349
|
+
line_1?: string;
|
|
350
|
+
/** Address line 2 */
|
|
351
|
+
line_2?: string;
|
|
352
|
+
/** Address line 3 */
|
|
353
|
+
line_3?: string;
|
|
354
|
+
/** City */
|
|
355
|
+
city?: string;
|
|
356
|
+
/** County/State */
|
|
357
|
+
county?: string;
|
|
358
|
+
/** Country */
|
|
359
|
+
country?: string;
|
|
360
|
+
/** Country code */
|
|
361
|
+
country_code?: string;
|
|
362
|
+
/** Postcode */
|
|
363
|
+
postcode?: string;
|
|
364
|
+
/** Courier service ID */
|
|
365
|
+
courier_service_id?: number;
|
|
366
|
+
/** Return items */
|
|
367
|
+
items?: CreateReturnItemRequest[];
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Customer login response
|
|
372
|
+
*/
|
|
373
|
+
export declare interface CustomerLoginResponse {
|
|
374
|
+
/** Whether login was successful */
|
|
375
|
+
success: boolean;
|
|
376
|
+
/** Order data if found */
|
|
377
|
+
order?: {
|
|
378
|
+
id: number;
|
|
379
|
+
order_ref: string;
|
|
380
|
+
[key: string]: unknown;
|
|
381
|
+
};
|
|
382
|
+
/** Error message if failed */
|
|
383
|
+
error?: string;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* Date range filter
|
|
388
|
+
*/
|
|
389
|
+
export declare interface DateRangeFilter {
|
|
390
|
+
/** Start date (ISO string) */
|
|
391
|
+
from?: string;
|
|
392
|
+
/** End date (ISO string) */
|
|
393
|
+
to?: string;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Default JANUS API base URL
|
|
398
|
+
*/
|
|
399
|
+
export declare const DEFAULT_JANUS_URL = "https://api.janus.pelygo.com";
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* Generic filter object type
|
|
403
|
+
*/
|
|
404
|
+
declare type FilterObject = Record<string, FilterValue>;
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* Order filter options response
|
|
408
|
+
*/
|
|
409
|
+
export declare interface FilterOptionsResponse {
|
|
410
|
+
/** Available statuses */
|
|
411
|
+
statuses?: Array<{
|
|
412
|
+
id: number;
|
|
413
|
+
name: string;
|
|
414
|
+
}>;
|
|
415
|
+
/** Available reasons */
|
|
416
|
+
reasons?: Array<{
|
|
417
|
+
id: number;
|
|
418
|
+
name: string;
|
|
419
|
+
}>;
|
|
420
|
+
/** Available courier services */
|
|
421
|
+
courier_services?: Array<{
|
|
422
|
+
id: number;
|
|
423
|
+
name: string;
|
|
424
|
+
}>;
|
|
425
|
+
[key: string]: unknown;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* Query Parameter Builder Utility
|
|
430
|
+
*
|
|
431
|
+
* Builds URL query strings from filter objects.
|
|
432
|
+
* @module utils/query-builder
|
|
433
|
+
*/
|
|
434
|
+
/**
|
|
435
|
+
* Filter value types that can be converted to query params
|
|
436
|
+
*/
|
|
437
|
+
declare type FilterValue = string | number | boolean | undefined | null;
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* Error thrown when access is forbidden (403)
|
|
441
|
+
*/
|
|
442
|
+
export declare class ForbiddenError extends JanusApiError {
|
|
443
|
+
constructor(message?: string, response?: unknown);
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* Helpers resource interface (no auth required)
|
|
448
|
+
*/
|
|
449
|
+
export declare interface HelpersResource {
|
|
450
|
+
/** Get public client settings by client name (for return portal branding) */
|
|
451
|
+
getClientSettingsByName(name: string): Promise<ClientSettingsPublicResponse>;
|
|
452
|
+
/** Get notification settings by client name */
|
|
453
|
+
getNotificationSettings(name: string): Promise<NotificationSettingsResponse>;
|
|
454
|
+
/** Customer login for return portal */
|
|
455
|
+
customerLogin(clientId: number, orderRef: string, postcode: string): Promise<CustomerLoginResponse>;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
/**
|
|
459
|
+
* Check if an error is a JanusApiError
|
|
460
|
+
*/
|
|
461
|
+
export declare function isJanusApiError(error: unknown): error is JanusApiError;
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* Check if an error is an UnauthorizedError
|
|
465
|
+
*/
|
|
466
|
+
export declare function isUnauthorizedError(error: unknown): error is UnauthorizedError;
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* JANUS API Client Interface
|
|
470
|
+
*
|
|
471
|
+
* Provides typed access to all JANUS API resources.
|
|
472
|
+
*/
|
|
473
|
+
export declare interface JanusApi {
|
|
474
|
+
/** Clients resource - manage client accounts */
|
|
475
|
+
clients: ClientsResource;
|
|
476
|
+
/** Returns resource - manage customer returns */
|
|
477
|
+
returns: ReturnsResource;
|
|
478
|
+
/** Reports resource - generate reports */
|
|
479
|
+
reports: ReportsResource;
|
|
480
|
+
/** Helpers resource - public endpoints (no auth required) */
|
|
481
|
+
helpers: HelpersResource;
|
|
482
|
+
/** Underlying AuthApi instance for raw requests */
|
|
483
|
+
auth: AuthApi;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* Error Utilities
|
|
488
|
+
*
|
|
489
|
+
* Custom error types and error handling utilities.
|
|
490
|
+
* @module utils/errors
|
|
491
|
+
*/
|
|
492
|
+
/**
|
|
493
|
+
* Base class for JANUS API errors
|
|
494
|
+
*/
|
|
495
|
+
export declare class JanusApiError extends Error {
|
|
496
|
+
/** HTTP status code */
|
|
497
|
+
readonly status: number;
|
|
498
|
+
/** Original error response */
|
|
499
|
+
readonly response?: unknown;
|
|
500
|
+
constructor(message: string, status: number, response?: unknown);
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
/**
|
|
504
|
+
* Options for creating a JANUS API client
|
|
505
|
+
*/
|
|
506
|
+
export declare interface JanusApiOptions {
|
|
507
|
+
/** Base URL for JANUS API (defaults to production) */
|
|
508
|
+
baseUrl?: string;
|
|
509
|
+
/** Base URL for auth API (if different from JANUS) */
|
|
510
|
+
authUrl?: string;
|
|
511
|
+
/** Called on 401 unauthorized response */
|
|
512
|
+
onUnauthorized?: () => void;
|
|
513
|
+
/** Called on successful login */
|
|
514
|
+
onLoginSuccess?: (token: string) => void;
|
|
515
|
+
/** Called on login failure */
|
|
516
|
+
onLoginError?: (error: Error) => void;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
* Error thrown when resource is not found (404)
|
|
521
|
+
*/
|
|
522
|
+
export declare class NotFoundError extends JanusApiError {
|
|
523
|
+
constructor(message?: string, response?: unknown);
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* Notification settings response
|
|
528
|
+
*/
|
|
529
|
+
declare interface NotificationSettingsResponse {
|
|
530
|
+
/** Client ID */
|
|
531
|
+
id: number;
|
|
532
|
+
/** Client name */
|
|
533
|
+
name: string;
|
|
534
|
+
/** Client short name */
|
|
535
|
+
short_name: string;
|
|
536
|
+
/** Notification settings */
|
|
537
|
+
settings?: Record<string, unknown>;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
/**
|
|
541
|
+
* Response Types for API Operations
|
|
542
|
+
* @module types/responses
|
|
543
|
+
*/
|
|
544
|
+
/**
|
|
545
|
+
* Paginated response wrapper
|
|
546
|
+
*/
|
|
547
|
+
export declare interface PaginatedResponse<T> {
|
|
548
|
+
/** Data items */
|
|
549
|
+
data: T[];
|
|
550
|
+
/** Total count */
|
|
551
|
+
total?: number;
|
|
552
|
+
/** Current page */
|
|
553
|
+
page?: number;
|
|
554
|
+
/** Page size */
|
|
555
|
+
pageSize?: number;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
/**
|
|
559
|
+
* Reports resource interface
|
|
560
|
+
*/
|
|
561
|
+
export declare interface ReportsResource {
|
|
562
|
+
/** Get returns summary report */
|
|
563
|
+
returnsSummary(filters?: ReturnsSummaryFilters): Promise<ReturnsSummaryResponse>;
|
|
564
|
+
/** Get returns summary as CSV */
|
|
565
|
+
returnsSummaryCsv(filters?: ReturnsSummaryFilters): Promise<string>;
|
|
566
|
+
/** Get returns by reason report */
|
|
567
|
+
returnsReasons(filters?: ReturnsReasonsFilters): Promise<unknown>;
|
|
568
|
+
/** Get returns by reason as CSV */
|
|
569
|
+
returnsReasonsCsv(filters?: ReturnsReasonsFilters): Promise<string>;
|
|
570
|
+
/** Get returns overview report */
|
|
571
|
+
returnsOverview(filters?: ReturnsOverviewFilters): Promise<unknown>;
|
|
572
|
+
/** Get returns overview as CSV */
|
|
573
|
+
returnsOverviewCsv(filters?: ReturnsOverviewFilters): Promise<string>;
|
|
574
|
+
/** Get returns statistics for a client */
|
|
575
|
+
returnsStats(clientId: number): Promise<ReturnsStatsResponse>;
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
/**
|
|
579
|
+
* Return Entity
|
|
580
|
+
*
|
|
581
|
+
* Represents a customer return in the JANUS system.
|
|
582
|
+
*/
|
|
583
|
+
export declare interface Return extends BaseEntity {
|
|
584
|
+
/** Unique return reference */
|
|
585
|
+
return_reference?: string;
|
|
586
|
+
/** Associated WMS order reference */
|
|
587
|
+
wms_order_ref?: string;
|
|
588
|
+
/** Client ID */
|
|
589
|
+
client_id?: number;
|
|
590
|
+
/** Current status ID */
|
|
591
|
+
status_id?: number;
|
|
592
|
+
/** Return reason ID */
|
|
593
|
+
reason_id?: number;
|
|
594
|
+
/** Customer name */
|
|
595
|
+
customername?: string;
|
|
596
|
+
/** Customer forename */
|
|
597
|
+
forename?: string;
|
|
598
|
+
/** Customer surname */
|
|
599
|
+
surname?: string;
|
|
600
|
+
/** Customer email */
|
|
601
|
+
email?: string;
|
|
602
|
+
/** Tracking number */
|
|
603
|
+
tracking_number?: string;
|
|
604
|
+
/** Tracking URL */
|
|
605
|
+
tracking_url?: string;
|
|
606
|
+
/** Approval status */
|
|
607
|
+
approval_status?: ApprovalStatus;
|
|
608
|
+
/** Whether return is approved */
|
|
609
|
+
approved?: boolean;
|
|
610
|
+
/** Approval timestamp */
|
|
611
|
+
approved_ts?: string;
|
|
612
|
+
/** Address line 1 */
|
|
613
|
+
line_1?: string;
|
|
614
|
+
/** Address line 2 */
|
|
615
|
+
line_2?: string;
|
|
616
|
+
/** Address line 3 */
|
|
617
|
+
line_3?: string;
|
|
618
|
+
/** City */
|
|
619
|
+
city?: string;
|
|
620
|
+
/** County/State */
|
|
621
|
+
county?: string;
|
|
622
|
+
/** Country */
|
|
623
|
+
country?: string;
|
|
624
|
+
/** Country code */
|
|
625
|
+
country_code?: string;
|
|
626
|
+
/** Postcode */
|
|
627
|
+
postcode?: string;
|
|
628
|
+
/** Company name */
|
|
629
|
+
company?: string;
|
|
630
|
+
/** WMS service cost */
|
|
631
|
+
wms_service_cost?: number;
|
|
632
|
+
/** Courier service cost */
|
|
633
|
+
courier_service_cost?: number;
|
|
634
|
+
/** Courier service ID */
|
|
635
|
+
courier_service_id?: number;
|
|
636
|
+
/** Return items */
|
|
637
|
+
items?: ReturnItem[];
|
|
638
|
+
/** Return statuses history */
|
|
639
|
+
statuses?: ReturnStatusHistory[];
|
|
640
|
+
/** Return comments */
|
|
641
|
+
comments?: ReturnComment[];
|
|
642
|
+
/** Latest status */
|
|
643
|
+
latestStatus?: ReturnStatusHistory;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
/**
|
|
647
|
+
* Return Category Entity
|
|
648
|
+
*
|
|
649
|
+
* Groups return reasons into categories.
|
|
650
|
+
*/
|
|
651
|
+
export declare interface ReturnCategory extends BaseEntity {
|
|
652
|
+
/** Category name */
|
|
653
|
+
name: string;
|
|
654
|
+
/** Whether category is active */
|
|
655
|
+
active?: boolean;
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
/**
|
|
659
|
+
* Return Comment Entity
|
|
660
|
+
*
|
|
661
|
+
* Represents a comment on a return.
|
|
662
|
+
*/
|
|
663
|
+
export declare interface ReturnComment extends BaseEntity {
|
|
664
|
+
/** Return ID */
|
|
665
|
+
return_id?: number;
|
|
666
|
+
/** Comment text */
|
|
667
|
+
comment?: string;
|
|
668
|
+
/** User who created the comment */
|
|
669
|
+
created_by_user?: {
|
|
670
|
+
id: number;
|
|
671
|
+
firstname?: string;
|
|
672
|
+
lastname?: string;
|
|
673
|
+
username?: string;
|
|
674
|
+
};
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
/**
|
|
678
|
+
* Return Item Entity
|
|
679
|
+
*
|
|
680
|
+
* Represents an item within a return.
|
|
681
|
+
*/
|
|
682
|
+
export declare interface ReturnItem extends BaseEntity {
|
|
683
|
+
/** Parent return ID */
|
|
684
|
+
return_id?: number;
|
|
685
|
+
/** WMS product SKU */
|
|
686
|
+
wms_product_sku?: string;
|
|
687
|
+
/** WMS product name */
|
|
688
|
+
wms_product_name?: string;
|
|
689
|
+
/** WMS product description */
|
|
690
|
+
wms_product_description?: string;
|
|
691
|
+
/** Quantity returned */
|
|
692
|
+
qty?: number;
|
|
693
|
+
/** Quantity restocked */
|
|
694
|
+
wms_restock_qty?: number;
|
|
695
|
+
/** Price paid per unit */
|
|
696
|
+
wms_price_paid?: number;
|
|
697
|
+
/** Customer note */
|
|
698
|
+
note?: string;
|
|
699
|
+
/** Return reason ID */
|
|
700
|
+
return_reason_id?: number;
|
|
701
|
+
/** Return reason */
|
|
702
|
+
return_reason?: ReturnReason;
|
|
703
|
+
/** WMS reason for non-restock */
|
|
704
|
+
wms_reason?: string;
|
|
705
|
+
/** WMS notes */
|
|
706
|
+
wms_notes?: string;
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
/**
|
|
710
|
+
* Return Reason Entity
|
|
711
|
+
*
|
|
712
|
+
* Defines a reason for returning items.
|
|
713
|
+
*/
|
|
714
|
+
export declare interface ReturnReason extends BaseEntity {
|
|
715
|
+
/** Reason name */
|
|
716
|
+
name: string;
|
|
717
|
+
/** Category ID */
|
|
718
|
+
category_id?: number;
|
|
719
|
+
/** Category */
|
|
720
|
+
category?: ReturnCategory;
|
|
721
|
+
/** Whether reason is active */
|
|
722
|
+
active?: boolean;
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
/**
|
|
726
|
+
* Filters for returns overview report
|
|
727
|
+
*/
|
|
728
|
+
export declare interface ReturnsOverviewFilters extends BaseFilters {
|
|
729
|
+
/** Filter by creation date from */
|
|
730
|
+
createdFrom?: string;
|
|
731
|
+
/** Filter by creation date to */
|
|
732
|
+
createdTo?: string;
|
|
733
|
+
/** Filter by client ID */
|
|
734
|
+
clientId?: number;
|
|
735
|
+
/** Include archived returns */
|
|
736
|
+
include_archived?: boolean;
|
|
737
|
+
/** Only show archived returns */
|
|
738
|
+
only_archived?: boolean;
|
|
739
|
+
/** Export as CSV */
|
|
740
|
+
csv?: boolean;
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
/**
|
|
744
|
+
* Filters for querying returns
|
|
745
|
+
*/
|
|
746
|
+
export declare interface ReturnsQueryFilters extends BaseFilters {
|
|
747
|
+
/** Filter by client ID */
|
|
748
|
+
clientId?: number;
|
|
749
|
+
/** Filter by last status IDs (comma-separated) */
|
|
750
|
+
last_status_ids?: string;
|
|
751
|
+
/** Include returns with these status IDs (comma-separated) */
|
|
752
|
+
include_status_ids?: string;
|
|
753
|
+
/** Exclude returns with these status IDs (comma-separated) */
|
|
754
|
+
exclude_status_ids?: string;
|
|
755
|
+
/** Filter by creation date from */
|
|
756
|
+
created_at?: string;
|
|
757
|
+
/** Filter by creation date to */
|
|
758
|
+
created_to?: string;
|
|
759
|
+
/** Filter by processed date from */
|
|
760
|
+
processed_at?: string;
|
|
761
|
+
/** Filter by processed date to */
|
|
762
|
+
processed_to?: string;
|
|
763
|
+
/** Minimum restock quantity */
|
|
764
|
+
min_restock_qty?: number;
|
|
765
|
+
/** Maximum restock quantity */
|
|
766
|
+
max_restock_qty?: number;
|
|
767
|
+
/** Export as CSV */
|
|
768
|
+
csv?: boolean;
|
|
769
|
+
/** Columns to include in response */
|
|
770
|
+
include_columns?: string;
|
|
771
|
+
/** Associations to include */
|
|
772
|
+
include_associations?: string;
|
|
773
|
+
/** Group results by field */
|
|
774
|
+
group_by?: string;
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
/**
|
|
778
|
+
* Filters for returns reasons report
|
|
779
|
+
*/
|
|
780
|
+
export declare interface ReturnsReasonsFilters extends BaseFilters {
|
|
781
|
+
/** Filter by creation date from */
|
|
782
|
+
createdFrom?: string;
|
|
783
|
+
/** Filter by creation date to */
|
|
784
|
+
createdTo?: string;
|
|
785
|
+
/** Filter by client ID */
|
|
786
|
+
clientId?: number;
|
|
787
|
+
/** Export as CSV */
|
|
788
|
+
csv?: boolean;
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
/**
|
|
792
|
+
* Returns resource interface
|
|
793
|
+
*/
|
|
794
|
+
export declare interface ReturnsResource {
|
|
795
|
+
/** Query returns with filters */
|
|
796
|
+
query(filters?: ReturnsQueryFilters): Promise<Return[]>;
|
|
797
|
+
/** Get a return by ID */
|
|
798
|
+
getById(id: number, options?: {
|
|
799
|
+
include_associations?: string;
|
|
800
|
+
}): Promise<Return>;
|
|
801
|
+
/** Create a new return (via helpers endpoint for portal access) */
|
|
802
|
+
create(data: CreateReturnRequest): Promise<Return>;
|
|
803
|
+
/** Update a return */
|
|
804
|
+
update(returnId: number, data: Partial<Return>): Promise<Return>;
|
|
805
|
+
/** Delete a return */
|
|
806
|
+
delete(returnId: number): Promise<void>;
|
|
807
|
+
/** Get all statuses for a return */
|
|
808
|
+
getStatuses(returnId: number): Promise<ReturnStatus[]>;
|
|
809
|
+
/** Add a status to a return */
|
|
810
|
+
addStatus(returnId: number, statusId: number): Promise<unknown>;
|
|
811
|
+
/** Remove a specific status from a return */
|
|
812
|
+
removeStatus(returnId: number, statusId: number): Promise<void>;
|
|
813
|
+
/** Get return items for a return */
|
|
814
|
+
getItems(returnId: number): Promise<ReturnItem[]>;
|
|
815
|
+
/** Add an item to a return */
|
|
816
|
+
addItem(returnId: number, item: CreateReturnItemRequest): Promise<ReturnItem>;
|
|
817
|
+
/** Update a return item */
|
|
818
|
+
updateItem(returnId: number, itemId: number, data: Partial<ReturnItem>): Promise<ReturnItem>;
|
|
819
|
+
/** Get comments for a return */
|
|
820
|
+
getComments(returnId: number): Promise<ReturnComment[]>;
|
|
821
|
+
/** Add a comment to a return */
|
|
822
|
+
addComment(returnId: number, comment: string): Promise<ReturnComment>;
|
|
823
|
+
/** Remove a comment from a return */
|
|
824
|
+
removeComment(returnId: number, commentId: number): Promise<void>;
|
|
825
|
+
/** Set approval status for a return */
|
|
826
|
+
setApproval(returnId: number, approved: boolean): Promise<unknown>;
|
|
827
|
+
/** Get all return reasons (reference data) */
|
|
828
|
+
getReasons(): Promise<ReturnReason[]>;
|
|
829
|
+
/** Get all return statuses (reference data) */
|
|
830
|
+
getAllStatuses(): Promise<ReturnStatus[]>;
|
|
831
|
+
/** Get filter options for returns */
|
|
832
|
+
getFilterOptions(clientId: number): Promise<FilterOptionsResponse>;
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
/**
|
|
836
|
+
* Returns stats response
|
|
837
|
+
*/
|
|
838
|
+
export declare interface ReturnsStatsResponse {
|
|
839
|
+
/** Total returns count */
|
|
840
|
+
total?: number;
|
|
841
|
+
/** Returns awaiting processing */
|
|
842
|
+
awaiting_processing?: number;
|
|
843
|
+
/** Returns in progress */
|
|
844
|
+
in_progress?: number;
|
|
845
|
+
/** Returns completed */
|
|
846
|
+
completed?: number;
|
|
847
|
+
/** Returns requiring approval */
|
|
848
|
+
awaiting_approval?: number;
|
|
849
|
+
/** Returns approved */
|
|
850
|
+
approved?: number;
|
|
851
|
+
/** Returns rejected */
|
|
852
|
+
rejected?: number;
|
|
853
|
+
/** Stats by status */
|
|
854
|
+
by_status?: Record<string, number>;
|
|
855
|
+
/** Stats by reason */
|
|
856
|
+
by_reason?: Record<string, number>;
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
/**
|
|
860
|
+
* Filters for returns summary report
|
|
861
|
+
*/
|
|
862
|
+
export declare interface ReturnsSummaryFilters extends BaseFilters {
|
|
863
|
+
/** Filter by creation date from */
|
|
864
|
+
createdFrom?: string;
|
|
865
|
+
/** Filter by creation date to */
|
|
866
|
+
createdTo?: string;
|
|
867
|
+
/** Filter by approval date from */
|
|
868
|
+
approvedFrom?: string;
|
|
869
|
+
/** Filter by approval date to */
|
|
870
|
+
approvedTo?: string;
|
|
871
|
+
/** Filter by client ID */
|
|
872
|
+
clientId?: number;
|
|
873
|
+
/** Filter by courier service ID */
|
|
874
|
+
courierServiceId?: number;
|
|
875
|
+
/** Filter by approval status */
|
|
876
|
+
approved?: boolean;
|
|
877
|
+
/** Include approval description */
|
|
878
|
+
approvedWithDesc?: boolean;
|
|
879
|
+
/** Generate clients report */
|
|
880
|
+
isClientsReport?: boolean;
|
|
881
|
+
/** Export as CSV */
|
|
882
|
+
csv?: boolean;
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
/**
|
|
886
|
+
* Returns summary report response
|
|
887
|
+
*/
|
|
888
|
+
export declare interface ReturnsSummaryResponse {
|
|
889
|
+
/** Summary data */
|
|
890
|
+
data: Array<{
|
|
891
|
+
/** Client ID */
|
|
892
|
+
client_id?: number;
|
|
893
|
+
/** Client name */
|
|
894
|
+
client_name?: string;
|
|
895
|
+
/** Total returns */
|
|
896
|
+
total_returns?: number;
|
|
897
|
+
/** Total items */
|
|
898
|
+
total_items?: number;
|
|
899
|
+
/** Total value */
|
|
900
|
+
total_value?: number;
|
|
901
|
+
/** Date */
|
|
902
|
+
date?: string;
|
|
903
|
+
[key: string]: unknown;
|
|
904
|
+
}>;
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
/**
|
|
908
|
+
* Return Status Entity
|
|
909
|
+
*
|
|
910
|
+
* Defines a status that can be applied to returns.
|
|
911
|
+
*/
|
|
912
|
+
export declare interface ReturnStatus extends BaseEntity {
|
|
913
|
+
/** Status name */
|
|
914
|
+
name: string;
|
|
915
|
+
/** Display color */
|
|
916
|
+
color?: string;
|
|
917
|
+
/** Sort order */
|
|
918
|
+
sort_order?: number;
|
|
919
|
+
/** Whether this is a final status */
|
|
920
|
+
is_final?: boolean;
|
|
921
|
+
/** Whether this status requires approval */
|
|
922
|
+
requires_approval?: boolean;
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
/**
|
|
926
|
+
* Return Status History Entry
|
|
927
|
+
*
|
|
928
|
+
* Tracks when a status was applied to a return.
|
|
929
|
+
*/
|
|
930
|
+
export declare interface ReturnStatusHistory extends BaseEntity {
|
|
931
|
+
/** Return ID */
|
|
932
|
+
return_id?: number;
|
|
933
|
+
/** Status ID */
|
|
934
|
+
return_status_id?: number;
|
|
935
|
+
/** The status */
|
|
936
|
+
return_status?: ReturnStatus;
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
/**
|
|
940
|
+
* Data for setting return approval
|
|
941
|
+
*/
|
|
942
|
+
export declare interface SetReturnApprovalRequest {
|
|
943
|
+
/** Whether to approve the return */
|
|
944
|
+
approve: boolean;
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
/**
|
|
948
|
+
* Error thrown when authentication fails (401)
|
|
949
|
+
*/
|
|
950
|
+
export declare class UnauthorizedError extends JanusApiError {
|
|
951
|
+
constructor(message?: string, response?: unknown);
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
/**
|
|
955
|
+
* Data for updating a client
|
|
956
|
+
*/
|
|
957
|
+
export declare interface UpdateClientRequest {
|
|
958
|
+
/** Client name */
|
|
959
|
+
name?: string;
|
|
960
|
+
/** Short name */
|
|
961
|
+
short_name?: string;
|
|
962
|
+
/** Email */
|
|
963
|
+
email?: string;
|
|
964
|
+
/** Phone */
|
|
965
|
+
phone?: string;
|
|
966
|
+
/** Operational status */
|
|
967
|
+
operational_status?: string;
|
|
968
|
+
/** Settings object */
|
|
969
|
+
settings?: Record<string, unknown>;
|
|
970
|
+
/** Whether returns require approval */
|
|
971
|
+
requires_approval?: boolean;
|
|
972
|
+
/** Default courier service ID */
|
|
973
|
+
default_courier_service_id?: number;
|
|
974
|
+
/** Whether client is active */
|
|
975
|
+
active?: boolean;
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
/**
|
|
979
|
+
* Data for uploading a file
|
|
980
|
+
*/
|
|
981
|
+
export declare interface UploadFileRequest {
|
|
982
|
+
/** File content type (e.g., 'image/png') */
|
|
983
|
+
contentType: string;
|
|
984
|
+
/** File as base64 encoded string (without prefix) */
|
|
985
|
+
fileBase64: string;
|
|
986
|
+
/** Source of the upload */
|
|
987
|
+
from?: string;
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
/**
|
|
991
|
+
* File upload response
|
|
992
|
+
*/
|
|
993
|
+
export declare interface UploadFileResponse {
|
|
994
|
+
/** URL of the uploaded file */
|
|
995
|
+
url: string;
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
/**
|
|
999
|
+
* User Entity
|
|
1000
|
+
*
|
|
1001
|
+
* Represents a user in the JANUS system.
|
|
1002
|
+
*/
|
|
1003
|
+
export declare interface User extends BaseEntity {
|
|
1004
|
+
/** Username for login */
|
|
1005
|
+
username: string;
|
|
1006
|
+
/** User's first name */
|
|
1007
|
+
firstname?: string;
|
|
1008
|
+
/** User's last name */
|
|
1009
|
+
lastname?: string;
|
|
1010
|
+
/** Whether user is an admin */
|
|
1011
|
+
isAdmin?: boolean;
|
|
1012
|
+
/** API key for programmatic access */
|
|
1013
|
+
api_key?: string;
|
|
1014
|
+
/** Legacy user ID for migration */
|
|
1015
|
+
legacy_user_id?: number;
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
/**
|
|
1019
|
+
* Client access entry for a user
|
|
1020
|
+
*/
|
|
1021
|
+
export declare interface UserClientAccess {
|
|
1022
|
+
/** Client ID */
|
|
1023
|
+
id: number;
|
|
1024
|
+
/** Client name */
|
|
1025
|
+
name: string;
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
/**
|
|
1029
|
+
* Error thrown for validation errors (400)
|
|
1030
|
+
*/
|
|
1031
|
+
export declare class ValidationError extends JanusApiError {
|
|
1032
|
+
/** Validation error details */
|
|
1033
|
+
readonly errors?: Record<string, string[]>;
|
|
1034
|
+
constructor(message?: string, errors?: Record<string, string[]>, response?: unknown);
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
export { }
|