@passly-nl/data 1.2.2 → 1.3.1

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.
Files changed (72) hide show
  1. package/dist/index.d.mts +664 -69
  2. package/dist/index.d.mts.map +1 -1
  3. package/dist/index.mjs +1982 -343
  4. package/dist/index.mjs.map +1 -1
  5. package/package.json +6 -8
  6. package/src/adapter/StatisticsBuyersAdapter.ts +50 -1
  7. package/src/adapter/StatisticsChartAdapter.ts +56 -0
  8. package/src/adapter/StatisticsEventsAdapter.ts +41 -2
  9. package/src/adapter/StatisticsGrowthAdapter.ts +9 -1
  10. package/src/adapter/StatisticsMarketingAdapter.ts +78 -0
  11. package/src/adapter/StatisticsOperationsAdapter.ts +45 -12
  12. package/src/adapter/StatisticsOverviewAdapter.ts +33 -2
  13. package/src/adapter/StatisticsRefundsAdapter.ts +43 -0
  14. package/src/adapter/StatisticsSalesAdapter.ts +36 -1
  15. package/src/adapter/index.ts +3 -1
  16. package/src/dto/eventStatistics/index.ts +0 -1
  17. package/src/dto/statistics/StatisticsBuyersAcquisitionSourceDto.ts +28 -0
  18. package/src/dto/statistics/StatisticsBuyersAgeGenderMatrixDto.ts +38 -0
  19. package/src/dto/statistics/StatisticsBuyersCohortRetentionDto.ts +48 -0
  20. package/src/dto/statistics/StatisticsBuyersDeviceConversionDto.ts +48 -0
  21. package/src/dto/statistics/StatisticsBuyersGeographicDistributionDto.ts +49 -0
  22. package/src/dto/statistics/StatisticsBuyersSpendBucketsDto.ts +36 -0
  23. package/src/dto/statistics/StatisticsChartDto.ts +43 -0
  24. package/src/dto/statistics/StatisticsEventsSalesCurveDto.ts +19 -0
  25. package/src/dto/statistics/StatisticsEventsSalesCurveEventDto.ts +59 -0
  26. package/src/dto/statistics/StatisticsEventsSellOutTimingDto.ts +39 -0
  27. package/src/dto/statistics/StatisticsEventsSellOutTimingEventDto.ts +38 -0
  28. package/src/dto/statistics/StatisticsEventsTimeToEventDto.ts +36 -0
  29. package/src/dto/statistics/StatisticsGrowthCmgrDto.ts +38 -0
  30. package/src/dto/statistics/StatisticsMarketingCampaignDto.ts +69 -0
  31. package/src/dto/statistics/StatisticsMarketingOverviewDto.ts +79 -0
  32. package/src/dto/statistics/StatisticsMarketingReferrerDto.ts +39 -0
  33. package/src/dto/statistics/StatisticsMarketingShortlinkRoiDto.ts +109 -0
  34. package/src/dto/statistics/StatisticsMarketingSourceBreakdownDto.ts +49 -0
  35. package/src/dto/statistics/StatisticsMarketingSourceFunnelDto.ts +48 -0
  36. package/src/dto/statistics/StatisticsMarketingSourceMediumMatrixDto.ts +39 -0
  37. package/src/dto/statistics/StatisticsOperationsNoShowRateDto.ts +59 -0
  38. package/src/dto/statistics/StatisticsOperationsNoShowRateEventDto.ts +58 -0
  39. package/src/dto/statistics/StatisticsOperationsScanTimeDistributionDto.ts +36 -0
  40. package/src/dto/statistics/{StatisticsOperationsTaskAssigneeDto.ts → StatisticsOperationsStewardDto.ts} +28 -8
  41. package/src/dto/statistics/StatisticsOperationsStockUtilizationDto.ts +100 -0
  42. package/src/dto/statistics/StatisticsOverviewCancellationFunnelDto.ts +58 -0
  43. package/src/dto/statistics/StatisticsOverviewReservationConversionRateDto.ts +78 -0
  44. package/src/dto/statistics/StatisticsOverviewTopShopDto.ts +49 -0
  45. package/src/dto/statistics/StatisticsPieChartDto.ts +29 -0
  46. package/src/dto/statistics/StatisticsRefundsAmountDistributionDto.ts +38 -0
  47. package/src/dto/statistics/StatisticsRefundsOverviewDto.ts +59 -0
  48. package/src/dto/statistics/StatisticsRefundsTopEventDto.ts +70 -0
  49. package/src/dto/statistics/StatisticsRefundsVelocityDto.ts +45 -0
  50. package/src/dto/statistics/StatisticsSalesDiscountEfficacyDto.ts +99 -0
  51. package/src/dto/statistics/StatisticsSalesFailedTransactionReasonDto.ts +29 -0
  52. package/src/dto/statistics/StatisticsSalesOrderValueDistributionDto.ts +38 -0
  53. package/src/dto/statistics/StatisticsSalesRepeatPurchaseVelocityDto.ts +35 -0
  54. package/src/dto/statistics/index.ts +37 -2
  55. package/src/service/MerchantEventStatisticsBuyersService.ts +4 -5
  56. package/src/service/MerchantEventStatisticsOperationsService.ts +4 -5
  57. package/src/service/MerchantEventStatisticsSalesService.ts +10 -11
  58. package/src/service/MerchantStatisticsBuyersService.ts +64 -5
  59. package/src/service/MerchantStatisticsEventsService.ts +48 -9
  60. package/src/service/MerchantStatisticsGrowthService.ts +25 -5
  61. package/src/service/MerchantStatisticsMarketingService.ts +96 -0
  62. package/src/service/MerchantStatisticsOperationsService.ts +39 -10
  63. package/src/service/MerchantStatisticsOverviewService.ts +34 -5
  64. package/src/service/MerchantStatisticsRefundsService.ts +76 -0
  65. package/src/service/MerchantStatisticsSalesService.ts +78 -9
  66. package/src/service/MerchantStatisticsService.ts +0 -11
  67. package/src/service/index.ts +2 -0
  68. package/src/types/index.ts +1 -0
  69. package/src/types/statistics.ts +32 -0
  70. package/src/adapter/EventStatisticsSalesAdapter.ts +0 -21
  71. package/src/dto/eventStatistics/EventStatisticsSalesFlowChartDto.ts +0 -66
  72. package/src/dto/statistics/StatisticsOperationsTasksOverviewDto.ts +0 -69
