palbase 0.7.0 → 0.8.1

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 (78) 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 +9 -9
  5. package/dist/backend/stack.js +1 -1
  6. package/dist/backend/test.js +2 -2
  7. package/dist/chunks/5M3HV3X4.js +2 -0
  8. package/dist/chunks/5RTSNQ4X.js +13 -0
  9. package/dist/chunks/{PJVWGUIT.js → 6RXVXPHC.js} +1 -1
  10. package/dist/chunks/{SU7BP6VF.js → 73R33XMD.js} +1 -1
  11. package/dist/chunks/{BKVU4I5R.js → 7XVI5JLP.js} +2 -2
  12. package/dist/chunks/{KDSWK3XW.js → CA4VJGGG.js} +1 -1
  13. package/dist/chunks/{X3MTLJRV.js → KHHJRNAO.js} +1 -1
  14. package/dist/chunks/KJWHR5BP.js +20 -0
  15. package/dist/chunks/KYJJJUEU.js +2 -0
  16. package/dist/chunks/M4XLAPDF.js +4 -0
  17. package/dist/chunks/{G3BK7L3J.js → MAYLG7WE.js} +2 -2
  18. package/dist/chunks/NSQAN2ME.js +6 -0
  19. package/dist/chunks/{5ZJCEQV5.js → Q4XTWEAW.js} +3 -3
  20. package/dist/chunks/{ZBOJEH7K.js → RYI2OB52.js} +2 -2
  21. package/dist/chunks/RZ525VLP.js +2 -0
  22. package/dist/chunks/T2Q5CKLL.js +18 -0
  23. package/dist/chunks/Y6AQWQBE.js +2 -0
  24. package/dist/chunks/ZSKMWUIQ.js +2 -0
  25. package/dist/cli.js +124 -123
  26. package/dist/refuse/ai.js +1 -1
  27. package/dist/refuse/backend.js +1 -1
  28. package/dist/refuse/server.js +1 -1
  29. package/dist/server/index.js +2 -2
  30. package/dist/server/testing.js +2 -2
  31. package/dist/web/index.js +2 -2
  32. package/dist/web/palbe.js +2 -2
  33. package/dist/web/paywall.js +2 -2
  34. package/dist/web/ssr.js +2 -2
  35. package/dist/web/vite.js +2 -2
  36. package/package.json +4 -2
  37. package/types/ai/src/ai.d.ts +44 -15
  38. package/types/ai/src/chats.d.ts +442 -12
  39. package/types/ai/src/index.d.ts +4 -4
  40. package/types/ai/src/tools.d.ts +158 -21
  41. package/types/backend/src/bootstrap.d.ts +8 -0
  42. package/types/backend/src/container.d.ts +9 -0
  43. package/types/backend/src/database.d.ts +17 -2
  44. package/types/backend/src/engine.d.ts +2 -0
  45. package/types/backend/src/gateways.d.ts +19 -0
  46. package/types/backend/src/index.d.ts +1 -0
  47. package/types/backend/src/runtime.d.ts +12 -0
  48. package/types/backend/src/testing/unit.d.ts +3 -1
  49. package/types/internal/src/chat.d.ts +168 -3
  50. package/types/internal/src/modules/ai.d.ts +1305 -57
  51. package/types/internal/src/modules/auth.d.ts +14 -2
  52. package/types/internal/src/modules/events.d.ts +2 -2
  53. package/types/internal/src/modules/machines.d.ts +57 -1
  54. package/types/internal/src/modules/notify.d.ts +6 -6
  55. package/types/internal/src/modules/purchases.d.ts +466 -14
  56. package/types/internal/src/modules/realtime.d.ts +36 -0
  57. package/types/internal/src/modules/stores.d.ts +259 -22
  58. package/types/internal/src/transport.d.ts +5 -0
  59. package/types/server/src/auth/jwt.d.ts +1 -6
  60. package/types/web/src/auth.d.ts +15 -4
  61. package/types/web/src/backends.d.ts +1 -1
  62. package/types/web/src/chat.d.ts +215 -4
  63. package/types/web/src/client.d.ts +28 -0
  64. package/types/web/src/gateways.d.ts +4 -3
  65. package/types/web/src/index.d.ts +4 -3
  66. package/types/web/src/purchases.d.ts +48 -5
  67. package/types/web/src/session.d.ts +11 -1
  68. package/types/web/src/voice.d.ts +36 -0
  69. package/dist/chunks/3ALGILOX.js +0 -2
  70. package/dist/chunks/AIIKXCWN.js +0 -2
  71. package/dist/chunks/ELEE7XO2.js +0 -18
  72. package/dist/chunks/G7E26S3Y.js +0 -13
  73. package/dist/chunks/H2EPK74V.js +0 -20
  74. package/dist/chunks/HEXIIGWS.js +0 -6
  75. package/dist/chunks/JS3TTUHS.js +0 -2
  76. package/dist/chunks/L3NTI4AZ.js +0 -2
  77. package/dist/chunks/LEBVOSG6.js +0 -4
  78. package/dist/chunks/OIA7KLRW.js +0 -2
@@ -59,6 +59,58 @@ export type AppleAccount = {
59
59
  status?: "active" | "refused";
60
60
  xcode_certificate?: XcodeCertificate;
61
61
  };
