@vxil/sdk 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.
package/dist/index.d.ts CHANGED
@@ -562,6 +562,30 @@ export interface PaymentsCharge {
562
562
  status: string;
563
563
  created_at: string;
564
564
  }
565
+ /** A subscription row as listed by GET /v1/payments/subscriptions (payments.md
566
+ * §3) — provider subscriptions, manual grants and purchase passes alike.
567
+ * `current_period_start` (2026-09-25) is the row's own window start: for a
568
+ * purchase pass (`provider_sub_id: 'purchase:<charge_id>'`) the day its access
569
+ * begins, which is in the FUTURE for a pass queued behind a live one; for a
570
+ * manual grant the time the grant was written. A `type` with an index
571
+ * signature (not an interface), so code that typed these rows as
572
+ * `Record<string, unknown>` keeps compiling. */
573
+ export type PaymentsSubscription = {
574
+ subscription_id: string;
575
+ end_user_id: string;
576
+ /** 'manual' for a support grant or a purchase pass; else the provider */
577
+ provider: string;
578
+ provider_sub_id: string;
579
+ tier: string | null;
580
+ /** trialing | active | past_due | cancelled | expired | lapsed */
581
+ status: string;
582
+ current_period_start: string | null;
583
+ current_period_end: string | null;
584
+ /** the vxil charge (`chg_…`) a pass or a charge-linked grant was bought with */
585
+ charge_id: string | null;
586
+ created_at: string;
587
+ [key: string]: unknown;
588
+ };
565
589
  export interface FileObject {
566
590
  object_id: string;
567
591
  filename: string;
@@ -2489,7 +2513,8 @@ export declare class Vxil<S extends VxilSchemaShape = VxilSchemaShape> {
2489
2513
  run_id: string;
2490
2514
  state: string;
2491
2515
  }>;
2492
- /** Clone a terminal run into a fresh queued run. */
2516
+ /** Clone a terminal run into a fresh queued run. A generation run answers
2517
+ * `409 not_replayable` — submit the generation again instead. */
2493
2518
  replay: (runId: string) => Promise<{
2494
2519
  run_id: string;
2495
2520
  replayed_from: string;
@@ -2804,8 +2829,11 @@ export declare class Vxil<S extends VxilSchemaShape = VxilSchemaShape> {
2804
2829
  * refresh token in one process share ONE rotation, and for 30 s after it
2805
2830
  * settles a call still carrying the OLD pair gets the new pair (no second
2806
2831
  * request) while a call with the just-minted pair gets it back unchanged.
2807
- * A refresh that fails (revoked, expired, or already rotated by another
2808
- * process) throws the `VxilError` — treat it as "sign in again".
2832
+ * A refresh that fails throws the `VxilError`. A `401 invalid_refresh`
2833
+ * can be a rotation another process (another server instance) just
2834
+ * made, so do not clear the session on the first one — keep the cookie
2835
+ * and treat only a repeat failure of the same pair after a short grace
2836
+ * as "sign in again"; see guide 09's refresh recipe.
2809
2837
  *
2810
2838
  * Call it on a client whose key carries `auth:signin` — normally the
2811
2839
  * sign-in key, in server mode. An end-user-mode client sends its
@@ -2965,9 +2993,18 @@ export declare class Vxil<S extends VxilSchemaShape = VxilSchemaShape> {
2965
2993
  * Consume budget. With behavior 'block' an exceeded check throws
2966
2994
  * VxilError(429); 'shape' resolves with allowed=false instead.
2967
2995
  * `override_id` is present when a per-identifier override was applied.
2996
+ * Name the policy by EXACTLY ONE of `policy_id` or `policy` (its name —
2997
+ * unique per project, and it survives a delete-and-recreate). An unknown
2998
+ * name is the same 404 `not_found` as an unknown id; a policy created
2999
+ * before 2026-09-23 is found by name once it has been saved or listed again.
2968
3000
  */
2969
- check: (input: {
3001
+ check: (input: ({
2970
3002
  policy_id: string;
3003
+ policy?: never;
3004
+ } | {
3005
+ policy: string;
3006
+ policy_id?: never;
3007
+ }) & {
2971
3008
  key_values?: Record<string, string>;
2972
3009
  cost?: number;
2973
3010
  }) => Promise<{
@@ -4789,11 +4826,14 @@ export declare class Vxil<S extends VxilSchemaShape = VxilSchemaShape> {
4789
4826
  cancel_at: string | null;
4790
4827
  }>;
4791
4828
  /** List subscriptions (the cancel enabler — discover the subscription_id);
4792
- * optionally scoped to one user / status. */
4829
+ * optionally scoped to one user / status. Each row carries its own
4830
+ * window: `current_period_start` … `current_period_end` (a queued pass
4831
+ * starts in the future). In end-user mode the list is always the signed-in
4832
+ * user's own rows, whatever `user_id` says. */
4793
4833
  listSubscriptions: (q?: {
4794
4834
  user_id?: string;
4795
4835
  status?: string;
4796
- }) => Promise<Array<Record<string, unknown>>>;
4836
+ }) => Promise<PaymentsSubscription[]>;
4797
4837
  /**
4798
4838
  * Create a hosted-checkout session (payments.md §3). Redirect the buyer to
4799
4839
  * the returned `url`; completion lands server-side via the provider webhook
@@ -4888,6 +4928,9 @@ export declare class Vxil<S extends VxilSchemaShape = VxilSchemaShape> {
4888
4928
  user_id: string;
4889
4929
  tier: string;
4890
4930
  status: string;
4931
+ /** (2026-09-25) the grant row's start — the time it was WRITTEN (a replay
4932
+ * answers the first grant's), never a window you computed */
4933
+ since?: string | null;
4891
4934
  until: string | null;
4892
4935
  charge_id: string | null;
4893
4936
  replayed: boolean;
package/dist/index.js CHANGED
@@ -699,7 +699,8 @@ export class Vxil {
699
699
  * number to alarm on), in-flight runs per lane, dead letters in 24 h. */
700
700
  queue: async () => (await this.call('GET', '/v1/jobs/queue')).data,
701
701
  cancel: async (runId) => (await this.call('POST', `/v1/jobs/runs/${encodeURIComponent(runId)}/cancel`)).data,
702
- /** Clone a terminal run into a fresh queued run. */
702
+ /** Clone a terminal run into a fresh queued run. A generation run answers
703
+ * `409 not_replayable` — submit the generation again instead. */
703
704
  replay: async (runId) => (await this.call('POST', `/v1/jobs/runs/${encodeURIComponent(runId)}/replay`)).data,
704
705
  /**
705
706
  * Suspend the RUNNING run until an event (call from the executing
@@ -879,8 +880,11 @@ export class Vxil {
879
880
  * refresh token in one process share ONE rotation, and for 30 s after it
880
881
  * settles a call still carrying the OLD pair gets the new pair (no second
881
882
  * request) while a call with the just-minted pair gets it back unchanged.
882
- * A refresh that fails (revoked, expired, or already rotated by another
883
- * process) throws the `VxilError` — treat it as "sign in again".
883
+ * A refresh that fails throws the `VxilError`. A `401 invalid_refresh`
884
+ * can be a rotation another process (another server instance) just
885
+ * made, so do not clear the session on the first one — keep the cookie
886
+ * and treat only a repeat failure of the same pair after a short grace
887
+ * as "sign in again"; see guide 09's refresh recipe.
884
888
  *
885
889
  * Call it on a client whose key carries `auth:signin` — normally the
886
890
  * sign-in key, in server mode. An end-user-mode client sends its
@@ -1017,6 +1021,10 @@ export class Vxil {
1017
1021
  * Consume budget. With behavior 'block' an exceeded check throws
1018
1022
  * VxilError(429); 'shape' resolves with allowed=false instead.
1019
1023
  * `override_id` is present when a per-identifier override was applied.
1024
+ * Name the policy by EXACTLY ONE of `policy_id` or `policy` (its name —
1025
+ * unique per project, and it survives a delete-and-recreate). An unknown
1026
+ * name is the same 404 `not_found` as an unknown id; a policy created
1027
+ * before 2026-09-23 is found by name once it has been saved or listed again.
1020
1028
  */
1021
1029
  check: async (input) => (await this.call('POST', '/v1/rate-limits/check', input)).data,
1022
1030
  /** Per-identifier overrides layered over a policy: `pattern` matches the
@@ -1967,7 +1975,10 @@ export class Vxil {
1967
1975
  * period closes; false revokes immediately and re-folds entitlements. */
1968
1976
  cancel: async (subscriptionId, opts) => (await this.call('DELETE', `/v1/payments/subscriptions/${encodeURIComponent(subscriptionId)}${opts?.atPeriodEnd ? '?at_period_end=true' : ''}`)).data,
1969
1977
  /** List subscriptions (the cancel enabler — discover the subscription_id);
1970
- * optionally scoped to one user / status. */
1978
+ * optionally scoped to one user / status. Each row carries its own
1979
+ * window: `current_period_start` … `current_period_end` (a queued pass
1980
+ * starts in the future). In end-user mode the list is always the signed-in
1981
+ * user's own rows, whatever `user_id` says. */
1971
1982
  listSubscriptions: async (q) => {
1972
1983
  const s = qs({ user_id: q?.user_id || undefined, status: q?.status || undefined });
1973
1984
  return (await this.call('GET', `/v1/payments/subscriptions${s}`)).data.subscriptions;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vxil/sdk",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
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).",