@stripe/link-cli 0.4.1 → 0.4.2

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 +17 -0
  2. package/dist/cli.js +23 -8
  3. package/package.json +2 -1
package/README.md CHANGED
@@ -71,6 +71,23 @@ The `--request-approval` flag triggers a push notification (or email) to the use
71
71
 
72
72
  Users can easily approve requests with the [Link app](https://link.com/download).
73
73
 
74
+ #### Line items and totals
75
+
76
+ `--line-item` and `--total` use repeatable `key:value` format.
77
+
78
+ **`--line-item` keys:** `name` (required), `quantity`, `unit_amount`, `description`, `sku`, `url`, `image_url`, `product_url`
79
+
80
+ ```bash
81
+ --line-item "name:Running Shoes,unit_amount:12000,quantity:1,description:Trail runners"
82
+ ```
83
+
84
+ **`--total` keys:** `type` (required), `display_text` (required), `amount` (required)
85
+
86
+ ```bash
87
+ --total "type:subtotal,display_text:Subtotal,amount:12000" \
88
+ --total "type:total,display_text:Total,amount:12000"
89
+ ```
90
+
74
91
  #### Credential types
75
92
 
76
93
  By default, a spend request provisions a virtual card. For merchants that support the [Machine Payments Protocol](https://mpp.dev) (HTTP 402) and the Stripe payment method, you can instead include `--credential-type "shared_payment_token"`.
package/dist/cli.js CHANGED
@@ -13590,8 +13590,13 @@ function parseKvString(raw) {
13590
13590
  }
13591
13591
  return result;
13592
13592
  }
13593
- function formatZodError(err, prefix) {
13593
+ function formatZodError(err, prefix, schema) {
13594
+ const allowed = Object.keys(schema.shape);
13594
13595
  const messages = err.issues.map((issue) => {
13596
+ if (issue.code === "unrecognized_keys") {
13597
+ const keys = issue.keys.map((k) => `"${k}"`).join(", ");
13598
+ return `${prefix}: unrecognized key ${keys}. Allowed keys: ${allowed.join(", ")}`;
13599
+ }
13595
13600
  const key = issue.path[0]?.toString();
13596
13601
  return key ? `${prefix} ${key}: ${issue.message}` : `${prefix}: ${issue.message}`;
13597
13602
  });
@@ -13602,7 +13607,8 @@ function parseLineItemFlag(raw) {
13602
13607
  try {
13603
13608
  return LineItemSchema.parse(obj);
13604
13609
  } catch (err) {
13605
- if (err instanceof z5.ZodError) throw formatZodError(err, "Line item");
13610
+ if (err instanceof z5.ZodError)
13611
+ throw formatZodError(err, "Line item", LineItemSchema);
13606
13612
  throw err;
13607
13613
  }
13608
13614
  }
@@ -13611,7 +13617,8 @@ function parseTotalFlag(raw) {
13611
13617
  try {
13612
13618
  return TotalSchema.parse(obj);
13613
13619
  } catch (err) {
13614
- if (err instanceof z5.ZodError) throw formatZodError(err, "Total");
13620
+ if (err instanceof z5.ZodError)
13621
+ throw formatZodError(err, "Total", TotalSchema);
13615
13622
  throw err;
13616
13623
  }
13617
13624
  }
@@ -14199,8 +14206,12 @@ var createOptions = z6.object({
14199
14206
  context: z6.string().min(100).describe(
14200
14207
  "Min 100 chars \u2014 describe the purchase and rationale; the user reads this when approving"
14201
14208
  ),
14202
- lineItem: z6.array(z6.union([z6.string(), z6.record(z6.string(), z6.unknown())])).default([]).describe("Line item (repeatable, key:value format)"),
14203
- total: z6.array(z6.union([z6.string(), z6.record(z6.string(), z6.unknown())])).default([]).describe("Total (repeatable, key:value format)"),
14209
+ lineItem: z6.array(z6.union([z6.string(), z6.record(z6.string(), z6.unknown())])).default([]).describe(
14210
+ 'Line item (repeatable, key:value format). Keys: name (required), quantity, unit_amount, description, sku, url, image_url, product_url. Example: "name:Shoes,unit_amount:5000,quantity:2"'
14211
+ ),
14212
+ total: z6.array(z6.union([z6.string(), z6.record(z6.string(), z6.unknown())])).default([]).describe(
14213
+ 'Total (repeatable, key:value format). Keys: type (required), display_text (required), amount (required). Example: "type:total,display_text:Total,amount:5000"'
14214
+ ),
14204
14215
  requestApproval: z6.boolean().default(true).describe("Request approval and poll until approved/denied/expired"),
14205
14216
  test: z6.boolean().default(false).describe(
14206
14217
  "Use test mode (creates testmode credentials from test card data)"
@@ -14225,8 +14236,12 @@ var updateOptions = z6.object({
14225
14236
  profileId: z6.string().optional().describe("Profile ID"),
14226
14237
  merchantId: z6.string().optional().describe("Merchant ID"),
14227
14238
  currency: z6.string().optional().describe("Currency code"),
14228
- lineItem: z6.array(z6.union([z6.string(), z6.record(z6.string(), z6.unknown())])).default([]).describe("Line item (repeatable, key:value format)"),
14229
- total: z6.array(z6.union([z6.string(), z6.record(z6.string(), z6.unknown())])).default([]).describe("Total (repeatable, key:value format)")
14239
+ lineItem: z6.array(z6.union([z6.string(), z6.record(z6.string(), z6.unknown())])).default([]).describe(
14240
+ 'Line item (repeatable, key:value format). Keys: name (required), quantity, unit_amount, description, sku, url, image_url, product_url. Example: "name:Shoes,unit_amount:5000,quantity:2"'
14241
+ ),
14242
+ total: z6.array(z6.union([z6.string(), z6.record(z6.string(), z6.unknown())])).default([]).describe(
14243
+ 'Total (repeatable, key:value format). Keys: type (required), display_text (required), amount (required). Example: "type:total,display_text:Total,amount:5000"'
14244
+ )
14230
14245
  });
14231
14246
 
14232
14247
  // src/commands/spend-request/update.tsx
@@ -14930,7 +14945,7 @@ var ResourceFactory = class {
14930
14945
  };
14931
14946
 
14932
14947
  // src/cli.tsx
14933
- var cliVersion = "0.4.1";
14948
+ var cliVersion = "0.4.2";
14934
14949
  var buildNumber = "1";
14935
14950
  var cliName = "@stripe/link-cli";
14936
14951
  var defaultHeaders = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stripe/link-cli",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "link-cli": "./dist/cli.js"
@@ -25,6 +25,7 @@
25
25
  "ink": "^5.2.1",
26
26
  "ink-spinner": "^5.0.0",
27
27
  "mppx": "^0.5.7",
28
+ "viem": "^2.47.5",
28
29
  "qrcode": "^1.5.4",
29
30
  "react": "^18.3.1",
30
31
  "update-notifier": "^7.3.1",