62
+ /**
63
+ * The environment's Google Play purchases.
64
+ */
65
+ export type GoogleAccount = {
66
+ /**
67
+ * What the person has to do next.
68
+ */
69
+ action?: string;
70
+ /**
71
+ * The registry's id of the Android app purchases are made in.
72
+ */
73
+ app_id?: string;
74
+ /**
75
+ * Google Play purchases are connected for one of the environment's Android apps.
76
+ */
77
+ connected: boolean;
78
+ connected_at?: string;
79
+ connected_by?: string;
80
+ /**
81
+ * Where Pub/Sub pushes the notifications for this environment.
82
+ */
83
+ notification_url?: string;
84
+ /**
85
+ * Its package name.
86
+ */
87
+ package_name?: string;
88
+ /**
89
+ * What Play last let the connection's account reach (the stores module's check).
90
+ */
91
+ play_status?: "invited" | "active" | "refused";
92
+ /**
93
+ * The project's Play connection's account (the stores module made it; its Play Console invites it): the account purchases are read and acknowledged as. Absent while the project has no Play connection.
94
+ */
95
+ service_account?: string;
96
+ /**
97
+ * The topic the app's Play Console names for real-time developer notifications (Monetize with Play › Monetization setup), in Palbase's Cloud project: Play's own account may publish to it. Every environment of the project selling in the app reads it.
98
+ */
99
+ topic?: string;
100
+ /**
101
+ * When a test notification arrived (Play Console's Send test notification): the topic is set.
102
+ */
103
+ verified_at?: string;
104
+ };
105
+ /**
106
+ * The Android app Google Play purchases are made in.
107
+ */
108
+ export type GoogleConnectRequest = {
109
+ /**
110
+ * One of the environment's Android apps (the registry's id).
111
+ */
112
+ app_id: string;
113
+ };
62
114
  /**
63
115
  * What names the customer to the App Store without saying who they are.
64
116
  */
@@ -68,6 +120,15 @@ export type AppleAccountToken = {
68
120
  */
69
121
  app_account_token: string;
70
122
  };
123
+ /**
124
+ * What names the customer to Google Play without saying who they are.
125
+ */
126
+ export type GoogleAccountID = {
127
+ /**
128
+ * The customer's, for the connected app: pass it to the billing flow (BillingFlowParams.Builder.setObfuscatedAccountId). Play's answers carry it back, and the purchase is the customer's before their app reports it.
129
+ */
130
+ obfuscated_account_id: string;
131
+ };
71
132
  /**
72
133
  * What the stores module answered of a plan's App Store part once it was confirmed: absent until it answers.
73
134
  */
@@ -124,6 +185,12 @@ export type AppleNotification = {
124
185
  signedPayload: string;
125
186
  [key: string]: unknown;
126
187
  };
188
+ /**
189
+ * Pub/Sub's push of a Play real-time developer notification, as Pub/Sub sends it: its message's data is the notification (DeveloperNotification, base64), its messageId the push's own.
190
+ */
191
+ export type GooglePush = {
192
+ [key: string]: unknown;
193
+ };
127
194
  /**
128
195
  * Where the App Store reports the app's purchases, and whether it does.
129
196
  */
@@ -205,6 +272,47 @@ export type AppleStepResult = {
205
272
  */
206
273
  store_id: string;
207
274
  };
275
+ /**
276
+ * What the stores module answered of a plan's Google Play part, once it wrote it (pending until then): Play's state, step by step.
277
+ */
278
+ export type GoogleCatalogResult = {
279
+ plan_id: string;
280
+ /**
281
+ * The app it was written for.
282
+ */
283
+ package_name: string;
284
+ /**
285
+ * The stores module has not answered yet.
286
+ */
287
+ pending?: boolean;
288
+ /**
289
+ * Every step was written.
290
+ */
291
+ ok: boolean;
292
+ /**
293
+ * Why it was not, in Play's words.
294
+ */
295
+ error?: string;
296
+ steps: GoogleStepResult[];
297
+ };
298
+ /**
299
+ * A step of the Google Play part as Play holds it now.
300
+ */
301
+ export type GoogleStepResult = {
302
+ op: string;
303
+ /**
304
+ * The product's id at Play.
305
+ */
306
+ store_id: string;
307
+ /**
308
+ * Its state at Play (a base plan's: ACTIVE, DRAFT; a one-time product's).
309
+ */
310
+ state?: string;
311
+ /**
312
+ * Why it was not written, in Play's words.
313
+ */
314
+ error?: string;
315
+ };
208
316
  /**
209
317
  * What StoreKit gave the customer's app.
210
318
  */
@@ -222,6 +330,36 @@ export type AppleTransactionReport = {
222
330
  */
223
331
  transactions: string[];
224
332
  };
333
+ /**
334
+ * What Play Billing gave the customer's app.
335
+ */
336
+ export type GooglePurchaseReport = {
337
+ /**
338
+ * The purchases: one just made (PurchasesUpdatedListener), or every one queryPurchasesAsync returns on a restore.
339
+ */
340
+ purchases: GoogleReported[];
341
+ /**
342
+ * The customer asked to restore their purchases: each moves to them from the customer that has it — never an account's by a guest's restore, and one purchase 3 times in 30 days at most; one that stays is answered (403, 409) once the rest is applied. Without it, a purchase another customer has stays theirs.
343
+ */
344
+ restore?: boolean;
345
+ };
346
+ /**
347
+ * A purchase Play Billing gave the app.
348
+ */
349
+ export type GoogleReported = {
350
+ /**
351
+ * Its product (Purchase.getProducts()).
352
+ */
353
+ product_id: string;
354
+ /**
355
+ * Its token (Purchase.getPurchaseToken()).
356
+ */
357
+ purchase_token: string;
358
+ /**
359
+ * It is a subscription's (ProductType.SUBS); a one-time product's otherwise.
360
+ */
361
+ subscription?: boolean;
362
+ };
225
363
  /**
226
364
  * What the Stripe account holds of the catalog once a plan was written, read back from Stripe; null maps when the plan failed before reading it.
227
365
  */
