@mestra-dev/contract 0.0.62 → 0.0.64

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 +175 -39
  2. package/package.json +2 -2
package/dist/index.d.ts CHANGED
@@ -167,10 +167,25 @@ declare const routes: import("hono/hono-base").HonoBase<{
167
167
  readonly example: "2025-01-20T10:30:00.000Z";
168
168
  };
169
169
  readonly error: {
170
- readonly type: "object";
171
170
  readonly nullable: true;
172
- readonly description: "Validation error details when the payload is invalid.";
173
- readonly additionalProperties: true;
171
+ readonly description: "Validation details (object) or a linking error string such as Phone already in use.";
172
+ readonly oneOf: readonly [
173
+ {
174
+ readonly type: "object";
175
+ readonly additionalProperties: true;
176
+ },
177
+ {
178
+ readonly type: "string";
179
+ readonly enum: readonly [
180
+ "User not found",
181
+ "Phone is already verified",
182
+ "Email is already verified",
183
+ "Phone already in use",
184
+ "Email already in use",
185
+ "An active OTP already exists"
186
+ ];
187
+ }
188
+ ];
174
189
  };
175
190
  };
176
191
  };
@@ -192,7 +207,7 @@ declare const routes: import("hono/hono-base").HonoBase<{
192
207
  };
193
208
  readonly refreshToken: {
194
209
  readonly type: "string";
195
- readonly description: "JWT refresh token (expires in 12 hours or 7 days when keepSignIn is true). Claims include email and userId.";
210
+ readonly description: "JWT refresh token (expires in 7 days, or 30 days when keepSignIn is true). Claims include email and userId.";
196
211
  };
197
212
  };
198
213
  };
@@ -219,10 +234,25 @@ declare const routes: import("hono/hono-base").HonoBase<{
219
234
  readonly example: null;
220
235
  };
221
236
  readonly error: {
222
- readonly type: "object";
223
237
  readonly nullable: true;
224
- readonly description: "Validation error details when the payload is invalid.";
225
- readonly additionalProperties: true;
238
+ readonly description: "Validation details (object) or a linking error string.";
239
+ readonly oneOf: readonly [
240
+ {
241
+ readonly type: "object";
242
+ readonly additionalProperties: true;
243
+ },
244
+ {
245
+ readonly type: "string";
246
+ readonly enum: readonly [
247
+ "User not found",
248
+ "Invalid or expired OTP",
249
+ "Phone is already verified",
250
+ "Email is already verified",
251
+ "Phone already in use",
252
+ "Email already in use"
253
+ ];
254
+ }
255
+ ];
226
256
  };
227
257
  };
228
258
  };