@@ -1,8 +1,7 @@
1
1
  import { BaseResponse, BaseService, QueryString } from '@basmilius/http-client';
2
- import type { ApexOptions } from 'apexcharts';
3
2
  import type { DateTime } from 'luxon';
4
- import { StatisticsSalesAdapter } from '#data/adapter';
5
- import type { StatisticsSalesLifetimeTotalsDto, StatisticsSalesPurchaseBehaviorDto, StatisticsSalesTransactionSuccessRateDto } from '#data/dto';
3
+ import { StatisticsChartAdapter, StatisticsSalesAdapter } from '#data/adapter';
4
+ import type { StatisticsChartDto, StatisticsPieChartDto, StatisticsSalesDiscountEfficacyDto, StatisticsSalesFailedTransactionReasonDto, StatisticsSalesLifetimeTotalsDto, StatisticsSalesOrderValueDistributionDto, StatisticsSalesPurchaseBehaviorDto, StatisticsSalesRepeatPurchaseVelocityDto, StatisticsSalesTransactionSuccessRateDto } from '#data/dto';
6
5
 
7
6
  export class MerchantStatisticsSalesService extends BaseService {
8
7
  async getLifetimeTotals(merchantId: string): Promise<BaseResponse<StatisticsSalesLifetimeTotalsDto>> {
@@ -15,14 +14,14 @@ export class MerchantStatisticsSalesService extends BaseService {
15
14
  .runAdapter(StatisticsSalesAdapter.parseLifetimeTotals);
16
15
  }
17
16
 
18
- async getPaymentMethodsChart(merchantId: string, from: DateTime, to: DateTime): Promise<BaseResponse<ApexOptions>> {
17
+ async getPaymentMethodsChart(merchantId: string, from: DateTime, to: DateTime): Promise<BaseResponse<StatisticsPieChartDto>> {
19
18
  return await this
20
19
  .request(`/merchants/${merchantId}/statistics/sales/payment-methods-chart/${from.toSQLDate()}/${to.toSQLDate()}`)
21
20
  .method('get')
22
21
  .queryString(QueryString.builder()
23
22
  .append('language', 'nl'))
24
23
  .bearerToken()
25
- .run();
24
+ .runAdapter(StatisticsChartAdapter.parsePie);
26
25
  }
27
26
 
28
27
  async getPurchaseBehavior(merchantId: string, from: DateTime, to: DateTime): Promise<BaseResponse<StatisticsSalesPurchaseBehaviorDto>> {
@@ -35,24 +34,24 @@ export class MerchantStatisticsSalesService extends BaseService {
35
34
  .runAdapter(StatisticsSalesAdapter.parsePurchaseBehavior);
36
35
  }
37
36
 
38
- async getRevenueTrend(merchantId: string, from: DateTime, to: DateTime): Promise<BaseResponse<ApexOptions>> {
37
+ async getRevenueTrend(merchantId: string, from: DateTime, to: DateTime): Promise<BaseResponse<StatisticsChartDto>> {
39
38
  return await this
40
39
  .request(`/merchants/${merchantId}/statistics/sales/revenue-trend/${from.toSQLDate()}/${to.toSQLDate()}`)
41
40
  .method('get')
42
41
  .queryString(QueryString.builder()
43
42
  .append('language', 'nl'))
44
43
  .bearerToken()
45
- .run();
44
+ .runAdapter(StatisticsChartAdapter.parseChart);
46
45
  }
47
46
 
48
- async getSalesByDayOfWeek(merchantId: string, from: DateTime, to: DateTime): Promise<BaseResponse<ApexOptions>> {
47
+ async getSalesByDayOfWeek(merchantId: string, from: DateTime, to: DateTime): Promise<BaseResponse<StatisticsChartDto>> {
49
48
  return await this
50
49
  .request(`/merchants/${merchantId}/statistics/sales/sales-by-day-of-week/${from.toSQLDate()}/${to.toSQLDate()}`)
51
50
  .method('get')
52
51
  .queryString(QueryString.builder()
53
52
  .append('language', 'nl'))
54
53
  .bearerToken()
55
- .run();
54
+ .runAdapter(StatisticsChartAdapter.parseChart);
56
55
  }
57
56
 
58
57
  async getTransactionSuccessRate(merchantId: string, from: DateTime, to: DateTime): Promise<BaseResponse<StatisticsSalesTransactionSuccessRateDto>> {
@@ -64,4 +63,74 @@ export class MerchantStatisticsSalesService extends BaseService {
64
63
  .bearerToken()
65
64
  .runAdapter(StatisticsSalesAdapter.parseTransactionSuccessRate);
66
65
  }
66
+
67
+ async getDiscountEfficacy(merchantId: string, from: DateTime, to: DateTime): Promise<BaseResponse<StatisticsSalesDiscountEfficacyDto>> {
68
+ return await this
69
+ .request(`/merchants/${merchantId}/statistics/sales/discount-efficacy/${from.toSQLDate()}/${to.toSQLDate()}`)
70
+ .method('get')
71
+ .queryString(QueryString.builder()
72
+ .append('language', 'nl'))
73
+ .bearerToken()
74
+ .runAdapter(StatisticsSalesAdapter.parseDiscountEfficacy);
75
+ }
76
+
77
+ async getCartAbandonmentTrend(merchantId: string, from: DateTime, to: DateTime): Promise<BaseResponse<StatisticsChartDto>> {
78
+ return await this
79
+ .request(`/merchants/${merchantId}/statistics/sales/cart-abandonment-trend/${from.toSQLDate()}/${to.toSQLDate()}`)
80
+ .method('get')
81
+ .queryString(QueryString.builder()
82
+ .append('language', 'nl'))
83
+ .bearerToken()
84
+ .runAdapter(StatisticsChartAdapter.parseChart);
85
+ }
86
+
87
+ async getOrderValueDistribution(merchantId: string, from: DateTime, to: DateTime): Promise<BaseResponse<StatisticsSalesOrderValueDistributionDto>> {
88
+ return await this
89
+ .request(`/merchants/${merchantId}/statistics/sales/order-value-distribution/${from.toSQLDate()}/${to.toSQLDate()}`)
90
+ .method('get')
91
+ .queryString(QueryString.builder()
92
+ .append('language', 'nl'))
93
+ .bearerToken()
94
+ .runAdapter(StatisticsSalesAdapter.parseOrderValueDistribution);
95
+ }
96
+
97
+ async getFailedTransactionReasons(merchantId: string, from: DateTime, to: DateTime): Promise<BaseResponse<StatisticsSalesFailedTransactionReasonDto[]>> {
98
+ return await this
99
+ .request(`/merchants/${merchantId}/statistics/sales/failed-transaction-reasons/${from.toSQLDate()}/${to.toSQLDate()}`)
100
+ .method('get')
101
+ .queryString(QueryString.builder()
102
+ .append('language', 'nl'))
103
+ .bearerToken()
104
+ .runArrayAdapter(StatisticsSalesAdapter.parseFailedTransactionReason);
105
+ }
106
+
107
+ async getOrderOriginDistribution(merchantId: string, from: DateTime, to: DateTime): Promise<BaseResponse<StatisticsPieChartDto>> {
108
+ return await this
109
+ .request(`/merchants/${merchantId}/statistics/sales/order-origin-distribution/${from.toSQLDate()}/${to.toSQLDate()}`)
110
+ .method('get')
111
+ .queryString(QueryString.builder()
112
+ .append('language', 'nl'))
113
+ .bearerToken()
114
+ .runAdapter(StatisticsChartAdapter.parsePie);
115
+ }
116
+
117
+ async getRepeatPurchaseVelocity(merchantId: string, from: DateTime, to: DateTime): Promise<BaseResponse<StatisticsSalesRepeatPurchaseVelocityDto>> {
118
+ return await this
119
+ .request(`/merchants/${merchantId}/statistics/sales/repeat-purchase-velocity/${from.toSQLDate()}/${to.toSQLDate()}`)
120
+ .method('get')
121
+ .queryString(QueryString.builder()
122
+ .append('language', 'nl'))
123
+ .bearerToken()
124
+ .runAdapter(StatisticsSalesAdapter.parseRepeatPurchaseVelocity);
125
+ }
126
+
127
+ async getAverageTicketPriceTrend(merchantId: string, from: DateTime, to: DateTime): Promise<BaseResponse<StatisticsChartDto>> {
128
+ return await this
129
+ .request(`/merchants/${merchantId}/statistics/sales/average-ticket-price-trend/${from.toSQLDate()}/${to.toSQLDate()}`)
130
+ .method('get')
131
+ .queryString(QueryString.builder()
132
+ .append('language', 'nl'))
133
+ .bearerToken()
134
+ .runAdapter(StatisticsChartAdapter.parseChart);
135
+ }
67
136
  }
@@ -1,17 +1,6 @@
1
1
  import { BaseResponse, BaseService, QueryString } from '@basmilius/http-client';
2
- import type { ApexOptions } from 'apexcharts';
3
2
 
4
3
  export class MerchantStatisticsService extends BaseService {
5
- async getRevenueTrend(merchantId: string): Promise<BaseResponse<ApexOptions>> {
6
- return await this
7
- .request(`/merchants/${merchantId}/statistics/revenue-trend`)
8
- .method('get')
9
- .queryString(QueryString.builder()
10
- .append('language', 'nl'))
11
- .bearerToken()
12
- .run();
13
- }
14
-
15
4
  async getStatus(merchantId: string): Promise<BaseResponse<boolean>> {
16
5
  return await this
17
6
  .request(`/merchants/${merchantId}/statistics/status`)
@@ -45,8 +45,10 @@ export * from './MerchantStatisticsBuyersService';
45
45
  export * from './MerchantStatisticsEventsService';
46
46
  export * from './MerchantStatisticsGrowthService';
47
47
  export * from './MerchantStatisticsInsightsService';
48
+ export * from './MerchantStatisticsMarketingService';
48
49
  export * from './MerchantStatisticsOperationsService';
49
50
  export * from './MerchantStatisticsOverviewService';
51
+ export * from './MerchantStatisticsRefundsService';
50
52
  export * from './MerchantStatisticsSalesService';
51
53
  export * from './MerchantAiChatService';
52
54
  export * from './MerchantAiSettingsService';
@@ -16,5 +16,6 @@ export type * from './payment';
16
16
  export type * from './product';
17
17
  export type * from './publicShop';
18
18
  export type * from './refund';
19
+ export type * from './statistics';
19
20
  export type * from './subscription';
20
21
  export type * from './ticket';
@@ -0,0 +1,32 @@
1
+ export type StatisticsChartValueType =
2
+ | 'count'
3
+ | 'integer'
4
+ | 'currency'
5
+ | 'percentage'
6
+ | 'duration';
7
+
8
+ export type StatisticsChartSeriesKind =
9
+ | 'line'
10
+ | 'area'
11
+ | 'bar';
12
+
13
+ export type StatisticsChartDataPoint = {
14
+ readonly value: number;
15
+ readonly formatted?: string;
16
+ };
17
+
18
+ export interface StatisticsChartSeries {
19
+ readonly name: string | null;
20
+ readonly valueType: StatisticsChartValueType;
21
+ readonly data: readonly (number | null | StatisticsChartDataPoint)[];
22
+ readonly type: StatisticsChartSeriesKind | null;
23
+ readonly axisIndex: number | null;
24
+ readonly zIndex: number | null;
25
+ readonly currency: string | null;
26
+ }
27
+
28
+ export interface StatisticsPieSlice {
29
+ readonly label: string;
30
+ readonly value: number;
31
+ readonly formatted: string | null;
32
+ }
@@ -1,21 +0,0 @@
1
- import { adapter, ForeignData } from '@basmilius/http-client';
2
- import { DateTimeAdapter } from '#data/adapter';
3
- import { EventStatisticsSalesFlowChartDto, EventStatisticsSalesFlowChartSeriesDto } from '#data/dto';
4
-
5
- @adapter
6
- export class EventStatisticsSalesAdapter {
7
- static parseSalesFlowChart(data: ForeignData): EventStatisticsSalesFlowChartDto {
8
- return new EventStatisticsSalesFlowChartDto(
9
- data.series.map(EventStatisticsSalesAdapter.parseSalesFlowChartSeries),
10
- data.xaxis.categories.map(DateTimeAdapter.parseDateTime)
11
- );
12
- }
13
-
14
- static parseSalesFlowChartSeries(data: ForeignData): EventStatisticsSalesFlowChartSeriesDto {
15
- return new EventStatisticsSalesFlowChartSeriesDto(
16
- data.name,
17
- data.data,
18
- data.zIndex
19
- );
20
- }
21
- }
@@ -1,66 +0,0 @@
1
- import { dto } from '@basmilius/http-client';
2
- import type { DateTime } from 'luxon';
3
-
4
- @dto
5
- export class EventStatisticsSalesFlowChartSeriesDto {
6
- get name(): string {
7
- return this.#name;
8
- }
9
-
10
- set name(value: string) {
11
- this.#name = value;
12
- }
13
-
14
- get data(): number[] {
15
- return this.#data;
16
- }
17
-
18
- set data(value: number[]) {
19
- this.#data = value;
20
- }
21
-
22
- get zIndex(): number {
23
- return this.#zIndex;
24
- }
25
-
26
- set zIndex(value: number) {
27
- this.#zIndex = value;
28
- }
29
-
30
- #name: string;
31
- #data: number[];
32
- #zIndex: number;
33
-
34
- constructor(name: string, data: number[], zIndex: number) {
35
- this.#name = name;
36
- this.#data = data;
37
- this.#zIndex = zIndex;
38
- }
39
- }
40
-
41
- @dto
42
- export class EventStatisticsSalesFlowChartDto {
43
- get series(): EventStatisticsSalesFlowChartSeriesDto[] {
44
- return this.#series;
45
- }
46
-
47
- set series(value: EventStatisticsSalesFlowChartSeriesDto[]) {
48
- this.#series = value;
49
- }
50
-
51
- get categories(): DateTime[] {
52
- return this.#categories;
53
- }
54
-
55
- set categories(value: DateTime[]) {
56
- this.#categories = value;
57
- }
58
-
59
- #series: EventStatisticsSalesFlowChartSeriesDto[];
60
- #categories: DateTime[];
61
-
62
- constructor(series: EventStatisticsSalesFlowChartSeriesDto[], categories: DateTime[]) {
63
- this.#series = series;
64
- this.#categories = categories;
65
- }
66
- }
@@ -1,69 +0,0 @@
1
- import { dto } from '@basmilius/http-client';
2
- import type { StatisticsOperationsTaskAssigneeDto } from '#data/dto';
3
-
4
- @dto
5
- export class StatisticsOperationsTasksOverviewDto {
6
- get open(): number {
7
- return this.#open;
8
- }
9
-
10
- set open(value: number) {
11
- this.#open = value;
12
- }
13
-
14
- get inProgress(): number {
15
- return this.#inProgress;
16
- }
17
-
18
- set inProgress(value: number) {
19
- this.#inProgress = value;
20
- }
21
-
22
- get resolved(): number {
23
- return this.#resolved;
24
- }
25
-
26
- set resolved(value: number) {
27
- this.#resolved = value;
28
- }
29
-
30
- get canceled(): number {
31
- return this.#canceled;
32
- }
33
-
34
- set canceled(value: number) {
35
- this.#canceled = value;
36
- }
37
-
38
- get averageResolveTimeSeconds(): number {
39
- return this.#averageResolveTimeSeconds;
40
- }
41
-
42
- set averageResolveTimeSeconds(value: number) {
43
- this.#averageResolveTimeSeconds = value;
44
- }
45
-
46
- get topAssignees(): StatisticsOperationsTaskAssigneeDto[] {
47
- return this.#topAssignees;
48
- }
49
-
50
- set topAssignees(value: StatisticsOperationsTaskAssigneeDto[]) {
51
- this.#topAssignees = value;
52
- }
53
-
54
- #open: number;
55
- #inProgress: number;
56
- #resolved: number;
57
- #canceled: number;
58
- #averageResolveTimeSeconds: number;
59
- #topAssignees: StatisticsOperationsTaskAssigneeDto[];
60
-
61
- constructor(open: number, inProgress: number, resolved: number, canceled: number, averageResolveTimeSeconds: number, topAssignees: StatisticsOperationsTaskAssigneeDto[]) {
62
- this.#open = open;
63
- this.#inProgress = inProgress;
64
- this.#resolved = resolved;
65
- this.#canceled = canceled;
66
- this.#averageResolveTimeSeconds = averageResolveTimeSeconds;
67
- this.#topAssignees = topAssignees;
68
- }
69
- }