@vxil/sdk 0.37.0 → 0.37.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.
package/dist/index.d.ts CHANGED
@@ -912,6 +912,20 @@ export type JobSchedulePatch = Partial<Omit<JobScheduleInput, 'external_id' | 'm
912
912
  external_id?: string | null;
913
913
  max_attempts?: number | null;
914
914
  };
915
+ /** One listed session of `vx.auth.sessions.list` (`GET /v1/auth/sessions`). */
916
+ export interface VxilAuthSessionInfo {
917
+ session_id: string;
918
+ created_at: string;
919
+ /** when the ACCESS token expires */
920
+ expires_at: string;
921
+ user_agent: string | null;
922
+ /** `active` while the access token is valid; `idle` when only the refresh
923
+ * token is (the device has not refreshed yet). */
924
+ state: 'active' | 'idle';
925
+ /** when the refresh token stops working (created_at + session.refreshTtlDays);
926
+ * null for a canary session, which never refreshes. */
927
+ refresh_expires_at: string | null;
928
+ }
915
929
  export interface AuthSession {
916
930
  token: string;
917
931
  refresh_token: string;
@@ -1010,6 +1024,12 @@ export interface PaymentsSyncOutcome {
1010
1024
  tier: string | null;
1011
1025
  until: string | null;
1012
1026
  }>;
1027
+ /** RevenueCat only, present only when non-empty: products the sync
1028
+ * deliberately did not fold, `<id>: <why>` (`<id>: not_restored` on an
1029
+ * end-user restore) — an ended product matching no store purchase, a
1030
+ * purchase the store ended inside the same period, a product whose own
1031
+ * row belongs to another store. Not errors: nothing was written. */
1032
+ not_folded?: string[];
1013
1033
  dry_run?: boolean;
1014
1034
  }
1015
1035
  /** A lifecycle simulation run (guide ch. 6, payments; mock/dev tenants only). */
@@ -4976,13 +4996,14 @@ export declare class Vxil<S extends VxilSchemaShape = VxilSchemaShape> {
4976
4996
  revokeById: (sessionId: string) => Promise<void>;
4977
4997
  /** List a user's active sessions (the account "signed-in devices" surface).
4978
4998
  * Scope `auth:read`. In end-user mode the list is bound to the signed-in
4979
- * user regardless of `userId` (the verified principal wins). */
4980
- list: (userId: string) => Promise<Array<{
4981
- session_id: string;
4982
- created_at: string;
4983
- expires_at: string;
4984
- user_agent: string | null;
4985
- }>>;
4999
+ * user regardless of `userId` (the verified principal wins). Each
5000
+ * session says `state` — `active` while its access token is valid,
5001
+ * `idle` when only its refresh token is — and `refresh_expires_at`
5002
+ * (null for a canary session, which never refreshes). Today only
5003
+ * `active` sessions are listed; idle devices are listed (and counted by
5004
+ * `session.maxConcurrent`) from the release the changelog's Coming next
5005
+ * names. */
5006
+ list: (userId: string) => Promise<Array<VxilAuthSessionInfo>>;
4986
5007
  };
