@gesagro/jaspion-sdk 1.0.9 → 1.0.11

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/dist/index.mjs CHANGED
@@ -632,6 +632,59 @@ var FarrowingCollectionForm = class extends Report {
632
632
  }
633
633
  };
634
634
 
635
+ // src/core/to-snake-case.ts
636
+ function toSnakeCase(str) {
637
+ return str.replace(/[A-Z]/g, (letter, index) => {
638
+ return index === 0 ? letter.toLowerCase() : `_${letter.toLowerCase()}`;
639
+ });
640
+ }
641
+
642
+ // src/namespaces/pig-master/reports/farrowing-list.ts
643
+ var FarrowingList = class extends Report {
644
+ constructor() {
645
+ super(...arguments);
646
+ this.template = "@pig-master/farrowing-list";
647
+ this.fileName = "Listagem de partos";
648
+ }
649
+ async pdf(input) {
650
+ return this.requestPdf({
651
+ resources: this.getResources(input),
652
+ parameters: [
653
+ ...this.getParameters(input),
654
+ { key: "DATA_ONLY", value: false }
655
+ ]
656
+ });
657
+ }
658
+ async csv(input) {
659
+ return this.requestCsv({
660
+ resources: this.getResources(input),
661
+ parameters: [
662
+ ...this.getParameters(input),
663
+ { key: "DATA_ONLY", value: true }
664
+ ]
665
+ });
666
+ }
667
+ getResources(input) {
668
+ return [{ key: "FARM_ID", value: input.farmId }];
669
+ }
670
+ getParameters(input) {
671
+ return [
672
+ { key: "DATE_BEGIN", value: input.dateRange?.start ?? null },
673
+ { key: "DATE_END", value: input.dateRange?.end ?? null },
674
+ { key: "CALENDAR", value: input.calendarType },
675
+ { key: "FEMALE_SWINE_ID", value: input.femaleSwineId },
676
+ { key: "PARITY", value: input.parity?.toString() ?? null },
677
+ { key: "MATING_DATE_BEGIN", value: input.matingDateRange?.start ?? null },
678
+ { key: "MATING_DATE_END", value: input.matingDateRange?.end ?? null },
679
+ { key: "BIRTH_PLACE_ID", value: input.birthPlaceId },
680
+ { key: "ORIGIN_ID", value: input.originId },
681
+ { key: "BREED_ID", value: input.breedId },
682
+ { key: "ORDERBYDIRECTION", value: input.orderBy.direction },
683
+ { key: "ORDERBYCOLUMN", value: toSnakeCase(input.orderBy.column) }
684
+ ];
685
+ }
686
+ };
687
+
635
688
  // src/namespaces/pig-master/reports/farrowing-type-list.ts
