@mestra-dev/contract 0.0.193 → 0.0.194

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 +93 -3
  2. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { ApplyGlobalResponse } from 'hono/client';
2
2
  import type { JwtVariables } from 'hono/jwt';
3
3
 
4
+ type GrowthDirection = "positive" | "negative" | "none";
4
5
  type Variables = JwtVariables;
5
6
  /** Shared error body for middleware / HTTPException responses (typed into AppType). */
6
7
  export type ApiError = {
@@ -4314,12 +4315,56 @@ declare const routes: import("hono/hono-base").HonoBase<{
4314
4315
  };
4315
4316
  };
4316
4317
  };
4318
+ readonly GrowthMetric: {
4319
+ readonly type: "object";
4320
+ readonly required: readonly [
4321
+ "previousValue",
4322
+ "growthPercentage",
4323
+ "direction"
4324
+ ];
4325
+ readonly properties: {
4326
+ readonly previousValue: {
4327
+ readonly type: "number";
4328
+ readonly description: "Metric value in the immediately previous period of the same duration.";
4329
+ };
4330
+ readonly growthPercentage: {
4331
+ readonly type: "number";
4332
+ readonly nullable: true;
4333
+ readonly description: "((current \u2212 previous) / previous) \u00D7 100, rounded to two decimal places. Zero when both values are 0. Null when previous is 0 and current is not, to avoid division by zero.";
4334
+ };
4335
+ readonly direction: {
4336
+ readonly type: "string";
4337
+ readonly enum: readonly [
4338
+ "positive",
4339
+ "negative",
4340
+ "none"
4341
+ ];
4342
+ readonly description: "positive when current > previous, negative when current < previous, none when they are equal.";
4343
+ };
4344
+ };
4345
+ };
4346
+ readonly RevenueTotalGrowth: {
4347
+ readonly type: "object";
4348
+ readonly required: readonly [
4349
+ "amountMinor",
4350
+ "invoiceCount"
4351
+ ];
4352
+ readonly properties: {
4353
+ readonly amountMinor: {
4354
+ readonly $ref: "#/components/schemas/GrowthMetric";
4355
+ };
4356
+ readonly invoiceCount: {
4357
+ readonly $ref: "#/components/schemas/GrowthMetric";
4358
+ };
4359
+ };
4360
+ };
4317
4361
  readonly RevenueTotal: {
4318
4362
  readonly type: "object";
4319
4363
  readonly required: readonly [
4320
4364
  "currency",
4321
4365
  "amountMinor",
4322
- "invoiceCount"
4366
+ "invoiceCount",
4367
+ "growth"
4323
4368
  ];
4324
4369
  readonly properties: {
4325
4370
  readonly currency: {
@@ -4334,6 +4379,15 @@ declare const routes: import("hono/hono-base").HonoBase<{
4334
4379
  readonly type: "integer";
4335
4380
  readonly description: "Number of paid invoices included in the total.";
4336
4381
  };
4382
+ readonly growth: {
4383
+ readonly allOf: readonly [
4384
+ {
4385
+ readonly $ref: "#/components/schemas/RevenueTotalGrowth";
4386
+ }
4387
+ ];
4388
+ readonly nullable: true;
4389
+ readonly description: "Comparison against the previous period. Null when from or to is omitted, so no previous window can be derived.";
4390
+ };
4337
4391
  };
4338
4392
  };
4339
4393
  readonly PaidRevenueAnalysisSuccess: {
@@ -4343,6 +4397,7 @@ declare const routes: import("hono/hono-base").HonoBase<{
4343
4397
  "workspaceId",
4344
4398
  "category",
4345
4399
  "period",
4400
+ "previousPeriod",
4346
4401
  "totals"
4347
4402
  ];
4348
4403
  readonly properties: {
@@ -4377,12 +4432,31 @@ declare const routes: import("hono/hono-base").HonoBase<{
4377
4432
  };
4378
4433
  };
4379
4434
  };
4435
+ readonly previousPeriod: {
4436
+ readonly type: "object";
4437
+ readonly nullable: true;
4438
+ readonly required: readonly [
4439
+ "from",
4440
+ "to"
4441
+ ];
4442
+ readonly description: "The immediately previous window of the same duration as period, adjacent and non-overlapping (from inclusive, to exclusive). Null when from or to is omitted.";
4443
+ readonly properties: {
4444
+ readonly from: {
4445
+ readonly type: "string";
4446
+ readonly format: "date-time";
4447
+ };
4448
+ readonly to: {
4449
+ readonly type: "string";
4450
+ readonly format: "date-time";
4451
+ };
4452
+ };
4453
+ };
4380
4454
  readonly totals: {
4381
4455
  readonly type: "array";
4382
4456
  readonly items: {
4383
4457
  readonly $ref: "#/components/schemas/RevenueTotal";
4384
4458
  };
4385
- readonly description: "Totals grouped by invoice currency. Empty when there are no paid invoices.";
4459
+ readonly description: "Totals grouped by invoice currency, including currencies that only appeared in the previous period (with current values of 0). Empty when neither period has paid invoices.";
4386
4460
  };
4387
4461
  };
4388
4462
  };
@@ -13934,7 +14008,7 @@ declare const routes: import("hono/hono-base").HonoBase<{
13934
14008
  "Analytics"
13935
14009
  ];
13936
14010
  readonly summary: "Get total paid customer-invoice revenue";
13937
- 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.";
14011
+ 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). When both bounds are supplied, each total is compared with the immediately previous period of the same duration (for 10 Sep \u2192 20 Sep, the previous window is 31 Aug \u2192 10 Sep exclusive). Growth is ((current \u2212 previous) / previous) \u00D7 100 with direction positive, negative, or none. 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.";
13938
14012
  readonly security: readonly [
13939
14013
  never
13940
14014
  ];
@@ -26848,10 +26922,26 @@ declare const routes: import("hono/hono-base").HonoBase<{
26848
26922
  from: string | null;
26849
26923
  to: string | null;
26850
26924
  };
26925
+ previousPeriod: {
26926
+ from: string;
26927
+ to: string;
26928
+ } | null;
26851
26929
  totals: {
26852
26930
  currency: string;
26853
26931
  amountMinor: number;
26854
26932
  invoiceCount: number;
26933
+ growth: {
26934
+ amountMinor: {
26935
+ previousValue: number;
26936
+ growthPercentage: number | null;
26937
+ direction: GrowthDirection;
26938
+ };
26939
+ invoiceCount: {
26940
+ previousValue: number;
26941
+ growthPercentage: number | null;
26942
+ direction: GrowthDirection;
26943
+ };
26944
+ } | null;
26855
26945
  }[];
26856
26946
  };
26857
26947
  outputFormat: "json";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mestra-dev/contract",
3
- "version": "0.0.193",
3
+ "version": "0.0.194",
4
4
  "description": "Types-only Hono AppType contract for the Mestra auth API",
5
5
  "type": "module",
6
6
  "sideEffects": false,