4987
5008
  password: {
4988
5009
  /** Always resolves (anti-enumeration). `captcha_token` is required only
@@ -7883,8 +7904,9 @@ export declare class Vxil<S extends VxilSchemaShape = VxilSchemaShape> {
7883
7904
  * subscription — use `cancel`; a production store row ends when the store
7884
7905
  * cancels or refunds it). Never touches a provider; a revoked RevenueCat
7885
7906
  * row is never revived by a later sandbox delivery or restore (a real
7886
- * production purchase still entitles the user). Credits the row
7887
- * already granted stay. */
7907
+ * production purchase still entitles the user). Revoke the user's
7908
+ * restored (`<app user id>:<product>`) row too if they have one: it is a
7909
+ * separate row. Credits the row already granted stay. */
7888
7910
  revokeSubscription: (subscriptionId: string) => Promise<{
7889
7911
  subscription_id: string;
7890
7912
  status: string;
@@ -7892,10 +7914,21 @@ export declare class Vxil<S extends VxilSchemaShape = VxilSchemaShape> {
7892
7914
  revoked_at: string | null;
7893
7915
  }>;
7894
7916
  /** SERVER-ONLY. Re-read a customer's subscriptions FROM the provider and
7895
- * fold them through the same conditional upsert a webhook uses (never a
7896
- * second write path). `dry_run` diffs without writing. Capped 30/min per
7897
- * project (429 rate_limited). The migration backfill (`vxil migrate
7898
- * payments --from-provider …`) drives this per customer. */
7917
+ * fold them through the same conditional upsert a webhook uses (a stale
7918
+ * snapshot never moves a newer row). `dry_run` diffs without writing.
7919
+ * Capped 30/min per project (429 rate_limited). The migration backfill
7920
+ * (`vxil migrate payments --from-provider …`) drives this per customer.
7921
+ *
7922
+ * RevenueCat: the subscriber read has no original transaction id, so a
7923
+ * snapshot is matched to the webhook row of the SAME store purchase — an
7924
+ * ended product only by its exact store transaction (else it is listed in
7925
+ * `not_folded` and nothing is written); a live one also by a live row of the
7926
+ * same store, environment and current product. With no match a live
7927
+ * product gets its own row (`<app user id>:<product>`) that ends at its
7928
+ * own period end and that the purchase's first webhook takes over. Emits
7929
+ * `payments.subscription.<status>` (`event_type: 'subscription.synced'`)
7930
+ * for each row it changes and `payments.entitlement.changed` (`reason:
7931
+ * 'subscription.synced'`) when access changed. */
7899
7932
  syncSubscriptions: (input: {
7900
7933
  user_id?: string;
7901
7934
  customer_ref?: string;
@@ -7905,7 +7938,10 @@ export declare class Vxil<S extends VxilSchemaShape = VxilSchemaShape> {
7905
7938
  /** The server leg of "Restore Purchases": in end-user mode the verified
7906
7939
  * principal's OWN provider state is re-read (no user id needed); in server
7907
7940
  * mode pass `user_id`. 3 per hour per user (429). Returns the sync outcome
7908
- * plus the fresh entitlement view in one answer. */
7941
+ * plus the fresh entitlement view in one answer. The same matching and
7942
+ * events as `syncSubscriptions`, with `event_type` / `reason`
7943
+ * `'subscription.restored'`; in end-user mode an unmatched ended product
7944
+ * is listed in `not_folded` as `<id>: not_restored`. */
7909
7945
  restoreSubscriptions: (input?: {
7910
7946
  user_id?: string;
7911
7947
  provider?: "mock" | "stripe" | "paddle" | "revenuecat" | "paypal";
package/dist/index.js CHANGED
@@ -1520,7 +1520,13 @@ export class Vxil {
1520
1520
  },
1521
1521
  /** List a user's active sessions (the account "signed-in devices" surface).
1522
1522
  * Scope `auth:read`. In end-user mode the list is bound to the signed-in
1523
- * user regardless of `userId` (the verified principal wins). */
1523
+ * user regardless of `userId` (the verified principal wins). Each
1524
+ * session says `state` — `active` while its access token is valid,
1525
+ * `idle` when only its refresh token is — and `refresh_expires_at`
1526
+ * (null for a canary session, which never refreshes). Today only
1527
+ * `active` sessions are listed; idle devices are listed (and counted by
1528
+ * `session.maxConcurrent`) from the release the changelog's Coming next
1529
+ * names. */
1524
1530
  list: async (userId) => (await this.call('GET', `/v1/auth/sessions?user_id=${encodeURIComponent(userId)}`)).data.sessions,
1525
1531
  },
1526
1532
  password: {
@@ -3152,19 +3158,34 @@ export class Vxil {
3152
3158
  * subscription — use `cancel`; a production store row ends when the store
3153
3159
  * cancels or refunds it). Never touches a provider; a revoked RevenueCat
3154
3160
  * row is never revived by a later sandbox delivery or restore (a real
3155
- * production purchase still entitles the user). Credits the row
3156
- * already granted stay. */
3161
+ * production purchase still entitles the user). Revoke the user's
3162
+ * restored (`<app user id>:<product>`) row too if they have one: it is a
3163
+ * separate row. Credits the row already granted stay. */
3157
3164
  revokeSubscription: async (subscriptionId) => (await this.call('POST', `/v1/payments/subscriptions/${encodeURIComponent(subscriptionId)}/revoke`)).data,
3158
3165
  /** SERVER-ONLY. Re-read a customer's subscriptions FROM the provider and
3159
- * fold them through the same conditional upsert a webhook uses (never a
3160
- * second write path). `dry_run` diffs without writing. Capped 30/min per
3161
- * project (429 rate_limited). The migration backfill (`vxil migrate
3162
- * payments --from-provider …`) drives this per customer. */
3166
+ * fold them through the same conditional upsert a webhook uses (a stale
3167
+ * snapshot never moves a newer row). `dry_run` diffs without writing.
3168
+ * Capped 30/min per project (429 rate_limited). The migration backfill
3169
+ * (`vxil migrate payments --from-provider …`) drives this per customer.
3170
+ *
3171
+ * RevenueCat: the subscriber read has no original transaction id, so a
3172
+ * snapshot is matched to the webhook row of the SAME store purchase — an
3173
+ * ended product only by its exact store transaction (else it is listed in
3174
+ * `not_folded` and nothing is written); a live one also by a live row of the
3175
+ * same store, environment and current product. With no match a live
3176
+ * product gets its own row (`<app user id>:<product>`) that ends at its
3177
+ * own period end and that the purchase's first webhook takes over. Emits
3178
+ * `payments.subscription.<status>` (`event_type: 'subscription.synced'`)
3179
+ * for each row it changes and `payments.entitlement.changed` (`reason:
3180
+ * 'subscription.synced'`) when access changed. */
3163
3181
  syncSubscriptions: async (input) => (await this.call('POST', '/v1/payments/subscriptions/sync', input)).data,
3164
3182
  /** The server leg of "Restore Purchases": in end-user mode the verified
3165
3183
  * principal's OWN provider state is re-read (no user id needed); in server
3166
3184
  * mode pass `user_id`. 3 per hour per user (429). Returns the sync outcome
3167
- * plus the fresh entitlement view in one answer. */
3185
+ * plus the fresh entitlement view in one answer. The same matching and
3186
+ * events as `syncSubscriptions`, with `event_type` / `reason`
3187
+ * `'subscription.restored'`; in end-user mode an unmatched ended product
3188
+ * is listed in `not_folded` as `<id>: not_restored`. */
3168
3189
  restoreSubscriptions: async (input) => (await this.call('POST', '/v1/payments/subscriptions/restore', input ?? {})).data,
3169
3190
  /** SERVER-ONLY. Account merge: move EVERY provider's subscriptions,
3170
3191
  * customer links and available credit balances of `from_user_id` onto
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vxil/sdk",
3
- "version": "0.37.0",
3
+ "version": "0.37.1",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Typed client for the Vxil REST API (notifications, auth, jobs, files, cms, comments, webhooks, realtime, orgs, rate-limits).",