@mestra-dev/contract 0.0.183 → 0.0.185

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 (2) hide show
  1. package/dist/index.d.ts +533 -0
  2. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -4458,6 +4458,103 @@ declare const routes: import("hono/hono-base").HonoBase<{
4458
4458
  };
4459
4459
  };
4460
4460
  };
4461
+ readonly ChannelPerformanceTotal: {
4462
+ readonly type: "object";
4463
+ readonly required: readonly [
4464
+ "leadSource",
4465
+ "currency",
4466
+ "paidAmountMinor",
4467
+ "paidInvoiceCount",
4468
+ "pendingAmountMinor",
4469
+ "pendingInvoiceCount"
4470
+ ];
4471
+ readonly properties: {
4472
+ readonly leadSource: {
4473
+ readonly type: "string";
4474
+ readonly enum: readonly [
4475
+ "cian",
4476
+ "avito",
4477
+ "vk",
4478
+ "yandex",
4479
+ "website",
4480
+ "referral",
4481
+ "walk_in",
4482
+ "unattributed"
4483
+ ];
4484
+ readonly description: "Lead acquisition source, or unattributed when no source was recorded.";
4485
+ };
4486
+ readonly currency: {
4487
+ readonly type: "string";
4488
+ readonly description: "Invoice currency.";
4489
+ };
4490
+ readonly paidAmountMinor: {
4491
+ readonly type: "integer";
4492
+ readonly description: "Paid invoice revenue in minor units after discount, excluding VAT.";
4493
+ };
4494
+ readonly paidInvoiceCount: {
4495
+ readonly type: "integer";
4496
+ readonly description: "Number of paid invoices included in the total.";
4497
+ };
4498
+ readonly pendingAmountMinor: {
4499
+ readonly type: "integer";
4500
+ readonly description: "Pending invoice value in minor units after discount, excluding VAT.";
4501
+ };
4502
+ readonly pendingInvoiceCount: {
4503
+ readonly type: "integer";
4504
+ readonly description: "Number of pending invoices included in the total.";
4505
+ };
4506
+ };
4507
+ };
4508
+ readonly ChannelPerformanceAnalysisSuccess: {
4509
+ readonly type: "object";
4510
+ readonly required: readonly [
4511
+ "success",
4512
+ "workspaceId",
4513
+ "category",
4514
+ "period",
4515
+ "channels"
4516
+ ];
4517
+ readonly properties: {
4518
+ readonly success: {
4519
+ readonly type: "boolean";
4520
+ readonly const: true;
4521
+ };
4522
+ readonly workspaceId: {
4523
+ readonly type: "string";
4524
+ readonly format: "uuid";
4525
+ };
4526
+ readonly category: {
4527
+ readonly type: "string";
4528
+ readonly description: "Workspace category.";
4529
+ };
4530
+ readonly period: {
4531
+ readonly type: "object";
4532
+ readonly required: readonly [
4533
+ "from",
4534
+ "to"
4535
+ ];
4536
+ readonly properties: {
4537
+ readonly from: {
4538
+ readonly type: "string";
4539
+ readonly format: "date-time";
4540
+ readonly nullable: true;
4541
+ };
4542
+ readonly to: {
4543
+ readonly type: "string";
4544
+ readonly format: "date-time";
4545
+ readonly nullable: true;
4546
+ };
4547
+ };
4548
+ };
4549
+ readonly channels: {
4550
+ readonly type: "array";
4551
+ readonly items: {
4552
+ readonly $ref: "#/components/schemas/ChannelPerformanceTotal";
4553
+ };
4554
+ readonly description: "Revenue grouped by lead source and invoice currency. Empty when no paid or pending invoices match the period.";
4555
+ };
4556
+ };
4557
+ };
4461
4558
  readonly ConversionRateAnalysisSuccess: {
4462
4559
  readonly type: "object";
4463
4560
  readonly required: readonly [
@@ -4515,6 +4612,113 @@ declare const routes: import("hono/hono-base").HonoBase<{
4515
4612
  };
4516
4613
  };
4517
4614
  };
