@stripe/link-cli 0.4.0 → 0.4.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 (3) hide show
  1. package/README.md +8 -0
  2. package/dist/cli.js +19 -6
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -84,6 +84,14 @@ link-cli spend-request retrieve lsrq_001 --format json
84
84
  ```
85
85
  By default, retrieving a spend request will not include card details. Use the `--include=card` to see unmasked card details.
86
86
 
87
+ For agent polling, pass `--interval` and optionally `--max-attempts`:
88
+
89
+ ```bash
90
+ link-cli spend-request retrieve lsrq_001 --interval 2 --max-attempts 150 --format json
91
+ ```
92
+
93
+ Polling exits successfully only after the request reaches a terminal status such as `approved`, `denied`, or `expired`. If polling reaches `--timeout` or exhausts `--max-attempts` while the request is still non-terminal, the command exits non-zero with `code: "POLLING_TIMEOUT"` so callers do not treat a still-pending request as complete.
94
+
87
95
  If the merchant supports MPP, use `link-cli mpp pay` instead:
88
96
 
89
97
  ```bash
package/dist/cli.js CHANGED
@@ -14207,11 +14207,15 @@ var createOptions = z6.object({
14207
14207
  )
14208
14208
  });
14209
14209
  var retrieveOptions = z6.object({
14210
- timeout: z6.coerce.number().default(300).describe("Polling timeout in seconds"),
14210
+ timeout: z6.coerce.number().default(300).describe(
14211
+ "Polling timeout in seconds. When reached during active polling, exits non-zero with POLLING_TIMEOUT."
14212
+ ),
14211
14213
  interval: z6.coerce.number().default(0).describe(
14212
- "Poll interval in seconds. When > 0, polls until status is terminal or timeout is reached, yielding status on each attempt."
14214
+ "Poll interval in seconds. When > 0, polls until status is terminal, timeout is reached, or max attempts are exhausted."
14215
+ ),
14216
+ maxAttempts: z6.coerce.number().default(0).describe(
14217
+ "Max poll attempts. 0 = unlimited. Exhaustion during active polling exits non-zero with POLLING_TIMEOUT."
14213
14218
  ),
14214
- maxAttempts: z6.coerce.number().default(0).describe("Max poll attempts. 0 = unlimited (use timeout instead)."),
14215
14219
  include: z6.array(z6.string()).default([]).describe("Include extra data (repeatable, e.g. --include card)")
14216
14220
  });
14217
14221
  var updateOptions = z6.object({
@@ -14600,11 +14604,20 @@ function createSpendRequestCli(repository) {
14600
14604
  return;
14601
14605
  }
14602
14606
  attempts++;
14603
- const shouldStop = interval <= 0 || maxAttempts > 0 && attempts >= maxAttempts || Date.now() >= deadline;
14604
- if (shouldStop) {
14607
+ if (interval <= 0) {
14605
14608
  yield request;
14606
14609
  return;
14607
14610
  }
14611
+ const maxAttemptsExhausted = maxAttempts > 0 && attempts >= maxAttempts;
14612
+ const timeoutReached = Date.now() >= deadline;
14613
+ if (maxAttemptsExhausted || timeoutReached) {
14614
+ const reason = maxAttemptsExhausted ? `max attempts (${maxAttempts}) exhausted` : `timeout (${timeout}s) reached`;
14615
+ return c.error({
14616
+ code: "POLLING_TIMEOUT",
14617
+ message: `Polling stopped before spend request ${id} reached a terminal status: ${reason}; current status is ${request.status}.`,
14618
+ retryable: true
14619
+ });
14620
+ }
14608
14621
  const snapshot = JSON.stringify(request);
14609
14622
  if (snapshot !== previousAttemptData) {
14610
14623
  previousAttemptData = snapshot;
@@ -14917,7 +14930,7 @@ var ResourceFactory = class {
14917
14930
  };
14918
14931
 
14919
14932
  // src/cli.tsx
14920
- var cliVersion = "0.4.0";
14933
+ var cliVersion = "0.4.1";
14921
14934
  var buildNumber = "1";
14922
14935
  var cliName = "@stripe/link-cli";
14923
14936
  var defaultHeaders = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stripe/link-cli",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "link-cli": "./dist/cli.js"