palbase 0.8.0 → 0.9.0

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 (73) hide show
  1. package/dist/ai/index.js +2 -2
  2. package/dist/backend/engine.js +2 -2
  3. package/dist/backend/env.js +1 -1
  4. package/dist/backend/index.js +3 -3
  5. package/dist/backend/stack.js +1 -1
  6. package/dist/backend/test.js +2 -2
  7. package/dist/chunks/{RO5Y5YU4.js → 23G5YVSL.js} +1 -1
  8. package/dist/chunks/{JSJVV43D.js → 3X7CRIHE.js} +1 -1
  9. package/dist/chunks/5UXVSEM2.js +2 -0
  10. package/dist/chunks/6YCANJ7U.js +2 -0
  11. package/dist/chunks/{BO5KR2EQ.js → 7HMBZG2R.js} +2 -2
  12. package/dist/chunks/{RBA6V3UO.js → 7OZCS3BA.js} +2 -2
  13. package/dist/chunks/FFWT3RBE.js +13 -0
  14. package/dist/chunks/{TUGRIOFX.js → GGKL7UV2.js} +2 -2
  15. package/dist/chunks/HGQXQMYU.js +95 -0
  16. package/dist/chunks/{Z5JVQNAZ.js → I45DYZZL.js} +2 -2
  17. package/dist/chunks/{WEI32SAJ.js → KSU226RI.js} +2 -2
  18. package/dist/chunks/MEIN5GAG.js +22 -0
  19. package/dist/chunks/OEZLXSQN.js +6 -0
  20. package/dist/chunks/{BRBCWPR3.js → OGREZP5F.js} +1 -1
  21. package/dist/chunks/{PGPQGKH2.js → ONP77MHF.js} +2 -2
  22. package/dist/chunks/{KDWDPSL2.js → QR4Z3ORW.js} +1 -1
  23. package/dist/chunks/{K6RRNI23.js → R5NCHIW3.js} +2 -2
  24. package/dist/chunks/{PDOHT46N.js → RV35QG7V.js} +2 -2
  25. package/dist/chunks/{P4Z5E6ZI.js → YOTK5642.js} +2 -2
  26. package/dist/chunks/{5VTGMNPL.js → Z7VRCVKE.js} +6 -6
  27. package/dist/cli.js +129 -127
  28. package/dist/refuse/ai.js +1 -1
  29. package/dist/refuse/backend.js +1 -1
  30. package/dist/refuse/server.js +1 -1
  31. package/dist/server/index.js +2 -2
  32. package/dist/server/testing.js +2 -2
  33. package/dist/web/index.js +2 -2
  34. package/dist/web/message.js +2 -0
  35. package/dist/web/palbe.js +2 -2
  36. package/dist/web/paywall.js +2 -2
  37. package/dist/web/push-sw.js +2 -0
  38. package/dist/web/ssr.js +2 -2
  39. package/dist/web/vite.js +2 -2
  40. package/package.json +9 -2
  41. package/types/backend/src/services.d.ts +2 -2
  42. package/types/internal/src/modules/ai.d.ts +1 -1
  43. package/types/internal/src/modules/analytics.d.ts +618 -1
  44. package/types/internal/src/modules/auth.d.ts +409 -90
  45. package/types/internal/src/modules/events.d.ts +7 -3
  46. package/types/internal/src/modules/flags.d.ts +380 -14
  47. package/types/internal/src/modules/notify.d.ts +2270 -99
  48. package/types/internal/src/modules/purchases.d.ts +773 -2
  49. package/types/server/src/webhooks.d.ts +1 -1
  50. package/types/web/src/analytics.d.ts +56 -5
  51. package/types/web/src/client.d.ts +26 -4
  52. package/types/web/src/consent.d.ts +218 -0
  53. package/types/web/src/flags.d.ts +75 -0
  54. package/types/web/src/inapp.d.ts +129 -0
  55. package/types/web/src/inbox.d.ts +59 -0
  56. package/types/web/src/index.d.ts +9 -3
  57. package/types/web/src/installation.d.ts +16 -0
  58. package/types/web/src/message/index.d.ts +5 -0
  59. package/types/web/src/message/present.d.ts +20 -0
  60. package/types/web/src/notify.d.ts +67 -0
  61. package/types/web/src/paywall/index.d.ts +4 -4
  62. package/types/web/src/paywall/placement.d.ts +11 -12
  63. package/types/web/src/paywall/prices.d.ts +7 -2
  64. package/types/web/src/purchases.d.ts +80 -5
  65. package/types/web/src/{paywall → screen}/assets.d.ts +6 -6
  66. package/types/web/src/screen/render.d.ts +186 -0
  67. package/types/web/src/{paywall → screen}/resolve.d.ts +56 -8
  68. package/dist/chunks/DB3SIBKB.js +0 -2
  69. package/dist/chunks/EGNEXFTZ.js +0 -2
  70. package/dist/chunks/FZ3MQOVA.js +0 -6
  71. package/dist/chunks/WINBISC2.js +0 -92
  72. package/types/web/src/paywall/render.d.ts +0 -93
  73. /package/types/web/src/{paywall → screen}/icons.d.ts +0 -0
