weflayr 0.22.1 → 0.23.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.
@@ -36,6 +36,38 @@ export type ApiErrorOutput = {
36
36
  error: string;
37
37
  };
38
38
 
39
+ /**
40
+ * CustomerMarginRow
41
+ *
42
+ * One customer's gross margin for a period.
43
+ */
44
+ export type CustomerMarginRow = {
45
+ /**
46
+ * Customer Name
47
+ */
48
+ customer_name: string;
49
+ /**
50
+ * Revenue
51
+ */
52
+ revenue: number;
53
+ /**
54
+ * Cost
55
+ */
56
+ cost: number;
57
+ /**
58
+ * Margin
59
+ */
60
+ margin: number;
61
+ /**
62
+ * Margin Pct
63
+ */
64
+ margin_pct: number | null;
65
+ /**
66
+ * Profitability Status
67
+ */
68
+ profitability_status: 'healthy' | 'watch' | 'at_risk' | 'unprofitable' | 'unknown';
69
+ };
70
+
39
71
  /**
40
72
  * CustomerTags
41
73
  *
@@ -149,11 +181,11 @@ export type KeyMetricOutput = {
149
181
  */
150
182
  export type KeyMetricRow = {
151
183
  /**
152
- * User Defined Id
184
+ * Metric Id
153
185
  *
154
186
  * Your own id for this value. Omit it to book a new value; reuse a previous one to update it (needs "upsert": true, see the "upsert" field).
155
187
  */
156
- user_defined_id?: string | null;
188
+ metric_id?: string | null;
157
189
  /**
158
190
  * User Name
159
191
  */
@@ -165,7 +197,7 @@ export type KeyMetricRow = {
165
197
  /**
166
198
  * Amount
167
199
  */
168
- amount: number | string;
200
+ amount: number;
169
201
  /**
170
202
  * Month
171
203
  */
@@ -186,10 +218,6 @@ export type KeyMetricRow = {
186
218
  * One booked key-metric value.
187
219
  */
188
220
  export type KeyMetricRowOutput = {
189
- /**
190
- * User Defined Id
191
- */
192
- user_defined_id: string;
193
221
  /**
194
222
  * Metric Name
195
223
  */
@@ -201,17 +229,42 @@ export type KeyMetricRowOutput = {
201
229
  /**
202
230
  * Amount
203
231
  */
204
- amount: string;
232
+ amount: number;
205
233
  /**
206
234
  * Source
207
235
  */
208
236
  source: string;
237
+ /**
238
+ * Metric Id
239
+ */
240
+ metric_id: string;
209
241
  /**
210
242
  * User Name
211
243
  */
212
244
  user_name: string;
213
245
  };
214
246
 
247
+ /**
248
+ * MarginListOutput
249
+ *
250
+ * Margin GET response: one row per customer with booked revenue, sorted by
251
+ * customer_name ascending.
252
+ */
253
+ export type MarginListOutput = {
254
+ /**
255
+ * Rows
256
+ */
257
+ rows: Array<CustomerMarginRow>;
258
+ /**
259
+ * Next Cursor
260
+ */
261
+ next_cursor: string | null;
262
+ /**
263
+ * Has More
264
+ */
265
+ has_more: boolean;
266
+ };
267
+
215
268
  /**
216
269
  * RevenueOrKeyMetricDeletedRowOutput
217
270
  *
@@ -272,11 +325,11 @@ export type RevenueOutput = {
272
325
  */
273
326
  export type RevenueRow = {
274
327
  /**
275
- * User Defined Id
328
+ * Revenue Id
276
329
  *
277
330
  * Your own id for this value. Omit it to book a new value; reuse a previous one to update it (needs "upsert": true, see the "upsert" field).
278
331
  */
279
- user_defined_id?: string | null;
332
+ revenue_id?: string | null;
280
333
  /**
281
334
  * Customer Name
282
335
  */
@@ -284,7 +337,7 @@ export type RevenueRow = {
284
337
  /**
285
338
  * Amount
286
339
  */
287
- amount: number | string;
340
+ amount: number;
288
341
  /**
289
342
  * Month
290
343
  */
@@ -305,10 +358,6 @@ export type RevenueRow = {
305
358
  * One booked revenue value.
306
359
  */
307
360
  export type RevenueRowOutput = {
308
- /**
309
- * User Defined Id
310
- */
311
- user_defined_id: string;
312
361
  /**
313
362
  * Metric Name
314
363
  */
@@ -320,11 +369,15 @@ export type RevenueRowOutput = {
320
369
  /**
321
370
  * Amount
322
371
  */
323
- amount: string;
372
+ amount: number;
324
373
  /**
325
374
  * Source
326
375
  */
327
376
  source: string;
377
+ /**
378
+ * Revenue Id
379
+ */
380
+ revenue_id: string;
328
381
  /**
329
382
  * Customer Name
330
383
  */
@@ -354,7 +407,7 @@ export type SetCustomerTagsInput = {
354
407
  *
355
408
  * The key-metric values posted to the public API. A user may have
356
409
  * several lines of the same metric in the same month; rows are only ever
357
- * matched against each other by user_defined_id, never by (user, metric,
410
+ * matched against each other by metric_id, never by (user, metric,
358
411
  * month).
359
412
  */
360
413
  export type SetKeyMetricsInput = {
@@ -365,7 +418,7 @@ export type SetKeyMetricsInput = {
365
418
  /**
366
419
  * Upsert
367
420
  *
368
- * If a row's user_defined_id already exists, overwrite it instead of rejecting the request.
421
+ * If a row's metric_id already exists, overwrite it instead of rejecting the request.
369
422
  */
370
423
  upsert?: boolean;
371
424
  };
@@ -375,7 +428,7 @@ export type SetKeyMetricsInput = {
375
428
  *
376
429
  * The revenue values posted to the public API. A customer may have several
377
430
  * revenue lines in the same month (e.g. one per product or contract); rows
378
- * are only ever matched against each other by user_defined_id, never by
431
+ * are only ever matched against each other by revenue_id, never by
379
432
  * (customer, month).
380
433
  */
381
434
  export type SetRevenueInput = {
@@ -386,7 +439,7 @@ export type SetRevenueInput = {
386
439
  /**
387
440
  * Upsert
388
441
  *
389
- * If a row's user_defined_id already exists, overwrite it instead of rejecting the request.
442
+ * If a row's revenue_id already exists, overwrite it instead of rejecting the request.
390
443
  */
391
444
  upsert?: boolean;
392
445
  };
@@ -407,45 +460,78 @@ export type TagsDeletedOutput = {
407
460
  tags_deleted: number;
408
461
  };
409
462
 
410
- export type GetAllRevenueData = {
463
+ export type GetMarginData = {
411
464
  body?: never;
412
465
  path?: never;
413
466
  query?: {
467
+ /**
468
+ * Return only these customers' margin. Omit to return every customer's.
469
+ */
470
+ customer_names?: Array<string>;
414
471
  /**
415
472
  * Opaque cursor from a previous page's next_cursor.
416
473
  */
417
474
  cursor?: string;
418
475
  limit?: number;
476
+ /**
477
+ * Start of the period (inclusive), YYYY-MM-DD. Defaults to 30 days ago.
478
+ */
479
+ date_from?: string;
480
+ /**
481
+ * End of the period (inclusive), YYYY-MM-DD. Defaults to today.
482
+ */
483
+ date_to?: string;
484
+ /**
485
+ * Apply free-credit discounts to cost. Defaults to false.
486
+ */
487
+ apply_credits?: boolean;
419
488
  };
420
- url: '/revenue/';
489
+ url: '/margin/';
421
490
  };
422
491
 
423
- export type GetAllRevenueErrors = {
492
+ export type GetMarginErrors = {
493
+ /**
494
+ * Invalid request for this project type.
495
+ */
496
+ 400: ApiErrorOutput;
424
497
  /**
425
498
  * Missing or invalid API key.
426
499
  */
427
500
  401: ApiErrorOutput;
428
501
  };
429
502
 
430
- export type GetAllRevenueError = GetAllRevenueErrors[keyof GetAllRevenueErrors];
503
+ export type GetMarginError = GetMarginErrors[keyof GetMarginErrors];
431
504
 
432
- export type GetAllRevenueResponses = {
505
+ export type GetMarginResponses = {
433
506
  /**
434
507
  * Success.
435
508
  */
436
- 200: RevenueOutput;
509
+ 200: MarginListOutput;
437
510
  };
438
511
 
439
- export type GetAllRevenueResponse = GetAllRevenueResponses[keyof GetAllRevenueResponses];
512
+ export type GetMarginResponse = GetMarginResponses[keyof GetMarginResponses];
440
513
 
441
- export type SetRevenueData = {
442
- body: SetRevenueInput;
514
+ export type DeleteRevenueData = {
515
+ body?: never;
443
516
  path?: never;
444
- query?: never;
517
+ query: {
518
+ /**
519
+ * Delete these customers' API-booked revenue (repeat the param for several).
520
+ */
521
+ customer_names: Array<string>;
522
+ /**
523
+ * First month to delete (inclusive). Omit both bounds to delete every matching API-booked value.
524
+ */
525
+ month_start?: string;
526
+ /**
527
+ * Last month to delete (inclusive).
528
+ */
529
+ month_end?: string;
530
+ };
445
531
  url: '/revenue/';
446
532
  };
447
533
 
448
- export type SetRevenueErrors = {
534
+ export type DeleteRevenueErrors = {
449
535
  /**
450
536
  * Missing or invalid API key.
451
537
  */
@@ -456,36 +542,60 @@ export type SetRevenueErrors = {
456
542
  422: InvalidPayloadOutput;
457
543
  };
458
544
 
459
- export type SetRevenueError = SetRevenueErrors[keyof SetRevenueErrors];
545
+ export type DeleteRevenueError = DeleteRevenueErrors[keyof DeleteRevenueErrors];
460
546
 
461
- export type SetRevenueResponses = {
547
+ export type DeleteRevenueResponses = {
462
548
  /**
463
549
  * Success.
464
550
  */
465
- 200: RevenueOrKeyMetricImportedRowOutput;
551
+ 200: RevenueOrKeyMetricDeletedRowOutput;
466
552
  };
467
553
 
468
- export type SetRevenueResponse = SetRevenueResponses[keyof SetRevenueResponses];
554
+ export type DeleteRevenueResponse = DeleteRevenueResponses[keyof DeleteRevenueResponses];
469
555
 
470
- export type DeleteCustomerRevenueData = {
556
+ export type GetRevenueData = {
471
557
  body?: never;
472
- path: {
473
- customer_name: string;
474
- };
558
+ path?: never;
475
559
  query?: {
476
560
  /**
477
- * First month to delete (inclusive). Omit both bounds to delete every matching API-booked value.
561
+ * Return only these customers' revenue. Omit to return every customer's.
478
562
  */
479
- month_start?: string;
563
+ customer_names?: Array<string>;
480
564
  /**
481
- * Last month to delete (inclusive).
565
+ * Opaque cursor from a previous page's next_cursor.
482
566
  */
483
- month_end?: string;
567
+ cursor?: string;
568
+ limit?: number;
484
569
  };
485
- url: '/revenue/{customer_name}/';
570
+ url: '/revenue/';
571
+ };
572
+
573
+ export type GetRevenueErrors = {
574
+ /**
575
+ * Missing or invalid API key.
576
+ */
577
+ 401: ApiErrorOutput;
578
+ };
579
+
580
+ export type GetRevenueError = GetRevenueErrors[keyof GetRevenueErrors];
581
+
582
+ export type GetRevenueResponses = {
583
+ /**
584
+ * Success.
585
+ */
586
+ 200: RevenueOutput;
587
+ };
588
+
589
+ export type GetRevenueResponse = GetRevenueResponses[keyof GetRevenueResponses];
590
+
591
+ export type SetRevenueData = {
592
+ body: SetRevenueInput;
593
+ path?: never;
594
+ query?: never;
595
+ url: '/revenue/';
486
596
  };
487
597
 
488
- export type DeleteCustomerRevenueErrors = {
598
+ export type SetRevenueErrors = {
489
599
  /**
490
600
  * Missing or invalid API key.
491
601
  */
@@ -496,52 +606,67 @@ export type DeleteCustomerRevenueErrors = {
496
606
  422: InvalidPayloadOutput;
497
607
  };
498
608
 
499
- export type DeleteCustomerRevenueError = DeleteCustomerRevenueErrors[keyof DeleteCustomerRevenueErrors];
609
+ export type SetRevenueError = SetRevenueErrors[keyof SetRevenueErrors];
500
610
 
501
- export type DeleteCustomerRevenueResponses = {
611
+ export type SetRevenueResponses = {
502
612
  /**
503
613
  * Success.
504
614
  */
505
- 200: RevenueOrKeyMetricDeletedRowOutput;
615
+ 200: RevenueOrKeyMetricImportedRowOutput;
506
616
  };
507
617
 
508
- export type DeleteCustomerRevenueResponse = DeleteCustomerRevenueResponses[keyof DeleteCustomerRevenueResponses];
618
+ export type SetRevenueResponse = SetRevenueResponses[keyof SetRevenueResponses];
509
619
 
510
- export type GetCustomerRevenueData = {
620
+ export type DeleteKeyMetricsData = {
511
621
  body?: never;
512
- path: {
513
- customer_name: string;
622
+ path?: never;
623
+ query: {
624
+ /**
625
+ * Delete these users' API-booked key metrics (repeat the param for several).
626
+ */
627
+ user_names: Array<string>;
628
+ /**
629
+ * First month to delete (inclusive). Omit both bounds to delete every matching API-booked value.
630
+ */
631
+ month_start?: string;
632
+ /**
633
+ * Last month to delete (inclusive).
634
+ */
635
+ month_end?: string;
514
636
  };
515
- query?: never;
516
- url: '/revenue/{customer_name}/';
637
+ url: '/key-metrics/';
517
638
  };
518
639
 
519
- export type GetCustomerRevenueErrors = {
640
+ export type DeleteKeyMetricsErrors = {
520
641
  /**
521
642
  * Missing or invalid API key.
522
643
  */
523
644
  401: ApiErrorOutput;
524
645
  /**
525
- * Nothing exists for this customer.
646
+ * Invalid payload: every offending field is listed and nothing was written.
526
647
  */
527
- 404: ApiErrorOutput;
648
+ 422: InvalidPayloadOutput;
528
649
  };
529
650
 
530
- export type GetCustomerRevenueError = GetCustomerRevenueErrors[keyof GetCustomerRevenueErrors];
651
+ export type DeleteKeyMetricsError = DeleteKeyMetricsErrors[keyof DeleteKeyMetricsErrors];
531
652
 
532
- export type GetCustomerRevenueResponses = {
653
+ export type DeleteKeyMetricsResponses = {
533
654
  /**
534
655
  * Success.
535
656
  */
536
- 200: RevenueOutput;
657
+ 200: RevenueOrKeyMetricDeletedRowOutput;
537
658
  };
538
659
 
539
- export type GetCustomerRevenueResponse = GetCustomerRevenueResponses[keyof GetCustomerRevenueResponses];
660
+ export type DeleteKeyMetricsResponse = DeleteKeyMetricsResponses[keyof DeleteKeyMetricsResponses];
540
661
 
541
- export type GetAllKeyMetricsData = {
662
+ export type GetKeyMetricsData = {
542
663
  body?: never;
543
664
  path?: never;
544
665
  query?: {
666
+ /**
667
+ * Return only these users' key metrics. Omit to return every user's.
668
+ */
669
+ user_names?: Array<string>;
545
670
  /**
546
671
  * Opaque cursor from a previous page's next_cursor.
547
672
  */
@@ -551,23 +676,23 @@ export type GetAllKeyMetricsData = {
551
676
  url: '/key-metrics/';
552
677
  };
553
678
 
554
- export type GetAllKeyMetricsErrors = {
679
+ export type GetKeyMetricsErrors = {
555
680
  /**
556
681
  * Missing or invalid API key.
557
682
  */
558
683
  401: ApiErrorOutput;
559
684
  };
560
685
 
561
- export type GetAllKeyMetricsError = GetAllKeyMetricsErrors[keyof GetAllKeyMetricsErrors];
686
+ export type GetKeyMetricsError = GetKeyMetricsErrors[keyof GetKeyMetricsErrors];
562
687
 
563
- export type GetAllKeyMetricsResponses = {
688
+ export type GetKeyMetricsResponses = {
564
689
  /**
565
690
  * Success.
566
691
  */
567
692
  200: KeyMetricOutput;
568
693
  };
569
694
 
570
- export type GetAllKeyMetricsResponse = GetAllKeyMetricsResponses[keyof GetAllKeyMetricsResponses];
695
+ export type GetKeyMetricsResponse = GetKeyMetricsResponses[keyof GetKeyMetricsResponses];
571
696
 
572
697
  export type SetKeyMetricsData = {
573
698
  body: SetKeyMetricsInput;
@@ -598,25 +723,19 @@ export type SetKeyMetricsResponses = {
598
723
 
599
724
  export type SetKeyMetricsResponse = SetKeyMetricsResponses[keyof SetKeyMetricsResponses];
600
725
 
601
- export type DeleteUserKeyMetricsData = {
726
+ export type DeleteCustomersTagsData = {
602
727
  body?: never;
603
- path: {
604
- user_name: string;
605
- };
606
- query?: {
607
- /**
608
- * First month to delete (inclusive). Omit both bounds to delete every matching API-booked value.
609
- */
610
- month_start?: string;
728
+ path?: never;
729
+ query: {
611
730
  /**
612
- * Last month to delete (inclusive).
731
+ * Delete every tag of these customers.
613
732
  */
614
- month_end?: string;
733
+ customer_names: Array<string>;
615
734
  };
616
- url: '/key-metrics/{user_name}/';
735
+ url: '/customer-tags/';
617
736
  };
618
737
 
619
- export type DeleteUserKeyMetricsErrors = {
738
+ export type DeleteCustomersTagsErrors = {
620
739
  /**
621
740
  * Missing or invalid API key.
622
741
  */
@@ -627,52 +746,25 @@ export type DeleteUserKeyMetricsErrors = {
627
746
  422: InvalidPayloadOutput;
628
747
  };
629
748
 
630
- export type DeleteUserKeyMetricsError = DeleteUserKeyMetricsErrors[keyof DeleteUserKeyMetricsErrors];
631
-
632
- export type DeleteUserKeyMetricsResponses = {
633
- /**
634
- * Success.
635
- */
636
- 200: RevenueOrKeyMetricDeletedRowOutput;
637
- };
638
-
639
- export type DeleteUserKeyMetricsResponse = DeleteUserKeyMetricsResponses[keyof DeleteUserKeyMetricsResponses];
640
-
641
- export type GetUserKeyMetricsData = {
642
- body?: never;
643
- path: {
644
- user_name: string;
645
- };
646
- query?: never;
647
- url: '/key-metrics/{user_name}/';
648
- };
649
-
650
- export type GetUserKeyMetricsErrors = {
651
- /**
652
- * Missing or invalid API key.
653
- */
654
- 401: ApiErrorOutput;
655
- /**
656
- * Nothing exists for this customer.
657
- */
658
- 404: ApiErrorOutput;
659
- };
660
-
661
- export type GetUserKeyMetricsError = GetUserKeyMetricsErrors[keyof GetUserKeyMetricsErrors];
749
+ export type DeleteCustomersTagsError = DeleteCustomersTagsErrors[keyof DeleteCustomersTagsErrors];
662
750
 
663
- export type GetUserKeyMetricsResponses = {
751
+ export type DeleteCustomersTagsResponses = {
664
752
  /**
665
753
  * Success.
666
754
  */
667
- 200: KeyMetricOutput;
755
+ 200: TagsDeletedOutput;
668
756
  };
669
757
 
670
- export type GetUserKeyMetricsResponse = GetUserKeyMetricsResponses[keyof GetUserKeyMetricsResponses];
758
+ export type DeleteCustomersTagsResponse = DeleteCustomersTagsResponses[keyof DeleteCustomersTagsResponses];
671
759
 
672
- export type GetAllCustomersTagsData = {
760
+ export type GetCustomersTagsData = {
673
761
  body?: never;
674
762
  path?: never;
675
763
  query?: {
764
+ /**
765
+ * Return only these customers' tags. Omit to return every customer's.
766
+ */
767
+ customer_names?: Array<string>;
676
768
  /**
677
769
  * Opaque cursor from a previous page's next_cursor.
678
770
  */
@@ -682,23 +774,23 @@ export type GetAllCustomersTagsData = {
682
774
  url: '/customer-tags/';
683
775
  };
684
776
 
685
- export type GetAllCustomersTagsErrors = {
777
+ export type GetCustomersTagsErrors = {
686
778
  /**
687
779
  * Missing or invalid API key.
688
780
  */
689
781
  401: ApiErrorOutput;
690
782
  };
691
783
 
692
- export type GetAllCustomersTagsError = GetAllCustomersTagsErrors[keyof GetAllCustomersTagsErrors];
784
+ export type GetCustomersTagsError = GetCustomersTagsErrors[keyof GetCustomersTagsErrors];
693
785
 
694
- export type GetAllCustomersTagsResponses = {
786
+ export type GetCustomersTagsResponses = {
695
787
  /**
696
788
  * Success.
697
789
  */
698
790
  200: AllCustomerTagsOutput;
699
791
  };
700
792
 
701
- export type GetAllCustomersTagsResponse = GetAllCustomersTagsResponses[keyof GetAllCustomersTagsResponses];
793
+ export type GetCustomersTagsResponse = GetCustomersTagsResponses[keyof GetCustomersTagsResponses];
702
794
 
703
795
  export type SetCustomersTagsData = {
704
796
  body: SetCustomerTagsInput;
@@ -728,65 +820,3 @@ export type SetCustomersTagsResponses = {
728
820
  };
729
821
 
730
822
  export type SetCustomersTagsResponse = SetCustomersTagsResponses[keyof SetCustomersTagsResponses];
731
-
732
- export type DeleteCustomerTagsData = {
733
- body?: never;
734
- path: {
735
- customer_name: string;
736
- };
737
- query?: never;
738
- url: '/customer-tags/{customer_name}/';
739
- };
740
-
741
- export type DeleteCustomerTagsErrors = {
742
- /**
743
- * Missing or invalid API key.
744
- */
745
- 401: ApiErrorOutput;
746
- /**
747
- * Nothing exists for this customer.
748
- */
749
- 404: ApiErrorOutput;
750
- };
751
-
752
- export type DeleteCustomerTagsError = DeleteCustomerTagsErrors[keyof DeleteCustomerTagsErrors];
753
-
754
- export type DeleteCustomerTagsResponses = {
755
- /**
756
- * Success.
757
- */
758
- 200: TagsDeletedOutput;
759
- };
760
-
761
- export type DeleteCustomerTagsResponse = DeleteCustomerTagsResponses[keyof DeleteCustomerTagsResponses];
762
-
763
- export type GetCustomerTagsData = {
764
- body?: never;
765
- path: {
766
- customer_name: string;
767
- };
768
- query?: never;
769
- url: '/customer-tags/{customer_name}/';
770
- };
771
-
772
- export type GetCustomerTagsErrors = {
773
- /**
774
- * Missing or invalid API key.
775
- */
776
- 401: ApiErrorOutput;
777
- /**
778
- * Nothing exists for this customer.
779
- */
780
- 404: ApiErrorOutput;
781
- };
782
-
783
- export type GetCustomerTagsError = GetCustomerTagsErrors[keyof GetCustomerTagsErrors];
784
-
785
- export type GetCustomerTagsResponses = {
786
- /**
787
- * Success.
788
- */
789
- 200: CustomerTagsOutput;
790
- };
791
-
792
- export type GetCustomerTagsResponse = GetCustomerTagsResponses[keyof GetCustomerTagsResponses];
package/src/api/index.ts CHANGED
@@ -12,7 +12,7 @@
12
12
  * const weflayr = require('weflayr');
13
13
  *
14
14
  * const apiClient = weflayr.client({ apiKey: 'wf-...' });
15
- * const { data } = await weflayr.api.getAllRevenue({ client: apiClient, throwOnError: true });
15
+ * const { data } = await weflayr.api.getRevenue({ client: apiClient, throwOnError: true });
16
16
  */
17
17
 
18
18
  import { type Client, createClient, createConfig } from './generated/client';