@@ -295,7 +433,7 @@ export type Catalog = {
295
433
  products: Product[];
296
434
  };
297
435
  /**
298
- * purchases.catalog.applied: a plan's Stripe part was written (applied) or failed; or the stores module answered of its App Store part.
436
+ * 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.
299
437
  */
300
438
  export type CatalogAppliedEvent = {
301
439
  /**
@@ -313,7 +451,7 @@ export type CatalogAppliedEvent = {
313
451
  /**
314
452
  * The store written.
315
453
  */
316
- store: "stripe" | "app_store";
454
+ store: "stripe" | "app_store" | "play_store";
317
455
  };
318
456
  /**
319
457
  * purchases.catalog.changed: a new revision of the catalog was saved; plans of older ones went stale.
@@ -417,6 +555,7 @@ export type CatalogPlan = {
417
555
  */
418
556
  error?: string;
419
557
  google: StorePlan;
558
+ google_result?: GoogleCatalogResult;
420
559
  /**
421
560
  * The plan's id.
422
561
  */
@@ -654,7 +793,7 @@ export type ChartDefinition = {
654
793
  window: boolean;
655
794
  };
656
795
  /**
657
- * What a chart is segmented or filtered by.
796
+ * What a chart is segmented or filtered by, with the values a filter can name in this project.
658
797
  */
659
798
  export type ChartDimension = {
660
799
  /**
@@ -665,6 +804,10 @@ export type ChartDimension = {
665
804
  * The dimension.
666
805
  */
667
806
  key: "store" | "platform" | "country" | "product" | "plan" | "duration" | "sandbox" | "paywall" | "experiment";
807
+ /**
808
+ * What a filter can name, each with what it is called: all of a closed dimension's values (store, platform, sandbox); the current catalog's products, plans and billing periods (with unmapped, one_time and unknown, what a chart gives what matches none); the project's paywalls and its experiments' variants (<experiment_id>:<variant>), with none. A country lists none: it is any ISO 3166-1 alpha-2 code, or unknown.
809
+ */
810
+ values?: ChartValue[];
668
811
  };
669
812
  /**
670
813
  * A value a dimension is filtered to.
@@ -846,6 +989,10 @@ export type Checkout = {
846
989
  * Where the customer pays.
847
990
  */
848
991
  url: string;
992
+ /**
993
+ * With the app's key alone: the key the success page asks the buyer's redemption link with (POST /purchases/stripe/checkout/redemption). Keep it in the page's own storage, never in a URL: whoever holds it and the session's id is shown the link.
994
+ */
995
+ redemption_key?: string;
849
996
  };
850
997
  /**
851
998
  * The error envelope of a refused checkout, with where the customer already has it when that is why (`already_entitled`): buying it again would charge twice for one thing.
@@ -881,7 +1028,7 @@ export type CheckoutConflictError = {
881
1028
  store?: "app_store" | "play_store" | "stripe";
882
1029
  };
883
1030
  /**
884
- * What the signed-in customer buys on the web.
1031
+ * What is bought on the web, and where it was opened.
885
1032
  */
886
1033
  export type CheckoutRequest = {
887
1034
  /**
@@ -897,9 +1044,10 @@ export type CheckoutRequest = {
897
1044
  */
898
1045
  product: string;
899
1046
  /**
900
- * Where Stripe sends the customer back once paid: a registered web app's origin, or a native app's own scheme.
1047
+ * Where Stripe sends the buyer back once paid: a registered web app's origin, or a native app's own scheme. Stripe replaces `{CHECKOUT_SESSION_ID}` in it with the session's id: the page asks the redemption link with it.
901
1048
  */
902
1049
  success_url: string;
1050
+ source?: CheckoutSource;
903
1051
  };
904
1052
  /**
905
1053
  * 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.
@@ -4490,6 +4638,14 @@ export type Settings = {
4490
4638
  * When the settings were last changed; absent while they are the defaults.
4491
4639
  */
4492
4640
  updated_at?: string | null;
4641
+ /**
4642
+ * What the App Store takes of a web purchase bought through a link out of an iOS app in its United States storefront (a checkout whose source is ios, USA), which the charts' proceeds take off: its share in basis points of the price net of tax (0 unless set: it takes nothing today, Guideline 3.1.1(a); a court is deciding what it may), up to 3000.
4643
+ */
4644
+ app_store_link_fee_bps: number;
4645
+ /**
4646
+ * For how many days after the link a purchase owes the App Store its fee (7 unless set), 1 to 90: a subscription's renewals past them owe none.
4647
+ */
4648
+ app_store_link_attribution_days: number;
4493
4649
  };
4494
4650
  /**
4495
4651
  * A change of the settings: the fields given change, the others stay.
@@ -4531,6 +4687,14 @@ export type SettingsUpdate = {
4531
4687
  * Where the quotas' calendar windows (a day, a month) begin: an IANA name such as Europe/Istanbul.
4532
4688
  */
4533
4689
  time_zone?: string;
4690
+ /**
4691
+ * What the App Store takes of a web purchase bought through a link out of an iOS app in its United States storefront (a checkout whose source is ios, USA), which the charts' proceeds take off: its share in basis points of the price net of tax (0 unless set: it takes nothing today, Guideline 3.1.1(a); a court is deciding what it may), up to 3000.
4692
+ */
4693
+ app_store_link_fee_bps?: number;
4694
+ /**
4695
+ * For how many days after the link a purchase owes the App Store its fee (7 unless set), 1 to 90: a subscription's renewals past them owe none.
4696
+ */
4697
+ app_store_link_attribution_days?: number;
4534
4698
  };
