@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.d.mts CHANGED
@@ -341,6 +341,33 @@ declare class FarrowingCollectionForm extends Report implements PdfReport {
341
341
  pdf(input: FarrowingCollectionFormInput): Promise<void>;
342
342
  }
343
343
 
344
+ interface FarrowingListInput {
345
+ farmId: string;
346
+ calendarType: CalendarType;
347
+ dateRange: {
348
+ start: string;
349
+ end: string;
350
+ } | null;
351
+ femaleSwineId: string | null;
352
+ parity: number | null;
353
+ matingDateRange: {
354
+ start: string;
355
+ end: string;
356
+ } | null;
357
+ birthPlaceId: string | null;
358
+ originId: string | null;
359
+ breedId: string | null;
360
+ orderBy: OrderBy<'date' | 'parity' | 'liveborn' | 'stillborn' | 'mummified' | 'createdAt'>;
361
+ }
362
+ declare class FarrowingList extends Report implements PdfReport, CsvReport {
363
+ readonly template = "@pig-master/farrowing-list";
364
+ fileName: string;
365
+ pdf(input: FarrowingListInput): Promise<void>;
366
+ csv(input: FarrowingListInput): Promise<void>;
367
+ private getResources;
368
+ private getParameters;
369
+ }
370
+
344
371
  interface FarrowingTypeListInput {
345
372
  farmId: string;
346
373
  language: Language;
@@ -1312,12 +1339,15 @@ interface WeaningListInput {
1312
1339
  femaleSwineId: string | null;
1313
1340
  context: MaternityContext | null;
1314
1341
  nurseryPigletBatchId: string | null;
1342
+ orderBy: OrderBy<'date' | 'parity' | 'weanedPiglets' | 'createdAt'>;
1315
1343
  }
1316
1344
  declare class WeaningList extends Report implements PdfReport, CsvReport {
1317
1345
  readonly template = "@pig-master/weaning-list";
1318
1346
  fileName: string;
1319
1347
  pdf(input: WeaningListInput): Promise<void>;
1320
1348
  csv(input: WeaningListInput): Promise<void>;
1349
+ private getResources;
1350
+ private getParameters;
1321
1351
  }
1322
1352
 
1323
1353
  declare class PigMaster {
@@ -1390,6 +1420,7 @@ declare class PigMaster {
1390
1420
  readonly weaningCollectionForm: WeaningCollectionForm;
1391
1421
  readonly maternityPigletDeathList: MaternityPigletDeathList;
1392
1422
  readonly weaningList: WeaningList;
1423
+ readonly farrowingList: FarrowingList;
1393
1424
  constructor(http: HttpClient);
1394
1425
  }
1395
1426
 
package/dist/index.d.ts CHANGED
@@ -341,6 +341,33 @@ declare class FarrowingCollectionForm extends Report implements PdfReport {
341
341
  pdf(input: FarrowingCollectionFormInput): Promise<void>;
342
342
  }
343
343
 
344
+ interface FarrowingListInput {
345
+ farmId: string;
346
+ calendarType: CalendarType;
347
+ dateRange: {
348
+ start: string;
349
+ end: string;
350
+ } | null;
351
+ femaleSwineId: string | null;
352
+ parity: number | null;
353
+ matingDateRange: {
354
+ start: string;
355
+ end: string;
356
+ } | null;
357
+ birthPlaceId: string | null;
358
+ originId: string | null;
359
+ breedId: string | null;
360
+ orderBy: OrderBy<'date' | 'parity' | 'liveborn' | 'stillborn' | 'mummified' | 'createdAt'>;
361
+ }
362
+ declare class FarrowingList extends Report implements PdfReport, CsvReport {
363
+ readonly template = "@pig-master/farrowing-list";
364
+ fileName: string;
365
+ pdf(input: FarrowingListInput): Promise<void>;
366
+ csv(input: FarrowingListInput): Promise<void>;
367
+ private getResources;
368
+ private getParameters;
369
+ }
370
+
344
371
  interface FarrowingTypeListInput {
345
372
  farmId: string;
346
373
  language: Language;
@@ -1312,12 +1339,15 @@ interface WeaningListInput {
1312
1339
  femaleSwineId: string | null;
1313
1340
  context: MaternityContext | null;
1314
1341
  nurseryPigletBatchId: string | null;
1342
+ orderBy: OrderBy<'date' | 'parity' | 'weanedPiglets' | 'createdAt'>;
1315
1343
  }
1316
1344
  declare class WeaningList extends Report implements PdfReport, CsvReport {
1317
1345
  readonly template = "@pig-master/weaning-list";
1318
1346
  fileName: string;
1319
1347
  pdf(input: WeaningListInput): Promise<void>;
1320
1348
  csv(input: WeaningListInput): Promise<void>;
1349
+ private getResources;
1350
+ private getParameters;
1321
1351
  }
1322
1352
 
1323
1353
  declare class PigMaster {
@@ -1390,6 +1420,7 @@ declare class PigMaster {
1390
1420
  readonly weaningCollectionForm: WeaningCollectionForm;
1391
1421
  readonly maternityPigletDeathList: MaternityPigletDeathList;
1392
1422
  readonly weaningList: WeaningList;
1423
+ readonly farrowingList: FarrowingList;
1393
1424
  constructor(http: HttpClient);
1394
1425
  }
1395
1426
 
package/dist/index.js CHANGED
@@ -658,6 +658,59 @@ var FarrowingCollectionForm = class extends Report {
658
658
  }
659
659
  };
660
660
 
661
+ // src/core/to-snake-case.ts
662
+ function toSnakeCase(str) {
663
+ return str.replace(/[A-Z]/g, (letter, index) => {
664
+ return index === 0 ? letter.toLowerCase() : `_${letter.toLowerCase()}`;
665
+ });
666
+ }
667
+
668
+ // src/namespaces/pig-master/reports/farrowing-list.ts
669
+ var FarrowingList = class extends Report {
670
+ constructor() {
671
+ super(...arguments);
672
+ this.template = "@pig-master/farrowing-list";
673
+ this.fileName = "Listagem de partos";
674
+ }
675
+ async pdf(input) {
676
+ return this.requestPdf({
677
+ resources: this.getResources(input),
678
+ parameters: [
679
+ ...this.getParameters(input),
680
+ { key: "DATA_ONLY", value: false }
681
+ ]
682
+ });
683
+ }
684
+ async csv(input) {
685
+ return this.requestCsv({
686
+ resources: this.getResources(input),
687
+ parameters: [
688
+ ...this.getParameters(input),
689
+ { key: "DATA_ONLY", value: true }
690
+ ]
691
+ });
692
+ }
693
+ getResources(input) {
694
+ return [{ key: "FARM_ID", value: input.farmId }];
695
+ }
696
+ getParameters(input) {
697
+ return [
698
+ { key: "DATE_BEGIN", value: input.dateRange?.start ?? null },
699
+ { key: "DATE_END", value: input.dateRange?.end ?? null },
700
+ { key: "CALENDAR", value: input.calendarType },
701
+ { key: "FEMALE_SWINE_ID", value: input.femaleSwineId },
702
+ { key: "PARITY", value: input.parity?.toString() ?? null },
703
+ { key: "MATING_DATE_BEGIN", value: input.matingDateRange?.start ?? null },
704
+ { key: "MATING_DATE_END", value: input.matingDateRange?.end ?? null },
705
+ { key: "BIRTH_PLACE_ID", value: input.birthPlaceId },
706
+ { key: "ORIGIN_ID", value: input.originId },
707
+ { key: "BREED_ID", value: input.breedId },
708
+ { key: "ORDERBYDIRECTION", value: input.orderBy.direction },
709
+ { key: "ORDERBYCOLUMN", value: toSnakeCase(input.orderBy.column) }
710
+ ];
711
+ }
712
+ };
713
+
661
714
  // src/namespaces/pig-master/reports/farrowing-type-list.ts
662
715
  var FarrowingTypeList = class extends Report {
663
716
  constructor() {
@@ -2348,48 +2401,57 @@ var WeaningList = class extends Report {
2348
2401
  }
2349
2402
  async pdf(input) {
2350
2403
  return this.requestPdf({
2351
- resources: [{ key: "FARM_ID", value: input.farmId }],
2404
+ resources: this.getResources(input),
2352
2405
  parameters: [
2353
- { key: "DATE_BEGIN", value: input.dateRange?.start ?? null },
2354
- { key: "DATE_END", value: input.dateRange?.end ?? null },
2355
- { key: "CALENDAR", value: input.calendarType },
2356
- { key: "PARITY", value: input.parity?.toString() ?? null },
2357
- { key: "ORIGIN_ID", value: input.originId },
2358
- { key: "BREED_ID", value: input.breedId },
2359
- { key: "BIRTH_PLACE_ID", value: input.birthPlaceId },
2360
- { key: "FEMALE_SWINE_ID", value: input.femaleSwineId },
2361
- {
2362
- key: "MATING_DATE_BEGIN",
2363
- value: input.matingDateRange?.start ?? null
2364
- },
2365
- { key: "MATING_DATE_END", value: input.matingDateRange?.end ?? null },
2366
- { key: "CONTEXT", value: input.context },
2367
- { key: "PIGLET_BATCH_ID", value: input.nurseryPigletBatchId }
2406
+ ...this.getParameters(input),
2407
+ { key: "DATA_ONLY", value: false }
2368
2408
  ]
2369
2409
  });
2370
2410
  }
2371
2411
  async csv(input) {
2372
2412
  return this.requestCsv({
2373
- resources: [{ key: "FARM_ID", value: input.farmId }],
2413
+ resources: this.getResources(input),
2374
2414
  parameters: [
2375
- { key: "DATE_BEGIN", value: input.dateRange?.start ?? null },
2376
- { key: "DATE_END", value: input.dateRange?.end ?? null },
2377
- { key: "CALENDAR", value: input.calendarType },
2378
- { key: "PARITY", value: input.parity?.toString() ?? null },
2379
- { key: "ORIGIN_ID", value: input.originId },
2380
- { key: "BREED_ID", value: input.breedId },
2381
- { key: "BIRTH_PLACE_ID", value: input.birthPlaceId },
2382
- { key: "FEMALE_SWINE_ID", value: input.femaleSwineId },
2383
- {
2384
- key: "MATING_DATE_BEGIN",
2385
- value: input.matingDateRange?.start ?? null
2386
- },
2387
- { key: "MATING_DATE_END", value: input.matingDateRange?.end ?? null },
2388
- { key: "CONTEXT", value: input.context },
2389
- { key: "PIGLET_BATCH_ID", value: input.nurseryPigletBatchId }
2415
+ ...this.getParameters(input),
2416
+ { key: "DATA_ONLY", value: true }
2390
2417
  ]
2391
2418
  });
2392
2419
  }
2420
+ getResources(input) {
2421
+ return [{ key: "FARM_ID", value: input.farmId }];
2422
+ }
2423
+ getParameters(input) {
2424
+ let orderByColumn = input.orderBy.column;
2425
+ switch (orderByColumn) {
2426
+ case "createdAt":
2427
+ orderByColumn = "created_at";
2428
+ break;
2429
+ case "weanedPiglets":
2430
+ orderByColumn = "weaned_piglets";
2431
+ break;
2432
+ default:
2433
+ break;
2434
+ }
2435
+ return [
2436
+ { key: "DATE_BEGIN", value: input.dateRange?.start ?? null },
2437
+ { key: "DATE_END", value: input.dateRange?.end ?? null },
2438
+ { key: "CALENDAR", value: input.calendarType },
2439
+ { key: "PARITY", value: input.parity?.toString() ?? null },
2440
+ { key: "ORIGIN_ID", value: input.originId },
2441
+ { key: "BREED_ID", value: input.breedId },
2442
+ { key: "BIRTH_PLACE_ID", value: input.birthPlaceId },
2443
+ { key: "FEMALE_SWINE_ID", value: input.femaleSwineId },
2444
+ {
2445
+ key: "MATING_DATE_BEGIN",
2446
+ value: input.matingDateRange?.start ?? null
2447
+ },
2448
+ { key: "MATING_DATE_END", value: input.matingDateRange?.end ?? null },
2449
+ { key: "CONTEXT", value: input.context },
2450
+ { key: "PIGLET_BATCH_ID", value: input.nurseryPigletBatchId },
2451
+ { key: "ORDERBYDIRECTION", value: input.orderBy.direction },
2452
+ { key: "ORDERBYCOLUMN", value: orderByColumn }
2453
+ ];
2454
+ }
2393
2455
  };
2394
2456
 
2395
2457
  // src/namespaces/pig-master/index.ts
@@ -2466,6 +2528,7 @@ var PigMaster = class {
2466
2528
  this.weaningCollectionForm = new WeaningCollectionForm(http);
2467
2529
  this.maternityPigletDeathList = new MaternityPigletDeathList(http);
2468
2530
  this.weaningList = new WeaningList(http);
2531
+ this.farrowingList = new FarrowingList(http);
2469
2532
  }
2470
2533
  };
2471
2534