4615
+ readonly EmployeeConversionRate: {
4616
+ readonly type: "object";
4617
+ readonly required: readonly [
4618
+ "collaboratorId",
4619
+ "userId",
4620
+ "firstName",
4621
+ "lastName",
4622
+ "profilePicture",
4623
+ "status",
4624
+ "assignedCustomerCount",
4625
+ "convertedCustomerCount",
4626
+ "conversionRate"
4627
+ ];
4628
+ readonly properties: {
4629
+ readonly collaboratorId: {
4630
+ readonly type: "string";
4631
+ readonly format: "uuid";
4632
+ readonly description: "Workspace collaborator identifier.";
4633
+ };
4634
+ readonly userId: {
4635
+ readonly type: "string";
4636
+ readonly format: "uuid";
4637
+ readonly description: "Underlying user identifier.";
4638
+ };
4639
+ readonly firstName: {
4640
+ readonly type: "string";
4641
+ readonly nullable: true;
4642
+ readonly description: "Collaborator first name.";
4643
+ };
4644
+ readonly lastName: {
4645
+ readonly type: "string";
4646
+ readonly nullable: true;
4647
+ readonly description: "Collaborator last name.";
4648
+ };
4649
+ readonly profilePicture: {
4650
+ readonly type: "string";
4651
+ readonly nullable: true;
4652
+ readonly description: "Collaborator profile image URL.";
4653
+ };
4654
+ readonly status: {
4655
+ readonly type: "string";
4656
+ readonly description: "Collaborator status, including active or inactive states.";
4657
+ };
4658
+ readonly assignedCustomerCount: {
4659
+ readonly type: "integer";
4660
+ readonly description: "Distinct non-deleted customers linked to this collaborator's qualifying tasks.";
4661
+ };
4662
+ readonly convertedCustomerCount: {
4663
+ readonly type: "integer";
4664
+ readonly description: "Assigned customers with at least one qualifying paid CInvoice.";
4665
+ };
4666
+ readonly conversionRate: {
4667
+ readonly type: "number";
4668
+ readonly description: "Converted customers divided by assigned customers, expressed as a percentage.";
4669
+ };
4670
+ };
4671
+ };
4672
+ readonly EmployeeConversionRateAnalysisSuccess: {
4673
+ readonly type: "object";
4674
+ readonly required: readonly [
4675
+ "success",
4676
+ "workspaceId",
4677
+ "category",
4678
+ "period",
4679
+ "employees"
4680
+ ];
4681
+ readonly properties: {
4682
+ readonly success: {
4683
+ readonly type: "boolean";
4684
+ readonly const: true;
4685
+ };
4686
+ readonly workspaceId: {
4687
+ readonly type: "string";
4688
+ readonly format: "uuid";
4689
+ };
4690
+ readonly category: {
4691
+ readonly type: "string";
4692
+ readonly description: "Workspace category.";
4693
+ };
4694
+ readonly period: {
4695
+ readonly type: "object";
4696
+ readonly required: readonly [
4697
+ "from",
4698
+ "to"
4699
+ ];
4700
+ readonly properties: {
4701
+ readonly from: {
4702
+ readonly type: "string";
4703
+ readonly format: "date-time";
4704
+ readonly nullable: true;
4705
+ };
4706
+ readonly to: {
4707
+ readonly type: "string";
4708
+ readonly format: "date-time";
4709
+ readonly nullable: true;
4710
+ };
4711
+ };
4712
+ };
4713
+ readonly employees: {
4714
+ readonly type: "array";
4715
+ readonly items: {
4716
+ readonly $ref: "#/components/schemas/EmployeeConversionRate";
4717
+ };
4718
+ readonly description: "Active and inactive collaborators with at least one task linked to a customer.";
4719
+ };
4720
+ };
4721
+ };
4518
4722
  readonly ForecastRevenueTotal: {
4519
4723
  readonly type: "object";
4520
4724
  readonly required: readonly [
@@ -13814,6 +14018,102 @@ declare const routes: import("hono/hono-base").HonoBase<{
13814
14018
  };
13815
14019
  };
13816
14020
  };
