@mestra-dev/contract 0.0.174 → 0.0.176

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 +490 -0
  2. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -4414,6 +4414,171 @@ declare const routes: import("hono/hono-base").HonoBase<{
4414
4414
  };
4415
4415
  };
4416
4416
  };
4417
+ readonly ConversionRateAnalysisSuccess: {
4418
+ readonly type: "object";
4419
+ readonly required: readonly [
4420
+ "success",
4421
+ "workspaceId",
4422
+ "category",
4423
+ "period",
4424
+ "paidInvoiceCount",
4425
+ "customerCount",
4426
+ "conversionRate"
4427
+ ];
4428
+ readonly properties: {
4429
+ readonly success: {
4430
+ readonly type: "boolean";
4431
+ readonly const: true;
4432
+ };
4433
+ readonly workspaceId: {
4434
+ readonly type: "string";
4435
+ readonly format: "uuid";
4436
+ };
4437
+ readonly category: {
4438
+ readonly type: "string";
4439
+ readonly description: "Workspace category.";
4440
+ };
4441
+ readonly period: {
4442
+ readonly type: "object";
4443
+ readonly required: readonly [
4444
+ "from",
4445
+ "to"
4446
+ ];
4447
+ readonly properties: {
4448
+ readonly from: {
4449
+ readonly type: "string";
4450
+ readonly format: "date-time";
4451
+ readonly nullable: true;
4452
+ };
4453
+ readonly to: {
4454
+ readonly type: "string";
4455
+ readonly format: "date-time";
4456
+ readonly nullable: true;
4457
+ };
4458
+ };
4459
+ };
4460
+ readonly paidInvoiceCount: {
4461
+ readonly type: "integer";
4462
+ readonly description: "Paid CInvoices included in the period.";
4463
+ };
4464
+ readonly customerCount: {
4465
+ readonly type: "integer";
4466
+ readonly description: "Non-deleted real-estate customers created in the period.";
4467
+ };
4468
+ readonly conversionRate: {
4469
+ readonly type: "number";
4470
+ readonly description: "Paid CInvoices divided by real-estate customers, expressed as a percentage. Zero when no customers match the period.";
4471
+ };
4472
+ };
4473
+ };
4474
+ readonly ForecastRevenueTotal: {
4475
+ readonly type: "object";
4476
+ readonly required: readonly [
4477
+ "currency",
4478
+ "pendingRevenueMinor",
4479
+ "pendingInvoiceCount",
4480
+ "averageDealSizeMinor",
4481
+ "projectedPipelineMinor",
4482
+ "forecastRevenueMinor"
4483
+ ];
4484
+ readonly properties: {
4485
+ readonly currency: {
4486
+ readonly type: "string";
4487
+ readonly description: "Invoice currency. Forecasts are not combined across currencies.";
4488
+ };
4489
+ readonly pendingRevenueMinor: {
4490
+ readonly type: "integer";
4491
+ readonly description: "Pending invoice value due in the period, after discount and excluding VAT.";
4492
+ };
4493
+ readonly pendingInvoiceCount: {
4494
+ readonly type: "integer";
4495
+ readonly description: "Number of pending invoices due in the period.";
4496
+ };
4497
+ readonly averageDealSizeMinor: {
4498
+ readonly type: "number";
4499
+ readonly description: "Average paid invoice value in the period, after discount and excluding VAT.";
4500
+ };
4501
+ readonly projectedPipelineMinor: {
4502
+ readonly type: "integer";
4503
+ readonly description: "Projected revenue: period leads \u00D7 conversion rate \u00D7 average deal size.";
4504
+ };
4505
+ readonly forecastRevenueMinor: {
4506
+ readonly type: "integer";
4507
+ readonly description: "Pending revenue plus projected pipeline revenue.";
4508
+ };
4509
+ };
4510
+ };
4511
+ readonly ForecastRevenueAnalysisSuccess: {
4512
+ readonly type: "object";
4513
+ readonly required: readonly [
4514
+ "success",
4515
+ "workspaceId",
4516
+ "category",
4517
+ "period",
4518
+ "leadCount",
4519
+ "averageDailyLeads",
4520
+ "paidInvoiceCount",
4521
+ "conversionRate",
4522
+ "forecasts"
4523
+ ];
4524
+ readonly properties: {
4525
+ readonly success: {
4526
+ readonly type: "boolean";
4527
+ readonly const: true;
4528
+ };
4529
+ readonly workspaceId: {
4530
+ readonly type: "string";
4531
+ readonly format: "uuid";
4532
+ };
4533
+ readonly category: {
4534
+ readonly type: "string";
4535
+ readonly description: "Workspace category.";
4536
+ };
4537
+ readonly period: {
4538
+ readonly type: "object";
4539
+ readonly required: readonly [
4540
+ "from",
4541
+ "to"
4542
+ ];
4543
+ readonly properties: {
4544
+ readonly from: {
4545
+ readonly type: "string";
4546
+ readonly format: "date-time";
4547
+ readonly nullable: true;
4548
+ };
4549
+ readonly to: {
4550
+ readonly type: "string";
4551
+ readonly format: "date-time";
4552
+ readonly nullable: true;
4553
+ };
4554
+ };
4555
+ };
4556
+ readonly leadCount: {
4557
+ readonly type: "integer";
4558
+ readonly description: "Non-deleted real-estate leads created in the period.";
4559
+ };
4560
+ readonly averageDailyLeads: {
4561
+ readonly type: "number";
4562
+ readonly nullable: true;
4563
+ readonly description: "Lead count divided by the reporting period duration in days; null without both period bounds.";
4564
+ };
4565
+ readonly paidInvoiceCount: {
4566
+ readonly type: "integer";
4567
+ readonly description: "Paid CInvoices included in the period.";
4568
+ };
4569
+ readonly conversionRate: {
4570
+ readonly type: "number";
4571
+ readonly description: "Paid CInvoices divided by real-estate leads, expressed as a percentage.";
4572
+ };
4573
+ readonly forecasts: {
4574
+ readonly type: "array";
4575
+ readonly items: {
4576
+ readonly $ref: "#/components/schemas/ForecastRevenueTotal";
4577
+ };
4578
+ readonly description: "Forecast totals grouped by currency. Empty when the period has neither pending nor paid invoices.";
4579
+ };
4580
+ };
4581
+ };
4417
4582
  readonly CHistory: {
4418
4583
  readonly type: "object";
4419
4584
  readonly required: readonly [
@@ -12997,6 +13162,198 @@ declare const routes: import("hono/hono-base").HonoBase<{
12997
13162
  };
12998
13163
  };
12999
13164
  };