@@ -431,6 +431,10 @@ export type Catalog = {
431
431
  * The products.
432
432
  */
433
433
  products: Product[];
434
+ /**
435
+ * Prices for a while, to whom the project chooses.
436
+ */
437
+ offers?: CatalogOffer[];
434
438
  };
435
439
  /**
436
440
  * purchases.catalog.applied: a plan's Stripe part was written (applied) or failed; or the stores module answered of its App Store or Google Play part.
@@ -1048,6 +1052,10 @@ export type CheckoutRequest = {
1048
1052
  */
1049
1053
  success_url: string;
1050
1054
  source?: CheckoutSource;
1055
+ /**
1056
+ * One of the catalog's offers the customer may take, on this plan: its coupon (or the promotion code of the coupon code that opened it), or its free trial, on the checkout.
1057
+ */
1058
+ offer?: string;
1051
1059
  };
1052
1060
  /**
1053
1061
  * What calling a leader takes — every variant seen by min_viewers subjects, the leader's chance to win min_chance — and what the results still lack, reason by reason: none, they are confident.
@@ -2456,6 +2464,10 @@ export type PaywallCondition = {
2456
2464
  * Locale.
2457
2465
  */
2458
2466
  locale?: string[];
2467
+ /**
2468
+ * Holds while the package's offer (its package component's offer) is the customer's to take: the package the component is in, else the selected one.
2469
+ */
2470
+ offer_open?: boolean;
2459
2471
  /**
2460
2472
  * Platform.
2461
2473
  */
@@ -2858,6 +2870,10 @@ export type PaywallPackage = {
2858
2870
  * Names the component, unique in the paywall: an app's code can draw its own part in its place.
2859
2871
  */
2860
2872
  id?: string;
2873
+ /**
2874
+ * One of the catalog's offers on the package: bought with it, and its texts' {{offer_price}} its price, while the customer may take it (GET /purchases/offers lists it).
2875
+ */
2876
+ offer?: string;
2861
2877
  /**
2862
2878
  * Plan.
2863
2879
  */
@@ -3164,7 +3180,7 @@ export type PaywallStop = {
3164
3180
  color: string;
3165
3181
  };
3166
3182
  /**
3167
- * A text: the string itself, or `{"t": key}` of the language table. Either may hold variables the app fills from its store — `{{price}}`, `{{price_per_month}}`, `{{period}}`, `{{trial}}`, `{{savings}}`, `{{product_name}}` — of the package an item is, or of the selected package anywhere else. A text that names a variable its package has no value for (no trial, no savings) is not drawn.
3183
+ * A text: the string itself, or `{"t": key}` of the language table. Either may hold variables the app fills from its store — `{{price}}`, `{{price_per_month}}`, `{{period}}`, `{{trial}}`, `{{savings}}`, `{{product_name}}`, `{{offer_price}}` (the price of the package's offer while the customer may take it, its price otherwise) — of the package an item is, or of the selected package anywhere else. A text that names a variable its package has no value for (no trial, no savings) is not drawn.
3168
3184
  */
3169
3185
  export type PaywallString = PaywallLiteral | PaywallTextKey;
3170
3186
  /**
@@ -3735,6 +3751,10 @@ export type PlacementPaywall = {
3735
3751
  * Its version; report it with the exposure.
3736
3752
  */
3737
3753
  version: number;
3754
+ /**
3755
+ * The offers the definition's packages are sold with that the signed-in customer may take now: what {{offer_price}} is the price of, and what such a package is bought with. None for no one signed in.
3756
+ */
3757
+ offers: OfferView[];
3738
3758
  };
3739
3759
  /**
3740
3760
  * What the placement shows the viewer at the moment, where it came from, and what each rule came to.
@@ -4861,7 +4881,7 @@ export type StripeAccount = {
4861
4881
  */
4862
4882
  connected_by?: string;
4863
4883
  /**
4864
- * The key's last characters, to tell it apart.
4884
+ * The key's last characters, to tell it apart (a key's connection).
4865
4885
  */
4866
4886
  key_hint?: string;
4867
4887
  /**
@@ -4880,6 +4900,10 @@ export type StripeAccount = {
4880
4900
  * Where Stripe reports changes on the account: the endpoint the module made there (POST /purchases/webhooks/stripe).
4881
4901
  */
4882
4902
  webhook_url?: string;
4903
+ /**
4904
+ * How the account was connected: `app` — Palbase's Stripe App, installed with one click (no key, no endpoint on the account) — or `key` — a restricted key handed over.
4905
+ */
4906
+ via?: "app" | "key";
4883
4907
  };
4884
4908
  /**
4885
4909
  * A Stripe event, as Stripe signs and sends it: only its id, type and the id of the object it names are read; the object is read again from Stripe.
@@ -5237,6 +5261,562 @@ export type RedemptionRequest = {
5237
5261
  */