14021
+ readonly "/analytics/{workspace}/channel-performance": {
14022
+ readonly get: {
14023
+ readonly tags: readonly [
14024
+ "Analytics"
14025
+ ];
14026
+ readonly summary: "Get real-estate channel performance";
14027
+ readonly description: "Returns paid and pending CInvoice revenue grouped by the linked customer's acquisition source and invoice currency. Paid invoices are filtered by paidAt; pending invoices are filtered by invoice date; both period bounds are from inclusive and to exclusive. Amounts are post-discount minor units and exclude VAT. Customers without a recorded source are grouped as unattributed. Soft-deleted invoices and customers, plus cancelled and refunded invoices, are excluded. Requires workspace access and read access to crm::analytics. Other workspace categories return 400.";
14028
+ readonly security: readonly [
14029
+ never
14030
+ ];
14031
+ readonly parameters: readonly [
14032
+ {
14033
+ readonly name: "workspace";
14034
+ readonly in: "path";
14035
+ readonly required: true;
14036
+ readonly schema: {
14037
+ readonly type: "string";
14038
+ readonly format: "uuid";
14039
+ };
14040
+ readonly description: "Workspace identifier.";
14041
+ },
14042
+ {
14043
+ readonly name: "from";
14044
+ readonly in: "query";
14045
+ readonly required: false;
14046
+ readonly schema: {
14047
+ readonly type: "string";
14048
+ readonly format: "date-time";
14049
+ };
14050
+ readonly description: "Include pending invoices dated and paid invoices paid at or after this timestamp.";
14051
+ },
14052
+ {
14053
+ readonly name: "to";
14054
+ readonly in: "query";
14055
+ readonly required: false;
14056
+ readonly schema: {
14057
+ readonly type: "string";
14058
+ readonly format: "date-time";
14059
+ };
14060
+ readonly description: "Include pending invoices dated and paid invoices paid before this timestamp.";
14061
+ }
14062
+ ];
14063
+ readonly responses: {
14064
+ readonly 200: {
14065
+ readonly description: "Channel performance fetched successfully.";
14066
+ readonly content: {
14067
+ readonly "application/json": {
14068
+ readonly schema: {
14069
+ readonly $ref: "#/components/schemas/ChannelPerformanceAnalysisSuccess";
14070
+ };
14071
+ };
14072
+ };
14073
+ };
14074
+ readonly 400: {
14075
+ readonly description: "Invalid query, invalid workspace ID, or unsupported workspace category.";
14076
+ readonly content: {
14077
+ readonly "application/json": {
14078
+ readonly schema: {
14079
+ readonly $ref: "#/components/schemas/ErrorResponse";
14080
+ };
14081
+ };
14082
+ };
14083
+ };
14084
+ readonly 401: {
14085
+ readonly description: "Unauthorized - Missing or invalid access token.";
14086
+ readonly content: {
14087
+ readonly "application/json": {
14088
+ readonly schema: {
14089
+ readonly $ref: "#/components/schemas/ErrorResponse";
14090
+ };
14091
+ };
14092
+ };
14093
+ };
14094
+ readonly 403: {
14095
+ readonly description: "Forbidden - Token issuer is not 'access', user lacks workspace access, or user lacks read access to crm::analytics resource.";
14096
+ readonly content: {
14097
+ readonly "application/json": {
14098
+ readonly schema: {
14099
+ readonly $ref: "#/components/schemas/ErrorResponse";
14100
+ };
14101
+ };
14102
+ };
14103
+ };
14104
+ readonly 404: {
14105
+ readonly description: "Workspace not found.";
14106
+ readonly content: {
14107
+ readonly "application/json": {
14108
+ readonly schema: {
14109
+ readonly $ref: "#/components/schemas/ErrorResponse";
14110
+ };
14111
+ };
14112
+ };
14113
+ };
14114
+ };
14115
+ };
14116
+ };
13817
14117
  readonly "/analytics/{workspace}/conversion-rate": {
13818
14118
  readonly get: {
13819
14119
  readonly tags: readonly [
@@ -13910,6 +14210,102 @@ declare const routes: import("hono/hono-base").HonoBase<{
13910
14210
  };
13911
14211
  };
13912
14212
  };
14213
+ readonly "/analytics/{workspace}/employee-conversion-rate": {
14214
+ readonly get: {
14215
+ readonly tags: readonly [
14216
+ "Analytics"
14217
+ ];
14218
+ readonly summary: "Get real-estate employee conversion rates";
14219
+ readonly description: "Returns a customer-level conversion rate for each active or inactive collaborator with at least one qualifying task linked to a non-deleted real-estate customer. Assigned customers are distinct customers on the collaborator's tasks created within the optional period. A converted customer has at least one non-deleted paid CInvoice in the period. When several collaborators worked on the same customer, each receives full credit; multiple tasks or invoices for that customer do not increase counts. The rate is zero when a returned collaborator has no assigned customers after filtering. Requires workspace access and read access to crm::analytics. Other workspace categories return 400.";
14220
+ readonly security: readonly [
14221
+ never
14222
+ ];
14223
+ readonly parameters: readonly [
14224
+ {
14225
+ readonly name: "workspace";
14226
+ readonly in: "path";
14227
+ readonly required: true;
14228
+ readonly schema: {
14229
+ readonly type: "string";
14230
+ readonly format: "uuid";
14231
+ };
14232
+ readonly description: "Workspace identifier.";
14233
+ },
14234
+ {
14235
+ readonly name: "from";
14236
+ readonly in: "query";
14237
+ readonly required: false;
14238
+ readonly schema: {
14239
+ readonly type: "string";
14240
+ readonly format: "date-time";
14241
+ };
14242
+ readonly description: "Include tasks created and CInvoices paid at or after this timestamp.";
14243
+ },
14244
+ {
14245
+ readonly name: "to";
14246
+ readonly in: "query";
14247
+ readonly required: false;
14248
+ readonly schema: {
14249
+ readonly type: "string";
14250
+ readonly format: "date-time";
14251
+ };
14252
+ readonly description: "Include tasks created and CInvoices paid before this timestamp.";
14253
+ }
14254
+ ];
14255
+ readonly responses: {
14256
+ readonly 200: {
14257
+ readonly description: "Employee conversion rates fetched successfully.";
14258
+ readonly content: {
14259
+ readonly "application/json": {
14260
+ readonly schema: {
14261
+ readonly $ref: "#/components/schemas/EmployeeConversionRateAnalysisSuccess";
14262
+ };
14263
+ };
14264
+ };
14265
+ };
14266
+ readonly 400: {
14267
+ readonly description: "Invalid query, invalid workspace ID, or unsupported workspace category.";
14268
+ readonly content: {
14269
+ readonly "application/json": {
14270
+ readonly schema: {
14271
+ readonly $ref: "#/components/schemas/ErrorResponse";
14272
+ };
14273
+ };
14274
+ };
14275
+ };
14276
+ readonly 401: {
14277
+ readonly description: "Unauthorized - Missing or invalid access token.";
14278
+ readonly content: {
14279
+ readonly "application/json": {
14280
+ readonly schema: {
14281
+ readonly $ref: "#/components/schemas/ErrorResponse";
14282
+ };
14283
+ };
14284
+ };
14285
+ };
14286
+ readonly 403: {
14287
+ readonly description: "Forbidden - Token issuer is not 'access', user lacks workspace access, or user lacks read access to crm::analytics resource.";
14288
+ readonly content: {
14289
+ readonly "application/json": {
14290
+ readonly schema: {
14291
+ readonly $ref: "#/components/schemas/ErrorResponse";
14292
+ };
14293
+ };
14294
+ };
14295
+ };
14296
+ readonly 404: {
14297
+ readonly description: "Workspace not found.";
14298
+ readonly content: {
14299
+ readonly "application/json": {
14300
+ readonly schema: {
14301
+ readonly $ref: "#/components/schemas/ErrorResponse";
14302
+ };
14303
+ };
14304
+ };
14305
+ };
14306
+ };
14307
+ };
14308
+ };
13913
14309
  readonly "/analytics/{workspace}/forecast-revenue": {
13914
14310
  readonly get: {
13915
14311
  readonly tags: readonly [
@@ -26371,6 +26767,143 @@ declare const routes: import("hono/hono-base").HonoBase<{
26371
26767
  status: 200;
26372
26768
  };
26373
26769
  };
26770
+ } & {
26771
+ "/:workspace/employee-conversion-rate": {
26772
+ $get: {
26773
+ input: {
26774
+ param: {
26775
+ workspace: string;
26776
+ };
26777
+ };
26778
+ output: {
26779
+ success: false;
26780
+ error: {
26781
+ [x: string]: import("hono/utils/types").JSONValue;
26782
+ };
26783
+ };
26784
+ outputFormat: "json";
26785
+ status: 400;
26786
+ } | {
26787
+ input: {
26788
+ param: {
26789
+ workspace: string;
26790
+ };
26791
+ };
26792
+ output: {
26793
+ success: false;
26794
+ error: string;
26795
+ };
26796
+ outputFormat: "json";
26797
+ status: 400;
26798
+ } | {
26799
+ input: {
26800
+ param: {
26801
+ workspace: string;
26802
+ };
26803
+ };
26804
+ output: {
26805
+ success: false;
26806
+ error: string;
26807
+ };
26808
+ outputFormat: "json";
26809
+ status: 404;
26810
+ } | {
26811
+ input: {
26812
+ param: {
26813
+ workspace: string;
26814
+ };
26815
+ };
26816
+ output: {
26817
+ success: true;
26818
+ workspaceId: string;
26819
+ category: string;
26820
+ period: {
26821
+ from: string | null;
26822
+ to: string | null;
26823
+ };
26824
+ employees: {
26825
+ collaboratorId: string;
26826
+ userId: string;
26827
+ firstName: string | null;
26828
+ lastName: string | null;
26829
+ profilePicture: string | null;
26830
+ status: string;
26831
+ assignedCustomerCount: number;
26832
+ convertedCustomerCount: number;
26833
+ conversionRate: number;
26834
+ }[];
26835
+ };
26836
+ outputFormat: "json";
26837
+ status: 200;
26838
+ };
26839
+ };
26840
+ } & {
26841
+ "/:workspace/channel-performance": {
26842
+ $get: {
26843
+ input: {
26844
+ param: {
26845
+ workspace: string;
26846
+ };
26847
+ };
26848
+ output: {
26849
+ success: false;
26850
+ error: {
26851
+ [x: string]: import("hono/utils/types").JSONValue;
26852
+ };
26853
+ };
26854
+ outputFormat: "json";
26855
+ status: 400;
26856
+ } | {
26857
+ input: {
26858
+ param: {
26859
+ workspace: string;
26860
+ };
26861
+ };
26862
+ output: {
26863
+ success: false;
26864
+ error: string;
26865
+ };
26866
+ outputFormat: "json";
26867
+ status: 400;
26868
+ } | {
26869
+ input: {
26870
+ param: {
26871
+ workspace: string;
26872
+ };
26873
+ };
26874
+ output: {
26875
+ success: false;
26876
+ error: string;
26877
+ };
26878
+ outputFormat: "json";
26879
+ status: 404;
26880
+ } | {
26881
+ input: {
26882
+ param: {
26883
+ workspace: string;
26884
+ };
26885
+ };
26886
+ output: {
26887
+ success: true;
26888
+ workspaceId: string;
26889
+ category: string;
26890
+ period: {
26891
+ from: string | null;
26892
+ to: string | null;
26893
+ };
26894
+ channels: {
26895
+ leadSource: string;
26896
+ currency: string;
26897
+ paidAmountMinor: number;
26898
+ paidInvoiceCount: number;
26899
+ pendingAmountMinor: number;
26900
+ pendingInvoiceCount: number;
26901
+ }[];
26902
+ };
26903
+ outputFormat: "json";
26904
+ status: 200;
26905
+ };
26906
+ };
26374
26907
  } & {
26375
26908
  "/:workspace/forecast-revenue": {
26376
26909
  $get: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mestra-dev/contract",
3
- "version": "0.0.183",
3
+ "version": "0.0.185",
4
4
  "description": "Types-only Hono AppType contract for the Mestra auth API",
5
5
  "type": "module",
6
6
  "sideEffects": false,