13165
+ readonly "/analytics/{workspace}/conversion-rate": {
13166
+ readonly get: {
13167
+ readonly tags: readonly [
13168
+ "Analytics"
13169
+ ];
13170
+ readonly summary: "Get real-estate conversion rate";
13171
+ readonly description: "Returns the conversion rate for a real-estate workspace: paid CInvoices divided by non-deleted real-estate customers, multiplied by 100. Optional from and to timestamps filter invoices by paidAt and customers by created_at (from inclusive, to exclusive). The rate is zero when no customers match. Requires workspace access and read access to crm::analytics. Other workspace categories return 400.";
13172
+ readonly security: readonly [
13173
+ never
13174
+ ];
13175
+ readonly parameters: readonly [
13176
+ {
13177
+ readonly name: "workspace";
13178
+ readonly in: "path";
13179
+ readonly required: true;
13180
+ readonly schema: {
13181
+ readonly type: "string";
13182
+ readonly format: "uuid";
13183
+ };
13184
+ readonly description: "Workspace identifier.";
13185
+ },
13186
+ {
13187
+ readonly name: "from";
13188
+ readonly in: "query";
13189
+ readonly required: false;
13190
+ readonly schema: {
13191
+ readonly type: "string";
13192
+ readonly format: "date-time";
13193
+ };
13194
+ readonly description: "Include invoices paid and customers created at or after this timestamp.";
13195
+ },
13196
+ {
13197
+ readonly name: "to";
13198
+ readonly in: "query";
13199
+ readonly required: false;
13200
+ readonly schema: {
13201
+ readonly type: "string";
13202
+ readonly format: "date-time";
13203
+ };
13204
+ readonly description: "Include invoices paid and customers created before this timestamp.";
13205
+ }
13206
+ ];
13207
+ readonly responses: {
13208
+ readonly 200: {
13209
+ readonly description: "Conversion rate fetched successfully.";
13210
+ readonly content: {
13211
+ readonly "application/json": {
13212
+ readonly schema: {
13213
+ readonly $ref: "#/components/schemas/ConversionRateAnalysisSuccess";
13214
+ };
13215
+ };
13216
+ };
13217
+ };
13218
+ readonly 400: {
13219
+ readonly description: "Invalid query, invalid workspace ID, or unsupported workspace category.";
13220
+ readonly content: {
13221
+ readonly "application/json": {
13222
+ readonly schema: {
13223
+ readonly $ref: "#/components/schemas/ErrorResponse";
13224
+ };
13225
+ };
13226
+ };
13227
+ };
13228
+ readonly 401: {
13229
+ readonly description: "Unauthorized - Missing or invalid access token.";
13230
+ readonly content: {
13231
+ readonly "application/json": {
13232
+ readonly schema: {
13233
+ readonly $ref: "#/components/schemas/ErrorResponse";
13234
+ };
13235
+ };
13236
+ };
13237
+ };
13238
+ readonly 403: {
13239
+ readonly description: "Forbidden - Token issuer is not 'access', user lacks workspace access, or user lacks read access to crm::analytics resource.";
13240
+ readonly content: {
13241
+ readonly "application/json": {
13242
+ readonly schema: {
13243
+ readonly $ref: "#/components/schemas/ErrorResponse";
13244
+ };
13245
+ };
13246
+ };
13247
+ };
13248
+ readonly 404: {
13249
+ readonly description: "Workspace not found.";
13250
+ readonly content: {
13251
+ readonly "application/json": {
13252
+ readonly schema: {
13253
+ readonly $ref: "#/components/schemas/ErrorResponse";
13254
+ };
13255
+ };
13256
+ };
13257
+ };
13258
+ };
13259
+ };
13260
+ };
13261
+ readonly "/analytics/{workspace}/forecast-revenue": {
13262
+ readonly get: {
13263
+ readonly tags: readonly [
13264
+ "Analytics"
13265
+ ];
13266
+ readonly summary: "Get real-estate forecast revenue";
13267
+ readonly description: "Returns forecast revenue for a real-estate workspace, grouped by currency. Pending CInvoices are filtered by their invoice date; paid invoices are filtered by paidAt; and leads are filtered by creation time (from inclusive, to exclusive). Projected pipeline revenue is leads in the period \u00D7 (paid invoices \u00F7 leads) \u00D7 average paid invoice size. Forecast revenue is pending revenue plus projected pipeline revenue. Amounts are post-discount minor units and exclude VAT. Requires workspace access and read access to crm::analytics. Other workspace categories return 400.";
13268
+ readonly security: readonly [
13269
+ never
13270
+ ];
13271
+ readonly parameters: readonly [
13272
+ {
13273
+ readonly name: "workspace";
13274
+ readonly in: "path";
13275
+ readonly required: true;
13276
+ readonly schema: {
13277
+ readonly type: "string";
13278
+ readonly format: "uuid";
13279
+ };
13280
+ readonly description: "Workspace identifier.";
13281
+ },
13282
+ {
13283
+ readonly name: "from";
13284
+ readonly in: "query";
13285
+ readonly required: false;
13286
+ readonly schema: {
13287
+ readonly type: "string";
13288
+ readonly format: "date-time";
13289
+ };
13290
+ readonly description: "Include pending invoices dated, paid invoices paid, and leads created at or after this timestamp.";
13291
+ },
13292
+ {
13293
+ readonly name: "to";
13294
+ readonly in: "query";
13295
+ readonly required: false;
13296
+ readonly schema: {
13297
+ readonly type: "string";
13298
+ readonly format: "date-time";
13299
+ };
13300
+ readonly description: "Include pending invoices dated, paid invoices paid, and leads created before this timestamp.";
13301
+ }
13302
+ ];
13303
+ readonly responses: {
13304
+ readonly 200: {
13305
+ readonly description: "Forecast revenue fetched successfully.";
13306
+ readonly content: {
13307
+ readonly "application/json": {
13308
+ readonly schema: {
13309
+ readonly $ref: "#/components/schemas/ForecastRevenueAnalysisSuccess";
13310
+ };
13311
+ };
13312
+ };
13313
+ };
13314
+ readonly 400: {
13315
+ readonly description: "Invalid query, invalid workspace ID, or unsupported workspace category.";
13316
+ readonly content: {
13317
+ readonly "application/json": {
13318
+ readonly schema: {
13319
+ readonly $ref: "#/components/schemas/ErrorResponse";
13320
+ };
13321
+ };
13322
+ };
13323
+ };
13324
+ readonly 401: {
13325
+ readonly description: "Unauthorized - Missing or invalid access token.";
13326
+ readonly content: {
13327
+ readonly "application/json": {
13328
+ readonly schema: {
13329
+ readonly $ref: "#/components/schemas/ErrorResponse";
13330
+ };
13331
+ };
13332
+ };
13333
+ };
13334
+ readonly 403: {
13335
+ readonly description: "Forbidden - Token issuer is not 'access', user lacks workspace access, or user lacks read access to crm::analytics resource.";
13336
+ readonly content: {
13337
+ readonly "application/json": {
13338
+ readonly schema: {
13339
+ readonly $ref: "#/components/schemas/ErrorResponse";
13340
+ };
13341
+ };
13342
+ };
13343
+ };
13344
+ readonly 404: {
13345
+ readonly description: "Workspace not found.";
13346
+ readonly content: {
13347
+ readonly "application/json": {
13348
+ readonly schema: {
13349
+ readonly $ref: "#/components/schemas/ErrorResponse";
13350
+ };
13351
+ };
13352
+ };
13353
+ };
13354
+ };
13355
+ };
13356
+ };
13000
13357
  readonly "/cinvoices/create": {
13001
13358
  readonly post: {
13002
13359
  readonly tags: readonly [
@@ -24987,6 +25344,139 @@ declare const routes: import("hono/hono-base").HonoBase<{
24987
25344
  status: 200;
24988
25345
  };
24989
25346
  };
25347
+ } & {
25348
+ "/:workspace/conversion-rate": {
25349
+ $get: {
25350
+ input: {
25351
+ param: {
25352
+ workspace: string;
25353
+ };
25354
+ };
25355
+ output: {
25356
+ success: false;
25357
+ error: {
25358
+ [x: string]: import("hono/utils/types").JSONValue;
25359
+ };
25360
+ };
25361
+ outputFormat: "json";
25362
+ status: 400;
25363
+ } | {
25364
+ input: {
25365
+ param: {
25366
+ workspace: string;
25367
+ };
25368
+ };
25369
+ output: {
25370
+ success: false;
25371
+ error: string;
25372
+ };
25373
+ outputFormat: "json";
25374
+ status: 400;
25375
+ } | {
25376
+ input: {
25377
+ param: {
25378
+ workspace: string;
25379
+ };
25380
+ };
25381
+ output: {
25382
+ success: false;
25383
+ error: string;
25384
+ };
25385
+ outputFormat: "json";
25386
+ status: 404;
25387
+ } | {
25388
+ input: {
25389
+ param: {
25390
+ workspace: string;
25391
+ };
25392
+ };
25393
+ output: {
25394
+ success: true;
25395
+ workspaceId: string;
25396
+ category: string;
25397
+ period: {
25398
+ from: string | null;
25399
+ to: string | null;
25400
+ };
25401
+ paidInvoiceCount: number;
25402
+ customerCount: number;
25403
+ conversionRate: number;
25404
+ };
25405
+ outputFormat: "json";
25406
+ status: 200;
25407
+ };
25408
+ };
25409
+ } & {
25410
+ "/:workspace/forecast-revenue": {
25411
+ $get: {
25412
+ input: {
25413
+ param: {
25414
+ workspace: string;
25415
+ };
25416
+ };
25417
+ output: {
25418
+ success: false;
25419
+ error: {
25420
+ [x: string]: import("hono/utils/types").JSONValue;
25421
+ };
25422
+ };
25423
+ outputFormat: "json";
25424
+ status: 400;
25425
+ } | {
25426
+ input: {
25427
+ param: {
25428
+ workspace: string;
25429
+ };
25430
+ };
25431
+ output: {
25432
+ success: false;
25433
+ error: string;
25434
+ };
25435
+ outputFormat: "json";
25436
+ status: 400;
25437
+ } | {
25438
+ input: {
25439
+ param: {
25440
+ workspace: string;
25441
+ };
25442
+ };
25443
+ output: {
25444
+ success: false;
25445
+ error: string;
25446
+ };
25447
+ outputFormat: "json";
25448
+ status: 404;
25449
+ } | {
25450
+ input: {
25451
+ param: {
25452
+ workspace: string;
25453
+ };
25454
+ };
25455
+ output: {
25456
+ success: true;
25457
+ workspaceId: string;
25458
+ category: string;
25459
+ period: {
25460
+ from: string | null;
25461
+ to: string | null;
25462
+ };
25463
+ leadCount: number;
25464
+ averageDailyLeads: number | null;
25465
+ paidInvoiceCount: number;
25466
+ conversionRate: number;
25467
+ forecasts: {
25468
+ currency: string;
25469
+ pendingRevenueMinor: number;
25470
+ pendingInvoiceCount: number;
25471
+ averageDealSizeMinor: number;
25472
+ projectedPipelineMinor: number;
25473
+ forecastRevenueMinor: number;
25474
+ }[];
25475
+ };
25476
+ outputFormat: "json";
25477
+ status: 200;
25478
+ };
25479
+ };
24990
25480
  }, "/analytics">, "/", "/">;
24991
25481
  type GlobalErrorResponses = {
24992
25482
  400: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mestra-dev/contract",
3
- "version": "0.0.174",
3
+ "version": "0.0.176",
4
4
  "description": "Types-only Hono AppType contract for the Mestra auth API",
5
5
  "type": "module",
6
6
  "sideEffects": false,