@@ -785,7 +815,8 @@ declare const routes: import("hono/hono-base").HonoBase<{
785
815
  readonly type: "object";
786
816
  readonly required: readonly [
787
817
  "id",
788
- "email"
818
+ "emailVerified",
819
+ "phoneVerified"
789
820
  ];
790
821
  readonly properties: {
791
822
  readonly id: {
@@ -795,11 +826,18 @@ declare const routes: import("hono/hono-base").HonoBase<{
795
826
  readonly email: {
796
827
  readonly type: "string";
797
828
  readonly format: "email";
829
+ readonly nullable: true;
798
830
  };
799
831
  readonly phone: {
800
832
  readonly type: "string";
801
833
  readonly nullable: true;
802
834
  };
835
+ readonly emailVerified: {
836
+ readonly type: "boolean";
837
+ };
838
+ readonly phoneVerified: {
839
+ readonly type: "boolean";
840
+ };
803
841
  readonly firstName: {
804
842
  readonly type: "string";
805
843
  readonly nullable: true;
@@ -4516,6 +4554,10 @@ declare const routes: import("hono/hono-base").HonoBase<{
4516
4554
  "Auth"
4517
4555
  ];
4518
4556
  readonly summary: "Request a one-time password";
4557
+ readonly description: "Without a bearer token this starts email login/signup. With an access token it links an email to the current account (for users who signed in with SMS).";
4558
+ readonly security: readonly [
4559
+ never
4560
+ ];
4519
4561
  readonly requestBody: {
4520
4562
  readonly required: true;
4521
4563
  readonly content: {
@@ -4548,7 +4590,7 @@ declare const routes: import("hono/hono-base").HonoBase<{
4548
4590
  };
4549
4591
  };
4550
4592
  readonly 400: {
4551
- readonly description: "Validation failed or an active OTP already exists.";
4593
+ readonly description: "Validation failed, an active OTP already exists, or linking was rejected (email already verified / in use).";
4552
4594
  readonly content: {
4553
4595
  readonly "application/json": {
4554
4596
  readonly schema: {
@@ -4557,6 +4599,16 @@ declare const routes: import("hono/hono-base").HonoBase<{
4557
4599
  };
4558
4600
  };
4559
4601
  };
4602
+ readonly 403: {
4603
+ readonly description: "Authorization header was sent but the access token is missing, invalid, or expired.";
4604
+ readonly content: {
4605
+ readonly "application/json": {
4606
+ readonly schema: {
4607
+ readonly $ref: "#/components/schemas/ErrorResponse";
4608
+ };
4609
+ };
4610
+ };
4611
+ };
4560
4612
  };
4561
4613
  };
4562
4614
  };
@@ -4566,6 +4618,10 @@ declare const routes: import("hono/hono-base").HonoBase<{
4566
4618
  "Auth"
4567
4619
  ];
4568
4620
  readonly summary: "Verify a one-time password";
4621
+ readonly description: "Without a bearer token this completes email login/signup and returns tokens. With an access token it verifies and attaches an email to the current account.";
4622
+ readonly security: readonly [
4623
+ never
4624
+ ];
4569
4625
  readonly requestBody: {
4570
4626
  readonly required: true;
4571
4627
  readonly content: {
@@ -4589,7 +4645,7 @@ declare const routes: import("hono/hono-base").HonoBase<{
4589
4645
  };
4590
4646
  readonly keepSignIn: {
4591
4647
  readonly type: "boolean";
4592
- readonly description: "Extend refresh token validity to 7 days when true (default 12 hours).";
4648
+ readonly description: "Login only. Extend refresh token validity to 30 days when true (default 7 days). Ignored when linking a contact.";
4593
4649
  };
4594
4650
  };
4595
4651
  };
@@ -4598,17 +4654,24 @@ declare const routes: import("hono/hono-base").HonoBase<{
4598
4654
  };
4599
4655
  readonly responses: {
4600
4656
  readonly 200: {
4601
- readonly description: "OTP verified successfully.";
4657
+ readonly description: "Login returns tokens. Linking an email to the current account returns success only (no new tokens).";
4602
4658
  readonly content: {
4603
4659
  readonly "application/json": {
4604
4660
  readonly schema: {
4605
- readonly $ref: "#/components/schemas/VerifyOtpSuccess";
4661
+ readonly oneOf: readonly [
4662
+ {
4663
+ readonly $ref: "#/components/schemas/VerifyOtpSuccess";
4664
+ },
4665
+ {
4666
+ readonly $ref: "#/components/schemas/SimpleSuccess";
4667
+ }
4668
+ ];
4606
4669
  };
4607
4670
  };
4608
4671
  };
4609
4672
  };
4610
4673
  readonly 400: {
4611
- readonly description: "Validation failed or OTP is invalid/expired.";
4674
+ readonly description: "Validation failed, OTP is invalid/expired, or linking was rejected.";
4612
4675
  readonly content: {
4613
4676
  readonly "application/json": {
4614
4677
  readonly schema: {
@@ -4617,6 +4680,16 @@ declare const routes: import("hono/hono-base").HonoBase<{
4617
4680
  };
4618
4681
  };
4619
4682
  };
4683
+ readonly 403: {
4684
+ readonly description: "Authorization header was sent but the access token is missing, invalid, or expired.";
4685
+ readonly content: {
4686
+ readonly "application/json": {
4687
+ readonly schema: {
4688
+ readonly $ref: "#/components/schemas/ErrorResponse";
4689
+ };
4690
+ };
4691
+ };
4692
+ };
4620
4693
  readonly 429: {
4621
4694
  readonly description: "Too Many Requests - Rate limit exceeded.";
4622
4695
  readonly content: {
@@ -4636,6 +4709,10 @@ declare const routes: import("hono/hono-base").HonoBase<{
4636
4709
  "Auth"
4637
4710
  ];
4638
4711
  readonly summary: "Request a one-time password by SMS";
4712
+ readonly description: "Without a bearer token this starts SMS login/signup. With an access token it links a phone to the current account (for users who signed in with email). SMS is sent via Kod.mobi only when dialCode is +7. Dial code +98 does not send SMS; the OTP is always 987321 for testing.";
4713
+ readonly security: readonly [
4714
+ never
4715
+ ];
4639
4716
  readonly requestBody: {
4640
4717
  readonly required: true;
4641
4718
  readonly content: {
@@ -4643,13 +4720,19 @@ declare const routes: import("hono/hono-base").HonoBase<{
4643
4720
  readonly schema: {
4644
4721
  readonly type: "object";
4645
4722
  readonly required: readonly [
4646
- "phone"
4723
+ "dialCode",
4724
+ "number"
4647
4725
  ];
4648
4726
  readonly properties: {
4649
- readonly phone: {
4727
+ readonly dialCode: {
4728
+ readonly type: "string";
4729
+ readonly description: "International dial code, with or without a leading +.";
4730
+ readonly example: "+7";
4731
+ };
4732
+ readonly number: {
4650
4733
  readonly type: "string";
4651
- readonly description: "Phone number in E.164 format. Russian numbers starting with 8 or 7 are normalized to +7.";
4652
- readonly example: "+79001234567";
4734
+ readonly description: "National phone number without the dial code.";
4735
+ readonly example: "9197286223";
4653
4736
  };
4654
4737
  };
4655
4738
  };
@@ -4668,7 +4751,7 @@ declare const routes: import("hono/hono-base").HonoBase<{
4668
4751
  };
4669
4752
  };
4670
4753
  readonly 400: {
4671
- readonly description: "Validation failed or an active OTP already exists.";
4754
+ readonly description: "Validation failed, an active OTP already exists, or linking was rejected (phone already verified / in use).";
4672
4755
  readonly content: {
4673
4756
  readonly "application/json": {
4674
4757
  readonly schema: {
@@ -4677,6 +4760,16 @@ declare const routes: import("hono/hono-base").HonoBase<{
4677
4760
  };
4678
4761
  };
4679
4762
  };
4763
+ readonly 403: {
4764
+ readonly description: "Authorization header was sent but the access token is missing, invalid, or expired.";
4765
+ readonly content: {
4766
+ readonly "application/json": {
4767
+ readonly schema: {
4768
+ readonly $ref: "#/components/schemas/ErrorResponse";
4769
+ };
4770
+ };
4771
+ };
4772
+ };
4680
4773
  readonly 429: {
4681
4774
  readonly description: "Too Many Requests - Rate limit exceeded.";
4682
4775
  readonly content: {
@@ -4696,6 +4789,10 @@ declare const routes: import("hono/hono-base").HonoBase<{
4696
4789
  "Auth"
4697
4790
  ];
4698
4791
  readonly summary: "Verify an SMS one-time password";
4792
+ readonly description: "Without a bearer token this completes SMS login/signup and returns tokens. With an access token it verifies and attaches a phone to the current account.";
4793
+ readonly security: readonly [
4794
+ never
4795
+ ];
4699
4796
  readonly requestBody: {
4700
4797
  readonly required: true;
4701
4798
  readonly content: {
@@ -4703,14 +4800,20 @@ declare const routes: import("hono/hono-base").HonoBase<{
4703
4800
  readonly schema: {
4704
4801
  readonly type: "object";
4705
4802
  readonly required: readonly [
4706
- "phone",
4803
+ "dialCode",
4804
+ "number",
4707
4805
  "otp"
4708
4806
  ];
4709
4807
  readonly properties: {
4710
- readonly phone: {
4808
+ readonly dialCode: {
4711
4809
  readonly type: "string";
4712
- readonly description: "Phone number in E.164 format. Russian numbers starting with 8 or 7 are normalized to +7.";
4713
- readonly example: "+79001234567";
4810
+ readonly description: "International dial code, with or without a leading +.";
4811
+ readonly example: "+7";
4812
+ };
4813
+ readonly number: {
4814
+ readonly type: "string";
4815
+ readonly description: "National phone number without the dial code.";
4816
+ readonly example: "9197286223";
4714
4817
  };
4715
4818
  readonly otp: {
4716
4819
  readonly type: "string";
@@ -4719,7 +4822,7 @@ declare const routes: import("hono/hono-base").HonoBase<{
4719
4822
  };
4720
4823
  readonly keepSignIn: {
4721
4824
  readonly type: "boolean";
4722
- readonly description: "Extend refresh token validity to 30 days when true (default 7 days).";
4825
+ readonly description: "Login only. Extend refresh token validity to 30 days when true (default 7 days). Ignored when linking a contact.";
4723
4826
  };
4724
4827
  };
4725
4828
  };
@@ -4728,17 +4831,24 @@ declare const routes: import("hono/hono-base").HonoBase<{
4728
4831
  };
4729
4832
  readonly responses: {
4730
4833
  readonly 200: {
4731
- readonly description: "OTP verified successfully.";
4834
+ readonly description: "Login returns tokens. Linking a phone to the current account returns success only (no new tokens).";
4732
4835
  readonly content: {
4733
4836
  readonly "application/json": {
4734
4837
  readonly schema: {
4735
- readonly $ref: "#/components/schemas/VerifyOtpSuccess";
4838
+ readonly oneOf: readonly [
4839
+ {
4840
+ readonly $ref: "#/components/schemas/VerifyOtpSuccess";
4841
+ },
4842
+ {
4843
+ readonly $ref: "#/components/schemas/SimpleSuccess";
4844
+ }
4845
+ ];
4736
4846
  };
4737
4847
  };
4738
4848
  };
4739
4849
  };
4740
4850
  readonly 400: {
4741
- readonly description: "Validation failed or OTP is invalid/expired.";
4851
+ readonly description: "Validation failed, OTP is invalid/expired, or linking was rejected.";
4742
4852
  readonly content: {
4743
4853
  readonly "application/json": {
4744
4854
  readonly schema: {
@@ -4747,6 +4857,16 @@ declare const routes: import("hono/hono-base").HonoBase<{
4747
4857
  };
4748
4858
  };
4749
4859
  };
4860
+ readonly 403: {
4861
+ readonly description: "Authorization header was sent but the access token is missing, invalid, or expired.";
4862
+ readonly content: {
4863
+ readonly "application/json": {
4864
+ readonly schema: {
4865
+ readonly $ref: "#/components/schemas/ErrorResponse";
4866
+ };
4867
+ };
4868
+ };
4869
+ };
4750
4870
  readonly 429: {
4751
4871
  readonly description: "Too Many Requests - Rate limit exceeded.";
4752
4872
  readonly content: {
@@ -4766,7 +4886,7 @@ declare const routes: import("hono/hono-base").HonoBase<{
4766
4886
  "Auth"
4767
4887
  ];
4768
4888
  readonly summary: "Get current authenticated user";
4769
- readonly description: "Returns the user profile for the `userId` claim on the provided access token.";
4889
+ readonly description: "Returns the user profile for the `userId` claim on the provided access token. SMS-only accounts have `email: null` until an email is linked. Use `emailVerified` and `phoneVerified` to decide whether the user can create a workspace or accept an invite.";
4770
4890
  readonly security: readonly [
4771
4891
  never
4772
4892
  ];
@@ -5123,7 +5243,7 @@ declare const routes: import("hono/hono-base").HonoBase<{
5123
5243
  "Workspace"
5124
5244
  ];
5125
5245
  readonly summary: "Create a new workspace";
5126
- readonly description: "Creates a workspace and its billing subscription atomically. Free starts a 15-day trial (default `TRIAL_WORKSPACE_LIMIT` is 1 Free trial per owner). Economy, Standard, and Professional create a pending invoice; use the returned invoiceId to start YooKassa checkout. An owner may have at most 5 pending unpaid invoices for those paid plans before creating another. Professional may create one complimentary workspace for an owner with an active paid Professional workspace.";
5246
+ readonly description: "Creates a workspace and its billing subscription atomically. Requires the caller to have both email and phone verified. Free starts a 15-day trial (default `TRIAL_WORKSPACE_LIMIT` is 1 Free trial per owner). Economy, Standard, and Professional create a pending invoice; use the returned invoiceId to start YooKassa checkout. An owner may have at most 5 pending unpaid invoices for those paid plans before creating another. Professional may create one complimentary workspace for an owner with an active paid Professional workspace.";
5127
5247
  readonly security: readonly [
5128
5248
  never
5129
5249
  ];
@@ -5208,7 +5328,7 @@ declare const routes: import("hono/hono-base").HonoBase<{
5208
5328
  };
5209
5329
  };
5210
5330
  readonly 403: {
5211
- readonly description: "Forbidden - Token issuer is not 'access'.";
5331
+ readonly description: "Forbidden - Token issuer is not 'access', or email and phone are not both verified.";
5212
5332
  readonly content: {
5213
5333
  readonly "application/json": {
5214
5334
  readonly schema: {
@@ -5989,7 +6109,7 @@ declare const routes: import("hono/hono-base").HonoBase<{
5989
6109
  "Workspace"
5990
6110
  ];
5991
6111
  readonly summary: "Accept workspace invitation";
5992
- readonly description: "Accepts a workspace invitation using the provided token. Requires authentication.";
6112
+ readonly description: "Accepts a workspace invitation using the provided token. Requires authentication and both email and phone verified.";
5993
6113
  readonly security: readonly [
5994
6114
  never
5995
6115
  ];
@@ -6048,7 +6168,7 @@ declare const routes: import("hono/hono-base").HonoBase<{
6048
6168
  };
6049
6169
  };
6050
6170
  readonly 403: {
6051
- readonly description: "Forbidden - Token issuer is not 'access' or user lacks workspace access.";
6171
+ readonly description: "Forbidden - Token issuer is not 'access', user lacks workspace access, or email and phone are not both verified.";
6052
6172
  readonly content: {
6053
6173
  readonly "application/json": {
6054
6174
  readonly schema: {
@@ -13015,11 +13135,11 @@ declare const routes: import("hono/hono-base").HonoBase<{
13015
13135
  $post: {
13016
13136
  input: {};
13017
13137
  output: {
13018
- success: false;
13019
- error: never;
13138
+ success: boolean;
13139
+ error: string | undefined;
13020
13140
  };
13021
13141
  outputFormat: "json";
13022
- status: 400;
13142
+ status: 200 | 400;
13023
13143
  } | {
13024
13144
  input: {};
13025
13145
  output: {
@@ -13056,11 +13176,11 @@ declare const routes: import("hono/hono-base").HonoBase<{
13056
13176
  $post: {
13057
13177
  input: {};
13058
13178
  output: {
13059
- success: false;
13060
- error: never;
13179
+ success: boolean;
13180
+ error: string | undefined;
13061
13181
  };
13062
13182
  outputFormat: "json";
13063
- status: 400;
13183
+ status: 200 | 400;
13064
13184
  } | {
13065
13185
  input: {};
13066
13186
  output: {
@@ -13080,8 +13200,10 @@ declare const routes: import("hono/hono-base").HonoBase<{
13080
13200
  success: true;
13081
13201
  user: {
13082
13202
  id: string;
13083
- email: string;
13203
+ email: string | null;
13084
13204
  phone: string | null;
13205
+ emailVerified: boolean;
13206
+ phoneVerified: boolean;
13085
13207
  firstName: string | null;
13086
13208
  lastName: string | null;
13087
13209
  profilePicture: string | null;
@@ -13515,6 +13637,20 @@ declare const routes: import("hono/hono-base").HonoBase<{
13515
13637
  };
13516
13638
  outputFormat: "json";
13517
13639
  status: 400;
13640
+ } | {
13641
+ input: {
13642
+ param: {
13643
+ workspace: string;
13644
+ } & {
13645
+ token: string;
13646
+ };
13647
+ };
13648
+ output: {
13649
+ success: false;
13650
+ error: string;
13651
+ };
13652
+ outputFormat: "json";
13653
+ status: 403;
13518
13654
  } | {
13519
13655
  input: {
13520
13656
  param: {
@@ -14365,11 +14501,11 @@ declare const routes: import("hono/hono-base").HonoBase<{
14365
14501
  email: string | null;
14366
14502
  workspaceId: string;
14367
14503
  description: string | null;
14368
- phone: string | null;
14369
14504
  updated_at: string | null;
14370
14505
  deleted_at: string | null;
14371
14506
  verified_at: string | null;
14372
14507
  suspended_at: string | null;
14508
+ phone: string | null;
14373
14509
  website: string | null;
14374
14510
  companyPhone: string | null;
14375
14511
  companyAddress: string | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mestra-dev/contract",
3
- "version": "0.0.62",
3
+ "version": "0.0.64",
4
4
  "description": "Types-only Hono AppType contract for the Mestra auth API",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -27,7 +27,7 @@
27
27
  "devDependencies": {
28
28
  "@types/bun": "^1.3.14",
29
29
  "dts-bundle-generator": "^9.5.1",
30
- "hono": "^4.13.1",
30
+ "hono": "^4.13.2",
31
31
  "typescript": "^5.9.3"
32
32
  }
33
33
  }