5238
5262
  key?: string;
5239
5263
  };
5264
+ /**
5265
+ * A link to install Palbase's Stripe App, in a mode.
5266
+ */
5267
+ export type StripeAppGrantRequest = {
5268
+ /**
5269
+ * Live mode, or Stripe's test mode (false).
5270
+ */
5271
+ livemode: boolean;
5272
+ };
5273
+ /**
5274
+ * A one-time link to install Palbase's Stripe App for the project.
5275
+ */
5276
+ export type StripeAppInstall = {
5277
+ /**
5278
+ * Palbase's install page, the grant in its fragment: open it in a browser; it names the project, then goes on to Stripe, where the account's owner picks the account and accepts what the App may do.
5279
+ */
5280
+ install_url: string;
5281
+ /**
5282
+ * When the link stops working (30 minutes; for an environment's token, no later than the token).
5283
+ */
5284
+ expires_at: string;
5285
+ };
5286
+ /**
5287
+ * An install started with its link's grant — or, with describe, only named.
5288
+ */
5289
+ export type StripeAppStartRequest = {
5290
+ /**
5291
+ * Name what the link connects, starting nothing: the grant is not spent, no cookie is set.
5292
+ */
5293
+ describe?: boolean;
5294
+ /**
5295
+ * The link's grant: `<project id>.<token>`, from its fragment.
5296
+ */
5297
+ grant: string;
5298
+ };
5299
+ /**
5300
+ * What an install link connects an account to — the project, its ref, in which mode — and, started, Stripe's page to go on to.
5301
+ */
5302
+ export type StripeAppStart = {
5303
+ /**
5304
+ * Stripe's install page, the install started: its state is the install's nonce, which the browser keeps. Absent when only described.
5305
+ */
5306
+ authorize_url?: string;
5307
+ /**
5308
+ * Live mode, or Stripe's test mode.
5309
+ */
5310
+ livemode: boolean;
5311
+ /**
5312
+ * The Palbase project's name.
5313
+ */
5314
+ project: string;
5315
+ /**
5316
+ * The project's ref: its address's first label.
5317
+ */
5318
+ project_ref: string;
5319
+ };
5320
+ /**
5321
+ * A percentage off a plan's price for a count of its billing periods.
5322
+ */
5323
+ export type OfferDiscount = {
5324
+ /**
5325
+ * Percent off, 1 to 99.
5326
+ */
5327
+ percent: number;
5328
+ /**
5329
+ * Billing periods it lasts, 1 to 12.
5330
+ */
5331
+ periods: number;
5332
+ };
5333
+ /**
5334
+ * An entitlement for a duration, with no store.
5335
+ */
5336
+ export type OfferGrant = {
5337
+ /**
5338
+ * The catalog's entitlement.
5339
+ */
5340
+ entitlement: string;
5341
+ /**
5342
+ * How long, an ISO 8601 duration (P7D, P1M).
5343
+ */
5344
+ duration: string;
5345
+ };
5346
+ /**
5347
+ * A price for a while, given to whom the project chooses — an analytics audience's members (who allowed personalization), or everyone — once a customer: a discount on some billing periods of a subscription's plans, a free trial of them, or an entitlement for a time with no store (a grant). One of discount, trial and grant. A discount or a trial is each store's own offer, written with the catalog: Apple's promotional offer, Google Play's developer-determined offer, a Stripe coupon; its key is its id at every store.
5348
+ */
5349
+ export type CatalogOffer = {
5350
+ /**
5351
+ * Its key, and its id at the stores (hyphenated at Google Play).
5352
+ */
5353
+ key: string;
5354
+ /**
5355
+ * Its name (Apple's reference name), 1 to 64 characters.
5356
+ */
5357
+ name: string;
5358
+ /**
5359
+ * The subscription a discount or a trial is on.
5360
+ */
5361
+ product?: string;
5362
+ /**
5363
+ * Its plans; none, every plan.
5364
+ */
5365
+ plans?: string[];
5366
+ discount?: OfferDiscount;
5367
+ /**
5368
+ * A free trial's length, an ISO 8601 duration.
5369
+ */
5370
+ trial?: string;
5371
+ grant?: OfferGrant;
5372
+ /**
5373
+ * The analytics audience whose members are given it; none, everyone.
5374
+ */
5375
+ audience?: string;
5376
+ /**
5377
+ * When it is first given.
5378
+ */
5379
+ starts_at?: string;
5380
+ /**
5381
+ * When it is no longer given.
5382
+ */
5383
+ ends_at?: string;
5384
+ };
5385
+ /**
5386
+ * An offer's promotional offer at the App Store.
5387
+ */
5388
+ export type AppStoreOffer = {
5389
+ /**
5390
+ * Its identifier.
5391
+ */
5392
+ offer_id: string;
5393
+ /**
5394
+ * The subscriptions it is on.
5395
+ */
5396
+ product_ids: string[];
5397
+ };
5398
+ /**
5399
+ * An offer's offer at Google Play: developer-determined, tagged palbase.
5400
+ */
5401
+ export type PlayStoreOffer = {
5402
+ /**
5403
+ * Its id.
5404
+ */
5405
+ offer_id: string;
5406
+ /**
5407
+ * The subscription.
5408
+ */
5409
+ product_id: string;
5410
+ /**
5411
+ * The base plans it is on.
5412
+ */
5413
+ base_plan_ids: string[];
5414
+ };
5415
+ /**
5416
+ * An offer on the web's checkout.
5417
+ */
5418
+ export type WebOffer = {
5419
+ /**
5420
+ * The plans.
5421
+ */
5422
+ plans: string[];
5423
+ };
5424
+ /**
5425
+ * An offer the customer may take now, with what each store sells it as.
5426
+ */
5427
+ export type OfferView = {
5428
+ /**
5429
+ * The offer.
5430
+ */
5431
+ key: string;
5432
+ /**
5433
+ * Its name.
5434
+ */
5435
+ name: string;
5436
+ /**
5437
+ * discount, trial or grant.
5438
+ */
5439
+ kind: "discount" | "trial" | "grant";
5440
+ /**
5441
+ * Its subscription.
5442
+ */
5443
+ product?: string;
5444
+ /**
5445
+ * Its plans.
5446
+ */
5447
+ plans?: string[];
5448
+ discount?: OfferDiscount;
5449
+ /**
5450
+ * A free trial's length.
5451
+ */
5452
+ trial?: string;
5453
+ grant?: OfferGrant;
5454
+ /**
5455
+ * When it ends.
5456
+ */
5457
+ ends_at?: string;
5458
+ /**
5459
+ * The coupon that opened it to the customer.
5460
+ */
5461
+ coupon?: string;
5462
+ app_store?: AppStoreOffer;
5463
+ play_store?: PlayStoreOffer;
5464
+ web?: WebOffer;
5465
+ };
5466
+ /**
5467
+ * The offers the signed-in customer may take now.
5468
+ */
5469
+ export type Offers = {
5470
+ /**
5471
+ * Each.
5472
+ */
5473
+ offers: OfferView[];
5474
+ };
5475
+ /**
5476
+ * Which subscription the signature is for, in which app, where StoreKit runs.
5477
+ */
5478
+ export type AppleOfferRequest = {
5479
+ /**
5480
+ * The App Store product (one the offer is on).
5481
+ */
5482
+ product_id: string;
5483
+ /**
5484
+ * The app's bundle identifier (the connected app's is used when one is connected).
5485
+ */
5486
+ bundle_id?: string;
5487
+ /**
5488
+ * xcode for a StoreKit configuration on a developer's Mac (signed with its Subscription Offers Key); otherwise the App Store's.
5489
+ */
5490
+ environment?: string;
5491
+ };
5492
+ /**
5493
+ * What StoreKit buys the promotional offer with, for this customer's purchases: Apple's subscription offer signature.
5494
+ */
5495
+ export type AppleOfferSignature = {
5496
+ /**
5497
+ * The offer's identifier.
5498
+ */
5499
+ offer_id: string;
5500
+ /**
5501
+ * The subscription.
5502
+ */
5503
+ product_id: string;
5504
+ /**
5505
+ * The customer's appAccountToken: the purchase carries it.
5506
+ */
5507
+ app_account_token: string;
5508
+ /**
5509
+ * The key's id.
5510
+ */
5511
+ key_id: string;
5512
+ /**
5513
+ * Used once, lowercase.
5514
+ */
5515
+ nonce: string;
5516
+ /**
5517
+ * Milliseconds since 1970.
5518
+ */
5519
+ timestamp: number;
5520
+ /**
5521
+ * ES256, base64.
5522
+ */
5523
+ signature: string;
5524
+ };
5525
+ /**
5526
+ * What came of an offer.
5527
+ */
5528
+ export type OfferStats = {
5529
+ /**
5530
+ * The offer.
5531
+ */
5532
+ offer: string;
5533
+ /**
5534
+ * Customers shown it.
5535
+ */
5536
+ viewers: number;
5537
+ /**
5538
+ * Customers who took it.
5539
+ */
5540
+ redemptions: number;
5541
+ /**
5542
+ * Redemptions by store: app_store, play_store, stripe, promotional.
5543
+ */
5544
+ by_store: {
5545
+ [key: string]: number;
5546
+ };
5547
+ };
5548
+ /**
5549
+ * Every offer of the catalog, counted.
5550
+ */
5551
+ export type OfferStatsList = {
5552
+ /**
5553
+ * Each.
5554
+ */
5555
+ offers: OfferStats[];
5556
+ };
5557
+ /**
5558
+ * A coupon to make: a code that opens one of the catalog's offers to whoever holds it, once a customer. palbase: Palbase takes the code; apple: an App Store offer code on one of the offer's plans, written to App Store Connect. One of code (shared) and one_time_codes.
5559
+ */
5560
+ export type CouponRequest = {
5561
+ /**
5562
+ * Its key.
5563
+ */
5564
+ key: string;
5565
+ /**
5566
+ * Its name.
5567
+ */
5568
+ name: string;
5569
+ /**
5570
+ * palbase or apple.
5571
+ */
5572
+ kind: "palbase" | "apple";
5573
+ /**
5574
+ * The offer it opens.
5575
+ */
5576
+ offer: string;
5577
+ /**
5578
+ * A code many share, 3 to 32 letters and digits.
5579
+ */
5580
+ code?: string;
5581
+ /**
5582
+ * How many times the shared code is taken.
5583
+ */
5584
+ max_redemptions?: number;
5585
+ /**
5586
+ * How many codes of one use each to make (1 to 25000).
5587
+ */
5588
+ one_time_codes?: number;
5589
+ /**
5590
+ * A guest cannot redeem it.
5591
+ */
5592
+ signed_in_only?: boolean;
5593
+ /**
5594
+ * When it ends (an App Store batch's codes must).
5595
+ */
5596
+ expires_at?: string;
5597
+ /**
5598
+ * An App Store offer code's plan of the offer's product.
5599
+ */
5600
+ plan?: string;
5601
+ };
5602
+ /**
5603
+ * A coupon and what came of it.
5604
+ */
5605
+ export type CouponInfo = {
5606
+ /**
5607
+ * Its key.
5608
+ */
5609
+ key: string;
5610
+ /**
5611
+ * Its name.
5612
+ */
5613
+ name: string;
5614
+ /**
5615
+ * palbase or apple.
5616
+ */
5617
+ kind: string;
5618
+ /**
5619
+ * The offer it opens.
5620
+ */
5621
+ offer: string;
5622
+ /**
5623
+ * Its shared code.
5624
+ */
5625
+ code?: string;
5626
+ /**
5627
+ * The shared code's cap.
5628
+ */
5629
+ max_redemptions?: number | null;
5630
+ /**
5631
+ * Its batch's size.
5632
+ */
5633
+ one_time_codes?: number | null;
5634
+ /**
5635
+ * A guest cannot redeem it.
5636
+ */
5637
+ signed_in_only: boolean;
5638
+ /**
5639
+ * When it ends.
5640
+ */
5641
+ expires_at?: string | null;
5642
+ /**
5643
+ * What App Store Connect holds of an App Store offer code: product_id, state (pending, applied, failed), offer_code_id, error.
5644
+ */
5645
+ apple?: ({
5646
+ [key: string]: unknown;
5647
+ }) | null;
5648
+ /**
5649
+ * The web's Stripe promotion code of a shared code.
5650
+ */
5651
+ stripe_promotion_code?: string;
5652
+ /**
5653
+ * Times it was redeemed: the cap's count (a deleted user's redemption still spends it).
5654
+ */
5655
+ redemptions: number;
5656
+ /**
5657
+ * One-time codes given to people by messages.
5658
+ */
5659
+ codes_given: number;
5660
+ /**
5661
+ * When it was made.
5662
+ */
5663
+ created_at: string;
5664
+ /**
5665
+ * When it was revoked.
5666
+ */
5667
+ revoked_at?: string | null;
5668
+ };
5669
+ /**
5670
+ * The project's coupons, newest first.
5671
+ */
5672
+ export type CouponList = {
5673
+ /**
5674
+ * Each.
5675
+ */
5676
+ coupons: CouponInfo[];
5677
+ };
5678
+ /**
5679
+ * A one-time code.
5680
+ */
5681
+ export type CouponCode = {
5682
+ /**
5683
+ * The code.
5684
+ */
5685
+ code: string;
5686
+ /**
5687
+ * The user a message gave it to.
5688
+ */
5689
+ assigned_to: string | null;
5690
+ /**
5691
+ * When.
5692
+ */
5693
+ assigned_at: string | null;
5694
+ /**
5695
+ * The customer who redeemed it.
5696
+ */
5697
+ redeemed_by: string | null;
5698
+ /**
5699
+ * When.
5700
+ */
5701
+ redeemed_at: string | null;
5702
+ };
5703
+ /**
5704
+ * A coupon's one-time codes.
5705
+ */
5706
+ export type CouponCodes = {
5707
+ /**
5708
+ * Each.
5709
+ */
5710
+ codes: CouponCode[];
5711
+ };
5712
+ /**
5713
+ * A code the customer typed.
5714
+ */
5715
+ export type CouponRedeemRequest = {
5716
+ /**
5717
+ * The code, any case.
5718
+ */
5719
+ code: string;
5720
+ };
5721
+ /**
5722
+ * What a code opened: the offer, and the grant when it gave one.
5723
+ */
5724
+ export type Redeemed = {
5725
+ /**
5726
+ * The coupon.
5727
+ */
5728
+ coupon: string;
5729
+ offer: OfferView;
5730
+ grant?: GrantInfo;
5731
+ };
5732
+ /**
5733
+ * The Subscription Offers Key of Xcode's StoreKit configuration.
5734
+ */
5735
+ export type XcodeOfferKeyRequest = {
5736
+ /**
5737
+ * Its id.
5738
+ */
5739
+ key_id: string;
5740
+ /**
5741
+ * Its .p8 (PEM).
5742
+ */
5743
+ private_key: string;
5744
+ };
5745
+ /**
5746
+ * The key kept.
5747
+ */
5748
+ export type XcodeOfferKey = {
5749
+ /**
5750
+ * Its id.
5751
+ */
5752
+ key_id: string;
5753
+ };
5754
+ /**
5755
+ * purchases.offer.redeemed.
5756
+ */
5757
+ export type OfferRedeemedEvent = {
5758
+ /**
5759
+ * The customer.
5760
+ */
5761
+ customer_id: string;
5762
+ /**
5763
+ * The offer.
5764
+ */
5765
+ offer: string;
5766
+ /**
5767
+ * discount, trial or grant.
5768
+ */
5769
+ kind: string;
5770
+ /**
5771
+ * app_store, play_store, stripe, or promotional (a grant).
5772
+ */
5773
+ store: string;
5774
+ /**
5775
+ * What was bought.
5776
+ */
5777
+ product?: string;
5778
+ /**
5779
+ * Its plan.
5780
+ */
5781
+ plan?: string;
5782
+ /**
5783
+ * The purchase's chain.
5784
+ */
5785
+ chain_id?: string;
5786
+ /**
5787
+ * The coupon it was taken with.
5788
+ */
5789
+ coupon?: string;
5790
+ /**
5791
+ * A grant's entitlement.
5792
+ */
5793
+ entitlement?: string;
5794
+ };
5795
+ /**
5796
+ * purchases.coupon.redeemed.
5797
+ */
5798
+ export type CouponRedeemedEvent = {
5799
+ /**
5800
+ * The customer.
5801
+ */
5802
+ customer_id: string;
5803
+ /**
5804
+ * The coupon.
5805
+ */
5806
+ coupon: string;
5807
+ /**
5808
+ * The offer it opens.
5809
+ */
5810
+ offer?: string;
5811
+ /**
5812
+ * palbase or app_store.
5813
+ */
5814
+ store: string;
5815
+ /**
5816
+ * A one-time code.
5817
+ */
5818
+ one_time: boolean;
5819
+ };
5240
5820
  /** The events this module sends the project's webhooks (x-palbase-events), by type: each one's payload, the event's data. */