4535
4699
  /**
4536
4700
  * What a commit, an extension or a reversal takes; a release takes nothing.
@@ -4619,7 +4783,7 @@ export type SpendReceipt = {
4619
4783
  */
4620
4784
  export type SpendRequest = CreditSpendRequest | QuotaSpendRequest;
4621
4785
  /**
4622
- * purchases.store.changed: the project's Stripe account or In-App Purchase key was connected, disconnected, or (Stripe) checked and Stripe's answer changed (active, refused). Never the key.
4786
+ * purchases.store.changed: the project's Stripe account or In-App Purchase key or Google Play purchases were connected, disconnected, verified (a test notification arrived), or (Stripe) checked and Stripe's answer changed (active, refused). Never the key.
4623
4787
  */
4624
4788
  export type StoreChangedEvent = {
4625
4789
  /**
@@ -4633,15 +4797,19 @@ export type StoreChangedEvent = {
4633
4797
  /**
4634
4798
  * What happened.
4635
4799
  */
4636
- change: "connected" | "active" | "refused" | "disconnected";
4800
+ change: "connected" | "active" | "refused" | "disconnected" | "verified";
4637
4801
  /**
4638
4802
  * Whether the key is a live one (Stripe's, connected).
4639
4803
  */
4640
4804
  livemode?: boolean;
4805
+ /**
4806
+ * The Android app Google Play purchases are connected for (Play's).
4807
+ */
4808
+ package_name?: string;
4641
4809
  /**
4642
4810
  * The store.
4643
4811
  */
4644
- store: "stripe" | "app_store";
4812
+ store: "stripe" | "app_store" | "play_store";
4645
4813
  };
4646
4814
  /**
4647
4815
  * One store's part of a plan.
@@ -4693,7 +4861,7 @@ export type StripeAccount = {
4693
4861
  */
4694
4862
  connected_by?: string;
4695
4863
  /**
4696
- * The key's last characters, to tell it apart.
4864
+ * The key's last characters, to tell it apart (a key's connection).
4697
4865
  */
4698
4866
  key_hint?: string;
4699
4867
  /**
@@ -4712,6 +4880,10 @@ export type StripeAccount = {
4712
4880
  * Where Stripe reports changes on the account: the endpoint the module made there (POST /purchases/webhooks/stripe).
4713
4881
  */
4714
4882
  webhook_url?: string;
4883
+ /**
4884
+ * 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.
4885
+ */
4886
+ via?: "app" | "key";
4715
4887
  };
4716
4888
  /**
4717
4889
  * 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.
@@ -4979,10 +5151,148 @@ export type XcodeCertificateRequest = {
4979
5151
  */
4980
5152
  certificate: string;
4981
5153
  };
5154
+ /**
5155
+ * A value of a dimension, as a filter names it, and what it is called.
5156
+ */
5157
+ export type ChartValue = {
5158
+ /**
5159
+ * The value a filter names (filter=dimension:key).
5160
+ */
5161
+ key: string;
5162
+ /**
5163
+ * What it is called: a store's or a product's name, a paywall's, an experiment's and its variant's.
5164
+ */
5165
+ label: string;
5166
+ };
5167
+ /**
5168
+ * Where a checkout was opened: an app linking out to buy on the web says its platform and its store's storefront. Kept with the checkout as the record of the link.
5169
+ */
5170
+ export type CheckoutSource = {
5171
+ /**
5172
+ * The app's platform.
5173
+ */
5174
+ platform: "ios" | "android" | "web";
5175
+ /**
5176
+ * The store's storefront the app runs in, ISO 3166-1 alpha-3 (StoreKit's Storefront.countryCode: USA).
5177
+ */
5178
+ storefront?: string;
5179
+ };
5180
+ /**
5181
+ * A one-time link to redeem a purchase made on the web by a buyer without an account: opened on the phone with the app, it hands the app its token (`<scheme>://palbase/redeem?token=…`), and the app's user redeems it.
5182
+ */
5183
+ export type RedemptionLink = {
5184
+ /**
5185
+ * The link's page (/purchases/redeem?token=…).
5186
+ */
5187
+ url: string;
5188
+ /**
5189
+ * When it stops working; opened after, it sends a new one to the buyer's email. An emailed link's hour starts when it is sent.
5190
+ */
5191
+ expires_at: string;
5192
+ };
5193
+ /**
5194
+ * A redemption link to redeem.
5195
+ */
5196
+ export type RedeemRequest = {
5197
+ /**
5198
+ * The link's token: what the app was handed (`token` of `<scheme>://palbase/redeem?token=…`).
5199
+ */
5200
+ token: string;
5201
+ };
5202
+ /**
5203
+ * The error envelope of an expired redemption link: `resent` says a new one went to the address the buyer gave at checkout.
5204
+ */
5205
+ export type RedemptionExpiredError = {
5206
+ /**
5207
+ * Machine-readable error code (snake_case)
5208
+ */
5209
+ error: string;
5210
+ /**
5211
+ * Human-readable explanation
5212
+ */
5213
+ error_description: string;
5214
+ /**
5215
+ * Correlation ID for log/audit lookup
5216
+ */
5217
+ request_id: string;
5218
+ /**
5219
+ * A new link was sent to the buyer's email: with `redemption_expired`.
5220
+ */
5221
+ resent?: boolean;
5222
+ /**
5223
+ * Seconds to wait before retrying; present on a refusal that ends with time.
5224
+ */
5225
+ retry_after?: number;
5226
+ /**
5227
+ * HTTP status code (mirrors the response status)
5228
+ */
5229
+ status: number;
5230
+ };
5231
+ /**
5232
+ * A checkout's redemption link to show: the checkout's session, and the key its opener was given — the project's secret key asks with none.
5233
+ */
5234
+ export type RedemptionRequest = {
5235
+ /**
5236
+ * The Checkout session's id (Stripe's `{CHECKOUT_SESSION_ID}`).
5237
+ */
5238
+ session_id: string;
5239
+ /**
5240
+ * The checkout's `redemption_key`.
5241
+ */
5242
+ key?: string;
5243
+ };
5244
+ /**
5245
+ * A link to install Palbase's Stripe App, in a mode.
5246
+ */
5247
+ export type StripeAppGrantRequest = {
5248
+ /**
5249
+ * Live mode, or Stripe's test mode (false).
5250
+ */
5251
+ livemode: boolean;
5252
+ };
5253
+ /**
5254
+ * A one-time link to install Palbase's Stripe App for the project.
5255
+ */
5256
+ export type StripeAppInstall = {
5257
+ /**
5258
+ * 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.
5259
+ */
5260
+ install_url: string;
5261
+ /**
5262
+ * When the link stops working (30 minutes; for an environment's token, no later than the token).
5263
+ */
5264
+ expires_at: string;
5265
+ };
5266
+ /**
5267
+ * An install started with its link's grant.
5268
+ */
5269
+ export type StripeAppStartRequest = {
5270
+ /**
5271
+ * The link's grant: `<project id>.<token>`, from its fragment.
5272
+ */
5273
+ grant: string;
5274
+ };
5275
+ /**
5276
+ * An install started: the project the account will be connected to, and Stripe's page to go on to.
5277
+ */
5278
+ export type StripeAppStart = {
5279
+ /**
5280
+ * The Palbase project's name.
5281
+ */
5282
+ project: string;
5283
+ /**
5284
+ * Live mode, or Stripe's test mode.
5285
+ */
5286
+ livemode: boolean;
5287
+ /**
5288
+ * Stripe's install page: its state is the install's nonce, which the browser keeps.
5289
+ */
5290
+ authorize_url: string;
5291
+ };
4982
5292
  /** The events this module sends the project's webhooks (x-palbase-events), by type: each one's payload, the event's data. */
