@glance-il/sdk 0.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/LICENSE +21 -0
- package/README.md +179 -0
- package/dist/index.cjs +571 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +819 -0
- package/dist/index.d.ts +819 -0
- package/dist/index.js +562 -0
- package/dist/index.js.map +1 -0
- package/package.json +48 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,819 @@
|
|
|
1
|
+
interface GlanceClientOptions {
|
|
2
|
+
apiKey: string;
|
|
3
|
+
baseUrl?: string;
|
|
4
|
+
timeout?: number;
|
|
5
|
+
fetch?: typeof globalThis.fetch;
|
|
6
|
+
}
|
|
7
|
+
interface ApiResponse<T> {
|
|
8
|
+
success: true;
|
|
9
|
+
data: T;
|
|
10
|
+
}
|
|
11
|
+
interface PaginationMeta {
|
|
12
|
+
total: number;
|
|
13
|
+
limit: number;
|
|
14
|
+
offset: number;
|
|
15
|
+
hasMore: boolean;
|
|
16
|
+
}
|
|
17
|
+
interface PaginatedResponse<T> {
|
|
18
|
+
success: true;
|
|
19
|
+
data: T[];
|
|
20
|
+
pagination: PaginationMeta;
|
|
21
|
+
}
|
|
22
|
+
interface RequestOptions {
|
|
23
|
+
signal?: AbortSignal;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
declare class HttpClient {
|
|
27
|
+
private readonly apiKey;
|
|
28
|
+
private readonly baseUrl;
|
|
29
|
+
private readonly timeout;
|
|
30
|
+
private readonly _fetch;
|
|
31
|
+
constructor(options: GlanceClientOptions);
|
|
32
|
+
get<T>(path: string, query?: Record<string, unknown>, options?: RequestOptions): Promise<T>;
|
|
33
|
+
post<T>(path: string, body?: unknown, options?: RequestOptions): Promise<T>;
|
|
34
|
+
put<T>(path: string, body?: unknown, options?: RequestOptions): Promise<T>;
|
|
35
|
+
delete<T>(path: string, options?: RequestOptions): Promise<T>;
|
|
36
|
+
private request;
|
|
37
|
+
private createError;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
declare abstract class BaseResource {
|
|
41
|
+
protected readonly http: HttpClient;
|
|
42
|
+
constructor(http: HttpClient);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
type ClientType = "MURSHE" | "COMPANY" | "PATOOR";
|
|
46
|
+
type PaymentTermType = "CURRENT_PLUS_DAYS" | "DAYS_ONLY";
|
|
47
|
+
type DocumentType = "quotation" | "order" | "delivery" | "return" | "invoice" | "invoiceReceipt" | "refund" | "bill" | "receipt";
|
|
48
|
+
type PurchaseDocumentType = "purchaseOrder" | "purchaseReceipt" | "supplierInvoice";
|
|
49
|
+
type PaymentMethod = "cash" | "check" | "creditCard" | "bankTransfer" | "giftCard" | "replacement" | "note" | "other";
|
|
50
|
+
type CustomFieldType = "text" | "number" | "date" | "select" | "boolean";
|
|
51
|
+
type CustomFieldEntityType = "client" | "product" | "document";
|
|
52
|
+
type EmployeeRole = "owner" | "manager" | "shift_manager" | "employee";
|
|
53
|
+
type SerialStatus = "IN_STOCK" | "SOLD" | "RESERVED" | "RETURNED";
|
|
54
|
+
type RetainerFrequency = "monthly" | "quarterly" | "yearly";
|
|
55
|
+
type RetainerDocumentType = "invoice" | "invoiceReceipt";
|
|
56
|
+
interface PaginationParams {
|
|
57
|
+
page?: number;
|
|
58
|
+
limit?: number;
|
|
59
|
+
}
|
|
60
|
+
interface DateRange {
|
|
61
|
+
startDate: string;
|
|
62
|
+
endDate: string;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
interface Contact {
|
|
66
|
+
visibleId: string;
|
|
67
|
+
firstName: string;
|
|
68
|
+
lastName?: string;
|
|
69
|
+
phoneNumber?: string;
|
|
70
|
+
email?: string;
|
|
71
|
+
addressId?: number;
|
|
72
|
+
clientVisibleId?: string;
|
|
73
|
+
}
|
|
74
|
+
interface CreateContactParams {
|
|
75
|
+
firstName: string;
|
|
76
|
+
lastName?: string;
|
|
77
|
+
phoneNumber?: string;
|
|
78
|
+
email?: string;
|
|
79
|
+
addressId?: number;
|
|
80
|
+
clientVisibleId?: string;
|
|
81
|
+
}
|
|
82
|
+
type UpdateContactParams = Partial<CreateContactParams>;
|
|
83
|
+
interface ListContactsParams extends PaginationParams {
|
|
84
|
+
search?: string;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
interface Address {
|
|
88
|
+
id: number;
|
|
89
|
+
name?: string;
|
|
90
|
+
street: string;
|
|
91
|
+
streetNumber?: string;
|
|
92
|
+
city: string;
|
|
93
|
+
notes?: string;
|
|
94
|
+
}
|
|
95
|
+
interface CreateAddressParams {
|
|
96
|
+
name?: string;
|
|
97
|
+
street: string;
|
|
98
|
+
streetNumber?: string;
|
|
99
|
+
city: string;
|
|
100
|
+
notes?: string;
|
|
101
|
+
}
|
|
102
|
+
type UpdateAddressParams = Partial<CreateAddressParams>;
|
|
103
|
+
interface ListAddressesParams extends PaginationParams {
|
|
104
|
+
search?: string;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
interface Client {
|
|
108
|
+
visibleId: string;
|
|
109
|
+
name: string;
|
|
110
|
+
taxId?: string;
|
|
111
|
+
type?: ClientType;
|
|
112
|
+
email?: string;
|
|
113
|
+
addressId?: number;
|
|
114
|
+
logoFileId?: number;
|
|
115
|
+
bankNumber?: string;
|
|
116
|
+
branchNumber?: string;
|
|
117
|
+
accountNumber?: string;
|
|
118
|
+
paymentTermType?: PaymentTermType;
|
|
119
|
+
paymentTermDays?: number;
|
|
120
|
+
contacts?: Contact[];
|
|
121
|
+
addresses?: Address[];
|
|
122
|
+
}
|
|
123
|
+
interface CreateClientParams {
|
|
124
|
+
name: string;
|
|
125
|
+
taxId?: string;
|
|
126
|
+
type?: ClientType;
|
|
127
|
+
email?: string;
|
|
128
|
+
addressId?: number;
|
|
129
|
+
logoFileId?: number;
|
|
130
|
+
bankNumber?: string;
|
|
131
|
+
branchNumber?: string;
|
|
132
|
+
accountNumber?: string;
|
|
133
|
+
paymentTermType?: PaymentTermType;
|
|
134
|
+
paymentTermDays?: number;
|
|
135
|
+
existingContactId?: number;
|
|
136
|
+
contact?: {
|
|
137
|
+
firstName: string;
|
|
138
|
+
lastName?: string;
|
|
139
|
+
phoneNumber?: string;
|
|
140
|
+
email?: string;
|
|
141
|
+
addressId?: number;
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
type UpdateClientParams = Partial<CreateClientParams>;
|
|
145
|
+
interface ListClientsParams extends PaginationParams {
|
|
146
|
+
search?: string;
|
|
147
|
+
type?: ClientType;
|
|
148
|
+
email?: string;
|
|
149
|
+
taxId?: string;
|
|
150
|
+
hasContacts?: boolean;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
declare class ClientsResource extends BaseResource {
|
|
154
|
+
list(params?: ListClientsParams): Promise<PaginatedResponse<Client>>;
|
|
155
|
+
get(visibleId: string): Promise<ApiResponse<Client>>;
|
|
156
|
+
create(params: CreateClientParams): Promise<ApiResponse<Client>>;
|
|
157
|
+
update(visibleId: string, params: UpdateClientParams): Promise<ApiResponse<Client>>;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
declare class ContactsResource extends BaseResource {
|
|
161
|
+
list(params?: ListContactsParams): Promise<PaginatedResponse<Contact>>;
|
|
162
|
+
get(visibleId: string): Promise<ApiResponse<Contact>>;
|
|
163
|
+
create(params: CreateContactParams): Promise<ApiResponse<Contact>>;
|
|
164
|
+
update(visibleId: string, params: UpdateContactParams): Promise<ApiResponse<Contact>>;
|
|
165
|
+
delete(visibleId: string): Promise<ApiResponse<void>>;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
declare class AddressesResource extends BaseResource {
|
|
169
|
+
list(params?: ListAddressesParams): Promise<PaginatedResponse<Address>>;
|
|
170
|
+
get(id: number): Promise<ApiResponse<Address>>;
|
|
171
|
+
create(params: CreateAddressParams): Promise<ApiResponse<Address>>;
|
|
172
|
+
update(id: number, params: UpdateAddressParams): Promise<ApiResponse<Address>>;
|
|
173
|
+
delete(id: number): Promise<ApiResponse<void>>;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
interface Product {
|
|
177
|
+
id: number;
|
|
178
|
+
visibleId: string;
|
|
179
|
+
name: string;
|
|
180
|
+
sku: string;
|
|
181
|
+
description?: string;
|
|
182
|
+
unit?: string;
|
|
183
|
+
fileId?: number;
|
|
184
|
+
vendorId?: number;
|
|
185
|
+
isPhysical?: boolean;
|
|
186
|
+
unitCost?: number;
|
|
187
|
+
buyingPrice?: number;
|
|
188
|
+
minStockLevel?: number;
|
|
189
|
+
maxStockLevel?: number;
|
|
190
|
+
trackSerialNumbers?: boolean;
|
|
191
|
+
isActive?: boolean;
|
|
192
|
+
isWithInventory?: boolean;
|
|
193
|
+
createdAt?: string;
|
|
194
|
+
updatedAt?: string;
|
|
195
|
+
}
|
|
196
|
+
interface CreateProductParams {
|
|
197
|
+
name: string;
|
|
198
|
+
sku: string;
|
|
199
|
+
description?: string;
|
|
200
|
+
unit?: string;
|
|
201
|
+
fileId?: number;
|
|
202
|
+
vendorId?: number;
|
|
203
|
+
isPhysical?: boolean;
|
|
204
|
+
unitCost?: number;
|
|
205
|
+
buyingPrice?: number;
|
|
206
|
+
minStockLevel?: number;
|
|
207
|
+
maxStockLevel?: number;
|
|
208
|
+
trackSerialNumbers?: boolean;
|
|
209
|
+
isWithInventory?: boolean;
|
|
210
|
+
warehouseId?: number;
|
|
211
|
+
startingInventory?: number;
|
|
212
|
+
inventoryLocation?: string;
|
|
213
|
+
}
|
|
214
|
+
type UpdateProductParams = Partial<CreateProductParams>;
|
|
215
|
+
interface ListProductsParams extends PaginationParams {
|
|
216
|
+
search?: string;
|
|
217
|
+
vendorId?: number;
|
|
218
|
+
isPhysical?: boolean;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
declare class ProductsResource extends BaseResource {
|
|
222
|
+
list(params?: ListProductsParams): Promise<PaginatedResponse<Product>>;
|
|
223
|
+
get(id: number): Promise<ApiResponse<Product>>;
|
|
224
|
+
getBySku(sku: string): Promise<ApiResponse<Product>>;
|
|
225
|
+
create(params: CreateProductParams): Promise<ApiResponse<Product>>;
|
|
226
|
+
update(id: number, params: UpdateProductParams): Promise<ApiResponse<Product>>;
|
|
227
|
+
delete(id: number): Promise<ApiResponse<void>>;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
interface ProductSerial {
|
|
231
|
+
id: number;
|
|
232
|
+
visibleId: string;
|
|
233
|
+
productId: number;
|
|
234
|
+
warehouseId: number;
|
|
235
|
+
serialNumber: string;
|
|
236
|
+
status: SerialStatus;
|
|
237
|
+
createdAt?: string;
|
|
238
|
+
updatedAt?: string;
|
|
239
|
+
}
|
|
240
|
+
interface CreateProductSerialsParams {
|
|
241
|
+
serials: Array<{
|
|
242
|
+
serialNumber: string;
|
|
243
|
+
warehouseId: number;
|
|
244
|
+
}>;
|
|
245
|
+
}
|
|
246
|
+
interface UpdateProductSerialParams {
|
|
247
|
+
serialNumber?: string;
|
|
248
|
+
warehouseId?: number;
|
|
249
|
+
status?: SerialStatus;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
declare class ProductSerialsResource extends BaseResource {
|
|
253
|
+
list(productId: number): Promise<PaginatedResponse<ProductSerial>>;
|
|
254
|
+
create(productId: number, params: CreateProductSerialsParams): Promise<ApiResponse<ProductSerial[]>>;
|
|
255
|
+
update(serialId: number, params: UpdateProductSerialParams): Promise<ApiResponse<ProductSerial>>;
|
|
256
|
+
delete(serialId: number): Promise<ApiResponse<void>>;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
interface Warehouse {
|
|
260
|
+
id: number;
|
|
261
|
+
visibleId: string;
|
|
262
|
+
name: string;
|
|
263
|
+
code?: string;
|
|
264
|
+
description?: string;
|
|
265
|
+
addressId?: number;
|
|
266
|
+
isActive?: boolean;
|
|
267
|
+
isDefault?: boolean;
|
|
268
|
+
createdAt?: string;
|
|
269
|
+
updatedAt?: string;
|
|
270
|
+
}
|
|
271
|
+
interface CreateWarehouseParams {
|
|
272
|
+
name: string;
|
|
273
|
+
code?: string;
|
|
274
|
+
description?: string;
|
|
275
|
+
addressId?: number;
|
|
276
|
+
}
|
|
277
|
+
type UpdateWarehouseParams = Partial<CreateWarehouseParams>;
|
|
278
|
+
type ListWarehousesParams = PaginationParams;
|
|
279
|
+
|
|
280
|
+
declare class WarehousesResource extends BaseResource {
|
|
281
|
+
list(params?: ListWarehousesParams): Promise<PaginatedResponse<Warehouse>>;
|
|
282
|
+
get(id: number): Promise<ApiResponse<Warehouse>>;
|
|
283
|
+
create(params: CreateWarehouseParams): Promise<ApiResponse<Warehouse>>;
|
|
284
|
+
update(id: number, params: UpdateWarehouseParams): Promise<ApiResponse<Warehouse>>;
|
|
285
|
+
delete(id: number): Promise<ApiResponse<void>>;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
interface Inventory {
|
|
289
|
+
id: number;
|
|
290
|
+
visibleId: string;
|
|
291
|
+
productId: number;
|
|
292
|
+
warehouseId: number;
|
|
293
|
+
quantity: number;
|
|
294
|
+
reservedQuantity?: number;
|
|
295
|
+
minStockLevel?: number;
|
|
296
|
+
maxStockLevel?: number;
|
|
297
|
+
location?: string;
|
|
298
|
+
createdAt?: string;
|
|
299
|
+
updatedAt?: string;
|
|
300
|
+
}
|
|
301
|
+
interface CreateInventoryParams {
|
|
302
|
+
productId: number;
|
|
303
|
+
warehouseId: number;
|
|
304
|
+
quantity?: number;
|
|
305
|
+
location?: string;
|
|
306
|
+
}
|
|
307
|
+
interface UpdateInventoryParams {
|
|
308
|
+
quantity?: number;
|
|
309
|
+
location?: string;
|
|
310
|
+
}
|
|
311
|
+
interface AdjustInventoryParams {
|
|
312
|
+
actions: Array<{
|
|
313
|
+
productId: number;
|
|
314
|
+
warehouseId: number;
|
|
315
|
+
amount: number;
|
|
316
|
+
reason?: string;
|
|
317
|
+
notes?: string;
|
|
318
|
+
}>;
|
|
319
|
+
}
|
|
320
|
+
interface ListInventoryParams extends PaginationParams {
|
|
321
|
+
search?: string;
|
|
322
|
+
warehouseId?: number;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
declare class InventoryResource extends BaseResource {
|
|
326
|
+
list(params?: ListInventoryParams): Promise<PaginatedResponse<Inventory>>;
|
|
327
|
+
get(id: number): Promise<ApiResponse<Inventory>>;
|
|
328
|
+
getByProduct(productId: number): Promise<ApiResponse<Inventory[]>>;
|
|
329
|
+
create(params: CreateInventoryParams): Promise<ApiResponse<Inventory>>;
|
|
330
|
+
update(id: number, params: UpdateInventoryParams): Promise<ApiResponse<Inventory>>;
|
|
331
|
+
delete(id: number): Promise<ApiResponse<void>>;
|
|
332
|
+
adjust(params: AdjustInventoryParams): Promise<ApiResponse<void>>;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
interface InventoryMovement {
|
|
336
|
+
id: number;
|
|
337
|
+
productId: number;
|
|
338
|
+
fromWarehouseId?: number;
|
|
339
|
+
toWarehouseId?: number;
|
|
340
|
+
quantity: number;
|
|
341
|
+
type: string;
|
|
342
|
+
reason?: string;
|
|
343
|
+
createdAt?: string;
|
|
344
|
+
}
|
|
345
|
+
interface CreateInventoryMovementParams {
|
|
346
|
+
productId: number;
|
|
347
|
+
quantity: number;
|
|
348
|
+
fromWarehouseId?: number;
|
|
349
|
+
toWarehouseId?: number;
|
|
350
|
+
reason?: string;
|
|
351
|
+
}
|
|
352
|
+
interface ListInventoryMovementsParams extends PaginationParams {
|
|
353
|
+
productId?: number;
|
|
354
|
+
warehouseId?: number;
|
|
355
|
+
type?: string;
|
|
356
|
+
startDate?: string;
|
|
357
|
+
endDate?: string;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
declare class InventoryMovementsResource extends BaseResource {
|
|
361
|
+
list(params?: ListInventoryMovementsParams): Promise<PaginatedResponse<InventoryMovement>>;
|
|
362
|
+
create(params: CreateInventoryMovementParams): Promise<ApiResponse<InventoryMovement>>;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
interface DocumentProduct {
|
|
366
|
+
description: string;
|
|
367
|
+
units: number;
|
|
368
|
+
price: number;
|
|
369
|
+
sku?: string;
|
|
370
|
+
typeOfUnit?: string;
|
|
371
|
+
discount?: number;
|
|
372
|
+
discountOn?: "price" | "total";
|
|
373
|
+
discountType?: "percentage" | "fixed";
|
|
374
|
+
warehouseId?: number;
|
|
375
|
+
serialNumbers?: string[];
|
|
376
|
+
customFields?: Array<{
|
|
377
|
+
id: number;
|
|
378
|
+
value: string | number | boolean;
|
|
379
|
+
}>;
|
|
380
|
+
}
|
|
381
|
+
interface DocumentPayment {
|
|
382
|
+
amount: number;
|
|
383
|
+
paymentMethod?: PaymentMethod;
|
|
384
|
+
date?: string;
|
|
385
|
+
details?: Array<Record<string, unknown>>;
|
|
386
|
+
ledgerId?: number;
|
|
387
|
+
}
|
|
388
|
+
interface GlanceDocument {
|
|
389
|
+
visibleId: string;
|
|
390
|
+
type: DocumentType;
|
|
391
|
+
number?: number;
|
|
392
|
+
title?: string;
|
|
393
|
+
date?: string;
|
|
394
|
+
payBy?: string;
|
|
395
|
+
clientId?: string;
|
|
396
|
+
client?: Record<string, unknown>;
|
|
397
|
+
products?: DocumentProduct[];
|
|
398
|
+
payments?: DocumentPayment[];
|
|
399
|
+
amount?: number;
|
|
400
|
+
tax?: number;
|
|
401
|
+
totalWithTax?: number;
|
|
402
|
+
discount?: number;
|
|
403
|
+
discountType?: "percentage" | "fixed";
|
|
404
|
+
notes?: string;
|
|
405
|
+
fileId?: number;
|
|
406
|
+
relatedDocuments?: string[];
|
|
407
|
+
createdAt?: string;
|
|
408
|
+
updatedAt?: string;
|
|
409
|
+
}
|
|
410
|
+
interface CreateDocumentParams {
|
|
411
|
+
clientId?: string;
|
|
412
|
+
client?: {
|
|
413
|
+
name: string;
|
|
414
|
+
taxId?: string;
|
|
415
|
+
type?: string;
|
|
416
|
+
email?: string;
|
|
417
|
+
};
|
|
418
|
+
title?: string;
|
|
419
|
+
products: DocumentProduct[];
|
|
420
|
+
payments?: DocumentPayment[];
|
|
421
|
+
date?: string;
|
|
422
|
+
payBy?: string;
|
|
423
|
+
tax?: number;
|
|
424
|
+
discount?: number;
|
|
425
|
+
discountType?: "percentage" | "fixed";
|
|
426
|
+
taxMode?: "inclusive" | "exclusive";
|
|
427
|
+
notes?: string;
|
|
428
|
+
withSignature?: boolean;
|
|
429
|
+
relatedDocuments?: string[];
|
|
430
|
+
sendToClient?: boolean;
|
|
431
|
+
emailRecipients?: string[];
|
|
432
|
+
skipInventoryActions?: boolean;
|
|
433
|
+
}
|
|
434
|
+
type UpdateDocumentParams = Partial<CreateDocumentParams>;
|
|
435
|
+
interface ListDocumentsParams extends PaginationParams {
|
|
436
|
+
type?: DocumentType;
|
|
437
|
+
startDate?: string;
|
|
438
|
+
endDate?: string;
|
|
439
|
+
clientId?: string;
|
|
440
|
+
open?: boolean;
|
|
441
|
+
sku?: string;
|
|
442
|
+
search?: string;
|
|
443
|
+
}
|
|
444
|
+
interface AllocateReceiptParams {
|
|
445
|
+
invoiceIds: string[];
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
declare class DocumentsResource extends BaseResource {
|
|
449
|
+
list(params?: ListDocumentsParams): Promise<PaginatedResponse<GlanceDocument>>;
|
|
450
|
+
get(visibleId: string): Promise<ApiResponse<GlanceDocument>>;
|
|
451
|
+
create(type: DocumentType, params: CreateDocumentParams): Promise<ApiResponse<GlanceDocument>>;
|
|
452
|
+
update(visibleId: string, params: UpdateDocumentParams): Promise<ApiResponse<GlanceDocument>>;
|
|
453
|
+
close(visibleId: string): Promise<ApiResponse<GlanceDocument>>;
|
|
454
|
+
allocate(visibleId: string, params: AllocateReceiptParams): Promise<ApiResponse<void>>;
|
|
455
|
+
cancelReceipt(visibleId: string): Promise<ApiResponse<void>>;
|
|
456
|
+
getSettings(route: string): Promise<ApiResponse<unknown>>;
|
|
457
|
+
previewPdf(type: DocumentType, params: CreateDocumentParams): Promise<ApiResponse<unknown>>;
|
|
458
|
+
previewHtml(params: CreateDocumentParams): Promise<ApiResponse<unknown>>;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
interface Vendor {
|
|
462
|
+
visibleId: string;
|
|
463
|
+
name: string;
|
|
464
|
+
taxId?: string;
|
|
465
|
+
email?: string;
|
|
466
|
+
bankNumber?: string;
|
|
467
|
+
branchNumber?: string;
|
|
468
|
+
accountNumber?: string;
|
|
469
|
+
}
|
|
470
|
+
interface CreateVendorParams {
|
|
471
|
+
name: string;
|
|
472
|
+
taxId?: string;
|
|
473
|
+
email?: string;
|
|
474
|
+
bankNumber?: string;
|
|
475
|
+
branchNumber?: string;
|
|
476
|
+
accountNumber?: string;
|
|
477
|
+
}
|
|
478
|
+
type UpdateVendorParams = Partial<CreateVendorParams>;
|
|
479
|
+
interface ListVendorsParams extends PaginationParams {
|
|
480
|
+
search?: string;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
declare class VendorsResource extends BaseResource {
|
|
484
|
+
list(params?: ListVendorsParams): Promise<PaginatedResponse<Vendor>>;
|
|
485
|
+
get(visibleId: string): Promise<ApiResponse<Vendor>>;
|
|
486
|
+
create(params: CreateVendorParams): Promise<ApiResponse<Vendor>>;
|
|
487
|
+
update(visibleId: string, params: UpdateVendorParams): Promise<ApiResponse<Vendor>>;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
interface PurchaseDocument {
|
|
491
|
+
visibleId: string;
|
|
492
|
+
type: PurchaseDocumentType;
|
|
493
|
+
vendorId?: string;
|
|
494
|
+
title?: string;
|
|
495
|
+
products?: DocumentProduct[];
|
|
496
|
+
date?: string;
|
|
497
|
+
tax?: number;
|
|
498
|
+
notes?: string;
|
|
499
|
+
amount?: number;
|
|
500
|
+
totalWithTax?: number;
|
|
501
|
+
relatedDocuments?: string[];
|
|
502
|
+
createdAt?: string;
|
|
503
|
+
}
|
|
504
|
+
interface CreatePurchaseDocumentParams {
|
|
505
|
+
vendorId: string;
|
|
506
|
+
title?: string;
|
|
507
|
+
products: DocumentProduct[];
|
|
508
|
+
date?: string;
|
|
509
|
+
tax?: number;
|
|
510
|
+
notes?: string;
|
|
511
|
+
relatedDocuments?: string[];
|
|
512
|
+
}
|
|
513
|
+
interface ListPurchaseDocumentsParams extends PaginationParams {
|
|
514
|
+
type?: PurchaseDocumentType;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
declare class PurchaseResource extends BaseResource {
|
|
518
|
+
list(params?: ListPurchaseDocumentsParams): Promise<PaginatedResponse<PurchaseDocument>>;
|
|
519
|
+
get(visibleId: string): Promise<ApiResponse<PurchaseDocument>>;
|
|
520
|
+
create(type: PurchaseDocumentType, params: CreatePurchaseDocumentParams): Promise<ApiResponse<PurchaseDocument>>;
|
|
521
|
+
close(visibleId: string): Promise<ApiResponse<PurchaseDocument>>;
|
|
522
|
+
getSettings(route: string): Promise<ApiResponse<unknown>>;
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
interface Expense {
|
|
526
|
+
id: number;
|
|
527
|
+
vendorId: number;
|
|
528
|
+
fileId?: number;
|
|
529
|
+
title?: string;
|
|
530
|
+
notes?: string;
|
|
531
|
+
date: string;
|
|
532
|
+
documentNumber?: string;
|
|
533
|
+
currency?: string;
|
|
534
|
+
total: number;
|
|
535
|
+
tax: number;
|
|
536
|
+
deductableTax: number;
|
|
537
|
+
isEquipment?: boolean;
|
|
538
|
+
createdAt?: string;
|
|
539
|
+
}
|
|
540
|
+
interface CreateExpenseParams {
|
|
541
|
+
vendorId: number;
|
|
542
|
+
fileId: number;
|
|
543
|
+
date: string;
|
|
544
|
+
total: number;
|
|
545
|
+
tax: number;
|
|
546
|
+
deductableTax: number;
|
|
547
|
+
title?: string;
|
|
548
|
+
notes?: string;
|
|
549
|
+
documentNumber?: string;
|
|
550
|
+
currency?: string;
|
|
551
|
+
isEquipment?: boolean;
|
|
552
|
+
}
|
|
553
|
+
type UpdateExpenseParams = Partial<CreateExpenseParams>;
|
|
554
|
+
interface ListExpensesParams extends PaginationParams {
|
|
555
|
+
search?: string;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
declare class ExpensesResource extends BaseResource {
|
|
559
|
+
list(params?: ListExpensesParams): Promise<PaginatedResponse<Expense>>;
|
|
560
|
+
get(id: number): Promise<ApiResponse<Expense>>;
|
|
561
|
+
create(params: CreateExpenseParams): Promise<ApiResponse<Expense>>;
|
|
562
|
+
update(id: number, params: UpdateExpenseParams): Promise<ApiResponse<Expense>>;
|
|
563
|
+
delete(id: number): Promise<ApiResponse<void>>;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
interface Retainer {
|
|
567
|
+
id: number;
|
|
568
|
+
visibleId: string;
|
|
569
|
+
clientId: string;
|
|
570
|
+
amount: number;
|
|
571
|
+
frequency: RetainerFrequency;
|
|
572
|
+
documentType: RetainerDocumentType;
|
|
573
|
+
startDate: string;
|
|
574
|
+
endDate?: string;
|
|
575
|
+
products?: DocumentProduct[];
|
|
576
|
+
isActive?: boolean;
|
|
577
|
+
nextRunDate?: string;
|
|
578
|
+
runsCount?: number;
|
|
579
|
+
createdAt?: string;
|
|
580
|
+
}
|
|
581
|
+
interface CreateRetainerParams {
|
|
582
|
+
clientId: string;
|
|
583
|
+
amount: number;
|
|
584
|
+
frequency: RetainerFrequency;
|
|
585
|
+
documentType: RetainerDocumentType;
|
|
586
|
+
startDate: string;
|
|
587
|
+
endDate?: string;
|
|
588
|
+
products: DocumentProduct[];
|
|
589
|
+
notes?: string;
|
|
590
|
+
}
|
|
591
|
+
type UpdateRetainerParams = Partial<CreateRetainerParams>;
|
|
592
|
+
type ListRetainersParams = PaginationParams;
|
|
593
|
+
|
|
594
|
+
declare class RetainersResource extends BaseResource {
|
|
595
|
+
list(params?: ListRetainersParams): Promise<PaginatedResponse<Retainer>>;
|
|
596
|
+
get(id: string): Promise<ApiResponse<Retainer>>;
|
|
597
|
+
create(params: CreateRetainerParams): Promise<ApiResponse<Retainer>>;
|
|
598
|
+
update(id: string, params: UpdateRetainerParams): Promise<ApiResponse<Retainer>>;
|
|
599
|
+
delete(id: string): Promise<ApiResponse<void>>;
|
|
600
|
+
reactivate(id: string): Promise<ApiResponse<Retainer>>;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
type IncomeReportParams = DateRange;
|
|
604
|
+
type ExpensesReportParams = DateRange;
|
|
605
|
+
interface DocumentsReportParams extends DateRange {
|
|
606
|
+
type?: DocumentType;
|
|
607
|
+
}
|
|
608
|
+
type MaamReportParams = DateRange;
|
|
609
|
+
interface ReportResponse {
|
|
610
|
+
total: number;
|
|
611
|
+
months: Array<{
|
|
612
|
+
month: string;
|
|
613
|
+
total: number;
|
|
614
|
+
}>;
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
declare class ReportsResource extends BaseResource {
|
|
618
|
+
income(params: IncomeReportParams): Promise<ApiResponse<ReportResponse>>;
|
|
619
|
+
expenses(params: ExpensesReportParams): Promise<ApiResponse<ReportResponse>>;
|
|
620
|
+
documents(params: DocumentsReportParams): Promise<ApiResponse<ReportResponse>>;
|
|
621
|
+
maam(params: MaamReportParams): Promise<ApiResponse<ReportResponse>>;
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
interface Employee {
|
|
625
|
+
visibleId: string;
|
|
626
|
+
firstName: string;
|
|
627
|
+
lastName?: string;
|
|
628
|
+
email: string;
|
|
629
|
+
phoneNumber?: string;
|
|
630
|
+
role?: EmployeeRole;
|
|
631
|
+
groupIds?: number[];
|
|
632
|
+
createdAt?: string;
|
|
633
|
+
}
|
|
634
|
+
interface CreateEmployeeParams {
|
|
635
|
+
firstName: string;
|
|
636
|
+
lastName?: string;
|
|
637
|
+
email: string;
|
|
638
|
+
phoneNumber?: string;
|
|
639
|
+
role?: EmployeeRole;
|
|
640
|
+
groupIds?: number[];
|
|
641
|
+
}
|
|
642
|
+
type UpdateEmployeeParams = Partial<CreateEmployeeParams>;
|
|
643
|
+
interface ListEmployeesParams extends PaginationParams {
|
|
644
|
+
search?: string;
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
declare class EmployeesResource extends BaseResource {
|
|
648
|
+
list(params?: ListEmployeesParams): Promise<PaginatedResponse<Employee>>;
|
|
649
|
+
get(visibleId: string): Promise<ApiResponse<Employee>>;
|
|
650
|
+
create(params: CreateEmployeeParams): Promise<ApiResponse<Employee>>;
|
|
651
|
+
update(visibleId: string, params: UpdateEmployeeParams): Promise<ApiResponse<Employee>>;
|
|
652
|
+
delete(visibleId: string): Promise<ApiResponse<void>>;
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
interface GlanceFile {
|
|
656
|
+
visibleId: string;
|
|
657
|
+
name: string;
|
|
658
|
+
type: string;
|
|
659
|
+
size: number;
|
|
660
|
+
remoteUrl?: string;
|
|
661
|
+
createdAt?: string;
|
|
662
|
+
}
|
|
663
|
+
interface ListFilesParams extends PaginationParams {
|
|
664
|
+
entityType?: string;
|
|
665
|
+
entityId?: number;
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
declare class FilesResource extends BaseResource {
|
|
669
|
+
list(params?: ListFilesParams): Promise<PaginatedResponse<GlanceFile>>;
|
|
670
|
+
get(visibleId: string): Promise<ApiResponse<GlanceFile>>;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
interface CustomField {
|
|
674
|
+
id: number;
|
|
675
|
+
name: string;
|
|
676
|
+
type: CustomFieldType;
|
|
677
|
+
entityType: CustomFieldEntityType;
|
|
678
|
+
options?: string[];
|
|
679
|
+
isRequired?: boolean;
|
|
680
|
+
showInDocuments?: boolean;
|
|
681
|
+
order?: number;
|
|
682
|
+
}
|
|
683
|
+
interface CreateCustomFieldParams {
|
|
684
|
+
label: string;
|
|
685
|
+
entityType: CustomFieldEntityType;
|
|
686
|
+
fieldType: CustomFieldType;
|
|
687
|
+
options?: string[];
|
|
688
|
+
required?: boolean;
|
|
689
|
+
}
|
|
690
|
+
type UpdateCustomFieldParams = Partial<CreateCustomFieldParams>;
|
|
691
|
+
interface CustomFieldValue {
|
|
692
|
+
fieldId: number;
|
|
693
|
+
value: string | number | boolean;
|
|
694
|
+
}
|
|
695
|
+
interface SetCustomFieldValuesParams {
|
|
696
|
+
values: CustomFieldValue[];
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
declare class CustomFieldsResource extends BaseResource {
|
|
700
|
+
list(): Promise<ApiResponse<CustomField[]>>;
|
|
701
|
+
listByType(entityType: CustomFieldEntityType): Promise<ApiResponse<CustomField[]>>;
|
|
702
|
+
create(params: CreateCustomFieldParams): Promise<ApiResponse<CustomField>>;
|
|
703
|
+
update(id: number, params: UpdateCustomFieldParams): Promise<ApiResponse<CustomField>>;
|
|
704
|
+
delete(id: number): Promise<ApiResponse<void>>;
|
|
705
|
+
getValues(entityId: number): Promise<ApiResponse<CustomFieldValue[]>>;
|
|
706
|
+
setValues(entityId: number, params: SetCustomFieldValuesParams): Promise<ApiResponse<void>>;
|
|
707
|
+
getProductValues(productId: number): Promise<ApiResponse<CustomFieldValue[]>>;
|
|
708
|
+
setProductValues(productId: number, params: SetCustomFieldValuesParams): Promise<ApiResponse<void>>;
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
interface Transaction {
|
|
712
|
+
id: string;
|
|
713
|
+
amount: number;
|
|
714
|
+
currency?: string;
|
|
715
|
+
status: string;
|
|
716
|
+
description?: string;
|
|
717
|
+
clientId?: string;
|
|
718
|
+
documentId?: string;
|
|
719
|
+
createdAt?: string;
|
|
720
|
+
}
|
|
721
|
+
interface ChargeParams {
|
|
722
|
+
amount: number;
|
|
723
|
+
cardToken: string;
|
|
724
|
+
currency?: string;
|
|
725
|
+
description?: string;
|
|
726
|
+
clientId?: string;
|
|
727
|
+
documentId?: string;
|
|
728
|
+
}
|
|
729
|
+
interface RefundParams {
|
|
730
|
+
transactionId: string;
|
|
731
|
+
amount: number;
|
|
732
|
+
reason: string;
|
|
733
|
+
}
|
|
734
|
+
interface ListTransactionsParams extends PaginationParams {
|
|
735
|
+
startDate?: string;
|
|
736
|
+
endDate?: string;
|
|
737
|
+
status?: string;
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
declare class PaymentsResource extends BaseResource {
|
|
741
|
+
charge(params: ChargeParams): Promise<ApiResponse<Transaction>>;
|
|
742
|
+
refund(params: RefundParams): Promise<ApiResponse<Transaction>>;
|
|
743
|
+
listTransactions(params?: ListTransactionsParams): Promise<PaginatedResponse<Transaction>>;
|
|
744
|
+
getTransaction(id: string): Promise<ApiResponse<Transaction>>;
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
interface Settings {
|
|
748
|
+
companyName?: string;
|
|
749
|
+
taxId?: string;
|
|
750
|
+
currency?: string;
|
|
751
|
+
taxRate?: number;
|
|
752
|
+
language?: string;
|
|
753
|
+
timezone?: string;
|
|
754
|
+
logo?: string;
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
declare class SettingsResource extends BaseResource {
|
|
758
|
+
get(): Promise<ApiResponse<Settings>>;
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
declare class GlanceClient {
|
|
762
|
+
readonly clients: ClientsResource;
|
|
763
|
+
readonly contacts: ContactsResource;
|
|
764
|
+
readonly addresses: AddressesResource;
|
|
765
|
+
readonly products: ProductsResource;
|
|
766
|
+
readonly productSerials: ProductSerialsResource;
|
|
767
|
+
readonly warehouses: WarehousesResource;
|
|
768
|
+
readonly inventory: InventoryResource;
|
|
769
|
+
readonly inventoryMovements: InventoryMovementsResource;
|
|
770
|
+
readonly documents: DocumentsResource;
|
|
771
|
+
readonly vendors: VendorsResource;
|
|
772
|
+
readonly purchase: PurchaseResource;
|
|
773
|
+
readonly expenses: ExpensesResource;
|
|
774
|
+
readonly retainers: RetainersResource;
|
|
775
|
+
readonly reports: ReportsResource;
|
|
776
|
+
readonly employees: EmployeesResource;
|
|
777
|
+
readonly files: FilesResource;
|
|
778
|
+
readonly customFields: CustomFieldsResource;
|
|
779
|
+
readonly payments: PaymentsResource;
|
|
780
|
+
readonly settings: SettingsResource;
|
|
781
|
+
constructor(options: GlanceClientOptions);
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
declare class GlanceError extends Error {
|
|
785
|
+
name: string;
|
|
786
|
+
constructor(message: string);
|
|
787
|
+
}
|
|
788
|
+
declare class GlanceApiError extends GlanceError {
|
|
789
|
+
readonly status: number;
|
|
790
|
+
readonly code?: string | undefined;
|
|
791
|
+
name: string;
|
|
792
|
+
constructor(status: number, message: string, code?: string | undefined);
|
|
793
|
+
}
|
|
794
|
+
declare class GlanceAuthenticationError extends GlanceApiError {
|
|
795
|
+
name: string;
|
|
796
|
+
constructor(message?: string);
|
|
797
|
+
}
|
|
798
|
+
declare class GlanceNotFoundError extends GlanceApiError {
|
|
799
|
+
name: string;
|
|
800
|
+
constructor(message?: string, code?: string);
|
|
801
|
+
}
|
|
802
|
+
declare class GlanceValidationError extends GlanceApiError {
|
|
803
|
+
readonly issues?: unknown[] | undefined;
|
|
804
|
+
name: string;
|
|
805
|
+
constructor(message?: string, issues?: unknown[] | undefined);
|
|
806
|
+
}
|
|
807
|
+
declare class GlanceRateLimitError extends GlanceApiError {
|
|
808
|
+
name: string;
|
|
809
|
+
constructor(message?: string);
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
interface PageResult<T> {
|
|
813
|
+
data: T[];
|
|
814
|
+
pagination: PaginationMeta;
|
|
815
|
+
hasMore: boolean;
|
|
816
|
+
}
|
|
817
|
+
declare function toPageResult<T>(response: PaginatedResponse<T>): PageResult<T>;
|
|
818
|
+
|
|
819
|
+
export { type Address, type AdjustInventoryParams, type AllocateReceiptParams, type ApiResponse, type ChargeParams, type Client, type ClientType, type Contact, type CreateAddressParams, type CreateClientParams, type CreateContactParams, type CreateCustomFieldParams, type CreateDocumentParams, type CreateEmployeeParams, type CreateExpenseParams, type CreateInventoryMovementParams, type CreateInventoryParams, type CreateProductParams, type CreateProductSerialsParams, type CreatePurchaseDocumentParams, type CreateRetainerParams, type CreateVendorParams, type CreateWarehouseParams, type CustomField, type CustomFieldEntityType, type CustomFieldType, type CustomFieldValue, type DateRange, type DocumentPayment, type DocumentProduct, type DocumentType, type DocumentsReportParams, type Employee, type EmployeeRole, type Expense, type ExpensesReportParams, GlanceApiError, GlanceAuthenticationError, GlanceClient, type GlanceClientOptions, type GlanceDocument, GlanceError, type GlanceFile, GlanceNotFoundError, GlanceRateLimitError, GlanceValidationError, type IncomeReportParams, type Inventory, type InventoryMovement, type ListAddressesParams, type ListClientsParams, type ListContactsParams, type ListDocumentsParams, type ListEmployeesParams, type ListExpensesParams, type ListFilesParams, type ListInventoryMovementsParams, type ListInventoryParams, type ListProductsParams, type ListPurchaseDocumentsParams, type ListRetainersParams, type ListTransactionsParams, type ListVendorsParams, type ListWarehousesParams, type MaamReportParams, type PageResult, type PaginatedResponse, type PaginationMeta, type PaginationParams, type PaymentMethod, type PaymentTermType, type Product, type ProductSerial, type PurchaseDocument, type PurchaseDocumentType, type RefundParams, type ReportResponse, type RequestOptions, type Retainer, type RetainerDocumentType, type RetainerFrequency, type SerialStatus, type SetCustomFieldValuesParams, type Settings, type Transaction, type UpdateAddressParams, type UpdateClientParams, type UpdateContactParams, type UpdateCustomFieldParams, type UpdateDocumentParams, type UpdateEmployeeParams, type UpdateExpenseParams, type UpdateInventoryParams, type UpdateProductParams, type UpdateProductSerialParams, type UpdateRetainerParams, type UpdateVendorParams, type UpdateWarehouseParams, type Vendor, type Warehouse, toPageResult };
|