@mestra-dev/contract 0.0.146 → 0.0.148

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 +454 -2
  2. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -4364,6 +4364,8 @@ declare const routes: import("hono/hono-base").HonoBase<{
4364
4364
  "interval",
4365
4365
  "billingCycles",
4366
4366
  "createdAt",
4367
+ "subtotalKopecks",
4368
+ "discountKopecks",
4367
4369
  "amountKopecks",
4368
4370
  "currency",
4369
4371
  "status"
@@ -4403,9 +4405,21 @@ declare const routes: import("hono/hono-base").HonoBase<{
4403
4405
  readonly type: "string";
4404
4406
  readonly format: "date-time";
4405
4407
  };
4408
+ readonly subtotalKopecks: {
4409
+ readonly type: "integer";
4410
+ readonly description: "Price before the coupon discount, in kopecks.";
4411
+ };
4412
+ readonly discountKopecks: {
4413
+ readonly type: "integer";
4414
+ readonly description: "Applied coupon discount, in kopecks.";
4415
+ };
4416
+ readonly couponCode: {
4417
+ readonly type: "string";
4418
+ readonly nullable: true;
4419
+ };
4406
4420
  readonly amountKopecks: {
4407
4421
  readonly type: "integer";
4408
- readonly description: "Full invoice amount in kopecks.";
4422
+ readonly description: "Payable invoice amount after any coupon discount, in kopecks.";
4409
4423
  };
4410
4424
  readonly currency: {
4411
4425
  readonly type: "string";
@@ -4437,6 +4451,8 @@ declare const routes: import("hono/hono-base").HonoBase<{
4437
4451
  "seats",
4438
4452
  "interval",
4439
4453
  "billingCycles",
4454
+ "subtotalKopecks",
4455
+ "discountKopecks",
4440
4456
  "amountKopecks",
4441
4457
  "currency"
4442
4458
  ];
@@ -4485,9 +4501,21 @@ declare const routes: import("hono/hono-base").HonoBase<{
4485
4501
  readonly billingCycles: {
4486
4502
  readonly $ref: "#/components/schemas/BillingCycles";
4487
4503
  };
4504
+ readonly subtotalKopecks: {
4505
+ readonly type: "integer";
4506
+ readonly description: "Price before the coupon discount, in kopecks.";
4507
+ };
4508
+ readonly discountKopecks: {
4509
+ readonly type: "integer";
4510
+ readonly description: "Applied coupon discount, in kopecks.";
4511
+ };
4512
+ readonly couponCode: {
4513
+ readonly type: "string";
4514
+ readonly nullable: true;
4515
+ };
4488
4516
  readonly amountKopecks: {
4489
4517
  readonly type: "integer";
4490
- readonly description: "Full invoice amount in kopecks.";
4518
+ readonly description: "Payable invoice amount after any coupon discount, in kopecks.";
4491
4519
  };
4492
4520
  readonly currency: {
4493
4521
  readonly type: "string";
@@ -8212,6 +8240,184 @@ declare const routes: import("hono/hono-base").HonoBase<{
8212
8240
  };
8213
8241
  };
8214
8242
  };
8243
+ readonly "/payments/invoice/{invoiceId}/coupon": {
8244
+ readonly post: {
8245
+ readonly tags: readonly [
8246
+ "Payments"
8247
+ ];
8248
+ readonly summary: "Apply a coupon to a pending invoice";
8249
+ readonly description: "Workspace owner only. Applies a fixed or percentage coupon before checkout begins. Coupon attempts are rate limited; invalid codes intentionally return the same response.";
8250
+ readonly security: readonly [
8251
+ never
8252
+ ];
8253
+ readonly parameters: readonly [
8254
+ {
8255
+ readonly name: "invoiceId";
8256
+ readonly in: "path";
8257
+ readonly required: true;
8258
+ readonly schema: {
8259
+ readonly type: "string";
8260
+ readonly format: "uuid";
8261
+ };
8262
+ }
8263
+ ];
8264
+ readonly requestBody: {
8265
+ readonly required: true;
8266
+ readonly content: {
8267
+ readonly "application/json": {
8268
+ readonly schema: {
8269
+ readonly type: "object";
8270
+ readonly required: readonly [
8271
+ "code"
8272
+ ];
8273
+ readonly properties: {
8274
+ readonly code: {
8275
+ readonly type: "string";
8276
+ readonly minLength: 3;
8277
+ readonly maxLength: 64;
8278
+ readonly pattern: "^[A-Za-z0-9_-]+$";
8279
+ };
8280
+ };
8281
+ };
8282
+ };
8283
+ };
8284
+ };
8285
+ readonly responses: {
8286
+ readonly 200: {
8287
+ readonly description: "Coupon applied.";
8288
+ readonly content: {
8289
+ readonly "application/json": {
8290
+ readonly schema: {
8291
+ readonly type: "object";
8292
+ readonly properties: {
8293
+ readonly success: {
8294
+ readonly type: "boolean";
8295
+ readonly const: true;
8296
+ };
8297
+ readonly invoice: {
8298
+ readonly type: "object";
8299
+ readonly properties: any;
8300
+ };
8301
+ };
8302
+ };
8303
+ };
8304
+ };
8305
+ };
8306
+ readonly 400: {
8307
+ readonly description: "Coupon cannot be applied.";
8308
+ readonly content: {
8309
+ readonly "application/json": {
8310
+ readonly schema: {
8311
+ readonly $ref: "#/components/schemas/ErrorResponse";
8312
+ };
8313
+ };
8314
+ };
8315
+ };
8316
+ readonly 403: {
8317
+ readonly description: "Unauthorized.";
8318
+ readonly content: {
8319
+ readonly "application/json": {
8320
+ readonly schema: {
8321
+ readonly $ref: "#/components/schemas/ErrorResponse";
8322
+ };
8323
+ };
8324
+ };
8325
+ };
8326
+ readonly 409: {
8327
+ readonly description: "Invoice is no longer eligible for a coupon.";
8328
+ readonly content: {
8329
+ readonly "application/json": {
8330
+ readonly schema: {
8331
+ readonly $ref: "#/components/schemas/ErrorResponse";
8332
+ };
8333
+ };
8334
+ };
8335
+ };
8336
+ readonly 429: {
8337
+ readonly description: "Too many coupon attempts.";
8338
+ readonly content: {
8339
+ readonly "application/json": {
8340
+ readonly schema: {
8341
+ readonly $ref: "#/components/schemas/ErrorResponse";
8342
+ };
8343
+ };
8344
+ };
8345
+ };
8346
+ };
8347
+ };
8348
+ readonly delete: {
8349
+ readonly tags: readonly [
8350
+ "Payments"
8351
+ ];
8352
+ readonly summary: "Remove a coupon from a pending invoice";
8353
+ readonly description: "Workspace owner only. Removes the invoice redemption and restores the full invoice amount. It is unavailable after YooKassa checkout has started.";
8354
+ readonly security: readonly [
8355
+ never
8356
+ ];
8357
+ readonly parameters: readonly [
8358
+ {
8359
+ readonly name: "invoiceId";
8360
+ readonly in: "path";
8361
+ readonly required: true;
8362
+ readonly schema: {
8363
+ readonly type: "string";
8364
+ readonly format: "uuid";
8365
+ };
8366
+ }
8367
+ ];
8368
+ readonly responses: {
8369
+ readonly 200: {
8370
+ readonly description: "Coupon removed.";
8371
+ readonly content: {
8372
+ readonly "application/json": {
8373
+ readonly schema: {
8374
+ readonly type: "object";
8375
+ readonly properties: {
8376
+ readonly success: {
8377
+ readonly type: "boolean";
8378
+ readonly const: true;
8379
+ };
8380
+ readonly invoice: {
8381
+ readonly $ref: "#/components/schemas/BillingInvoice";
8382
+ };
8383
+ };
8384
+ };
8385
+ };
8386
+ };
8387
+ };
8388
+ readonly 404: {
8389
+ readonly description: "Invoice not found.";
8390
+ readonly content: {
8391
+ readonly "application/json": {
8392
+ readonly schema: {
8393
+ readonly $ref: "#/components/schemas/ErrorResponse";
8394
+ };
8395
+ };
8396
+ };
8397
+ };
8398
+ readonly 409: {
8399
+ readonly description: "No coupon is applied or checkout has started.";
8400
+ readonly content: {
8401
+ readonly "application/json": {
8402
+ readonly schema: {
8403
+ readonly $ref: "#/components/schemas/ErrorResponse";
8404
+ };
8405
+ };
8406
+ };
8407
+ };
8408
+ readonly 429: {
8409
+ readonly description: "Too many requests.";
8410
+ readonly content: {
8411
+ readonly "application/json": {
8412
+ readonly schema: {
8413
+ readonly $ref: "#/components/schemas/ErrorResponse";
8414
+ };
8415
+ };
8416
+ };
8417
+ };
8418
+ };
8419
+ };
8420
+ };
8215
8421
  readonly "/payments/upgrade": {
8216
8422
  readonly post: {
8217
8423
  readonly tags: readonly [
@@ -16406,6 +16612,176 @@ declare const routes: import("hono/hono-base").HonoBase<{
16406
16612
  status: 400 | 404;
16407
16613
  };
16408
16614
  };
16615
+ } & {
16616
+ "/admin/coupons": {
16617
+ $get: {
16618
+ input: {};
16619
+ output: {
16620
+ success: false;
16621
+ error: string;
16622
+ };
16623
+ outputFormat: "json";
16624
+ status: 401;
16625
+ } | {
16626
+ input: {};
16627
+ output: {
16628
+ success: true;
16629
+ coupons: {
16630
+ id: string;
16631
+ code: string;
16632
+ discountType: string;
16633
+ fixedKopecks: number | null;
16634
+ percent: number | null;
16635
+ active: boolean;
16636
+ expiresAt: string | null;
16637
+ maxRedemptions: number | null;
16638
+ redemptionCount: number;
16639
+ createdAt: string;
16640
+ }[];
16641
+ };
16642
+ outputFormat: "json";
16643
+ status: 200;
16644
+ };
16645
+ };
16646
+ } & {
16647
+ "/admin/coupons": {
16648
+ $post: {
16649
+ input: {};
16650
+ output: {
16651
+ success: false;
16652
+ error: string;
16653
+ };
16654
+ outputFormat: "json";
16655
+ status: 401;
16656
+ } | {
16657
+ input: {};
16658
+ output: {
16659
+ success: true;
16660
+ coupon: {
16661
+ expiresAt: string | null;
16662
+ id: string;
16663
+ created_at: string;
16664
+ active: boolean;
16665
+ code: string;
16666
+ updated_at: string | null;
16667
+ deleted_at: string | null;
16668
+ verified_at: string | null;
16669
+ suspended_at: string | null;
16670
+ discountType: string;
16671
+ fixedKopecks: number | null;
16672
+ percent: number | null;
16673
+ maxRedemptions: number | null;
16674
+ redemptionCount: number;
16675
+ createdBy: string;
16676
+ };
16677
+ };
16678
+ outputFormat: "json";
16679
+ status: 201;
16680
+ } | {
16681
+ input: {};
16682
+ output: {
16683
+ success: false;
16684
+ error: string;
16685
+ };
16686
+ outputFormat: "json";
16687
+ status: 400 | 409;
16688
+ };
16689
+ };
16690
+ } & {
16691
+ "/admin/coupons/:couponId": {
16692
+ $patch: {
16693
+ input: {
16694
+ param: {
16695
+ couponId: string;
16696
+ };
16697
+ };
16698
+ output: {
16699
+ success: false;
16700
+ error: string;
16701
+ };
16702
+ outputFormat: "json";
16703
+ status: 401;
16704
+ } | {
16705
+ input: {
16706
+ param: {
16707
+ couponId: string;
16708
+ };
16709
+ };
16710
+ output: {
16711
+ success: true;
16712
+ coupon: {
16713
+ updated_at: string | null;
16714
+ deleted_at: string | null;
16715
+ verified_at: string | null;
16716
+ suspended_at: string | null;
16717
+ created_at: string;
16718
+ id: string;
16719
+ code: string;
16720
+ discountType: string;
16721
+ fixedKopecks: number | null;
16722
+ percent: number | null;
16723
+ active: boolean;
16724
+ expiresAt: string | null;
16725
+ maxRedemptions: number | null;
16726
+ redemptionCount: number;
16727
+ createdBy: string;
16728
+ };
16729
+ };
16730
+ outputFormat: "json";
16731
+ status: 200;
16732
+ } | {
16733
+ input: {
16734
+ param: {
16735
+ couponId: string;
16736
+ };
16737
+ };
16738
+ output: {
16739
+ success: false;
16740
+ error: string;
16741
+ };
16742
+ outputFormat: "json";
16743
+ status: 400 | 404;
16744
+ };
16745
+ };
16746
+ } & {
16747
+ "/admin/coupons/:couponId": {
16748
+ $delete: {
16749
+ input: {
16750
+ param: {
16751
+ couponId: string;
16752
+ };
16753
+ };
16754
+ output: {
16755
+ success: false;
16756
+ error: string;
16757
+ };
16758
+ outputFormat: "json";
16759
+ status: 401;
16760
+ } | {
16761
+ input: {
16762
+ param: {
16763
+ couponId: string;
16764
+ };
16765
+ };
16766
+ output: {
16767
+ success: true;
16768
+ };
16769
+ outputFormat: "json";
16770
+ status: 200;
16771
+ } | {
16772
+ input: {
16773
+ param: {
16774
+ couponId: string;
16775
+ };
16776
+ };
16777
+ output: {
16778
+ success: false;
16779
+ error: string;
16780
+ };
16781
+ outputFormat: "json";
16782
+ status: 404;
16783
+ };
16784
+ };
16409
16785
  } & {
16410
16786
  "/create": {
16411
16787
  $post: {
@@ -16516,6 +16892,9 @@ declare const routes: import("hono/hono-base").HonoBase<{
16516
16892
  interval: string;
16517
16893
  billingCycles: number;
16518
16894
  amountKopecks: number;
16895
+ subtotalKopecks: number;
16896
+ discountKopecks: number;
16897
+ couponCode: string | null;
16519
16898
  currency: string;
16520
16899
  periodStart: string;
16521
16900
  periodEnd: string;
@@ -23159,6 +23538,9 @@ declare const routes: import("hono/hono-base").HonoBase<{
23159
23538
  planName: string;
23160
23539
  interval: string;
23161
23540
  billingCycles: number;
23541
+ subtotalKopecks: number;
23542
+ discountKopecks: number;
23543
+ couponCode: string | null;
23162
23544
  amountKopecks: number;
23163
23545
  currency: string;
23164
23546
  status: string;
@@ -23197,6 +23579,76 @@ declare const routes: import("hono/hono-base").HonoBase<{
23197
23579
  status: 400 | 403 | 404 | 409 | 502 | 503;
23198
23580
  };
23199
23581
  };
23582
+ } & {
23583
+ "/invoice/:invoiceId/coupon": {
23584
+ $post: {
23585
+ input: {
23586
+ param: {
23587
+ invoiceId: string;
23588
+ };
23589
+ };
23590
+ output: {
23591
+ success: true;
23592
+ invoice: {
23593
+ id: string;
23594
+ subtotalKopecks: number;
23595
+ discountKopecks: number;
23596
+ amountKopecks: number;
23597
+ couponCode: string | null;
23598
+ status: string;
23599
+ };
23600
+ };
23601
+ outputFormat: "json";
23602
+ status: 200;
23603
+ } | {
23604
+ input: {
23605
+ param: {
23606
+ invoiceId: string;
23607
+ };
23608
+ };
23609
+ output: {
23610
+ success: false;
23611
+ error: string;
23612
+ };
23613
+ outputFormat: "json";
23614
+ status: 400 | 403 | 404 | 409;
23615
+ };
23616
+ };
23617
+ } & {
23618
+ "/invoice/:invoiceId/coupon": {
23619
+ $delete: {
23620
+ input: {
23621
+ param: {
23622
+ invoiceId: string;
23623
+ };
23624
+ };
23625
+ output: {
23626
+ success: true;
23627
+ invoice: {
23628
+ id: string;
23629
+ subtotalKopecks: number;
23630
+ discountKopecks: number;
23631
+ amountKopecks: number;
23632
+ couponCode: string | null;
23633
+ status: string;
23634
+ };
23635
+ };
23636
+ outputFormat: "json";
23637
+ status: 200;
23638
+ } | {
23639
+ input: {
23640
+ param: {
23641
+ invoiceId: string;
23642
+ };
23643
+ };
23644
+ output: {
23645
+ success: false;
23646
+ error: string;
23647
+ };
23648
+ outputFormat: "json";
23649
+ status: 400 | 403 | 404 | 409;
23650
+ };
23651
+ };
23200
23652
  } & {
23201
23653
  "/upgrade": {
23202
23654
  $post: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mestra-dev/contract",
3
- "version": "0.0.146",
3
+ "version": "0.0.148",
4
4
  "description": "Types-only Hono AppType contract for the Mestra auth API",
5
5
  "type": "module",
6
6
  "sideEffects": false,