@mestra-dev/contract 0.0.173 → 0.0.174

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 +484 -3
  2. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -27,7 +27,7 @@ declare const routes: import("hono/hono-base").HonoBase<{
27
27
  readonly info: {
28
28
  readonly title: "Auth Service API";
29
29
  readonly version: "1.5.12";
30
- readonly description: "OpenAPI specification for the Auth, Integrations, Workspace, Payments, Tasks, Templates, Tags, Comments, Assignees, Chat, Events, Billings, CInvoices, Customer History, Files, and Notifications endpoints exposed by the k3-core platform. Unhandled HTTPException and unexpected errors are normalized by the global error handler to `{ success: false, error: string }` (status preserved for HTTPException; 500 otherwise).";
30
+ readonly description: "OpenAPI specification for the Auth, Integrations, Workspace, Payments, Analytics, Tasks, Templates, Tags, Comments, Assignees, Chat, Events, Billings, CInvoices, Customer History, Files, and Notifications endpoints exposed by the k3-core platform. Unhandled HTTPException and unexpected errors are normalized by the global error handler to `{ success: false, error: string }` (status preserved for HTTPException; 500 otherwise).";
31
31
  };
32
32
  readonly servers: readonly [
33
33
  {
@@ -60,6 +60,10 @@ declare const routes: import("hono/hono-base").HonoBase<{
60
60
  readonly name: "Payments";
61
61
  readonly description: "Workspace subscription invoices, YooKassa checkout, renewals, and upgrades.";
62
62
  },
63
+ {
64
+ readonly name: "Analytics";
65
+ readonly description: "Read-only CRM analytics for a workspace. Requires workspace access and crm::analytics read access.";
66
+ },
63
67
  {
64
68
  readonly name: "Tasks";
65
69
  readonly description: "Task management endpoints";
@@ -4126,6 +4130,12 @@ declare const routes: import("hono/hono-base").HonoBase<{
4126
4130
  "refunded"
4127
4131
  ];
4128
4132
  };
4133
+ readonly paidAt: {
4134
+ readonly type: "string";
4135
+ readonly format: "date-time";
4136
+ readonly nullable: true;
4137
+ readonly description: "Server-set timestamp when the invoice was marked paid.";
4138
+ };
4129
4139
  readonly buyerInn: {
4130
4140
  readonly type: "string";
4131
4141
  readonly nullable: true;
@@ -4255,6 +4265,155 @@ declare const routes: import("hono/hono-base").HonoBase<{
4255
4265
  };
4256
4266
  };
4257
4267
  };
4268
+ readonly RevenueTotal: {
4269
+ readonly type: "object";
4270
+ readonly required: readonly [
4271
+ "currency",
4272
+ "amountMinor",
4273
+ "invoiceCount"
4274
+ ];
4275
+ readonly properties: {
4276
+ readonly currency: {
4277
+ readonly type: "string";
4278
+ readonly description: "Invoice currency.";
4279
+ };
4280
+ readonly amountMinor: {
4281
+ readonly type: "integer";
4282
+ readonly description: "Revenue in the currency's minor units after discount, excluding VAT.";
4283
+ };
4284
+ readonly invoiceCount: {
4285
+ readonly type: "integer";
4286
+ readonly description: "Number of paid invoices included in the total.";
4287
+ };
4288
+ };
4289
+ };
4290
+ readonly PaidRevenueAnalysisSuccess: {
4291
+ readonly type: "object";
4292
+ readonly required: readonly [
4293
+ "success",
4294
+ "workspaceId",
4295
+ "category",
4296
+ "period",
4297
+ "totals"
4298
+ ];
4299
+ readonly properties: {
4300
+ readonly success: {
4301
+ readonly type: "boolean";
4302
+ readonly const: true;
4303
+ };
4304
+ readonly workspaceId: {
4305
+ readonly type: "string";
4306
+ readonly format: "uuid";
4307
+ };
4308
+ readonly category: {
4309
+ readonly type: "string";
4310
+ readonly description: "Workspace category.";
4311
+ };
4312
+ readonly period: {
4313
+ readonly type: "object";
4314
+ readonly required: readonly [
4315
+ "from",
4316
+ "to"
4317
+ ];
4318
+ readonly properties: {
4319
+ readonly from: {
4320
+ readonly type: "string";
4321
+ readonly format: "date-time";
4322
+ readonly nullable: true;
4323
+ };
4324
+ readonly to: {
4325
+ readonly type: "string";
4326
+ readonly format: "date-time";
4327
+ readonly nullable: true;
4328
+ };
4329
+ };
4330
+ };
4331
+ readonly totals: {
4332
+ readonly type: "array";
4333
+ readonly items: {
4334
+ readonly $ref: "#/components/schemas/RevenueTotal";
4335
+ };
4336
+ readonly description: "Totals grouped by invoice currency. Empty when there are no paid invoices.";
4337
+ };
4338
+ };
4339
+ };
4340
+ readonly LeadSourceTotal: {
4341
+ readonly type: "object";
4342
+ readonly required: readonly [
4343
+ "leadSource",
4344
+ "leadCount"
4345
+ ];
4346
+ readonly properties: {
4347
+ readonly leadSource: {
4348
+ readonly type: "string";
4349
+ readonly enum: readonly [
4350
+ "cian",
4351
+ "avito",
4352
+ "vk",
4353
+ "yandex",
4354
+ "website",
4355
+ "referral",
4356
+ "walk_in",
4357
+ "unattributed"
4358
+ ];
4359
+ readonly description: "Lead acquisition source, or unattributed when no source was recorded.";
4360
+ };
4361
+ readonly leadCount: {
4362
+ readonly type: "integer";
4363
+ readonly description: "Number of leads from this source.";
4364
+ };
4365
+ };
4366
+ };
4367
+ readonly LeadSourceAnalysisSuccess: {
4368
+ readonly type: "object";
4369
+ readonly required: readonly [
4370
+ "success",
4371
+ "workspaceId",
4372
+ "category",
4373
+ "period",
4374
+ "sources"
4375
+ ];
4376
+ readonly properties: {
4377
+ readonly success: {
4378
+ readonly type: "boolean";
4379
+ readonly const: true;
4380
+ };
4381
+ readonly workspaceId: {
4382
+ readonly type: "string";
4383
+ readonly format: "uuid";
4384
+ };
4385
+ readonly category: {
4386
+ readonly type: "string";
4387
+ readonly description: "Workspace category.";
4388
+ };
4389
+ readonly period: {
4390
+ readonly type: "object";
4391
+ readonly required: readonly [
4392
+ "from",
4393
+ "to"
4394
+ ];
4395
+ readonly properties: {
4396
+ readonly from: {
4397
+ readonly type: "string";
4398
+ readonly format: "date-time";
4399
+ readonly nullable: true;
4400
+ };
4401
+ readonly to: {
4402
+ readonly type: "string";
4403
+ readonly format: "date-time";
4404
+ readonly nullable: true;
4405
+ };
4406
+ };
4407
+ };
4408
+ readonly sources: {
4409
+ readonly type: "array";
4410
+ readonly items: {
4411
+ readonly $ref: "#/components/schemas/LeadSourceTotal";
4412
+ };
4413
+ readonly description: "Lead totals grouped by acquisition source. Empty when no leads match the period.";
4414
+ };
4415
+ };
4416
+ };
4258
4417
  readonly CHistory: {
4259
4418
  readonly type: "object";
4260
4419
  readonly required: readonly [
@@ -12646,6 +12805,198 @@ declare const routes: import("hono/hono-base").HonoBase<{
12646
12805
  };
12647
12806
  };
12648
12807
  };
12808
+ readonly "/analytics/{workspace}/total-revenue": {
12809
+ readonly get: {
12810
+ readonly tags: readonly [
12811
+ "Analytics"
12812
+ ];
12813
+ readonly summary: "Get total paid customer-invoice revenue";
12814
+ readonly description: "Returns paid CInvoice revenue for a real-estate workspace, grouped by currency. Optional from and to timestamps filter the server-set paidAt field (from inclusive, to exclusive). Each total is calculated as unitPrice \u00D7 unitQuantity \u2212 discount in minor units and excludes VAT. Requires workspace access and read access to crm::analytics. Other workspace categories return 400.";
12815
+ readonly security: readonly [
12816
+ never
12817
+ ];
12818
+ readonly parameters: readonly [
12819
+ {
12820
+ readonly name: "workspace";
12821
+ readonly in: "path";
12822
+ readonly required: true;
12823
+ readonly schema: {
12824
+ readonly type: "string";
12825
+ readonly format: "uuid";
12826
+ };
12827
+ readonly description: "Workspace identifier.";
12828
+ },
12829
+ {
12830
+ readonly name: "from";
12831
+ readonly in: "query";
12832
+ readonly required: false;
12833
+ readonly schema: {
12834
+ readonly type: "string";
12835
+ readonly format: "date-time";
12836
+ };
12837
+ readonly description: "Include invoices paid at or after this timestamp.";
12838
+ },
12839
+ {
12840
+ readonly name: "to";
12841
+ readonly in: "query";
12842
+ readonly required: false;
12843
+ readonly schema: {
12844
+ readonly type: "string";
12845
+ readonly format: "date-time";
12846
+ };
12847
+ readonly description: "Include invoices paid before this timestamp.";
12848
+ }
12849
+ ];
12850
+ readonly responses: {
12851
+ readonly 200: {
12852
+ readonly description: "Paid revenue totals fetched successfully.";
12853
+ readonly content: {
12854
+ readonly "application/json": {
12855
+ readonly schema: {
12856
+ readonly $ref: "#/components/schemas/PaidRevenueAnalysisSuccess";
12857
+ };
12858
+ };
12859
+ };
12860
+ };
12861
+ readonly 400: {
12862
+ readonly description: "Invalid workspace ID or unsupported workspace category.";
12863
+ readonly content: {
12864
+ readonly "application/json": {
12865
+ readonly schema: {
12866
+ readonly $ref: "#/components/schemas/ErrorResponse";
12867
+ };
12868
+ };
12869
+ };
12870
+ };
12871
+ readonly 401: {
12872
+ readonly description: "Unauthorized - Missing or invalid access token.";
12873
+ readonly content: {
12874
+ readonly "application/json": {
12875
+ readonly schema: {
12876
+ readonly $ref: "#/components/schemas/ErrorResponse";
12877
+ };
12878
+ };
12879
+ };
12880
+ };
12881
+ readonly 403: {
12882
+ readonly description: "Forbidden - Token issuer is not 'access', user lacks workspace access, or user lacks read access to crm::analytics resource.";
12883
+ readonly content: {
12884
+ readonly "application/json": {
12885
+ readonly schema: {
12886
+ readonly $ref: "#/components/schemas/ErrorResponse";
12887
+ };
12888
+ };
12889
+ };
12890
+ };
12891
+ readonly 404: {
12892
+ readonly description: "Workspace not found.";
12893
+ readonly content: {
12894
+ readonly "application/json": {
12895
+ readonly schema: {
12896
+ readonly $ref: "#/components/schemas/ErrorResponse";
12897
+ };
12898
+ };
12899
+ };
12900
+ };
12901
+ };
12902
+ };
12903
+ };
12904
+ readonly "/analytics/{workspace}/leads-by-source": {
12905
+ readonly get: {
12906
+ readonly tags: readonly [
12907
+ "Analytics"
12908
+ ];
12909
+ readonly summary: "Get real-estate leads by acquisition source";
12910
+ readonly description: "Returns real-estate leads grouped by their recorded acquisition source. Optional from and to timestamps filter lead creation time (from inclusive, to exclusive). Leads with no recorded source are grouped as unattributed. Soft-deleted leads are excluded. Requires workspace access and read access to crm::analytics. Other workspace categories return 400.";
12911
+ readonly security: readonly [
12912
+ never
12913
+ ];
12914
+ readonly parameters: readonly [
12915
+ {
12916
+ readonly name: "workspace";
12917
+ readonly in: "path";
12918
+ readonly required: true;
12919
+ readonly schema: {
12920
+ readonly type: "string";
12921
+ readonly format: "uuid";
12922
+ };
12923
+ readonly description: "Workspace identifier.";
12924
+ },
12925
+ {
12926
+ readonly name: "from";
12927
+ readonly in: "query";
12928
+ readonly required: false;
12929
+ readonly schema: {
12930
+ readonly type: "string";
12931
+ readonly format: "date-time";
12932
+ };
12933
+ readonly description: "Include leads created at or after this timestamp.";
12934
+ },
12935
+ {
12936
+ readonly name: "to";
12937
+ readonly in: "query";
12938
+ readonly required: false;
12939
+ readonly schema: {
12940
+ readonly type: "string";
12941
+ readonly format: "date-time";
12942
+ };
12943
+ readonly description: "Include leads created before this timestamp.";
12944
+ }
12945
+ ];
12946
+ readonly responses: {
12947
+ readonly 200: {
12948
+ readonly description: "Lead totals by source fetched successfully.";
12949
+ readonly content: {
12950
+ readonly "application/json": {
12951
+ readonly schema: {
12952
+ readonly $ref: "#/components/schemas/LeadSourceAnalysisSuccess";
12953
+ };
12954
+ };
12955
+ };
12956
+ };
12957
+ readonly 400: {
12958
+ readonly description: "Invalid query, invalid workspace ID, or unsupported workspace category.";
12959
+ readonly content: {
12960
+ readonly "application/json": {
12961
+ readonly schema: {
12962
+ readonly $ref: "#/components/schemas/ErrorResponse";
12963
+ };
12964
+ };
12965
+ };
12966
+ };
12967
+ readonly 401: {
12968
+ readonly description: "Unauthorized - Missing or invalid access token.";
12969
+ readonly content: {
12970
+ readonly "application/json": {
12971
+ readonly schema: {
12972
+ readonly $ref: "#/components/schemas/ErrorResponse";
12973
+ };
12974
+ };
12975
+ };
12976
+ };
12977
+ readonly 403: {
12978
+ readonly description: "Forbidden - Token issuer is not 'access', user lacks workspace access, or user lacks read access to crm::analytics resource.";
12979
+ readonly content: {
12980
+ readonly "application/json": {
12981
+ readonly schema: {
12982
+ readonly $ref: "#/components/schemas/ErrorResponse";
12983
+ };
12984
+ };
12985
+ };
12986
+ };
12987
+ readonly 404: {
12988
+ readonly description: "Workspace not found.";
12989
+ readonly content: {
12990
+ readonly "application/json": {
12991
+ readonly schema: {
12992
+ readonly $ref: "#/components/schemas/ErrorResponse";
12993
+ };
12994
+ };
12995
+ };
12996
+ };
12997
+ };
12998
+ };
12999
+ };
12649
13000
  readonly "/cinvoices/create": {
12650
13001
  readonly post: {
12651
13002
  readonly tags: readonly [
@@ -18835,6 +19186,7 @@ declare const routes: import("hono/hono-base").HonoBase<{
18835
19186
  workspaceId: string;
18836
19187
  created_by: string | null;
18837
19188
  companyName: string | null;
19189
+ leadSource: string | null;
18838
19190
  updated_at: string | null;
18839
19191
  deleted_at: string | null;
18840
19192
  verified_at: string | null;
@@ -18846,7 +19198,6 @@ declare const routes: import("hono/hono-base").HonoBase<{
18846
19198
  igSynapseId: string | null;
18847
19199
  waSynapseId: string | null;
18848
19200
  tgSynapseId: string | null;
18849
- leadSource: string | null;
18850
19201
  budgetMin: number | null;
18851
19202
  budgetMax: number | null;
18852
19203
  fullPayment: boolean | null;
@@ -19455,6 +19806,7 @@ declare const routes: import("hono/hono-base").HonoBase<{
19455
19806
  deleted_at: string | null;
19456
19807
  verified_at: string | null;
19457
19808
  suspended_at: string | null;
19809
+ paidAt: string | null;
19458
19810
  fullPayment: boolean | null;
19459
19811
  notes: string | null;
19460
19812
  buyerInn: string | null;
@@ -19538,6 +19890,7 @@ declare const routes: import("hono/hono-base").HonoBase<{
19538
19890
  subscriptionStartDate: string | null;
19539
19891
  subscriptionEndDate: string | null;
19540
19892
  status: string;
19893
+ paidAt: string | null;
19541
19894
  created_by: string;
19542
19895
  }[];
19543
19896
  };
@@ -19597,6 +19950,7 @@ declare const routes: import("hono/hono-base").HonoBase<{
19597
19950
  subscriptionStartDate: string | null;
19598
19951
  subscriptionEndDate: string | null;
19599
19952
  status: string;
19953
+ paidAt: string | null;
19600
19954
  created_by: string;
19601
19955
  }[];
19602
19956
  };
@@ -24506,7 +24860,134 @@ declare const routes: import("hono/hono-base").HonoBase<{
24506
24860
  status: 400 | 404 | 409 | 502 | 503;
24507
24861
  };
24508
24862
  };
24509
- }, "/payments">, "/", "/">;
24863
+ }, "/payments"> | import("hono/types").MergeSchemaPath<{
24864
+ "/:workspace/total-revenue": {
24865
+ $get: {
24866
+ input: {
24867
+ param: {
24868
+ workspace: string;
24869
+ };
24870
+ };
24871
+ output: {
24872
+ success: false;
24873
+ error: {
24874
+ [x: string]: import("hono/utils/types").JSONValue;
24875
+ };
24876
+ };
24877
+ outputFormat: "json";
24878
+ status: 400;
24879
+ } | {
24880
+ input: {
24881
+ param: {
24882
+ workspace: string;
24883
+ };
24884
+ };
24885
+ output: {
24886
+ success: false;
24887
+ error: string;
24888
+ };
24889
+ outputFormat: "json";
24890
+ status: 400;
24891
+ } | {
24892
+ input: {
24893
+ param: {
24894
+ workspace: string;
24895
+ };
24896
+ };
24897
+ output: {
24898
+ success: false;
24899
+ error: string;
24900
+ };
24901
+ outputFormat: "json";
24902
+ status: 404;
24903
+ } | {
24904
+ input: {
24905
+ param: {
24906
+ workspace: string;
24907
+ };
24908
+ };
24909
+ output: {
24910
+ success: true;
24911
+ workspaceId: string;
24912
+ category: string;
24913
+ period: {
24914
+ from: string | null;
24915
+ to: string | null;
24916
+ };
24917
+ totals: {
24918
+ currency: string;
24919
+ amountMinor: number;
24920
+ invoiceCount: number;
24921
+ }[];
24922
+ };
24923
+ outputFormat: "json";
24924
+ status: 200;
24925
+ };
24926
+ };
24927
+ } & {
24928
+ "/:workspace/leads-by-source": {
24929
+ $get: {
24930
+ input: {
24931
+ param: {
24932
+ workspace: string;
24933
+ };
24934
+ };
24935
+ output: {
24936
+ success: false;
24937
+ error: {
24938
+ [x: string]: import("hono/utils/types").JSONValue;
24939
+ };
24940
+ };
24941
+ outputFormat: "json";
24942
+ status: 400;
24943
+ } | {
24944
+ input: {
24945
+ param: {
24946
+ workspace: string;
24947
+ };
24948
+ };
24949
+ output: {
24950
+ success: false;
24951
+ error: string;
24952
+ };
24953
+ outputFormat: "json";
24954
+ status: 400;
24955
+ } | {
24956
+ input: {
24957
+ param: {
24958
+ workspace: string;
24959
+ };
24960
+ };
24961
+ output: {
24962
+ success: false;
24963
+ error: string;
24964
+ };
24965
+ outputFormat: "json";
24966
+ status: 404;
24967
+ } | {
24968
+ input: {
24969
+ param: {
24970
+ workspace: string;
24971
+ };
24972
+ };
24973
+ output: {
24974
+ success: true;
24975
+ workspaceId: string;
24976
+ category: string;
24977
+ period: {
24978
+ from: string | null;
24979
+ to: string | null;
24980
+ };
24981
+ sources: {
24982
+ leadSource: string;
24983
+ leadCount: number;
24984
+ }[];
24985
+ };
24986
+ outputFormat: "json";
24987
+ status: 200;
24988
+ };
24989
+ };
24990
+ }, "/analytics">, "/", "/">;
24510
24991
  type GlobalErrorResponses = {
24511
24992
  400: {
24512
24993
  json: ApiError;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mestra-dev/contract",
3
- "version": "0.0.173",
3
+ "version": "0.0.174",
4
4
  "description": "Types-only Hono AppType contract for the Mestra auth API",
5
5
  "type": "module",
6
6
  "sideEffects": false,