5241
5821
  export interface Events {
5242
5822
  /**
@@ -5303,6 +5883,14 @@ export interface Events {
5303
5883
  * purchases.subscription.changed: a customer's subscription started, renewed, stopped renewing (canceled) or renews again (uncanceled), could not be charged (billing_issue) or was again (recovered), ended (expired), or moved to another product (product_changed).
5304
5884
  */
5305
5885
  "purchases.subscription.changed": SubscriptionChangedEvent;
5886
+ /**
5887
+ * purchases.offer.redeemed: a customer took one of the catalog's offers — bought with it at a store, or given its grant — once.
5888
+ */
5889
+ "purchases.offer.redeemed": OfferRedeemedEvent;
5890
+ /**
5891
+ * purchases.coupon.redeemed: a customer redeemed a coupon — its code here, or an App Store offer code at Apple.
5892
+ */
5893
+ "purchases.coupon.redeemed": CouponRedeemedEvent;
5306
5894
  }
5307
5895
  /** Palbase Purchases */
5308
5896
  export declare function client(t: Transport): {
@@ -5594,6 +6182,38 @@ export declare function client(t: Transport): {
5594
6182
  body: ConnectStripeKeyRequest; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
5595
6183
  signal?: AbortSignal;
5596
6184
  }): Promise<Reply<200, StripeAccount>>;
