@jars-lt/jars-app-sdk 0.1.0 → 0.2.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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @jars-lt/jars-app-sdk
2
2
 
3
- Official TypeScript SDK for the [JARS Apskaita](https://app.jars.lt) accounting API — Lithuanian cloud accounting for partners, products, invoices, journal entries, and reports.
3
+ Official TypeScript SDK for the [JARS Apskaita](https://app.jars.lt) accounting API — Lithuanian cloud accounting. Covers partners, products, invoices, journal entries and reports, plus cash registers & orders, bank transactions & statements, fixed assets & depreciation, employees & payroll, business trips, price lists, projects, professions, per-diem rates, numberings and exchange rates.
4
4
 
5
5
  ## Install
6
6
 
@@ -76,6 +76,21 @@ Every resource is reachable as a property on the client (`jars.partners`, `jars.
76
76
  | `jars.reports` | `trialBalance` · `generalLedger` · `partnerBalance` · `cashBook` · `isafExport` |
77
77
  | `jars.auditLogs` | `list` · `get` |
78
78
  | `jars.lookups` | `accounts` · `vatCodes` · `units` · `templates` (list-only) |
79
+ | `jars.cashRegisters` | `list` · `create` · `update` · `remove` |
80
+ | `jars.cashOrders` | `list` · `get` · `create` · `update` · `remove` · `post` · `unpost` · `fiscalize` · `setExternalStatus` |
81
+ | `jars.bankTransactions` | `list` · `get` · `create` · `update` · `post` · `unpost` · `setExternalStatus` |
82
+ | `jars.bankStatements` | `list` · `remove` · `detect` · `import` (file upload) |
83
+ | `jars.fixedAssets` | `list` · `get` · `create` · `update` · `remove` · `dispose` |
84
+ | `jars.depreciation` | `list` · `preview` · `post` · `unpost` |
85
+ | `jars.employees` | `list` · `get` · `create` · `update` · `remove` · `nextCode` · `verifyPin` |
86
+ | `jars.payroll` | `list` · `preview` · `post` · `unpost` |
87
+ | `jars.businessTrips` | `list` · `create` · `update` · `remove` · `postAdvance` · `postSettlement` · `unpost` |
88
+ | `jars.priceLists` | `list` · `get` · `create` · `update` · `remove` |
89
+ | `jars.projects` | `list` · `get` · `create` · `update` · `remove` |
90
+ | `jars.professions` | `list` · `get` · `create` · `update` · `remove` |
91
+ | `jars.perDiemRates` | `list` · `create` · `update` · `remove` |
92
+ | `jars.numberings` | `list` · `update` (by prefix) |
93
+ | `jars.exchangeRates` | `list` (read-only euro FX rates) |
79
94
 
80
95
  ### Method signatures
81
96
 
@@ -98,6 +113,16 @@ setExternalStatus<T = unknown>(id: string, externalStatus: string | null): Promi
98
113
  trialBalance<T = unknown>(params?: ReportParams): Promise<T>
99
114
  // lookups: list-only, e.g.
100
115
  accounts<T = unknown[]>(params?: ListParams): Promise<T>
116
+
117
+ // document-lifecycle actions (cashOrders, bankTransactions, businessTrips, …)
118
+ post<T = unknown>(id: string): Promise<T>
119
+ unpost<T = unknown>(id: string): Promise<T>
120
+ // batch runs (payroll, depreciation)
121
+ preview<T = unknown>(body: Record<string, unknown>): Promise<T>
122
+ post<T = unknown>(body: Record<string, unknown>): Promise<T>
123
+ // bankStatements: multipart file upload (Blob/File)
124
+ detect<T = unknown>(file: Blob | File, filename?: string): Promise<T>
125
+ import<T = unknown>(file: Blob | File, fields?: Record<string, string>, filename?: string): Promise<T>
101
126
  ```
102
127
 
103
128
  ### Not in the facade yet
package/dist/index.cjs CHANGED
@@ -31,14 +31,29 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
33
  AuditLogsResource: () => AuditLogsResource,
34
+ BankStatementsResource: () => BankStatementsResource,
35
+ BankTransactionsResource: () => BankTransactionsResource,
36
+ BusinessTripsResource: () => BusinessTripsResource,
37
+ CashOrdersResource: () => CashOrdersResource,
38
+ CashRegistersResource: () => CashRegistersResource,
34
39
  DEFAULT_BASE_URL: () => DEFAULT_BASE_URL,
40
+ DepreciationResource: () => DepreciationResource,
41
+ EmployeesResource: () => EmployeesResource,
42
+ ExchangeRatesResource: () => ExchangeRatesResource,
43
+ FixedAssetsResource: () => FixedAssetsResource,
35
44
  InvoicesResource: () => InvoicesResource,
36
45
  JarsApiError: () => JarsApiError,
37
46
  JarsClient: () => JarsClient,
38
47
  JournalResource: () => JournalResource,
39
48
  LookupsResource: () => LookupsResource,
49
+ NumberingsResource: () => NumberingsResource,
40
50
  PartnersResource: () => PartnersResource,
51
+ PayrollResource: () => PayrollResource,
52
+ PerDiemRatesResource: () => PerDiemRatesResource,
53
+ PriceListsResource: () => PriceListsResource,
41
54
  ProductsResource: () => ProductsResource,
55
+ ProfessionsResource: () => ProfessionsResource,
56
+ ProjectsResource: () => ProjectsResource,
42
57
  ReportsResource: () => ReportsResource
43
58
  });
44
59
  module.exports = __toCommonJS(index_exports);
@@ -217,6 +232,342 @@ var LookupsResource = class {
217
232
  }
218
233
  };
