@forjio/storlaunch-cli 0.1.0 → 0.2.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/commands/buy.d.ts +3 -0
- package/dist/commands/buy.d.ts.map +1 -0
- package/dist/commands/buy.js +512 -0
- package/dist/commands/buy.js.map +1 -0
- package/dist/commands/sell.d.ts +10 -0
- package/dist/commands/sell.d.ts.map +1 -0
- package/dist/commands/sell.js +20 -0
- package/dist/commands/sell.js.map +1 -0
- package/dist/index.js +4 -10
- package/dist/index.js.map +1 -1
- package/dist/lib/buyer-api.d.ts +31 -0
- package/dist/lib/buyer-api.d.ts.map +1 -0
- package/dist/lib/buyer-api.js +92 -0
- package/dist/lib/buyer-api.js.map +1 -0
- package/dist/lib/buyer-config.d.ts +24 -0
- package/dist/lib/buyer-config.d.ts.map +1 -0
- package/dist/lib/buyer-config.js +58 -0
- package/dist/lib/buyer-config.js.map +1 -0
- package/dist/lib/prompt.d.ts +7 -0
- package/dist/lib/prompt.d.ts.map +1 -0
- package/dist/lib/prompt.js +41 -0
- package/dist/lib/prompt.js.map +1 -0
- package/package.json +5 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buy.d.ts","sourceRoot":"","sources":["../../src/commands/buy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAapC,eAAO,MAAM,GAAG,SAA6E,CAAC"}
|
|
@@ -0,0 +1,512 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import { writeFileSync } from "node:fs";
|
|
4
|
+
import { spawn } from "node:child_process";
|
|
5
|
+
import { platform } from "node:os";
|
|
6
|
+
import { buyerRequest, parseSessionCookie, buyerDownload, BuyerApiError } from "../lib/buyer-api.js";
|
|
7
|
+
import { getBuyerSession, setBuyerSession, clearBuyerSession, listBuyerSessions, requireBuyerSession, } from "../lib/buyer-config.js";
|
|
8
|
+
import { prompt, promptChoice, promptConfirm, closePrompt } from "../lib/prompt.js";
|
|
9
|
+
import { output } from "../lib/output.js";
|
|
10
|
+
// ─── Top-level `buy` ─────────────────────────────────────────────────────────
|
|
11
|
+
export const buy = new Command("buy").description("Buyer commands — shop, pay, track orders");
|
|
12
|
+
// ─── auth ────────────────────────────────────────────────────────────────────
|
|
13
|
+
const auth = buy.command("auth").description("Manage buyer authentication (per merchant)");
|
|
14
|
+
auth
|
|
15
|
+
.command("login")
|
|
16
|
+
.description("Log in to a merchant via email OTP")
|
|
17
|
+
.requiredOption("--merchant <slug>", "Merchant slug (e.g. my-shop)")
|
|
18
|
+
.action(async (opts) => {
|
|
19
|
+
try {
|
|
20
|
+
const email = (await prompt("Email:")) || "";
|
|
21
|
+
if (!email)
|
|
22
|
+
throw new Error("Email is required");
|
|
23
|
+
await buyerRequest(null, "/checkout/verify-email", {
|
|
24
|
+
method: "POST",
|
|
25
|
+
body: { email, accountSlug: opts.merchant },
|
|
26
|
+
});
|
|
27
|
+
console.log(chalk.dim(`Code sent to ${email}. Check your inbox.`));
|
|
28
|
+
const code = (await prompt("6-digit code:")) || "";
|
|
29
|
+
if (!/^\d{6}$/.test(code))
|
|
30
|
+
throw new Error("Must be 6 digits");
|
|
31
|
+
const { setCookie } = await buyerRequest(null, "/checkout/verify-otp", {
|
|
32
|
+
method: "POST",
|
|
33
|
+
body: { email, accountSlug: opts.merchant, code },
|
|
34
|
+
});
|
|
35
|
+
const parsed = parseSessionCookie(setCookie);
|
|
36
|
+
if (!parsed)
|
|
37
|
+
throw new Error("Login succeeded but no session cookie received");
|
|
38
|
+
setBuyerSession({ accountSlug: opts.merchant, email, ...parsed });
|
|
39
|
+
console.log(chalk.green(`✓ Signed in as ${email} for ${opts.merchant}`));
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
console.error(chalk.red(err.message));
|
|
43
|
+
process.exitCode = 1;
|
|
44
|
+
}
|
|
45
|
+
finally {
|
|
46
|
+
closePrompt();
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
auth
|
|
50
|
+
.command("logout")
|
|
51
|
+
.description("Clear the buyer session for a merchant")
|
|
52
|
+
.requiredOption("--merchant <slug>", "Merchant slug")
|
|
53
|
+
.action(async (opts) => {
|
|
54
|
+
const session = getBuyerSession(opts.merchant);
|
|
55
|
+
if (!session) {
|
|
56
|
+
console.log(chalk.dim(`Not signed in to ${opts.merchant}.`));
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
try {
|
|
60
|
+
await buyerRequest(opts.merchant, "/checkout/signout", { method: "POST" });
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
// Server-side failure is non-fatal — local clear still runs.
|
|
64
|
+
}
|
|
65
|
+
clearBuyerSession(opts.merchant);
|
|
66
|
+
console.log(chalk.green(`✓ Signed out of ${opts.merchant}`));
|
|
67
|
+
});
|
|
68
|
+
auth
|
|
69
|
+
.command("whoami")
|
|
70
|
+
.description("Show the currently signed-in buyer for a merchant (or all)")
|
|
71
|
+
.option("--merchant <slug>", "Merchant slug (omit to list all)")
|
|
72
|
+
.action(async (opts) => {
|
|
73
|
+
if (opts.merchant) {
|
|
74
|
+
const s = getBuyerSession(opts.merchant);
|
|
75
|
+
if (!s) {
|
|
76
|
+
console.log(chalk.dim(`Not signed in to ${opts.merchant}`));
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
console.log(`${chalk.bold(opts.merchant)}: ${s.email} (expires ${s.expiresAt})`);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const all = listBuyerSessions();
|
|
83
|
+
if (all.length === 0) {
|
|
84
|
+
console.log(chalk.dim("No buyer sessions"));
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
for (const s of all) {
|
|
88
|
+
console.log(`${chalk.bold(s.accountSlug)}: ${s.email} (expires ${s.expiresAt})`);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
// ─── shop / browse ───────────────────────────────────────────────────────────
|
|
92
|
+
buy
|
|
93
|
+
.command("shop <merchant> [product]")
|
|
94
|
+
.description("Browse a merchant's products (or view one product)")
|
|
95
|
+
.action(async (merchant, productSlug) => {
|
|
96
|
+
try {
|
|
97
|
+
if (productSlug) {
|
|
98
|
+
const { data } = await buyerRequest(null, `/storefront/public/${merchant}/${productSlug}`);
|
|
99
|
+
output(data);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
const { data } = await buyerRequest(null, `/storefront/public/${merchant}`);
|
|
103
|
+
output(data);
|
|
104
|
+
}
|
|
105
|
+
catch (err) {
|
|
106
|
+
console.error(chalk.red(err.message));
|
|
107
|
+
process.exitCode = 1;
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
// ─── checkout ────────────────────────────────────────────────────────────────
|
|
111
|
+
buy
|
|
112
|
+
.command("checkout <merchant> <product>")
|
|
113
|
+
.description("Buy a product — interactive for physical, direct for digital; opens payment URL")
|
|
114
|
+
.option("--open", "Automatically open the payment URL in the browser", true)
|
|
115
|
+
.option("--no-open", "Print the URL instead of opening the browser")
|
|
116
|
+
.action(async (merchant, productSlug, opts) => {
|
|
117
|
+
try {
|
|
118
|
+
const session = requireBuyerSession(merchant);
|
|
119
|
+
const { data: product } = await buyerRequest(null, `/storefront/public/${merchant}/${productSlug}`);
|
|
120
|
+
if (!product)
|
|
121
|
+
throw new Error("Product not found");
|
|
122
|
+
const isPhysical = product.type === "physical";
|
|
123
|
+
const body = { email: session.email };
|
|
124
|
+
if (isPhysical) {
|
|
125
|
+
// Address picker
|
|
126
|
+
const { data: addresses } = await buyerRequest(merchant, `/checkout/addresses`, {
|
|
127
|
+
query: { accountSlug: merchant },
|
|
128
|
+
});
|
|
129
|
+
if (addresses.length === 0) {
|
|
130
|
+
console.log(chalk.yellow("No saved addresses. Run: storlaunch buy addresses add --merchant " + merchant));
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
const picked = await promptChoice("Pick an address:", addresses.map((a) => ({
|
|
134
|
+
...a,
|
|
135
|
+
label: `${a.label} — ${a.contactName}, ${a.address}${a.isDefault ? " [default]" : ""}`,
|
|
136
|
+
})));
|
|
137
|
+
if (!picked)
|
|
138
|
+
return;
|
|
139
|
+
// Rate quote
|
|
140
|
+
const { data: rates } = await buyerRequest(null, `/shipping/rates`, {
|
|
141
|
+
method: "POST",
|
|
142
|
+
body: {
|
|
143
|
+
accountSlug: merchant,
|
|
144
|
+
destination: {
|
|
145
|
+
contactName: picked.contactName, contactPhone: picked.contactPhone, email: session.email,
|
|
146
|
+
address: picked.address, note: picked.note, postalCode: picked.postalCode,
|
|
147
|
+
areaId: picked.areaId, lat: picked.lat, lng: picked.lng,
|
|
148
|
+
},
|
|
149
|
+
items: [{
|
|
150
|
+
productId: product.id, name: product.name, value: product.price,
|
|
151
|
+
weight: Math.max(1, product.weight ?? 1), quantity: 1,
|
|
152
|
+
}],
|
|
153
|
+
},
|
|
154
|
+
});
|
|
155
|
+
if (!rates.rates?.length) {
|
|
156
|
+
console.log(chalk.yellow("No couriers available for this address."));
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
const rate = await promptChoice("Pick a courier:", rates.rates.map((r) => ({
|
|
160
|
+
...r,
|
|
161
|
+
label: `${r.courier_name} · ${r.courier_service_name} — ${fmtIDR(r.price)} (${r.duration})`,
|
|
162
|
+
})));
|
|
163
|
+
if (!rate)
|
|
164
|
+
return;
|
|
165
|
+
body.shipping = {
|
|
166
|
+
destination: {
|
|
167
|
+
contactName: picked.contactName, contactPhone: picked.contactPhone, email: session.email,
|
|
168
|
+
address: picked.address, note: picked.note, postalCode: picked.postalCode,
|
|
169
|
+
areaId: picked.areaId, lat: picked.lat, lng: picked.lng,
|
|
170
|
+
},
|
|
171
|
+
courierCode: rate.courier_code,
|
|
172
|
+
courierService: rate.courier_service_code,
|
|
173
|
+
courierType: rate.service_type,
|
|
174
|
+
shippingCost: rate.price,
|
|
175
|
+
insured: false,
|
|
176
|
+
insuranceValue: product.price,
|
|
177
|
+
addressId: picked.id,
|
|
178
|
+
};
|
|
179
|
+
const total = product.price + rate.price;
|
|
180
|
+
const ok = await promptConfirm(`Total: ${fmtIDR(total)}. Confirm?`);
|
|
181
|
+
if (!ok) {
|
|
182
|
+
console.log(chalk.dim("Cancelled."));
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
const ok = await promptConfirm(`Buy ${product.name} for ${fmtIDR(product.price)}?`);
|
|
188
|
+
if (!ok) {
|
|
189
|
+
console.log(chalk.dim("Cancelled."));
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
const { data: result } = await buyerRequest(null, `/storefront/public/${merchant}/${productSlug}/checkout`, {
|
|
194
|
+
method: "POST",
|
|
195
|
+
body,
|
|
196
|
+
});
|
|
197
|
+
console.log(chalk.green("\n✓ Checkout created"));
|
|
198
|
+
console.log(`Pay here: ${chalk.cyan(result.checkoutUrl)}`);
|
|
199
|
+
if (opts.open)
|
|
200
|
+
openBrowser(result.checkoutUrl);
|
|
201
|
+
}
|
|
202
|
+
catch (err) {
|
|
203
|
+
if (err instanceof BuyerApiError && err.status === 401) {
|
|
204
|
+
console.error(chalk.red(`Not signed in. Run: storlaunch buy auth login --merchant ${merchant}`));
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
console.error(chalk.red(err.message));
|
|
208
|
+
}
|
|
209
|
+
process.exitCode = 1;
|
|
210
|
+
}
|
|
211
|
+
finally {
|
|
212
|
+
closePrompt();
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
// ─── orders ──────────────────────────────────────────────────────────────────
|
|
216
|
+
const orders = buy.command("orders").description("Your orders with a merchant");
|
|
217
|
+
orders
|
|
218
|
+
.command("list")
|
|
219
|
+
.requiredOption("--merchant <slug>", "Merchant slug")
|
|
220
|
+
.description("List your orders")
|
|
221
|
+
.action(async (opts) => {
|
|
222
|
+
try {
|
|
223
|
+
requireBuyerSession(opts.merchant);
|
|
224
|
+
const { data } = await buyerRequest(opts.merchant, `/checkout/orders`, {
|
|
225
|
+
query: { accountSlug: opts.merchant },
|
|
226
|
+
});
|
|
227
|
+
output(data);
|
|
228
|
+
}
|
|
229
|
+
catch (err) {
|
|
230
|
+
errExit(err);
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
orders
|
|
234
|
+
.command("get <id>")
|
|
235
|
+
.requiredOption("--merchant <slug>", "Merchant slug")
|
|
236
|
+
.description("Show a single order with shipment + deliveries + invoice")
|
|
237
|
+
.action(async (id, opts) => {
|
|
238
|
+
try {
|
|
239
|
+
requireBuyerSession(opts.merchant);
|
|
240
|
+
const { data } = await buyerRequest(opts.merchant, `/checkout/orders/${id}`, {
|
|
241
|
+
query: { accountSlug: opts.merchant },
|
|
242
|
+
});
|
|
243
|
+
output(data);
|
|
244
|
+
}
|
|
245
|
+
catch (err) {
|
|
246
|
+
errExit(err);
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
// ─── subscriptions ───────────────────────────────────────────────────────────
|
|
250
|
+
const subs = buy.command("subs").description("Your subscriptions with a merchant");
|
|
251
|
+
subs
|
|
252
|
+
.command("list")
|
|
253
|
+
.requiredOption("--merchant <slug>", "Merchant slug")
|
|
254
|
+
.action(async (opts) => {
|
|
255
|
+
try {
|
|
256
|
+
requireBuyerSession(opts.merchant);
|
|
257
|
+
const { data } = await buyerRequest(opts.merchant, `/checkout/subscriptions`, {
|
|
258
|
+
query: { accountSlug: opts.merchant },
|
|
259
|
+
});
|
|
260
|
+
output(data);
|
|
261
|
+
}
|
|
262
|
+
catch (err) {
|
|
263
|
+
errExit(err);
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
subs
|
|
267
|
+
.command("get <id>")
|
|
268
|
+
.requiredOption("--merchant <slug>", "Merchant slug")
|
|
269
|
+
.action(async (id, opts) => {
|
|
270
|
+
try {
|
|
271
|
+
requireBuyerSession(opts.merchant);
|
|
272
|
+
const { data } = await buyerRequest(opts.merchant, `/checkout/subscriptions/${id}`, {
|
|
273
|
+
query: { accountSlug: opts.merchant },
|
|
274
|
+
});
|
|
275
|
+
output(data);
|
|
276
|
+
}
|
|
277
|
+
catch (err) {
|
|
278
|
+
errExit(err);
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
subs
|
|
282
|
+
.command("cancel <id>")
|
|
283
|
+
.requiredOption("--merchant <slug>", "Merchant slug")
|
|
284
|
+
.option("--immediate", "Cancel right now instead of at period end", false)
|
|
285
|
+
.description("Cancel a subscription (end-of-period by default)")
|
|
286
|
+
.action(async (id, opts) => {
|
|
287
|
+
try {
|
|
288
|
+
requireBuyerSession(opts.merchant);
|
|
289
|
+
const { data } = await buyerRequest(opts.merchant, `/checkout/subscriptions/${id}/cancel`, {
|
|
290
|
+
method: "POST",
|
|
291
|
+
body: { accountSlug: opts.merchant, immediate: opts.immediate },
|
|
292
|
+
});
|
|
293
|
+
output(data);
|
|
294
|
+
}
|
|
295
|
+
catch (err) {
|
|
296
|
+
errExit(err);
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
// ─── invoices ────────────────────────────────────────────────────────────────
|
|
300
|
+
const invoices = buy.command("invoices").description("Your invoices from a merchant");
|
|
301
|
+
invoices
|
|
302
|
+
.command("list")
|
|
303
|
+
.requiredOption("--merchant <slug>", "Merchant slug")
|
|
304
|
+
.action(async (opts) => {
|
|
305
|
+
try {
|
|
306
|
+
requireBuyerSession(opts.merchant);
|
|
307
|
+
const { data } = await buyerRequest(opts.merchant, `/checkout/invoices`, {
|
|
308
|
+
query: { accountSlug: opts.merchant },
|
|
309
|
+
});
|
|
310
|
+
output(data);
|
|
311
|
+
}
|
|
312
|
+
catch (err) {
|
|
313
|
+
errExit(err);
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
invoices
|
|
317
|
+
.command("download <id>")
|
|
318
|
+
.requiredOption("--merchant <slug>", "Merchant slug")
|
|
319
|
+
.option("--out <path>", "Write to a file path (default: ./invoice-<id>.pdf)")
|
|
320
|
+
.description("Download an invoice PDF")
|
|
321
|
+
.action(async (id, opts) => {
|
|
322
|
+
try {
|
|
323
|
+
requireBuyerSession(opts.merchant);
|
|
324
|
+
const buf = await buyerDownload(opts.merchant, `/checkout/invoices/${id}/pdf?download=1`);
|
|
325
|
+
const path = opts.out ?? `./invoice-${id}.pdf`;
|
|
326
|
+
writeFileSync(path, buf);
|
|
327
|
+
console.log(chalk.green(`✓ Saved to ${path}`));
|
|
328
|
+
}
|
|
329
|
+
catch (err) {
|
|
330
|
+
errExit(err);
|
|
331
|
+
}
|
|
332
|
+
});
|
|
333
|
+
// ─── addresses ───────────────────────────────────────────────────────────────
|
|
334
|
+
const addresses = buy.command("addresses").description("Your saved addresses for a merchant");
|
|
335
|
+
addresses
|
|
336
|
+
.command("list")
|
|
337
|
+
.requiredOption("--merchant <slug>", "Merchant slug")
|
|
338
|
+
.action(async (opts) => {
|
|
339
|
+
try {
|
|
340
|
+
requireBuyerSession(opts.merchant);
|
|
341
|
+
const { data } = await buyerRequest(opts.merchant, `/checkout/addresses`, {
|
|
342
|
+
query: { accountSlug: opts.merchant },
|
|
343
|
+
});
|
|
344
|
+
output(data);
|
|
345
|
+
}
|
|
346
|
+
catch (err) {
|
|
347
|
+
errExit(err);
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
addresses
|
|
351
|
+
.command("add")
|
|
352
|
+
.requiredOption("--merchant <slug>", "Merchant slug")
|
|
353
|
+
.option("--label <label>", "Label (e.g. Home, Office)", "Home")
|
|
354
|
+
.requiredOption("--name <name>", "Contact name")
|
|
355
|
+
.requiredOption("--phone <phone>", "Contact phone")
|
|
356
|
+
.requiredOption("--address <address>", "Street address")
|
|
357
|
+
.option("--postal <code>", "Postal code")
|
|
358
|
+
.option("--lat <lat>", "Latitude (required for instant couriers)", parseFloat)
|
|
359
|
+
.option("--lng <lng>", "Longitude", parseFloat)
|
|
360
|
+
.option("--note <note>", "Delivery note")
|
|
361
|
+
.option("--default", "Mark this as the default address", false)
|
|
362
|
+
.description("Add a new address")
|
|
363
|
+
.action(async (opts) => {
|
|
364
|
+
try {
|
|
365
|
+
requireBuyerSession(opts.merchant);
|
|
366
|
+
const { data } = await buyerRequest(opts.merchant, `/checkout/addresses`, {
|
|
367
|
+
method: "POST",
|
|
368
|
+
body: {
|
|
369
|
+
accountSlug: opts.merchant,
|
|
370
|
+
label: opts.label, contactName: opts.name, contactPhone: opts.phone,
|
|
371
|
+
address: opts.address, postalCode: opts.postal, note: opts.note,
|
|
372
|
+
lat: opts.lat, lng: opts.lng, isDefault: opts.default ?? false,
|
|
373
|
+
},
|
|
374
|
+
});
|
|
375
|
+
output(data);
|
|
376
|
+
}
|
|
377
|
+
catch (err) {
|
|
378
|
+
errExit(err);
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
addresses
|
|
382
|
+
.command("edit <id>")
|
|
383
|
+
.requiredOption("--merchant <slug>", "Merchant slug")
|
|
384
|
+
.option("--label <label>")
|
|
385
|
+
.option("--name <name>")
|
|
386
|
+
.option("--phone <phone>")
|
|
387
|
+
.option("--address <address>")
|
|
388
|
+
.option("--postal <code>")
|
|
389
|
+
.option("--lat <lat>", "", parseFloat)
|
|
390
|
+
.option("--lng <lng>", "", parseFloat)
|
|
391
|
+
.option("--note <note>")
|
|
392
|
+
.description("Update fields on an existing address")
|
|
393
|
+
.action(async (id, opts) => {
|
|
394
|
+
try {
|
|
395
|
+
requireBuyerSession(opts.merchant);
|
|
396
|
+
const body = { accountSlug: opts.merchant };
|
|
397
|
+
if (opts.label !== undefined)
|
|
398
|
+
body.label = opts.label;
|
|
399
|
+
if (opts.name !== undefined)
|
|
400
|
+
body.contactName = opts.name;
|
|
401
|
+
if (opts.phone !== undefined)
|
|
402
|
+
body.contactPhone = opts.phone;
|
|
403
|
+
if (opts.address !== undefined)
|
|
404
|
+
body.address = opts.address;
|
|
405
|
+
if (opts.postal !== undefined)
|
|
406
|
+
body.postalCode = opts.postal;
|
|
407
|
+
if (opts.lat !== undefined)
|
|
408
|
+
body.lat = opts.lat;
|
|
409
|
+
if (opts.lng !== undefined)
|
|
410
|
+
body.lng = opts.lng;
|
|
411
|
+
if (opts.note !== undefined)
|
|
412
|
+
body.note = opts.note;
|
|
413
|
+
const { data } = await buyerRequest(opts.merchant, `/checkout/addresses/${id}`, {
|
|
414
|
+
method: "PATCH", body,
|
|
415
|
+
});
|
|
416
|
+
output(data);
|
|
417
|
+
}
|
|
418
|
+
catch (err) {
|
|
419
|
+
errExit(err);
|
|
420
|
+
}
|
|
421
|
+
});
|
|
422
|
+
addresses
|
|
423
|
+
.command("delete <id>")
|
|
424
|
+
.requiredOption("--merchant <slug>", "Merchant slug")
|
|
425
|
+
.action(async (id, opts) => {
|
|
426
|
+
try {
|
|
427
|
+
requireBuyerSession(opts.merchant);
|
|
428
|
+
await buyerRequest(opts.merchant, `/checkout/addresses/${id}`, {
|
|
429
|
+
method: "DELETE", query: { accountSlug: opts.merchant },
|
|
430
|
+
});
|
|
431
|
+
console.log(chalk.green("✓ Address deleted"));
|
|
432
|
+
}
|
|
433
|
+
catch (err) {
|
|
434
|
+
errExit(err);
|
|
435
|
+
}
|
|
436
|
+
});
|
|
437
|
+
addresses
|
|
438
|
+
.command("default <id>")
|
|
439
|
+
.requiredOption("--merchant <slug>", "Merchant slug")
|
|
440
|
+
.description("Mark an address as default")
|
|
441
|
+
.action(async (id, opts) => {
|
|
442
|
+
try {
|
|
443
|
+
requireBuyerSession(opts.merchant);
|
|
444
|
+
const { data } = await buyerRequest(opts.merchant, `/checkout/addresses/${id}/default`, {
|
|
445
|
+
method: "POST", body: { accountSlug: opts.merchant },
|
|
446
|
+
});
|
|
447
|
+
output(data);
|
|
448
|
+
}
|
|
449
|
+
catch (err) {
|
|
450
|
+
errExit(err);
|
|
451
|
+
}
|
|
452
|
+
});
|
|
453
|
+
// ─── profile ─────────────────────────────────────────────────────────────────
|
|
454
|
+
const profile = buy.command("profile").description("Your profile with a merchant");
|
|
455
|
+
profile
|
|
456
|
+
.command("show")
|
|
457
|
+
.requiredOption("--merchant <slug>", "Merchant slug")
|
|
458
|
+
.action(async (opts) => {
|
|
459
|
+
try {
|
|
460
|
+
requireBuyerSession(opts.merchant);
|
|
461
|
+
const { data } = await buyerRequest(opts.merchant, `/checkout/profile`, {
|
|
462
|
+
query: { accountSlug: opts.merchant },
|
|
463
|
+
});
|
|
464
|
+
output(data);
|
|
465
|
+
}
|
|
466
|
+
catch (err) {
|
|
467
|
+
errExit(err);
|
|
468
|
+
}
|
|
469
|
+
});
|
|
470
|
+
profile
|
|
471
|
+
.command("update")
|
|
472
|
+
.requiredOption("--merchant <slug>", "Merchant slug")
|
|
473
|
+
.option("--name <name>", "New display name")
|
|
474
|
+
.description("Update profile fields (name only; change-email is a separate OTP flow)")
|
|
475
|
+
.action(async (opts) => {
|
|
476
|
+
try {
|
|
477
|
+
requireBuyerSession(opts.merchant);
|
|
478
|
+
const { data } = await buyerRequest(opts.merchant, `/checkout/profile`, {
|
|
479
|
+
method: "PATCH", body: { accountSlug: opts.merchant, name: opts.name ?? null },
|
|
480
|
+
});
|
|
481
|
+
output(data);
|
|
482
|
+
}
|
|
483
|
+
catch (err) {
|
|
484
|
+
errExit(err);
|
|
485
|
+
}
|
|
486
|
+
});
|
|
487
|
+
// ─── helpers ─────────────────────────────────────────────────────────────────
|
|
488
|
+
function errExit(err) {
|
|
489
|
+
if (err instanceof BuyerApiError) {
|
|
490
|
+
if (err.status === 401)
|
|
491
|
+
console.error(chalk.red("Not signed in — run: storlaunch buy auth login --merchant <slug>"));
|
|
492
|
+
else
|
|
493
|
+
console.error(chalk.red(`${err.message} (HTTP ${err.status})`));
|
|
494
|
+
}
|
|
495
|
+
else {
|
|
496
|
+
console.error(chalk.red(err.message));
|
|
497
|
+
}
|
|
498
|
+
process.exitCode = 1;
|
|
499
|
+
}
|
|
500
|
+
function fmtIDR(n) {
|
|
501
|
+
return `Rp ${n.toLocaleString("id-ID")}`;
|
|
502
|
+
}
|
|
503
|
+
function openBrowser(url) {
|
|
504
|
+
const cmd = platform() === "darwin" ? "open" : platform() === "win32" ? "start" : "xdg-open";
|
|
505
|
+
try {
|
|
506
|
+
spawn(cmd, [url], { detached: true, stdio: "ignore" }).unref();
|
|
507
|
+
}
|
|
508
|
+
catch {
|
|
509
|
+
// Opening the browser is best-effort — user already sees the URL.
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
//# sourceMappingURL=buy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buy.js","sourceRoot":"","sources":["../../src/commands/buy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACrG,OAAO,EACL,eAAe,EAAE,eAAe,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,mBAAmB,GAC5F,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpF,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,gFAAgF;AAChF,MAAM,CAAC,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,WAAW,CAAC,0CAA0C,CAAC,CAAC;AAE9F,gFAAgF;AAChF,MAAM,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,4CAA4C,CAAC,CAAC;AAE3F,IAAI;KACD,OAAO,CAAC,OA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` — seller-side commands. Wraps existing command modules (auth,
|
|
4
|
+
* payment, storefront, webhook, config) as subcommands.
|
|
5
|
+
*
|
|
6
|
+
* Before 0.2.0 these were top-level — moved here so `buy` can coexist
|
|
7
|
+
* symmetrically. Use `storlaunch sell --help` to list seller commands.
|
|
8
|
+
*/
|
|
9
|
+
export declare const sell: Command;
|
|
10
|
+
//# sourceMappingURL=sell.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sell.d.ts","sourceRoot":"","sources":["../../src/commands/sell.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOpC;;;;;;GAMG;AACH,eAAO,MAAM,IAAI,SAAoF,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { auth } from "./auth.js";
|
|
3
|
+
import { payment } from "./payment.js";
|
|
4
|
+
import { storefront } from "./storefront.js";
|
|
5
|
+
import { webhook } from "./webhook.js";
|
|
6
|
+
import { config } from "./config.js";
|
|
7
|
+
/**
|
|
8
|
+
* `sell` — seller-side commands. Wraps existing command modules (auth,
|
|
9
|
+
* payment, storefront, webhook, config) as subcommands.
|
|
10
|
+
*
|
|
11
|
+
* Before 0.2.0 these were top-level — moved here so `buy` can coexist
|
|
12
|
+
* symmetrically. Use `storlaunch sell --help` to list seller commands.
|
|
13
|
+
*/
|
|
14
|
+
export const sell = new Command("sell").description("Seller commands — manage your merchant account");
|
|
15
|
+
sell.addCommand(auth);
|
|
16
|
+
sell.addCommand(payment);
|
|
17
|
+
sell.addCommand(storefront);
|
|
18
|
+
sell.addCommand(webhook);
|
|
19
|
+
sell.addCommand(config);
|
|
20
|
+
//# sourceMappingURL=sell.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sell.js","sourceRoot":"","sources":["../../src/commands/sell.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,gDAAgD,CAAC,CAAC;AAEtG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;AACtB,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;AACzB,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;AAC5B,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;AACzB,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -10,16 +10,10 @@ program
|
|
|
10
10
|
.option("--json", "Output in JSON format")
|
|
11
11
|
.option("--sandbox", "Use sandbox/test API key");
|
|
12
12
|
// ─── Register command groups ─────────────────────────────────
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
import { config } from "./commands/config.js";
|
|
18
|
-
program.addCommand(auth);
|
|
19
|
-
program.addCommand(payment);
|
|
20
|
-
program.addCommand(storefront);
|
|
21
|
-
program.addCommand(webhook);
|
|
22
|
-
program.addCommand(config);
|
|
13
|
+
import { sell } from "./commands/sell.js";
|
|
14
|
+
import { buy } from "./commands/buy.js";
|
|
15
|
+
program.addCommand(sell);
|
|
16
|
+
program.addCommand(buy);
|
|
23
17
|
// ─── Parse ───────────────────────────────────────────────────
|
|
24
18
|
program.parse();
|
|
25
19
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,MAAM,GAAG,GAAG,OAAO,CAAC,iBAAiB,CAA6C,CAAC;AAEnF,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,YAAY,CAAC;KAClB,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC;KACpB,WAAW,CAAC,GAAG,CAAC,WAAW,CAAC;KAC5B,MAAM,CAAC,QAAQ,EAAE,uBAAuB,CAAC;KACzC,MAAM,CAAC,WAAW,EAAE,0BAA0B,CAAC,CAAC;AAEnD,gEAAgE;AAEhE,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,MAAM,GAAG,GAAG,OAAO,CAAC,iBAAiB,CAA6C,CAAC;AAEnF,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,YAAY,CAAC;KAClB,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC;KACpB,WAAW,CAAC,GAAG,CAAC,WAAW,CAAC;KAC5B,MAAM,CAAC,QAAQ,EAAE,uBAAuB,CAAC;KACzC,MAAM,CAAC,WAAW,EAAE,0BAA0B,CAAC,CAAC;AAEnD,gEAAgE;AAEhE,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAExC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;AACzB,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;AAExB,gEAAgE;AAEhE,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export interface BuyerRequestOptions {
|
|
2
|
+
method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
3
|
+
body?: unknown;
|
|
4
|
+
query?: Record<string, string | number | boolean | undefined>;
|
|
5
|
+
}
|
|
6
|
+
export declare class BuyerApiError extends Error {
|
|
7
|
+
readonly status: number;
|
|
8
|
+
readonly code?: string | undefined;
|
|
9
|
+
constructor(status: number, message: string, code?: string | undefined);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Buyer-authed request. Sends the stored session token as Cookie header.
|
|
13
|
+
* For auth endpoints (verify-email, verify-otp), pass slug=null and no auth is attached.
|
|
14
|
+
*/
|
|
15
|
+
export declare function buyerRequest<T = unknown>(slug: string | null, path: string, options?: BuyerRequestOptions): Promise<{
|
|
16
|
+
data: T;
|
|
17
|
+
setCookie?: string[];
|
|
18
|
+
}>;
|
|
19
|
+
/**
|
|
20
|
+
* Extract the `storlaunch_buyer_session=<value>` cookie from a Set-Cookie
|
|
21
|
+
* response header array. Returns { token, expiresAt }.
|
|
22
|
+
*/
|
|
23
|
+
export declare function parseSessionCookie(setCookie: string[] | undefined): {
|
|
24
|
+
token: string;
|
|
25
|
+
expiresAt: string;
|
|
26
|
+
} | null;
|
|
27
|
+
/**
|
|
28
|
+
* Download a binary response (e.g., invoice PDF) to a Buffer.
|
|
29
|
+
*/
|
|
30
|
+
export declare function buyerDownload(slug: string, path: string): Promise<Buffer>;
|
|
31
|
+
//# sourceMappingURL=buyer-api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buyer-api.d.ts","sourceRoot":"","sources":["../../src/lib/buyer-api.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;IACrD,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC;CAC/D;AAED,qBAAa,aAAc,SAAQ,KAAK;aACV,MAAM,EAAE,MAAM;aAAmC,IAAI,CAAC,EAAE,MAAM;gBAA9D,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAkB,IAAI,CAAC,EAAE,MAAM,YAAA;CAI3F;AAQD;;;GAGG;AACH,wBAAsB,YAAY,CAAC,CAAC,GAAG,OAAO,EAC5C,IAAI,EAAE,MAAM,GAAG,IAAI,EACnB,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC;IAAE,IAAI,EAAE,CAAC,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAkC5C;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,SAAS,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAc/G;AAED;;GAEG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAU/E"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { resolveApiUrl } from "./config.js";
|
|
2
|
+
import { getBuyerSession } from "./buyer-config.js";
|
|
3
|
+
export class BuyerApiError extends Error {
|
|
4
|
+
status;
|
|
5
|
+
code;
|
|
6
|
+
constructor(status, message, code) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.status = status;
|
|
9
|
+
this.code = code;
|
|
10
|
+
this.name = "BuyerApiError";
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function apiBase() {
|
|
14
|
+
// Strip /api/v1 suffix if caller configured that — buyer routes include /api/v1 explicitly.
|
|
15
|
+
const raw = resolveApiUrl();
|
|
16
|
+
return raw.replace(/\/api\/v1\/?$/, "");
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Buyer-authed request. Sends the stored session token as Cookie header.
|
|
20
|
+
* For auth endpoints (verify-email, verify-otp), pass slug=null and no auth is attached.
|
|
21
|
+
*/
|
|
22
|
+
export async function buyerRequest(slug, path, options = {}) {
|
|
23
|
+
const url = new URL(`${apiBase()}/api/v1${path}`);
|
|
24
|
+
if (options.query) {
|
|
25
|
+
for (const [k, v] of Object.entries(options.query)) {
|
|
26
|
+
if (v !== undefined)
|
|
27
|
+
url.searchParams.set(k, String(v));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const headers = { "Content-Type": "application/json" };
|
|
31
|
+
if (slug) {
|
|
32
|
+
const session = getBuyerSession(slug);
|
|
33
|
+
if (session) {
|
|
34
|
+
headers.Cookie = `storlaunch_buyer_session=${session.token}`;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const response = await fetch(url.toString(), {
|
|
38
|
+
method: options.method ?? "GET",
|
|
39
|
+
headers,
|
|
40
|
+
body: options.body ? JSON.stringify(options.body) : undefined,
|
|
41
|
+
});
|
|
42
|
+
const text = await response.text();
|
|
43
|
+
let parsed = {};
|
|
44
|
+
try {
|
|
45
|
+
parsed = text ? JSON.parse(text) : {};
|
|
46
|
+
}
|
|
47
|
+
catch { /* non-JSON (e.g. PDF) */ }
|
|
48
|
+
if (!response.ok) {
|
|
49
|
+
const msg = parsed?.error?.message ?? `HTTP ${response.status}`;
|
|
50
|
+
const code = parsed?.error?.code;
|
|
51
|
+
throw new BuyerApiError(response.status, msg, code);
|
|
52
|
+
}
|
|
53
|
+
const setCookie = response.headers.getSetCookie?.() ?? undefined;
|
|
54
|
+
return { data: (parsed.data ?? parsed), setCookie };
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Extract the `storlaunch_buyer_session=<value>` cookie from a Set-Cookie
|
|
58
|
+
* response header array. Returns { token, expiresAt }.
|
|
59
|
+
*/
|
|
60
|
+
export function parseSessionCookie(setCookie) {
|
|
61
|
+
if (!setCookie)
|
|
62
|
+
return null;
|
|
63
|
+
for (const raw of setCookie) {
|
|
64
|
+
const parts = raw.split(";").map((p) => p.trim());
|
|
65
|
+
const tokenPart = parts.find((p) => p.startsWith("storlaunch_buyer_session="));
|
|
66
|
+
if (!tokenPart)
|
|
67
|
+
continue;
|
|
68
|
+
const token = tokenPart.slice("storlaunch_buyer_session=".length);
|
|
69
|
+
const maxAge = parts.find((p) => p.startsWith("Max-Age="))?.slice("Max-Age=".length);
|
|
70
|
+
const expiresAt = maxAge
|
|
71
|
+
? new Date(Date.now() + parseInt(maxAge, 10) * 1000).toISOString()
|
|
72
|
+
: new Date(Date.now() + 30 * 24 * 60 * 60 * 1000).toISOString();
|
|
73
|
+
return { token, expiresAt };
|
|
74
|
+
}
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Download a binary response (e.g., invoice PDF) to a Buffer.
|
|
79
|
+
*/
|
|
80
|
+
export async function buyerDownload(slug, path) {
|
|
81
|
+
const session = getBuyerSession(slug);
|
|
82
|
+
const headers = {};
|
|
83
|
+
if (session)
|
|
84
|
+
headers.Cookie = `storlaunch_buyer_session=${session.token}`;
|
|
85
|
+
const url = `${apiBase()}/api/v1${path}${path.includes("?") ? "&" : "?"}accountSlug=${encodeURIComponent(slug)}`;
|
|
86
|
+
const response = await fetch(url, { headers });
|
|
87
|
+
if (!response.ok) {
|
|
88
|
+
throw new BuyerApiError(response.status, `Download failed (HTTP ${response.status})`);
|
|
89
|
+
}
|
|
90
|
+
return Buffer.from(await response.arrayBuffer());
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=buyer-api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buyer-api.js","sourceRoot":"","sources":["../../src/lib/buyer-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAQpD,MAAM,OAAO,aAAc,SAAQ,KAAK;IACV;IAAiD;IAA7E,YAA4B,MAAc,EAAE,OAAe,EAAkB,IAAa;QACxF,KAAK,CAAC,OAAO,CAAC,CAAC;QADW,WAAM,GAAN,MAAM,CAAQ;QAAmC,SAAI,GAAJ,IAAI,CAAS;QAExF,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF;AAED,SAAS,OAAO;IACd,4FAA4F;IAC5F,MAAM,GAAG,GAAG,aAAa,EAAE,CAAC;IAC5B,OAAO,GAAG,CAAC,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;AAC1C,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,IAAmB,EACnB,IAAY,EACZ,UAA+B,EAAE;IAEjC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,OAAO,EAAE,UAAU,IAAI,EAAE,CAAC,CAAC;IAClD,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;QAClB,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACnD,IAAI,CAAC,KAAK,SAAS;gBAAE,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1D,CAAC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AC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,IAAY,EAAE,IAAY;IAC5D,MAAM,OAAO,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IACtC,MAAM,OAAO,GAA2B,EAAE,CAAC;IAC3C,IAAI,OAAO;QAAE,OAAO,CAAC,MAAM,GAAG,4BAA4B,OAAO,CAAC,KAAK,EAAE,CAAC;IAC1E,MAAM,GAAG,GAAG,GAAG,OAAO,EAAE,UAAU,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,eAAe,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC;IACjH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;IAC/C,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,IAAI,aAAa,CAAC,QAAQ,CAAC,MAAM,EAAE,yBAAyB,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;IACxF,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC;AACnD,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Buyer sessions are per-merchant. Stored separately from the seller config
|
|
3
|
+
* so that logging into merchant A doesn't affect merchant B.
|
|
4
|
+
*
|
|
5
|
+
* Layout:
|
|
6
|
+
* ~/.storlaunch/buyer/<merchant-slug>.json
|
|
7
|
+
*/
|
|
8
|
+
export interface BuyerSession {
|
|
9
|
+
accountSlug: string;
|
|
10
|
+
email: string;
|
|
11
|
+
token: string;
|
|
12
|
+
expiresAt: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function getBuyerSession(slug: string): BuyerSession | null;
|
|
15
|
+
export declare function setBuyerSession(session: BuyerSession): void;
|
|
16
|
+
export declare function clearBuyerSession(slug: string): void;
|
|
17
|
+
export declare function listBuyerSessions(): BuyerSession[];
|
|
18
|
+
/**
|
|
19
|
+
* Ensures a session is active for the given slug. Returns the token. If no
|
|
20
|
+
* session exists OR the local record says it's expired, throws — caller should
|
|
21
|
+
* prompt `storlaunch buy auth login --merchant <slug>`.
|
|
22
|
+
*/
|
|
23
|
+
export declare function requireBuyerSession(slug: string): BuyerSession;
|
|
24
|
+
//# sourceMappingURL=buyer-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buyer-config.d.ts","sourceRoot":"","sources":["../../src/lib/buyer-config.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AAEH,MAAM,WAAW,YAAY;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IAEd,KAAK,EAAE,MAAM,CAAC;IAEd,SAAS,EAAE,MAAM,CAAC;CACnB;AAQD,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI,CAQjE;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI,CAG3D;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAGpD;AAED,wBAAgB,iBAAiB,IAAI,YAAY,EAAE,CAYlD;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CAS9D"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { readFileSync, writeFileSync, mkdirSync, unlinkSync, existsSync, readdirSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { homedir } from "node:os";
|
|
4
|
+
const BUYER_DIR = join(homedir(), ".storlaunch", "buyer");
|
|
5
|
+
function fileFor(slug) {
|
|
6
|
+
return join(BUYER_DIR, `${slug}.json`);
|
|
7
|
+
}
|
|
8
|
+
export function getBuyerSession(slug) {
|
|
9
|
+
const f = fileFor(slug);
|
|
10
|
+
if (!existsSync(f))
|
|
11
|
+
return null;
|
|
12
|
+
try {
|
|
13
|
+
return JSON.parse(readFileSync(f, "utf-8"));
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export function setBuyerSession(session) {
|
|
20
|
+
mkdirSync(BUYER_DIR, { recursive: true });
|
|
21
|
+
writeFileSync(fileFor(session.accountSlug), JSON.stringify(session, null, 2) + "\n", "utf-8");
|
|
22
|
+
}
|
|
23
|
+
export function clearBuyerSession(slug) {
|
|
24
|
+
const f = fileFor(slug);
|
|
25
|
+
if (existsSync(f))
|
|
26
|
+
unlinkSync(f);
|
|
27
|
+
}
|
|
28
|
+
export function listBuyerSessions() {
|
|
29
|
+
if (!existsSync(BUYER_DIR))
|
|
30
|
+
return [];
|
|
31
|
+
const files = readdirSync(BUYER_DIR).filter((f) => f.endsWith(".json"));
|
|
32
|
+
const sessions = [];
|
|
33
|
+
for (const f of files) {
|
|
34
|
+
try {
|
|
35
|
+
sessions.push(JSON.parse(readFileSync(join(BUYER_DIR, f), "utf-8")));
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
// Skip corrupt sessions
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return sessions;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Ensures a session is active for the given slug. Returns the token. If no
|
|
45
|
+
* session exists OR the local record says it's expired, throws — caller should
|
|
46
|
+
* prompt `storlaunch buy auth login --merchant <slug>`.
|
|
47
|
+
*/
|
|
48
|
+
export function requireBuyerSession(slug) {
|
|
49
|
+
const session = getBuyerSession(slug);
|
|
50
|
+
if (!session) {
|
|
51
|
+
throw new Error(`Not signed in to ${slug}. Run: storlaunch buy auth login --merchant ${slug}`);
|
|
52
|
+
}
|
|
53
|
+
if (new Date(session.expiresAt) < new Date()) {
|
|
54
|
+
throw new Error(`Session for ${slug} expired. Run: storlaunch buy auth login --merchant ${slug}`);
|
|
55
|
+
}
|
|
56
|
+
return session;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=buyer-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buyer-config.js","sourceRoot":"","sources":["../../src/lib/buyer-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtG,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAmBlC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC;AAE1D,SAAS,OAAO,CAAC,IAAY;IAC3B,OAAO,IAAI,CAAC,SAAS,EAAE,GAAG,IAAI,OAAO,CAAC,CAAC;AACzC,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxB,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IAChC,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,EAAE,OAAO,CAAC,CAAiB,CAAC;IAC9D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,OAAqB;IACnD,SAAS,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC1C,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,OAAO,CAAC,CAAC;AAChG,CAAC;AAED,MAAM,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
+
export declare function prompt(question: string): Promise<string>;
|
|
2
|
+
export declare function promptChoice<T extends {
|
|
3
|
+
label: string;
|
|
4
|
+
}>(title: string, choices: T[]): Promise<T | null>;
|
|
5
|
+
export declare function promptConfirm(question: string): Promise<boolean>;
|
|
6
|
+
export declare function closePrompt(): void;
|
|
7
|
+
//# sourceMappingURL=prompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../src/lib/prompt.ts"],"names":[],"mappings":"AAcA,wBAAsB,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAI9D;AAED,wBAAsB,YAAY,CAAC,CAAC,SAAS;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,EAC5D,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,CAAC,EAAE,GACX,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAUnB;AAED,wBAAsB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAGtE;AAED,wBAAgB,WAAW,IAAI,IAAI,CAElC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { createInterface } from "node:readline/promises";
|
|
2
|
+
import { stdin, stdout } from "node:process";
|
|
3
|
+
/**
|
|
4
|
+
* Minimal interactive prompt helpers (no extra deps). For production UX we'd
|
|
5
|
+
* use inquirer/enquirer; this covers CLI flows without bloating the bundle.
|
|
6
|
+
*/
|
|
7
|
+
let _rl = null;
|
|
8
|
+
function rl() {
|
|
9
|
+
if (!_rl)
|
|
10
|
+
_rl = createInterface({ input: stdin, output: stdout });
|
|
11
|
+
return _rl;
|
|
12
|
+
}
|
|
13
|
+
export async function prompt(question) {
|
|
14
|
+
const r = rl();
|
|
15
|
+
const answer = await r.question(`${question} `);
|
|
16
|
+
return answer.trim();
|
|
17
|
+
}
|
|
18
|
+
export async function promptChoice(title, choices) {
|
|
19
|
+
if (choices.length === 0)
|
|
20
|
+
return null;
|
|
21
|
+
console.log(`\n${title}`);
|
|
22
|
+
choices.forEach((c, i) => console.log(` ${i + 1}. ${c.label}`));
|
|
23
|
+
while (true) {
|
|
24
|
+
const answer = await prompt(`Choice [1-${choices.length}]:`);
|
|
25
|
+
const n = parseInt(answer, 10);
|
|
26
|
+
if (!Number.isNaN(n) && n >= 1 && n <= choices.length)
|
|
27
|
+
return choices[n - 1];
|
|
28
|
+
console.log("Invalid choice.");
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export async function promptConfirm(question) {
|
|
32
|
+
const answer = (await prompt(`${question} (y/N):`)).toLowerCase();
|
|
33
|
+
return answer === "y" || answer === "yes";
|
|
34
|
+
}
|
|
35
|
+
export function closePrompt() {
|
|
36
|
+
if (_rl) {
|
|
37
|
+
_rl.close();
|
|
38
|
+
_rl = null;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../src/lib/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE7C;;;GAGG;AAEH,IAAI,GAAG,GAA8C,IAAI,CAAC;AAC1D,SAAS,EAAE;IACT,IAAI,CAAC,GAAG;QAAE,GAAG,GAAG,eAAe,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAClE,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,QAAgB;IAC3C,MAAM,CAAC,GAAG,EAAE,EAAE,CAAC;IACf,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,QAAQ,CAAC,GAAG,QAAQ,GAAG,CAAC,CAAC;IAChD,OAAO,MAAM,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|
1
1
|
{
|
|
2
2
|
"name": "@forjio/storlaunch-cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Storlaunch CLI —
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Storlaunch CLI — seller tools (storefronts, payments, webhooks) and buyer tools (shop, orders, subs, invoices) in one CLI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"bin": {
|
|
8
|
-
"storlaunch": "
|
|
8
|
+
"storlaunch": "bin/storlaunch.js"
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
11
|
"build": "tsc",
|
|
12
12
|
"dev": "tsc --watch",
|
|
13
13
|
"test": "vitest run --exclude src/__tests__/e2e/**",
|
|
14
14
|
"test:watch": "vitest --exclude src/__tests__/e2e/**",
|
|
15
|
-
"test:e2e": "BACKEND_URL=https://storlaunch.forjio.com/api/v1 vitest run src/__tests__/e2e/"
|
|
15
|
+
"test:e2e": "BACKEND_URL=https://storlaunch.forjio.com/api/v1 vitest run src/__tests__/e2e/",
|
|
16
|
+
"prepublishOnly": "npm run build"
|
|
16
17
|
},
|
|
17
18
|
"dependencies": {
|
|
18
19
|
"chalk": "^5.3.0",
|