6185
+ /**
6186
+ * The Stripe App's install page
6187
+ *
6188
+ * The page an install link opens: its script reads the grant from the fragment, starts the install (POST /purchases/stripe/app/install) and names the Palbase project the Stripe account will be connected to before the installer goes on to Stripe. No credential: the grant is the authorization.
6189
+ */
6190
+ getStripeAppInstallPage(input?: {
6191
+ signal?: AbortSignal;
6192
+ }): Promise<Reply<200, Response>>;
6193
+ /**
6194
+ * Start a Stripe App install
6195
+ *
6196
+ * Names what an install link's grant connects (describe), or starts the install with it, once: the grant is traded for the install's nonce, kept in the browser (an HttpOnly cookie of Palbase's address, the install's own) and carried by Stripe (the state) — the way back is taken once, only in this browser, and the grant never reaches Stripe. Answers the project's name and ref and, started, Stripe's install page. A grant of no project, used, expired or started already: 410 `grant_invalid`, the same answer for each.
6197
+ */
6198
+ startStripeAppInstall(input: {
6199
+ body: StripeAppStartRequest; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
6200
+ signal?: AbortSignal;
6201
+ }): Promise<Reply<200, StripeAppStart>>;
6202
+ /**
6203
+ * The Stripe App's return
6204
+ *
6205
+ * Where Stripe sends a Stripe App's installer back, with the install's code and its state (the project and the install's nonce): taken once, only in the browser that started the install — its install's cookie is the nonce —, where the grant, spent now whatever comes of it, names the project; the code is traded at Stripe for the install's tokens, sealed under the project's key, and the account is the project's connection. A cancelled install (`error`) connects nothing; an account already connected through the App to another project is refused there (409), and that project keeps it with the tokens Stripe answered now. Answers a page the installer reads. No credential: the grant and the browser's nonce are the authorization.
6206
+ */
6207
+ completeStripeAppInstall(input?: {
6208
+ query?: {
6209
+ code?: string; /** The link's state: the project and its grant. */
6210
+ state?: string; /** What the App may do, as Stripe granted it. */
6211
+ scope?: string; /** Stripe's error, when the installer did not finish. */
6212
+ error?: string; /** And its words. */
6213
+ error_description?: string;
6214
+ }; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
6215
+ signal?: AbortSignal;
6216
+ }): Promise<Reply<200, Response>>;
5597
6217
  /**
5598
6218
  * Read a customer
5599
6219
  *
@@ -6353,6 +6973,18 @@ export declare function client(t: Transport): {
6353
6973
  }; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
6354
6974
  signal?: AbortSignal;
6355
6975
  }): Promise<Reply<201, StripeGrant>>;
6976
+ /**
6977
+ * Install the Stripe App
6978
+ *
6979
+ * A one-time link, good for 30 minutes, to connect the project's Stripe account with one click: Palbase's Stripe App, installed at Stripe in the mode asked — no key pasted, nothing made on the account (the App's events come to Palbase's own endpoint). The link is Palbase's install page, the grant in its fragment (no browser sends it): the page names the project the account will be connected to, trades the grant — once — for the install's nonce, which the browser keeps and Stripe carries back, and goes on to Stripe. Stripe sends the installer back to Palbase (GET /purchases/stripe/app/callback), in the same browser, which connects the account in place of any connected before. One Stripe account, in a mode, is one Palbase project's App connection. A restricted key (POST /purchases/stripe/grants) stays the other way. A project holds 10 open grants at most (429 `too_many_grants`); a Palbase that runs no App in that mode answers 503 `stripe_app_unavailable`.
6980
+ */
6981
+ createStripeAppInstall(input: {
6982
+ headers?: {
6983
+ "Idempotency-Key"?: string;
6984
+ };
6985
+ body: StripeAppGrantRequest; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
6986
+ signal?: AbortSignal;
6987
+ }): Promise<Reply<201, StripeAppInstall>>;
6356
6988
  /**
6357
6989
  * Manage what was bought on the web
6358
6990
  *
@@ -6392,5 +7024,144 @@ export declare function client(t: Transport): {
6392
7024
  body: StripeEvent; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
6393
7025
  signal?: AbortSignal;
6394
7026
  }): Promise<Reply<200, undefined>>;
7027
+ /**
7028
+ * Receive the Stripe App's events
7029
+ *
7030
+ * Where Stripe sends the events of every account that installed Palbase's Stripe App, signed for Palbase's own endpoint of either mode (Stripe-Signature) — no key. Each is handed to the projects connected through the App to its account in its mode, and applied there as a project's Stripe event (ReceiveStripeEvent): the object it names is read again from Stripe as the account, an event of another environment's object is ignored there, and each is kept once per project by its event id. An uninstall (`apps.install.deleted`, `account.application.deauthorized`) refuses the connection. Stripe hears 2xx only once every project took it.
7031
+ */
7032
+ receiveStripeAppEvent(input: {
7033
+ headers: {
7034
+ "Stripe-Signature": string;
7035
+ };
7036
+ body: StripeEvent; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
7037
+ signal?: AbortSignal;
7038
+ }): Promise<Reply<200, undefined>>;
7039
+ /**
7040
+ * List my offers
7041
+ *
7042
+ * The offers the signed-in customer may take now: live, not taken before (once a customer), for everyone, for an audience they are in having allowed personalization, or opened to them by a coupon they redeemed — with what each store sells them as.
7043
+ */
7044
+ listMyOffers(input?: {
7045
+ signal?: AbortSignal;
7046
+ }): Promise<Reply<200, Offers>>;
7047
+ /**
7048
+ * Record an offer shown
7049
+ *
7050
+ * The app showed the offer to its customer: the first time is counted (GET /purchases/offers/stats).
7051
+ */
7052
+ recordOfferView(input: {
7053
+ path: {
7054
+ offer_key: string;
7055
+ }; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
7056
+ signal?: AbortSignal;
7057
+ }): Promise<Reply<204, undefined>>;
7058
+ /**
7059
+ * Sign an App Store offer
7060
+ *
7061
+ * Apple's signature of the offer's promotional offer for the customer's purchase of one of its subscriptions: StoreKit buys it with these (Product.PurchaseOption.promotionalOffer). Signed with the connected In-App Purchase key — or, for a StoreKit configuration on a developer's Mac, its Subscription Offers Key (PUT /purchases/apple/xcode-offer-key). Apple gives a promotional offer to a customer who subscribes, or subscribed, in the group.
7062
+ */
7063
+ signAppleOffer(input: {
7064
+ path: {
7065
+ offer_key: string;
7066
+ };
7067
+ body: AppleOfferRequest; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
7068
+ signal?: AbortSignal;
7069
+ }): Promise<Reply<200, AppleOfferSignature>>;
7070
+ /**
7071
+ * Claim a grant offer
7072
+ *
7073
+ * Takes a grant offer: its entitlement for its duration, from now. Emits `purchases.offer.redeemed` and `purchases.entitlement.changed`.
7074
+ */
7075
+ claimOffer(input: {
7076
+ path: {
7077
+ offer_key: string;
7078
+ }; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
7079
+ signal?: AbortSignal;
7080
+ }): Promise<Reply<201, GrantInfo>>;
7081
+ /**
7082
+ * Redeem a coupon code
7083
+ *
7084
+ * Redeems a code the customer typed, once a customer: a grant at once, a discount or a trial theirs to buy (GET /purchases/offers lists it with the coupon). A one-time code is anyone's once; a shared code up to its cap. Emits `purchases.coupon.redeemed` (and `purchases.offer.redeemed` for a grant).
7085
+ */
7086
+ redeemCoupon(input: {
7087
+ body: CouponRedeemRequest; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
7088
+ signal?: AbortSignal;
7089
+ }): Promise<Reply<200, Redeemed>>;
7090
+ /**
7091
+ * Count the offers
7092
+ *
7093
+ * Every offer of the catalog, counted: customers shown it, customers who took it, by store.
7094
+ */
7095
+ getOfferStats(input?: {
7096
+ signal?: AbortSignal;
7097
+ }): Promise<Reply<200, OfferStatsList>>;
7098
+ /**
7099
+ * List coupons
7100
+ *
7101
+ * The project's coupons, newest first, with what came of each.
7102
+ */
7103
+ listCoupons(input?: {
7104
+ signal?: AbortSignal;
7105
+ }): Promise<Reply<200, CouponList>>;
7106
+ /**
7107
+ * Create a coupon
7108
+ *
7109
+ * Makes a coupon: a code that opens one of the catalog's offers. A palbase coupon's one-time codes are made here; a shared code of a discount on the web is the Stripe promotion code of the offer's coupon too. An apple coupon is an App Store offer code App Store Connect makes (the stores module writes it; `apple.state` says how it went) — its one-time codes are given out as Palbase's are.
7110
+ */
7111
+ createCoupon(input: {
7112
+ headers?: {
7113
+ "Idempotency-Key"?: string;
7114
+ };
7115
+ body: CouponRequest; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
7116
+ signal?: AbortSignal;
7117
+ }): Promise<Reply<201, CouponInfo>>;
7118
+ /**
7119
+ * Get a coupon
7120
+ *
7121
+ * A coupon and what came of it.
7122
+ */
7123
+ getCoupon(input: {
7124
+ path: {
7125
+ coupon_key: string;
7126
+ }; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
7127
+ signal?: AbortSignal;
7128
+ }): Promise<Reply<200, CouponInfo>>;
7129
+ /**
7130
+ * Revoke a coupon
7131
+ *
7132
+ * Revokes a coupon: no code of it is redeemed from now; what was redeemed stays.
7133
+ */
7134
+ revokeCoupon(input: {
7135
+ path: {
7136
+ coupon_key: string;
7137
+ };
7138
+ headers?: {
7139
+ "Idempotency-Key"?: string;
7140
+ }; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
7141
+ signal?: AbortSignal;
7142
+ }): Promise<Reply<204, undefined>>;
7143
+ /**
7144
+ * List a coupon’s codes
7145
+ *
7146
+ * A coupon's one-time codes: whom a message gave each to, who redeemed it. Accept: text/csv answers a file to hand out.
7147
+ */
7148
+ listCouponCodes(input: {
7149
+ path: {
7150
+ coupon_key: string;
7151
+ }; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
7152
+ signal?: AbortSignal;
7153
+ }): Promise<Reply<200, CouponCodes>>;
7154
+ /**
7155
+ * Set Xcode’s offer key
7156
+ *
7157
+ * Keeps the Subscription Offers Key of Xcode's StoreKit configuration (Editor › Subscription Offers Key), sealed: an app run there buys a promotional offer with Palbase's signature. The Xcode certificate is set first.
7158
+ */
7159
+ setXcodeOfferKey(input: {
7160
+ headers?: {
7161
+ "Idempotency-Key"?: string;
7162
+ };
7163
+ body: XcodeOfferKeyRequest; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
7164
+ signal?: AbortSignal;
7165
+ }): Promise<Reply<200, XcodeOfferKey>>;
6395
7166
  };
6396
7167
  export type Client = ReturnType<typeof client>;