219
234
 
235
+ // src/resources/cash-registers.ts
236
+ var CashRegistersResource = class {
237
+ constructor(client) {
238
+ this.client = client;
239
+ }
240
+ list(params) {
241
+ return this.client.request("get", "/api/cash-registers", { query: toQuery(params) });
242
+ }
243
+ create(body) {
244
+ return this.client.request("post", "/api/cash-registers", { body });
245
+ }
246
+ update(id, body) {
247
+ return this.client.request("put", "/api/cash-registers/{id}", { params: { id }, body });
248
+ }
249
+ remove(id) {
250
+ return this.client.request("delete", "/api/cash-registers/{id}", { params: { id } });
251
+ }
252
+ };
253
+
254
+ // src/resources/projects.ts
255
+ var ProjectsResource = class {
256
+ constructor(client) {
257
+ this.client = client;
258
+ }
259
+ list(params) {
260
+ return this.client.request("get", "/api/projects", { query: toQuery(params) });
261
+ }
262
+ get(id) {
263
+ return this.client.request("get", "/api/projects/{id}", { params: { id } });
264
+ }
265
+ create(body) {
266
+ return this.client.request("post", "/api/projects", { body });
267
+ }
268
+ update(id, body) {
269
+ return this.client.request("put", "/api/projects/{id}", { params: { id }, body });
270
+ }
271
+ remove(id) {
272
+ return this.client.request("delete", "/api/projects/{id}", { params: { id } });
273
+ }
274
+ };
275
+
276
+ // src/resources/professions.ts
277
+ var ProfessionsResource = class {
278
+ constructor(client) {
279
+ this.client = client;
280
+ }
281
+ list(params) {
282
+ return this.client.request("get", "/api/professions", { query: toQuery(params) });
283
+ }
284
+ get(id) {
285
+ return this.client.request("get", "/api/professions/{id}", { params: { id } });
286
+ }
287
+ create(body) {
288
+ return this.client.request("post", "/api/professions", { body });
289
+ }
290
+ update(id, body) {
291
+ return this.client.request("put", "/api/professions/{id}", { params: { id }, body });
292
+ }
293
+ remove(id) {
294
+ return this.client.request("delete", "/api/professions/{id}", { params: { id } });
295
+ }
296
+ };
297
+
298
+ // src/resources/perdiem-rates.ts
299
+ var PerDiemRatesResource = class {
300
+ constructor(client) {
301
+ this.client = client;
302
+ }
303
+ list(params) {
304
+ return this.client.request("get", "/api/perdiem-rates", { query: toQuery(params) });
305
+ }
306
+ create(body) {
307
+ return this.client.request("post", "/api/perdiem-rates", { body });
308
+ }
309
+ update(id, body) {
310
+ return this.client.request("put", "/api/perdiem-rates/{id}", { params: { id }, body });
311
+ }
312
+ remove(id) {
313
+ return this.client.request("delete", "/api/perdiem-rates/{id}", { params: { id } });
314
+ }
315
+ };
316
+
317
+ // src/resources/price-lists.ts
318
+ var PriceListsResource = class {
319
+ constructor(client) {
320
+ this.client = client;
321
+ }
322
+ list(params) {
323
+ return this.client.request("get", "/api/price-lists", { query: toQuery(params) });
324
+ }
325
+ get(id) {
326
+ return this.client.request("get", "/api/price-lists/{id}", { params: { id } });
327
+ }
328
+ create(body) {
329
+ return this.client.request("post", "/api/price-lists", { body });
330
+ }
331
+ update(id, body) {
332
+ return this.client.request("put", "/api/price-lists/{id}", { params: { id }, body });
333
+ }
334
+ remove(id) {
335
+ return this.client.request("delete", "/api/price-lists/{id}", { params: { id } });
336
+ }
337
+ };
338
+
339
+ // src/resources/fixed-assets.ts
340
+ var FixedAssetsResource = class {
341
+ constructor(client) {
342
+ this.client = client;
343
+ }
344
+ list(params) {
345
+ return this.client.request("get", "/api/fixed-assets", { query: toQuery(params) });
346
+ }
347
+ get(id) {
348
+ return this.client.request("get", "/api/fixed-assets/{id}", { params: { id } });
349
+ }
350
+ create(body) {
351
+ return this.client.request("post", "/api/fixed-assets", { body });
352
+ }
353
+ update(id, body) {
354
+ return this.client.request("put", "/api/fixed-assets/{id}", { params: { id }, body });
355
+ }
356
+ remove(id) {
357
+ return this.client.request("delete", "/api/fixed-assets/{id}", { params: { id } });
358
+ }
359
+ dispose(id, body) {
360
+ return this.client.request("post", "/api/fixed-assets/{id}/dispose", { params: { id }, body });
361
+ }
362
+ };
363
+
364
+ // src/resources/employees.ts
365
+ var EmployeesResource = class {
366
+ constructor(client) {
367
+ this.client = client;
368
+ }
369
+ list(params) {
370
+ return this.client.request("get", "/api/employees", { query: toQuery(params) });
371
+ }
372
+ get(id) {
373
+ return this.client.request("get", "/api/employees/{id}", { params: { id } });
374
+ }
375
+ create(body) {
376
+ return this.client.request("post", "/api/employees", { body });
377
+ }
378
+ update(id, body) {
379
+ return this.client.request("put", "/api/employees/{id}", { params: { id }, body });
380
+ }
381
+ remove(id) {
382
+ return this.client.request("delete", "/api/employees/{id}", { params: { id } });
383
+ }
384
+ nextCode() {
385
+ return this.client.request("get", "/api/employees/next-code");
386
+ }
387
+ verifyPin(body) {
388
+ return this.client.request("post", "/api/employees/verify-pin", { body });
389
+ }
390
+ };
391
+
392
+ // src/resources/cash-orders.ts
393
+ var CashOrdersResource = class {
394
+ constructor(client) {
395
+ this.client = client;
396
+ }
397
+ list(params) {
398
+ return this.client.request("get", "/api/cash-orders", { query: toQuery(params) });
399
+ }
400
+ get(id) {
401
+ return this.client.request("get", "/api/cash-orders/{id}", { params: { id } });
402
+ }
403
+ create(body) {
404
+ return this.client.request("post", "/api/cash-orders", { body });
405
+ }
406
+ update(id, body) {
407
+ return this.client.request("put", "/api/cash-orders/{id}", { params: { id }, body });
408
+ }
409
+ remove(id) {
410
+ return this.client.request("delete", "/api/cash-orders/{id}", { params: { id } });
411
+ }
412
+ setExternalStatus(id, body) {
413
+ return this.client.request("patch", "/api/cash-orders/{id}/external-status", { params: { id }, body });
414
+ }
415
+ post(id) {
416
+ return this.client.request("post", "/api/cash-orders/{id}/post", { params: { id } });
417
+ }
418
+ unpost(id) {
419
+ return this.client.request("post", "/api/cash-orders/{id}/unpost", { params: { id } });
420
+ }
421
+ fiscalize(id, body) {
422
+ return this.client.request("post", "/api/cash-orders/{id}/fiscalize", { params: { id }, body: body ?? {} });
423
+ }
424
+ };
425
+
426
+ // src/resources/bank-transactions.ts
427
+ var BankTransactionsResource = class {
428
+ constructor(client) {
429
+ this.client = client;
430
+ }
431
+ list(params) {
432
+ return this.client.request("get", "/api/bank-transactions", { query: toQuery(params) });
433
+ }
434
+ get(id) {
435
+ return this.client.request("get", "/api/bank-transactions/{id}", { params: { id } });
436
+ }
437
+ create(body) {
438
+ return this.client.request("post", "/api/bank-transactions", { body });
439
+ }
440
+ update(id, body) {
441
+ return this.client.request("put", "/api/bank-transactions/{id}", { params: { id }, body });
442
+ }
443
+ setExternalStatus(id, body) {
444
+ return this.client.request("patch", "/api/bank-transactions/{id}/external-status", { params: { id }, body });
445
+ }
446
+ post(id) {
447
+ return this.client.request("post", "/api/bank-transactions/{id}/post", { params: { id } });
448
+ }
449
+ unpost(id) {
450
+ return this.client.request("post", "/api/bank-transactions/{id}/unpost", { params: { id } });
451
+ }
452
+ };
453
+
454
+ // src/resources/business-trips.ts
455
+ var BusinessTripsResource = class {
456
+ constructor(client) {
457
+ this.client = client;
458
+ }
459
+ list(params) {
460
+ return this.client.request("get", "/api/business-trips", { query: toQuery(params) });
461
+ }
462
+ create(body) {
463
+ return this.client.request("post", "/api/business-trips", { body });
464
+ }
465
+ update(id, body) {
466
+ return this.client.request("put", "/api/business-trips/{id}", { params: { id }, body });
467
+ }
468
+ remove(id) {
469
+ return this.client.request("delete", "/api/business-trips/{id}", { params: { id } });
470
+ }
471
+ postAdvance(id) {
472
+ return this.client.request("post", "/api/business-trips/{id}/post-advance", { params: { id } });
473
+ }
474
+ postSettlement(id) {
475
+ return this.client.request("post", "/api/business-trips/{id}/post-settlement", { params: { id } });
476
+ }
477
+ unpost(id) {
478
+ return this.client.request("post", "/api/business-trips/{id}/unpost", { params: { id } });
479
+ }
480
+ };
481
+
482
+ // src/resources/payroll.ts
483
+ var PayrollResource = class {
484
+ constructor(client) {
485
+ this.client = client;
486
+ }
487
+ list(params) {
488
+ return this.client.request("get", "/api/payroll", { query: toQuery(params) });
489
+ }
490
+ preview(body) {
491
+ return this.client.request("post", "/api/payroll/preview", { body });
492
+ }
493
+ post(body) {
494
+ return this.client.request("post", "/api/payroll/post", { body });
495
+ }
496
+ unpost(id) {
497
+ return this.client.request("post", "/api/payroll/{id}/unpost", { params: { id } });
498
+ }
499
+ };
500
+
501
+ // src/resources/depreciation.ts
502
+ var DepreciationResource = class {
503
+ constructor(client) {
504
+ this.client = client;
505
+ }
506
+ list(params) {
507
+ return this.client.request("get", "/api/depreciation", { query: toQuery(params) });
508
+ }
509
+ preview(body) {
510
+ return this.client.request("post", "/api/depreciation/preview", { body });
511
+ }
512
+ post(body) {
513
+ return this.client.request("post", "/api/depreciation/post", { body });
514
+ }
515
+ unpost(id) {
516
+ return this.client.request("post", "/api/depreciation/{id}/unpost", { params: { id } });
517
+ }
518
+ };
519
+
520
+ // src/resources/numberings.ts
521
+ var NumberingsResource = class {
522
+ constructor(client) {
523
+ this.client = client;
524
+ }
525
+ list(params) {
526
+ return this.client.request("get", "/api/numberings", { query: toQuery(params) });
527
+ }
528
+ update(prefix, body) {
529
+ return this.client.request("put", "/api/numberings/{prefix}", { params: { prefix }, body });
530
+ }
531
+ };
532
+
533
+ // src/resources/exchange-rates.ts
534
+ var ExchangeRatesResource = class {
535
+ constructor(client) {
536
+ this.client = client;
537
+ }
538
+ list(params) {
539
+ return this.client.request("get", "/api/exchange-rates", { query: toQuery(params) });
540
+ }
541
+ };
542
+
543
+ // src/resources/bank-statements.ts
544
+ var BankStatementsResource = class {
545
+ constructor(client) {
546
+ this.client = client;
547
+ }
548
+ list(params) {
549
+ return this.client.request("get", "/api/bank-statements", { query: toQuery(params) });
550
+ }
551
+ remove(id) {
552
+ return this.client.request("delete", "/api/bank-statements/{id}", { params: { id } });
553
+ }
554
+ detect(file, filename) {
555
+ const fd = new FormData();
556
+ fd.append("file", file, filename);
557
+ return this.client.request("post", "/api/bank-statements/detect", { body: fd });
558
+ }
559
+ import(file, fields, filename) {
560
+ const fd = new FormData();
561
+ fd.append("file", file, filename);
562
+ if (fields) {
563
+ for (const [key, value] of Object.entries(fields)) {
564
+ fd.append(key, value);
565
+ }
566
+ }
567
+ return this.client.request("post", "/api/bank-statements/import", { body: fd });
568
+ }
569
+ };
570
+
220
571
  // src/client.ts
