tiime-cli 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.
@@ -0,0 +1,554 @@
1
+ import { $Fetch } from 'ofetch';
2
+
3
+ interface AuthTokens {
4
+ access_token: string;
5
+ expires_at: number;
6
+ }
7
+ interface AuthConfig {
8
+ email: string;
9
+ password: string;
10
+ }
11
+ interface TiimeClientOptions {
12
+ companyId: number;
13
+ tokens?: AuthTokens;
14
+ }
15
+ interface Address {
16
+ street: string;
17
+ additional_information1: string | null;
18
+ additional_information2: string | null;
19
+ postal_code: string;
20
+ city: string;
21
+ country: Country;
22
+ }
23
+ interface Country {
24
+ id?: number;
25
+ name: string;
26
+ code: string;
27
+ invoicing_vat_exoneration_area?: string;
28
+ nationality?: string;
29
+ }
30
+ interface User {
31
+ id: number;
32
+ firstname: string;
33
+ lastname: string;
34
+ email: string;
35
+ phone: string;
36
+ civility: string;
37
+ status: string;
38
+ roles: string[];
39
+ active_company: number;
40
+ director: boolean;
41
+ has_wallet_access: boolean;
42
+ has_business_account: boolean;
43
+ address: Address;
44
+ created_at: string;
45
+ acronym: string;
46
+ }
47
+ interface ApeCode {
48
+ id: number;
49
+ code: string;
50
+ label: string;
51
+ }
52
+ interface VatSystem {
53
+ id: number;
54
+ code: string;
55
+ label: string;
56
+ type: string;
57
+ }
58
+ interface Company {
59
+ id: number;
60
+ name: string;
61
+ legal_form: string;
62
+ siret: string;
63
+ vat_number: string;
64
+ intracom_vat_number: string;
65
+ ape_code: ApeCode;
66
+ street: string;
67
+ address_complement: string | null;
68
+ postal_code: string;
69
+ city: string;
70
+ country: string;
71
+ share_capital: number;
72
+ registration_date: string;
73
+ activity_start_date: string;
74
+ vat_system: VatSystem;
75
+ tax_regime: string;
76
+ receipt_email: string;
77
+ payment_email: string;
78
+ has_invoices: boolean;
79
+ logo: {
80
+ id: number;
81
+ };
82
+ uuid: string;
83
+ slug: string;
84
+ }
85
+ interface Client {
86
+ id: number;
87
+ name: string;
88
+ slug: string;
89
+ address: string;
90
+ address_complement: string | null;
91
+ postal_code: string;
92
+ city: string;
93
+ country: Country;
94
+ country_code: string;
95
+ email: string | null;
96
+ phone: string | null;
97
+ siren_or_siret: string;
98
+ siret: string | null;
99
+ siren: string | null;
100
+ intracom_vat_number: string | null;
101
+ archived: boolean;
102
+ archived_at: string | null;
103
+ professional: boolean;
104
+ color: string;
105
+ acronym: string;
106
+ note: string | null;
107
+ bic: string | null;
108
+ iban: string | null;
109
+ invoicing_use_email: boolean;
110
+ }
111
+ interface Bank {
112
+ id: number;
113
+ name: string;
114
+ brand: string;
115
+ sigle: string;
116
+ code: string;
117
+ logo_url: string;
118
+ }
119
+ interface BankAccount {
120
+ id: number;
121
+ name: string;
122
+ bank: Bank;
123
+ bank_account_type: {
124
+ id: number;
125
+ code: string;
126
+ description: string;
127
+ };
128
+ iban: string;
129
+ bic: string;
130
+ enabled: boolean;
131
+ balance_amount: number;
132
+ balance_currency: string;
133
+ balance_date: string;
134
+ is_wallet: boolean;
135
+ closed: boolean;
136
+ synchronization_date: string;
137
+ }
138
+ interface BankTransaction {
139
+ id: number;
140
+ wording: string;
141
+ original_wording: string;
142
+ amount: number;
143
+ currency: string;
144
+ transaction_date: string;
145
+ realization_date: string;
146
+ vat_application_date: string;
147
+ bank_account: {
148
+ id: number;
149
+ };
150
+ operation_type: string;
151
+ status: string;
152
+ status_code: string;
153
+ comment: string | null;
154
+ tags: unknown[];
155
+ short_bank_name: string;
156
+ beneficiary: unknown | null;
157
+ merchant: unknown | null;
158
+ transfer_label: string | null;
159
+ imputations: unknown[];
160
+ }
161
+ interface BankTransactionsResponse {
162
+ metadata: {
163
+ has_multiple_cardholder: boolean;
164
+ accountant_detail_request_data: unknown[];
165
+ total_amount: number;
166
+ };
167
+ transactions: BankTransaction[];
168
+ }
169
+ interface InvoiceLine {
170
+ id?: number | null;
171
+ description: string;
172
+ quantity: number;
173
+ unit_amount: number;
174
+ line_amount?: number;
175
+ vat_type: {
176
+ code: string;
177
+ };
178
+ invoicing_unit?: {
179
+ id: number;
180
+ code: string;
181
+ } | null;
182
+ invoicing_category_type?: string;
183
+ article?: {
184
+ id: number;
185
+ } | null;
186
+ sequence?: number;
187
+ discount_description?: string;
188
+ discount_amount?: number | null;
189
+ discount_percentage?: number | null;
190
+ }
191
+ interface InvoiceSendParams {
192
+ recipients: {
193
+ email: string;
194
+ }[];
195
+ message?: string;
196
+ subject?: string;
197
+ }
198
+ interface InvoiceCreateParams {
199
+ client?: {
200
+ id: number;
201
+ } | null;
202
+ client_name?: string;
203
+ client_address?: string;
204
+ client_postal_code?: string;
205
+ client_city?: string;
206
+ client_country_code?: string;
207
+ client_siren_or_siret?: string | null;
208
+ client_siren_or_siret_enabled?: boolean;
209
+ client_intracom_vat_number?: string | null;
210
+ client_intracom_vat_number_enabled?: boolean;
211
+ emission_date: string;
212
+ due_date?: string;
213
+ due_date_mode?: string;
214
+ title?: string | null;
215
+ title_enabled?: boolean;
216
+ lines: InvoiceLine[];
217
+ text_lines?: unknown[];
218
+ status?: "draft" | "saved";
219
+ template?: string;
220
+ free_field?: string;
221
+ free_field_enabled?: boolean;
222
+ discount_enabled?: boolean;
223
+ bank_detail_enabled?: boolean;
224
+ payment_condition_enabled?: boolean;
225
+ payment_condition?: string;
226
+ iban?: string;
227
+ bic?: string;
228
+ }
229
+ interface Invoice {
230
+ id: number;
231
+ client_id: number | null;
232
+ client_name: string;
233
+ compiled_number: string;
234
+ emission_date: string;
235
+ number: number | null;
236
+ status: string;
237
+ title: string | null;
238
+ template: string;
239
+ total_excluding_taxes: number;
240
+ total_including_taxes: number;
241
+ due_date: string;
242
+ lines: InvoiceLine[];
243
+ type: string;
244
+ color: string;
245
+ tags: unknown[];
246
+ totals_per_vat_type: Record<string, {
247
+ total_excluding_taxes: number;
248
+ vat_amount: number;
249
+ }>;
250
+ }
251
+ interface Quotation {
252
+ id: number;
253
+ quotation_number: string | null;
254
+ date: string;
255
+ status: string;
256
+ amount_excluding_taxes: number;
257
+ amount_including_taxes: number;
258
+ client: {
259
+ id: number;
260
+ name: string;
261
+ } | null;
262
+ invoices?: Invoice[];
263
+ }
264
+ interface Document {
265
+ id: number;
266
+ name: string;
267
+ type: string;
268
+ source: string;
269
+ created_at: string;
270
+ metadata: {
271
+ date: string | null;
272
+ amount: number | null;
273
+ supplier_name: string | null;
274
+ };
275
+ file_family: string | null;
276
+ preview_available: boolean;
277
+ }
278
+ interface DocumentCategory {
279
+ id: number;
280
+ name: string;
281
+ code: string;
282
+ count: number;
283
+ }
284
+ interface ExpenseReport {
285
+ id: number;
286
+ name: string;
287
+ status: string;
288
+ total_amount: number | null;
289
+ metadata: {
290
+ date: string | null;
291
+ };
292
+ }
293
+ interface QuotationCreateParams {
294
+ client?: {
295
+ id: number;
296
+ } | null;
297
+ client_name?: string;
298
+ date: string;
299
+ title?: string | null;
300
+ lines: InvoiceLine[];
301
+ status?: "draft" | "saved";
302
+ }
303
+ interface QuotationSendParams {
304
+ recipients: {
305
+ email: string;
306
+ }[];
307
+ message?: string;
308
+ subject?: string;
309
+ }
310
+ interface ExpenseReportCreateParams {
311
+ name: string;
312
+ metadata?: {
313
+ date?: string;
314
+ };
315
+ }
316
+ interface Label {
317
+ id: number;
318
+ name: string;
319
+ color: string;
320
+ }
321
+ interface Tag {
322
+ id: number;
323
+ label: string;
324
+ tag_detail?: {
325
+ id: number;
326
+ label: string;
327
+ };
328
+ }
329
+ interface PaginatedResponse<T> {
330
+ items: T[];
331
+ total: number | null;
332
+ range: {
333
+ start: number;
334
+ end: number;
335
+ };
336
+ }
337
+ interface DashboardBlock {
338
+ id: number;
339
+ type: string;
340
+ rank: number;
341
+ display_group: string;
342
+ }
343
+ interface AccountingPeriod {
344
+ id: number;
345
+ start_date: string;
346
+ end_date: string;
347
+ status: string;
348
+ }
349
+
350
+ declare class TokenManager {
351
+ private tokens;
352
+ constructor();
353
+ login(email: string, password: string): Promise<AuthTokens>;
354
+ getValidToken(): Promise<string>;
355
+ isAuthenticated(): boolean;
356
+ logout(): void;
357
+ getTokenInfo(): {
358
+ email: string | null;
359
+ expiresAt: Date | null;
360
+ };
361
+ private isExpired;
362
+ private loadFromDisk;
363
+ private saveToDisk;
364
+ }
365
+
366
+ declare class BankAccountsResource {
367
+ private fetch;
368
+ private companyId;
369
+ constructor(fetch: $Fetch, companyId: number);
370
+ list(enabled?: boolean): Promise<BankAccount[]>;
371
+ get(bankAccountId: number): Promise<BankAccount>;
372
+ balance(): Promise<{
373
+ name: string;
374
+ balance_amount: number;
375
+ currency: string;
376
+ }[]>;
377
+ }
378
+
379
+ interface BankTransactionsListParams {
380
+ hide_refused?: boolean;
381
+ bank_account?: number;
382
+ amount_type?: "positive" | "negative";
383
+ operation_type?: string;
384
+ sorts?: string;
385
+ page?: number;
386
+ pageSize?: number;
387
+ from?: string;
388
+ to?: string;
389
+ search?: string;
390
+ }
391
+ declare class BankTransactionsResource {
392
+ private fetch;
393
+ private companyId;
394
+ constructor(fetch: $Fetch, companyId: number);
395
+ list(params?: BankTransactionsListParams): Promise<BankTransactionsResponse>;
396
+ listAll(params?: Omit<BankTransactionsListParams, "page">): Promise<BankTransaction[]>;
397
+ unimputed(): Promise<BankTransaction[]>;
398
+ }
399
+
400
+ interface ClientsListParams {
401
+ archived?: boolean;
402
+ }
403
+ interface ClientCreateParams {
404
+ name: string;
405
+ address?: string;
406
+ postal_code?: string;
407
+ city?: string;
408
+ country_id?: number;
409
+ email?: string;
410
+ phone?: string;
411
+ siren_or_siret?: string;
412
+ professional?: boolean;
413
+ }
414
+ declare class ClientsResource {
415
+ private fetch;
416
+ private companyId;
417
+ constructor(fetch: $Fetch, companyId: number);
418
+ list(params?: ClientsListParams): Promise<Client[]>;
419
+ get(clientId: number): Promise<Client>;
420
+ create(params: ClientCreateParams): Promise<Client>;
421
+ search(query: string): Promise<Client[]>;
422
+ }
423
+
424
+ declare class CompanyResource {
425
+ private fetch;
426
+ private companyId;
427
+ constructor(fetch: $Fetch, companyId: number);
428
+ get(): Promise<Company>;
429
+ users(): Promise<any>;
430
+ appConfig(): Promise<any>;
431
+ accountingPeriod(rangeYear?: number): Promise<AccountingPeriod>;
432
+ tiles(keys: string[]): Promise<any>;
433
+ dashboardBlocks(displayGroup?: string): Promise<any>;
434
+ }
435
+
436
+ interface DocumentsListParams {
437
+ types?: string;
438
+ source?: string;
439
+ sorts?: string;
440
+ accountable?: boolean;
441
+ page?: number;
442
+ pageSize?: number;
443
+ }
444
+ declare class DocumentsResource {
445
+ private fetch;
446
+ private companyId;
447
+ constructor(fetch: $Fetch, companyId: number);
448
+ list(params?: DocumentsListParams): Promise<Document[]>;
449
+ categories(): Promise<DocumentCategory[]>;
450
+ preview(documentId: number): Promise<any>;
451
+ upload(file: Uint8Array, filename: string, type?: string): Promise<Document>;
452
+ download(documentId: number): Promise<ArrayBuffer>;
453
+ }
454
+
455
+ declare class ExpenseReportsResource {
456
+ private fetch;
457
+ private companyId;
458
+ constructor(fetch: $Fetch, companyId: number);
459
+ list(sorts?: string): Promise<ExpenseReport[]>;
460
+ get(expenseReportId: number): Promise<ExpenseReport>;
461
+ create(params: ExpenseReportCreateParams): Promise<ExpenseReport>;
462
+ }
463
+
464
+ interface InvoicesListParams {
465
+ sorts?: string;
466
+ status?: string;
467
+ page?: number;
468
+ pageSize?: number;
469
+ }
470
+ declare class InvoicesResource {
471
+ private fetch;
472
+ private companyId;
473
+ constructor(fetch: $Fetch, companyId: number);
474
+ list(params?: InvoicesListParams): Promise<Invoice[]>;
475
+ listAll(params?: {
476
+ sorts?: string;
477
+ status?: string;
478
+ pageSize?: number;
479
+ }): Promise<Invoice[]>;
480
+ get(invoiceId: number): Promise<Invoice>;
481
+ create(params: InvoiceCreateParams): Promise<Invoice>;
482
+ update(invoiceId: number, params: Partial<InvoiceCreateParams>): Promise<Invoice>;
483
+ send(invoiceId: number, params: InvoiceSendParams): Promise<void>;
484
+ downloadPdf(invoiceId: number): Promise<ArrayBuffer>;
485
+ delete(invoiceId: number): Promise<void>;
486
+ duplicate(invoiceId: number, overrides?: {
487
+ emission_date?: string;
488
+ quantity?: number;
489
+ }): Promise<Invoice>;
490
+ }
491
+
492
+ declare class LabelsResource {
493
+ private fetch;
494
+ private companyId;
495
+ constructor(fetch: $Fetch, companyId: number);
496
+ list(): Promise<Label[]>;
497
+ standard(): Promise<Label[]>;
498
+ tags(): Promise<Tag[]>;
499
+ }
500
+
501
+ declare class QuotationsResource {
502
+ private fetch;
503
+ private companyId;
504
+ constructor(fetch: $Fetch, companyId: number);
505
+ list(expand?: string): Promise<Quotation[]>;
506
+ get(quotationId: number): Promise<Quotation>;
507
+ create(params: QuotationCreateParams): Promise<Quotation>;
508
+ downloadPdf(quotationId: number): Promise<ArrayBuffer>;
509
+ send(quotationId: number, params: QuotationSendParams): Promise<void>;
510
+ }
511
+
512
+ declare class UsersResource {
513
+ private fetch;
514
+ constructor(fetch: $Fetch);
515
+ me(): Promise<User>;
516
+ legalInformations(): Promise<any>;
517
+ settings(companyId: number): Promise<any>;
518
+ }
519
+
520
+ declare class TiimeClient {
521
+ readonly fetch: $Fetch;
522
+ readonly tokenManager: TokenManager;
523
+ readonly companyId: number;
524
+ constructor(options: TiimeClientOptions & {
525
+ tokenManager?: TokenManager;
526
+ });
527
+ listCompanies(): Promise<Company[]>;
528
+ get users(): UsersResource;
529
+ get company(): CompanyResource;
530
+ get clients(): ClientsResource;
531
+ get invoices(): InvoicesResource;
532
+ get quotations(): QuotationsResource;
533
+ get bankAccounts(): BankAccountsResource;
534
+ get bankTransactions(): BankTransactionsResource;
535
+ get documents(): DocumentsResource;
536
+ get expenseReports(): ExpenseReportsResource;
537
+ get labels(): LabelsResource;
538
+ }
539
+
540
+ declare class TiimeError extends Error {
541
+ status: number;
542
+ endpoint: string;
543
+ details?: unknown | undefined;
544
+ constructor(message: string, status: number, endpoint: string, details?: unknown | undefined);
545
+ toJSON(): {
546
+ error: string;
547
+ message: string;
548
+ status: number;
549
+ endpoint: string;
550
+ details: unknown;
551
+ };
552
+ }
553
+
554
+ export { type AccountingPeriod, type Address, type ApeCode, type AuthConfig, type AuthTokens, type Bank, type BankAccount, type BankTransaction, type BankTransactionsResponse, type Client, type Company, type Country, type DashboardBlock, type Document, type DocumentCategory, type ExpenseReport, type ExpenseReportCreateParams, type Invoice, type InvoiceCreateParams, type InvoiceLine, type InvoiceSendParams, type Label, type PaginatedResponse, type Quotation, type QuotationCreateParams, type QuotationSendParams, type Tag, TiimeClient, type TiimeClientOptions, TiimeError, TokenManager, type User, type VatSystem };