4983
5293
  export interface Events {
4984
5294
  /**
4985
- * purchases.catalog.applied: a plan's Stripe part was written (applied) or failed; or the stores module answered of its App Store part.
5295
+ * 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.
4986
5296
  */
4987
5297
  "purchases.catalog.applied": CatalogAppliedEvent;
4988
5298
  /**
@@ -5038,7 +5348,7 @@ export interface Events {
5038
5348
  */
5039
5349
  "purchases.refund.changed": RefundChangedEvent;
5040
5350
  /**
5041
- * purchases.store.changed: the project's Stripe account or In-App Purchase key was connected, disconnected, or (Stripe) checked and Stripe's answer changed (active, refused). Never the key.
5351
+ * purchases.store.changed: the project's Stripe account or In-App Purchase key or Google Play purchases were connected, disconnected, verified (a test notification arrived), or (Stripe) checked and Stripe's answer changed (active, refused). Never the key.
5042
5352
  */
5043
5353
  "purchases.store.changed": StoreChangedEvent;
5044
5354
  /**
@@ -5120,6 +5430,23 @@ export declare function client(t: Transport): {
5120
5430
  body: AppleTransactionReport; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
5121
5431
  signal?: AbortSignal;
5122
5432
  }): Promise<Reply<200, CustomerInfo>>;
5433
+ /**
5434
+ * Get the customer's obfuscated account id
5435
+ *
5436
+ * The signed-in customer's obfuscated account id for the connected app — a guest's too: random, made the first time it is asked for, the same afterwards. The app passes it to Play Billing's billing flow; Play's answers carry it back, so a purchase is the customer's before the app reports it, and nothing personal goes to Google. A guest's goes with it when it merges into an account.
5437
+ */
5438
+ getGoogleAccountId(input?: {
5439
+ signal?: AbortSignal;
5440
+ }): Promise<Reply<200, GoogleAccountID>>;
5441
+ /**
5442
+ * Report Play Billing's purchases
5443
+ *
5444
+ * The signed-in customer's app — a guest's too: a guest buys in the app — reports the purchases Play Billing gave it: one just made, or on a restore every one queryPurchasesAsync returns. Nothing of the device's word is taken: each is read from Play by its token, as the project's Play connection account, and applied to the ledger. Whose a purchase is: one nobody has becomes the customer's its obfuscated account id names, or the reporter's; one another customer has stays theirs — unless `restore`, which moves it to the reporter (an account's is never taken by a guest's restore, and one purchase moves 3 times in 30 days at most); one that stays is answered once the rest is applied (403 `restore_account_owned`, 409 `restore_limit`). A purchase the catalog maps is acknowledged — a consumable's consumed — once the ledger has it (Play refunds one not acknowledged in three days); one it does not map gives nothing and is not acknowledged.
5445
+ */
5446
+ reportGooglePurchases(input: {
5447
+ body: GooglePurchaseReport; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
5448
+ signal?: AbortSignal;
5449
+ }): Promise<Reply<200, CustomerInfo>>;
5123
5450
  /**
5124
5451
  * Take Xcode's StoreKit Testing purchases
5125
5452
  *
@@ -5143,6 +5470,37 @@ export declare function client(t: Transport): {
5143
5470
  }; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
5144
5471
  signal?: AbortSignal;
5145
5472
  }): Promise<Reply<204, undefined>>;
5473
+ /**
5474
+ * Read the Google Play purchases
5475
+ *
5476
+ * The environment's Google Play purchases: the project's Play connection (the stores module's; its account reads and acknowledges purchases), the Android app they are made in, the topic its Play Console names, and whether a test notification proved it — with what to do next.
5477
+ */
5478
+ getGoogleAccount(input?: {
5479
+ signal?: AbortSignal;
5480
+ }): Promise<Reply<200, GoogleAccount>>;
5481
+ /**
5482
+ * Connect Google Play purchases
5483
+ *
5484
+ * Sells in one of the environment's Android apps on Google Play: the app's topic is made in Palbase's Cloud project (Play's own account may publish to it; every environment of the project selling in the app shares it) and this environment's push subscription of it, to its own address, signed. The project's Play connection must exist (the stores module's: palbase stores:google:connect). Connected again for the same app, nothing changes. Then, in Play Console: Monetize with Play › Monetization setup, the topic, Send test notification. Emits `purchases.store.changed` (connected).
5485
+ */
5486
+ connectGoogle(input: {
5487
+ headers?: {
5488
+ "Idempotency-Key"?: string;
5489
+ };
5490
+ body: GoogleConnectRequest; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
5491
+ signal?: AbortSignal;
5492
+ }): Promise<Reply<200, GoogleAccount> | Reply<201, GoogleAccount>>;
5493
+ /**
5494
+ * Disconnect Google Play purchases
5495
+ *
5496
+ * Deletes this environment's push subscription and forgets the app: Play's notifications stop reaching it, and the apps' reports are refused. Purchases already made stay in the ledger. The app's topic stays (another environment of the project may read it). Emits `purchases.store.changed` (disconnected).
5497
+ */
5498
+ disconnectGoogle(input?: {
5499
+ headers?: {
5500
+ "Idempotency-Key"?: string;
5501
+ }; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
5502
+ signal?: AbortSignal;
5503
+ }): Promise<Reply<204, undefined>>;
5146
5504
  /**
5147
5505
  * Read the catalog
5148
5506
  *
@@ -5238,7 +5596,7 @@ export declare function client(t: Transport): {
5238
5596
  /**
5239
5597
  * Read the charts' overview
5240
5598
  *
5241
- * The project's figures at a glance: MRR, active subscriptions and active trials now; revenue (of revenue_type), new customers and active customers over the last 28 days, today included — each as its chart counts it. Money is in the reporting currency (or currency); an amount in a currency the European Central Bank does not publish is left out and named (unconverted). A replica computes two charts (the overview among them) at once and one of a project; another is refused at once as busy (503 `charts_busy`, Retry-After), and so is one that takes longer than 15 seconds. The same request within a minute is answered from the replica's cache (a change of the project's settings drops it there). A replica computes 3 charts of a project in a row, then one each 10 seconds (6 a minute); past that a chart is refused (429 `too_many_charts`, Retry-After) — an answer from the cache is not counted.
5599
+ * The project's figures at a glance: MRR, active subscriptions and active trials now; revenue (of revenue_type), new customers and active customers over the last 28 days, today included — each as its chart counts it. Money is in the reporting currency (or currency); an amount in a currency the European Central Bank does not publish is left out and named (unconverted). A replica computes two charts (the overview among them) at once and one of a project; another is refused at once as busy (503 `charts_busy`, Retry-After), and so is one that takes longer than 15 seconds. The same request within a minute is answered from the replica's cache (a change of the project's settings drops it there). A replica computes 20 charts of a project in a row, then one each 2 seconds (30 a minute); past that a chart is refused (429 `too_many_charts`, Retry-After) — an answer from the cache is not counted.
5242
5600
  */
5243
5601
  getChartsOverview(input?: {
5244
5602
  query?: {
@@ -5251,7 +5609,7 @@ export declare function client(t: Transport): {
5251
5609
  /**
5252
5610
  * Read a chart
5253
5611
  *
5254
- * One chart of the project's ledger, period by period (GET /purchases/charts says what each counts). Periods are UTC days, ISO weeks (Monday to Sunday) or calendar months, the first and the last cut to `from` and `to` (both included, at most two years apart; `to` later than today is today). A flow counts what happened in the period, a snapshot is the state at its end (now, for the period now is in), a ratio divides its measures, a cohort follows what began in the period over its ages. The ledger is read whole each time: a refund arriving later, a renewal, a product change, a guest merged into an account and a change of the settings are in the next answer. Money is converted to the reporting currency (or `currency`) at the European Central Bank's reference rate of the day it was paid; what is in a currency it does not publish is left out and named (`unconverted`). A store's test purchases count only with sandbox=true. `segment` splits a segmentable chart by a dimension: the 20 largest values each a segment, the rest together in one keyed `(other)` (the segments' sum is the whole; a subscription changing segment is churned in one and moved in to the other); `filter` (repeated, one dimension:value each) keeps what has one of the values given for each dimension named. The paywall and experiment dimensions attribute a subscription whose first purchase is in the days asked for (by the exposures of those days and the 7 before); an older one is `none`. A cohort chart follows at most 120 cohorts (by day, 120 days). Answered as CSV when the request accepts text/csv first: a row a segment and period (and age, for a cohort), its value, its measures. The ledger is read customer by customer, never held whole. A customer holding more than 20,000 transactions is refused (422 `chart_too_large`). The same request within a minute is answered from the replica's cache (a change of the project's settings drops it there). A replica computes two charts at once and one of a project; another is refused at once as busy (503 `charts_busy`, Retry-After), and so is one whose reading and computing take longer than 15 seconds. A replica computes 3 charts of a project in a row, then one each 10 seconds (6 a minute); past that a chart is refused (429 `too_many_charts`, Retry-After) — an answer from the cache is not counted.
5612
+ * One chart of the project's ledger, period by period (GET /purchases/charts says what each counts). Periods are UTC days, ISO weeks (Monday to Sunday) or calendar months, the first and the last cut to `from` and `to` (both included, at most two years apart; `to` later than today is today). A flow counts what happened in the period, a snapshot is the state at its end (now, for the period now is in), a ratio divides its measures, a cohort follows what began in the period over its ages. The ledger is read whole each time: a refund arriving later, a renewal, a product change, a guest merged into an account and a change of the settings are in the next answer. Money is converted to the reporting currency (or `currency`) at the European Central Bank's reference rate of the day it was paid; what is in a currency it does not publish is left out and named (`unconverted`). A store's test purchases count only with sandbox=true. `segment` splits a segmentable chart by a dimension: the 20 largest values each a segment, the rest together in one keyed `(other)` (the segments' sum is the whole; a subscription changing segment is churned in one and moved in to the other); `filter` (repeated, one dimension:value each) keeps what has one of the values given for each dimension named. The paywall and experiment dimensions attribute each subscription once, when its first purchase is recorded: to the paywall (and the experiment's variant) its owner — or a guest merged into the owner — saw first within the 7 days before that purchase, as the experiments' results count it; one that followed none is `none`, its renewals in any later days included. A cohort chart follows at most 120 cohorts (by day, 120 days). Answered as CSV when the request accepts text/csv first: a row a segment and period (and age, for a cohort), its value, its measures. The ledger is read customer by customer, never held whole. A customer holding more than 20,000 transactions is refused (422 `chart_too_large`). The same request within a minute is answered from the replica's cache (a change of the project's settings drops it there). A replica computes two charts at once and one of a project; another is refused at once as busy (503 `charts_busy`, Retry-After), and so is one whose reading and computing take longer than 15 seconds. A replica computes 20 charts of a project in a row, then one each 2 seconds (30 a minute); past that a chart is refused (429 `too_many_charts`, Retry-After) — an answer from the cache is not counted.
5255
5613
  */
5256
5614
  getChart(input: {
5257
5615
  path: {
@@ -5288,6 +5646,38 @@ export declare function client(t: Transport): {
5288
5646
  body: ConnectStripeKeyRequest; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
5289
5647
  signal?: AbortSignal;
5290
5648
  }): Promise<Reply<200, StripeAccount>>;
5649
+ /**
5650
+ * The Stripe App's install page
5651
+ *
5652
+ * 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.
5653
+ */
5654
+ getStripeAppInstallPage(input?: {
5655
+ signal?: AbortSignal;
5656
+ }): Promise<Reply<200, Response>>;
5657
+ /**
5658
+ * Start a Stripe App install
5659
+ *
5660
+ * Starts an install with its link's grant, once: the grant is traded for the install's nonce, kept in the browser (an HttpOnly cookie of Palbase's address) and carried by Stripe (the state) — the way back is taken only in this browser, and the grant never reaches Stripe. Answers the project's name and Stripe's install page. A grant of no project, used, expired or started already: 410 `grant_invalid`, the same answer for each.
5661
+ */
5662
+ startStripeAppInstall(input: {
5663
+ body: StripeAppStartRequest; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
5664
+ signal?: AbortSignal;
5665
+ }): Promise<Reply<200, StripeAppStart>>;
5666
+ /**
5667
+ * The Stripe App's return
5668
+ *
5669
+ * 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 only in the browser that started the install — its cookie is the nonce —, where the grant, tried once more, 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`) spends its grant; an account already connected through the App to another project is refused. Answers a page the installer reads. No credential: the grant and the browser's nonce are the authorization.
5670
+ */
5671
+ completeStripeAppInstall(input?: {
5672
+ query?: {
5673
+ code?: string; /** The link's state: the project and its grant. */
5674
+ state?: string; /** What the App may do, as Stripe granted it. */
5675
+ scope?: string; /** Stripe's error, when the installer did not finish. */
5676
+ error?: string; /** And its words. */
5677
+ error_description?: string;
5678
+ }; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
5679
+ signal?: AbortSignal;
5680
+ }): Promise<Reply<200, Response>>;
5291
5681
  /**
5292
5682
  * Read a customer
5293
5683
  *
@@ -6001,12 +6391,41 @@ export declare function client(t: Transport): {
6001
6391
  /**
6002
6392
  * Buy on the web
6003
6393
  *
6004
- * Opens a Stripe Checkout session for the signed-in customer to buy one of the catalog's products sold on the web, at the plan's price on the project's Stripe account: send the customer to `url`. Stripe sends them back to `success_url` or `cancel_url`, which go back to one of the project's registered apps — a web app's origin, or a native app's own scheme — and nowhere else. What is bought on the web is the account's on every device: a guest is refused. A customer who already has the product, or a subscription of its group, from any store is refused (409 `already_entitled`, naming the store to manage it in): nothing is charged twice. Credits can always be bought again. A free trial is given once per customer, across every channel. The purchase is the customer's once Stripe reports it (POST /purchases/webhooks/stripe).
6394
+ * Opens a Stripe Checkout session to buy one of the catalog's products sold on the web, at the plan's price on the project's Stripe account: send the buyer to `url`. Stripe sends them back to `success_url` or `cancel_url`, which go back to one of the project's registered apps — a web app's origin, or a native app's own scheme — and nowhere else. With a customer's session — a guest's as well: what a guest buys is theirs, and goes with them to the account they sign in to — the purchase is that customer's; a customer who already has the product, or a subscription of its group, from any store is refused (409 `already_entitled`, naming the store to manage it in): nothing is charged twice. Credits can always be bought again. A free trial is given once per customer, across every channel, and not to a guest: a new one is free to make. With the app's key alone (no session) the buyer is no one yet: Checkout asks their email, no free trial is given, and what they buy waits for the app user who redeems it — its link is shown on the success page to the holder of `redemption_key` (POST /purchases/stripe/checkout/redemption) and sent to that email. Checkouts are limited per address and per project with the app's key alone, per customer and per address with a session (429 `too_many_checkouts`). `source` records where the checkout was opened: an app linking out to buy on the web (the App Store's United States storefront allows it, Guideline 3.1.1(a)) says its platform and storefront, and the charts take the App Store's link fee (settings) off what it brings. The checkout is kept as the record of it. The purchase is applied once Stripe reports it (POST /purchases/webhooks/stripe).
6005
6395
  */
6006
6396
  createCheckout(input: {
6007
6397
  body: CheckoutRequest; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
6008
6398
  signal?: AbortSignal;
6009
6399
  }): Promise<Reply<201, Checkout>>;
6400
+ /**
6401
+ * A web purchase's redemption link
6402
+ *
6403
+ * The link a checkout's success page shows its buyer, who has no account (a checkout opened with the app's key alone): to the holder of the key the checkout's opener was given (`redemption_key`), a new one each time asked, ten at most, within an hour of the payment — past it the link is the email's alone. A session Stripe has not reported yet is read from Stripe. The project's secret key — its support, for a buyer whose email went astray — is shown one at any time, with no key. Limited per address and per project with the app's key alone, per customer and per address with a session. Closed to an environment's token (403 `token_out_of_scope`): the link hands a purchase to whoever opens it.
6404
+ */
6405
+ createCheckoutRedemption(input: {
6406
+ body: RedemptionRequest; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
6407
+ signal?: AbortSignal;
6408
+ }): Promise<Reply<201, RedemptionLink>>;
6409
+ /**
6410
+ * Redeem a web purchase
6411
+ *
6412
+ * Redeems a link to a purchase made on the web by a buyer without an account: the purchase becomes the session's customer's — a guest's goes with them to the account they sign in to, as all a guest has. A link works once, for an hour; once one of a purchase's links is redeemed, all of them are spent. An expired link sends a new one to the address the buyer gave at checkout (410 `redemption_expired`, `resent`), once. Limited per customer and per address. Answers what the customer has now.
6413
+ */
6414
+ redeemPurchase(input: {
6415
+ body: RedeemRequest; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
6416
+ signal?: AbortSignal;
6417
+ }): Promise<Reply<200, CustomerInfo>>;
6418
+ /**
6419
+ * The redemption page
6420
+ *
6421
+ * The page a redemption link opens: a button per app of the project's that hands the app the link (`<scheme>://palbase/redeem?token=…`), and the link as a QR code to scan with the phone when it is opened elsewhere. It reads nothing of the link: the app redeems it (POST /purchases/redemptions/redeem). No credential: the link is the authorization; its token is a query's, which no request log keeps.
6422
+ */
6423
+ getRedemptionPage(input: {
6424
+ query: {
6425
+ token: string;
6426
+ }; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
6427
+ signal?: AbortSignal;
6428
+ }): Promise<Reply<200, Response>>;
6010
6429
  /**
6011
6430
  * Grant a key's connection
6012
6431
  *
@@ -6018,6 +6437,18 @@ export declare function client(t: Transport): {
6018
6437
  }; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
6019
6438
  signal?: AbortSignal;
6020
6439
  }): Promise<Reply<201, StripeGrant>>;
6440
+ /**
6441
+ * Install the Stripe App
6442
+ *
6443
+ * 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`.
6444
+ */
6445
+ createStripeAppInstall(input: {
6446
+ headers?: {
6447
+ "Idempotency-Key"?: string;
6448
+ };
6449
+ body: StripeAppGrantRequest; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
6450
+ signal?: AbortSignal;
6451
+ }): Promise<Reply<201, StripeAppInstall>>;
6021
6452
  /**
6022
6453
  * Manage what was bought on the web
6023
6454
  *
@@ -6036,6 +6467,15 @@ export declare function client(t: Transport): {
6036
6467
  body: AppleNotification; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
6037
6468
  signal?: AbortSignal;
6038
6469
  }): Promise<Reply<200, undefined>>;
6470
+ /**
6471
+ * Receive a Google Play notification
6472
+ *
6473
+ * Where Pub/Sub pushes the connected app's real-time developer notifications — no key: the push carries an OIDC token Google minted for Palbase's push account, for this environment's own address, and anything else is refused. A notification only says something changed: what it is, is read from Play by its token as the project's Play connection account and applied to the ledger; a voided purchase's, by reading the app's voided purchases. Each push is kept once, sealed, by its message id: one pushed again is answered and not applied twice. A test notification proves the topic (`verified_at`). Another app's notification is taken and ignored. Pub/Sub hears 204 once that is written; a 503 (Google unreachable), and it pushes it again.
6474
+ */
6475
+ receiveGoogleNotification(input: {
6476
+ body: GooglePush; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
6477
+ signal?: AbortSignal;
6478
+ }): Promise<Reply<204, undefined>>;
6039
6479
  /**
6040
6480
  * Take Stripe's notification
6041
6481
  *
@@ -6048,5 +6488,17 @@ export declare function client(t: Transport): {
6048
6488
  body: StripeEvent; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
6049
6489
  signal?: AbortSignal;
6050
6490
  }): Promise<Reply<200, undefined>>;
6491
+ /**
6492
+ * Receive the Stripe App's events
6493
+ *
6494
+ * 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.
6495
+ */
6496
+ receiveStripeAppEvent(input: {
6497
+ headers: {
6498
+ "Stripe-Signature": string;
6499
+ };
6500
+ body: StripeEvent; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
6501
+ signal?: AbortSignal;
6502
+ }): Promise<Reply<200, undefined>>;
6051
6503
  };
6052
6504
  export type Client = ReturnType<typeof client>;