221
572
  var DEFAULT_BASE_URL = "https://app.jars.lt";
222
573
  function safeJson(text) {
@@ -236,6 +587,21 @@ var JarsClient = class {
236
587
  reports;
237
588
  auditLogs;
238
589
  lookups;
590
+ cashRegisters;
591
+ projects;
592
+ professions;
593
+ perDiemRates;
594
+ priceLists;
595
+ fixedAssets;
596
+ employees;
597
+ cashOrders;
598
+ bankTransactions;
599
+ businessTrips;
600
+ payroll;
601
+ depreciation;
602
+ numberings;
603
+ exchangeRates;
604
+ bankStatements;
239
605
  baseUrl;
240
606
  authHeader;
241
607
  fetchImpl;
@@ -256,6 +622,21 @@ var JarsClient = class {
256
622
  this.reports = new ReportsResource(this);
257
623
  this.auditLogs = new AuditLogsResource(this);
258
624
  this.lookups = new LookupsResource(this);
625
+ this.cashRegisters = new CashRegistersResource(this);
626
+ this.projects = new ProjectsResource(this);
627
+ this.professions = new ProfessionsResource(this);
628
+ this.perDiemRates = new PerDiemRatesResource(this);
629
+ this.priceLists = new PriceListsResource(this);
630
+ this.fixedAssets = new FixedAssetsResource(this);
631
+ this.employees = new EmployeesResource(this);
632
+ this.cashOrders = new CashOrdersResource(this);
633
+ this.bankTransactions = new BankTransactionsResource(this);
634
+ this.businessTrips = new BusinessTripsResource(this);
635
+ this.payroll = new PayrollResource(this);
636
+ this.depreciation = new DepreciationResource(this);
637
+ this.numberings = new NumberingsResource(this);
638
+ this.exchangeRates = new ExchangeRatesResource(this);
639
+ this.bankStatements = new BankStatementsResource(this);
259
640
  }
260
641
  async request(method, path, opts = {}) {
261
642
  const finalPath = opts.params ? path.replace(/\{([^}]+)\}/g, (_, key) => {
@@ -271,8 +652,13 @@ var JarsClient = class {
271
652
  const headers = new Headers({ Authorization: this.authHeader });
272
653
  let body;
273
654
  if (opts.body !== void 0) {
274
- headers.set("content-type", "application/json");
275
- body = JSON.stringify(opts.body);
655
+ const isForm = typeof FormData !== "undefined" && opts.body instanceof FormData;
656
+ if (isForm) {
657
+ body = opts.body;
658
+ } else {
659
+ headers.set("content-type", "application/json");
660
+ body = JSON.stringify(opts.body);
661
+ }
276
662
  }
277
663
  let res;
278
664
  try {
@@ -300,14 +686,29 @@ var JarsClient = class {
300
686
  // Annotate the CommonJS export names for ESM import in node:
301
687
  0 && (module.exports = {
302
688
  AuditLogsResource,
689
+ BankStatementsResource,
690
+ BankTransactionsResource,
691
+ BusinessTripsResource,
692
+ CashOrdersResource,
693
+ CashRegistersResource,
303
694
  DEFAULT_BASE_URL,
695
+ DepreciationResource,
696
+ EmployeesResource,
697
+ ExchangeRatesResource,
698
+ FixedAssetsResource,
304
699
  InvoicesResource,
305
700
  JarsApiError,
306
701
  JarsClient,
307
702
  JournalResource,
308
703
  LookupsResource,
704
+ NumberingsResource,
309
705
  PartnersResource,
706
+ PayrollResource,
707
+ PerDiemRatesResource,
708
+ PriceListsResource,
310
709
  ProductsResource,
710
+ ProfessionsResource,
711
+ ProjectsResource,
311
712
  ReportsResource
312
713
  });
313
714
  //# sourceMappingURL=index.cjs.map