636
689
  var FarrowingTypeList = class extends Report {
637
690
  constructor() {
@@ -2322,48 +2375,57 @@ var WeaningList = class extends Report {
2322
2375
  }
2323
2376
  async pdf(input) {
2324
2377
  return this.requestPdf({
2325
- resources: [{ key: "FARM_ID", value: input.farmId }],
2378
+ resources: this.getResources(input),
2326
2379
  parameters: [
2327
- { key: "DATE_BEGIN", value: input.dateRange?.start ?? null },
2328
- { key: "DATE_END", value: input.dateRange?.end ?? null },
2329
- { key: "CALENDAR", value: input.calendarType },
2330
- { key: "PARITY", value: input.parity?.toString() ?? null },
2331
- { key: "ORIGIN_ID", value: input.originId },
2332
- { key: "BREED_ID", value: input.breedId },
2333
- { key: "BIRTH_PLACE_ID", value: input.birthPlaceId },
2334
- { key: "FEMALE_SWINE_ID", value: input.femaleSwineId },
2335
- {
2336
- key: "MATING_DATE_BEGIN",
2337
- value: input.matingDateRange?.start ?? null
2338
- },
2339
- { key: "MATING_DATE_END", value: input.matingDateRange?.end ?? null },
2340
- { key: "CONTEXT", value: input.context },
2341
- { key: "PIGLET_BATCH_ID", value: input.nurseryPigletBatchId }
2380
+ ...this.getParameters(input),
2381
+ { key: "DATA_ONLY", value: false }
2342
2382
  ]
2343
2383
  });
2344
2384
  }
2345
2385
  async csv(input) {
2346
2386
  return this.requestCsv({
2347
- resources: [{ key: "FARM_ID", value: input.farmId }],
2387
+ resources: this.getResources(input),
2348
2388
  parameters: [
2349
- { key: "DATE_BEGIN", value: input.dateRange?.start ?? null },
2350
- { key: "DATE_END", value: input.dateRange?.end ?? null },
2351
- { key: "CALENDAR", value: input.calendarType },
2352
- { key: "PARITY", value: input.parity?.toString() ?? null },
2353
- { key: "ORIGIN_ID", value: input.originId },
2354
- { key: "BREED_ID", value: input.breedId },
2355
- { key: "BIRTH_PLACE_ID", value: input.birthPlaceId },
2356
- { key: "FEMALE_SWINE_ID", value: input.femaleSwineId },
2357
- {
2358
- key: "MATING_DATE_BEGIN",
2359
- value: input.matingDateRange?.start ?? null
2360
- },
2361
- { key: "MATING_DATE_END", value: input.matingDateRange?.end ?? null },
2362
- { key: "CONTEXT", value: input.context },
2363
- { key: "PIGLET_BATCH_ID", value: input.nurseryPigletBatchId }
2389
+ ...this.getParameters(input),
2390
+ { key: "DATA_ONLY", value: true }
2364
2391
  ]
2365
2392
  });
2366
2393
  }
2394
+ getResources(input) {
2395
+ return [{ key: "FARM_ID", value: input.farmId }];
2396
+ }
2397
+ getParameters(input) {
2398
+ let orderByColumn = input.orderBy.column;
2399
+ switch (orderByColumn) {
2400
+ case "createdAt":
2401
+ orderByColumn = "created_at";
2402
+ break;
2403
+ case "weanedPiglets":
2404
+ orderByColumn = "weaned_piglets";
2405
+ break;
2406
+ default:
2407
+ break;
2408
+ }
2409
+ return [
2410
+ { key: "DATE_BEGIN", value: input.dateRange?.start ?? null },
2411
+ { key: "DATE_END", value: input.dateRange?.end ?? null },
2412
+ { key: "CALENDAR", value: input.calendarType },
2413
+ { key: "PARITY", value: input.parity?.toString() ?? null },
2414
+ { key: "ORIGIN_ID", value: input.originId },
2415
+ { key: "BREED_ID", value: input.breedId },
2416
+ { key: "BIRTH_PLACE_ID", value: input.birthPlaceId },
2417
+ { key: "FEMALE_SWINE_ID", value: input.femaleSwineId },
2418
+ {
2419
+ key: "MATING_DATE_BEGIN",
2420
+ value: input.matingDateRange?.start ?? null
2421
+ },
2422
+ { key: "MATING_DATE_END", value: input.matingDateRange?.end ?? null },
2423
+ { key: "CONTEXT", value: input.context },
2424
+ { key: "PIGLET_BATCH_ID", value: input.nurseryPigletBatchId },
2425
+ { key: "ORDERBYDIRECTION", value: input.orderBy.direction },
2426
+ { key: "ORDERBYCOLUMN", value: orderByColumn }
2427
+ ];
2428
+ }
2367
2429
  };
2368
2430
 
2369
2431
  // src/namespaces/pig-master/index.ts
@@ -2440,6 +2502,7 @@ var PigMaster = class {
2440
2502
  this.weaningCollectionForm = new WeaningCollectionForm(http);
2441
2503
  this.maternityPigletDeathList = new MaternityPigletDeathList(http);
2442
2504
  this.weaningList = new WeaningList(http);
2505
+ this.farrowingList = new FarrowingList(http);
2443
2506
  }
2444
2507
  };
2445
2508