@forjio/storlaunch-cli 0.5.0 → 0.7.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.
@@ -0,0 +1,4 @@
1
+ import { Command } from "commander";
2
+ declare const discountCodes: Command;
3
+ export { discountCodes };
4
+ //# sourceMappingURL=discount-codes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discount-codes.d.ts","sourceRoot":"","sources":["../../src/commands/discount-codes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAgCpC,QAAA,MAAM,aAAa,SAAgF,CAAC;AAsNpG,OAAO,EAAE,aAAa,EAAE,CAAC"}
@@ -0,0 +1,264 @@
1
+ import { Command } from "commander";
2
+ import chalk from "chalk";
3
+ import { apiRequest, ApiClientError } from "../lib/api.js";
4
+ import { output } from "../lib/output.js";
5
+ /**
6
+ * `sell discount-codes` — manage promo codes. Maps to /discount-codes CRUD
7
+ * + the public /storefront/public/validate-discount dry-run endpoint.
8
+ */
9
+ function getExitCode(err) {
10
+ if (err instanceof ApiClientError) {
11
+ if (err.status === 401 || err.status === 403)
12
+ return 2;
13
+ if (err.status === 429)
14
+ return 3;
15
+ }
16
+ return 1;
17
+ }
18
+ function handleError(err, json) {
19
+ if (json && err instanceof ApiClientError) {
20
+ console.error(JSON.stringify({ data: null, error: { code: err.code, message: err.message } }, null, 2));
21
+ }
22
+ else {
23
+ console.error(chalk.red(`Error: ${err instanceof Error ? err.message : String(err)}`));
24
+ }
25
+ process.exit(getExitCode(err));
26
+ }
27
+ function parseCsv(value) {
28
+ if (!value)
29
+ return undefined;
30
+ return value.split(",").map((s) => s.trim()).filter(Boolean);
31
+ }
32
+ const discountCodes = new Command("discount-codes").description("Manage discount codes / vouchers");
33
+ discountCodes
34
+ .command("list")
35
+ .description("List discount codes")
36
+ .option("--active", "Only show active codes")
37
+ .option("--limit <n>", "Items per page", parseInt)
38
+ .option("--cursor <cursor>", "Pagination cursor")
39
+ .action(async (opts, cmd) => {
40
+ const g = cmd.optsWithGlobals();
41
+ try {
42
+ const result = await apiRequest("/discount-codes", {
43
+ query: { active: opts.active ? "true" : undefined, limit: opts.limit, cursor: opts.cursor },
44
+ sandbox: g.sandbox,
45
+ });
46
+ if (g.json) {
47
+ output(result, { json: true });
48
+ }
49
+ else {
50
+ const cols = [
51
+ { key: "code", header: "Code", width: 20 },
52
+ { key: "type", header: "Type", width: 18 },
53
+ { key: "value", header: "Value" },
54
+ { key: "currency", header: "Ccy" },
55
+ { key: "scope", header: "Scope", width: 10 },
56
+ { key: "redemptionCount", header: "Used" },
57
+ { key: "active", header: "Active" },
58
+ { key: "expiresAt", header: "Expires", width: 22 },
59
+ ];
60
+ output((result["data"] ?? result), { columns: cols });
61
+ }
62
+ }
63
+ catch (err) {
64
+ handleError(err, g.json);
65
+ }
66
+ });
67
+ discountCodes
68
+ .command("get <id>")
69
+ .description("Get a single discount code")
70
+ .action(async (id, _opts, cmd) => {
71
+ const g = cmd.optsWithGlobals();
72
+ try {
73
+ const result = await apiRequest(`/discount-codes/${id}`, {
74
+ sandbox: g.sandbox,
75
+ });
76
+ output(result, { json: g.json });
77
+ }
78
+ catch (err) {
79
+ handleError(err, g.json);
80
+ }
81
+ });
82
+ discountCodes
83
+ .command("create")
84
+ .description("Create a discount code")
85
+ .requiredOption("--code <code>", "Code the buyer types (normalized to UPPERCASE)")
86
+ .requiredOption("--type <type>", "percent | fixed | shipping_percent | shipping_fixed")
87
+ .requiredOption("--value <n>", "Percent 1-100 OR fixed amount in smallest currency unit", parseInt)
88
+ .requiredOption("--currency <code>", "Currency code (must match cart currency)")
89
+ .option("--description <text>", "Human description / internal note")
90
+ .option("--scope <scope>", "cart | products | tags", "cart")
91
+ .option("--products <ids>", "Comma-separated product IDs (scope=products)")
92
+ .option("--tags <tags>", "Comma-separated product tags (scope=tags)")
93
+ .option("--min-purchase <n>", "Minimum subtotal required", parseInt)
94
+ .option("--max-uses <n>", "Global maximum redemptions", parseInt)
95
+ .option("--max-per-customer <n>", "Per-customer redemption cap", parseInt)
96
+ .option("--starts <iso>", "ISO-8601 datetime (not-yet-active before this)")
97
+ .option("--expires <iso>", "ISO-8601 datetime (expired after this)")
98
+ .option("--inactive", "Create in inactive state")
99
+ .action(async (opts, cmd) => {
100
+ const g = cmd.optsWithGlobals();
101
+ try {
102
+ const body = {
103
+ code: opts.code,
104
+ type: opts.type,
105
+ value: opts.value,
106
+ currency: opts.currency,
107
+ };
108
+ if (opts.description)
109
+ body["description"] = opts.description;
110
+ if (opts.scope)
111
+ body["scope"] = opts.scope;
112
+ const products = parseCsv(opts.products);
113
+ if (products)
114
+ body["productIds"] = products;
115
+ const tags = parseCsv(opts.tags);
116
+ if (tags)
117
+ body["tagFilter"] = tags;
118
+ if (opts.minPurchase !== undefined)
119
+ body["minPurchaseAmount"] = opts.minPurchase;
120
+ if (opts.maxUses !== undefined)
121
+ body["maxUsesTotal"] = opts.maxUses;
122
+ if (opts.maxPerCustomer !== undefined)
123
+ body["maxUsesPerCustomer"] = opts.maxPerCustomer;
124
+ if (opts.starts)
125
+ body["startsAt"] = opts.starts;
126
+ if (opts.expires)
127
+ body["expiresAt"] = opts.expires;
128
+ if (opts.inactive)
129
+ body["active"] = false;
130
+ const result = await apiRequest("/discount-codes", {
131
+ method: "POST",
132
+ body,
133
+ sandbox: g.sandbox,
134
+ });
135
+ if (g.json) {
136
+ output(result, { json: true });
137
+ }
138
+ else {
139
+ const data = (result["data"] ?? result);
140
+ console.log(chalk.green(`Discount code created: ${String(data["code"])}`));
141
+ console.log(chalk.dim(`ID: ${String(data["id"])}`));
142
+ }
143
+ }
144
+ catch (err) {
145
+ handleError(err, g.json);
146
+ }
147
+ });
148
+ discountCodes
149
+ .command("update <id>")
150
+ .description("Update a discount code (code string itself is immutable)")
151
+ .option("--description <text>", "New description")
152
+ .option("--value <n>", "New value", parseInt)
153
+ .option("--min-purchase <n>", "New min purchase", parseInt)
154
+ .option("--max-uses <n>", "New global max", parseInt)
155
+ .option("--max-per-customer <n>", "New per-customer max", parseInt)
156
+ .option("--expires <iso>", "New expiry ISO-8601")
157
+ .option("--active", "Reactivate")
158
+ .option("--inactive", "Deactivate")
159
+ .action(async (id, opts, cmd) => {
160
+ const g = cmd.optsWithGlobals();
161
+ try {
162
+ const body = {};
163
+ if (opts.description !== undefined)
164
+ body["description"] = opts.description;
165
+ if (opts.value !== undefined)
166
+ body["value"] = opts.value;
167
+ if (opts.minPurchase !== undefined)
168
+ body["minPurchaseAmount"] = opts.minPurchase;
169
+ if (opts.maxUses !== undefined)
170
+ body["maxUsesTotal"] = opts.maxUses;
171
+ if (opts.maxPerCustomer !== undefined)
172
+ body["maxUsesPerCustomer"] = opts.maxPerCustomer;
173
+ if (opts.expires)
174
+ body["expiresAt"] = opts.expires;
175
+ if (opts.active)
176
+ body["active"] = true;
177
+ if (opts.inactive)
178
+ body["active"] = false;
179
+ const result = await apiRequest(`/discount-codes/${id}`, {
180
+ method: "PATCH",
181
+ body,
182
+ sandbox: g.sandbox,
183
+ });
184
+ if (g.json) {
185
+ output(result, { json: true });
186
+ }
187
+ else {
188
+ console.log(chalk.green(`Discount code ${id} updated.`));
189
+ }
190
+ }
191
+ catch (err) {
192
+ handleError(err, g.json);
193
+ }
194
+ });
195
+ discountCodes
196
+ .command("delete <id>")
197
+ .description("Soft-archive a discount code (deactivates without deleting history)")
198
+ .action(async (id, _opts, cmd) => {
199
+ const g = cmd.optsWithGlobals();
200
+ try {
201
+ await apiRequest(`/discount-codes/${id}`, { method: "DELETE", sandbox: g.sandbox });
202
+ if (g.json) {
203
+ output({ id, active: false }, { json: true });
204
+ }
205
+ else {
206
+ console.log(chalk.green(`Discount code ${id} deactivated.`));
207
+ }
208
+ }
209
+ catch (err) {
210
+ handleError(err, g.json);
211
+ }
212
+ });
213
+ discountCodes
214
+ .command("validate")
215
+ .description("Dry-run validate a code against a simulated cart (no commit)")
216
+ .requiredOption("--merchant <slug>", "Merchant slug")
217
+ .requiredOption("--code <code>", "Discount code to validate")
218
+ .requiredOption("--subtotal <n>", "Cart subtotal (smallest currency unit)", parseInt)
219
+ .requiredOption("--currency <code>", "Currency")
220
+ .option("--shipping <n>", "Shipping cost", parseInt, 0)
221
+ .option("--items <json>", "JSON array of items [{productId, price, quantity, tags}]")
222
+ .action(async (opts, cmd) => {
223
+ const g = cmd.optsWithGlobals();
224
+ try {
225
+ const { resolveApiUrl } = await import("../lib/config.js");
226
+ const baseUrl = resolveApiUrl();
227
+ const url = new URL(`/storefront/public/validate-discount`, baseUrl.endsWith("/") ? baseUrl : baseUrl + "/");
228
+ const body = {
229
+ merchantSlug: opts.merchant,
230
+ code: opts.code,
231
+ subtotal: opts.subtotal,
232
+ currency: opts.currency,
233
+ shipping: opts.shipping ?? 0,
234
+ };
235
+ if (opts.items) {
236
+ try {
237
+ body["items"] = JSON.parse(opts.items);
238
+ }
239
+ catch {
240
+ console.error(chalk.red("Error: --items must be valid JSON array"));
241
+ process.exit(1);
242
+ }
243
+ }
244
+ const response = await fetch(url.toString(), {
245
+ method: "POST",
246
+ headers: { "Content-Type": "application/json", Accept: "application/json" },
247
+ body: JSON.stringify(body),
248
+ });
249
+ const data = (await response.json());
250
+ if (!response.ok) {
251
+ throw new ApiClientError({
252
+ status: response.status,
253
+ message: data.error?.message ?? `Validation failed with status ${response.status}`,
254
+ code: data.error?.code,
255
+ });
256
+ }
257
+ output(data, { json: g.json });
258
+ }
259
+ catch (err) {
260
+ handleError(err, g.json);
261
+ }
262
+ });
263
+ export { discountCodes };
264
+ //# sourceMappingURL=discount-codes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discount-codes.js","sourceRoot":"","sources":["../../src/commands/discount-codes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AA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MAAM,EAAE;gBACxH,IAAI,EAAG,IAAsC,CAAC,KAAK,EAAE,IAAI;aAC1D,CAAC,CAAC;QACL,CAAC;QACD,MAAM,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IACjC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,WAAW,CAAC,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;AACH,CAAC,CAAC,CAAC;AAEL,OAAO,EAAE,aAAa,EAAE,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { Command } from "commander";
2
+ declare const payouts: Command;
3
+ export { payouts };
4
+ //# sourceMappingURL=payouts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payouts.d.ts","sourceRoot":"","sources":["../../src/commands/payouts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA+EpC,QAAA,MAAM,OAAO,SAAgE,CAAC;AA8H9E,OAAO,EAAE,OAAO,EAAE,CAAC"}
@@ -0,0 +1,208 @@
1
+ import { Command } from "commander";
2
+ import chalk from "chalk";
3
+ import { apiRequest, ApiClientError } from "../lib/api.js";
4
+ import { output } from "../lib/output.js";
5
+ /**
6
+ * `sell payouts` — withdraw funds to the merchant bank. Manual mode for
7
+ * now (platform operator wires money + marks paid). Commands mirror the
8
+ * REST routes at /api/v1/payouts/*.
9
+ */
10
+ function getExitCode(err) {
11
+ if (err instanceof ApiClientError) {
12
+ if (err.status === 401 || err.status === 403)
13
+ return 2;
14
+ if (err.status === 429)
15
+ return 3;
16
+ }
17
+ return 1;
18
+ }
19
+ function handleError(err, json) {
20
+ if (json && err instanceof ApiClientError) {
21
+ console.error(JSON.stringify({ data: null, error: { code: err.code, message: err.message } }, null, 2));
22
+ }
23
+ else {
24
+ console.error(chalk.red(`Error: ${err instanceof Error ? err.message : String(err)}`));
25
+ }
26
+ process.exit(getExitCode(err));
27
+ }
28
+ // ─── Bank account ────────────────────────────────────────────
29
+ const bankAccount = new Command("bank-account").description("Default payout bank account");
30
+ bankAccount
31
+ .command("get")
32
+ .description("Show the current default bank account")
33
+ .action(async (_opts, cmd) => {
34
+ const g = cmd.optsWithGlobals();
35
+ try {
36
+ const result = await apiRequest("/payouts/bank-account", {
37
+ sandbox: g.sandbox,
38
+ });
39
+ output(result, { json: g.json });
40
+ }
41
+ catch (err) {
42
+ handleError(err, g.json);
43
+ }
44
+ });
45
+ bankAccount
46
+ .command("set")
47
+ .description("Set the default bank account")
48
+ .requiredOption("--name <name>", "Bank name (e.g. 'Bank Central Asia')")
49
+ .requiredOption("--number <number>", "Bank account number")
50
+ .requiredOption("--holder <name>", "Account holder name (as on passbook)")
51
+ .option("--code <code>", "Bank code (e.g. BCA, MANDIRI, BNI)")
52
+ .action(async (opts, cmd) => {
53
+ const g = cmd.optsWithGlobals();
54
+ try {
55
+ const result = await apiRequest("/payouts/bank-account", {
56
+ method: "PATCH",
57
+ body: {
58
+ bankName: opts.name,
59
+ bankAccountNumber: opts.number,
60
+ bankAccountHolder: opts.holder,
61
+ bankCode: opts.code ?? null,
62
+ },
63
+ sandbox: g.sandbox,
64
+ });
65
+ if (g.json) {
66
+ output(result, { json: true });
67
+ }
68
+ else {
69
+ console.log(chalk.green(`Bank account saved: ${opts.name} · ${opts.number} · ${opts.holder}`));
70
+ }
71
+ }
72
+ catch (err) {
73
+ handleError(err, g.json);
74
+ }
75
+ });
76
+ // ─── Payouts ─────────────────────────────────────────────────
77
+ const payouts = new Command("payouts").description("Manage merchant payouts");
78
+ payouts.addCommand(bankAccount);
79
+ payouts
80
+ .command("balance")
81
+ .description("Show available payout balance (ledger − in-flight)")
82
+ .action(async (_opts, cmd) => {
83
+ const g = cmd.optsWithGlobals();
84
+ try {
85
+ const result = await apiRequest("/payouts/balance", {
86
+ sandbox: g.sandbox,
87
+ });
88
+ output(result, { json: g.json });
89
+ }
90
+ catch (err) {
91
+ handleError(err, g.json);
92
+ }
93
+ });
94
+ payouts
95
+ .command("list")
96
+ .description("List payouts")
97
+ .option("--status <status>", "Filter: pending | in_transit | paid | failed | cancelled")
98
+ .option("--limit <n>", "Items per page", parseInt)
99
+ .option("--cursor <cursor>", "Pagination cursor")
100
+ .action(async (opts, cmd) => {
101
+ const g = cmd.optsWithGlobals();
102
+ try {
103
+ const result = await apiRequest("/payouts", {
104
+ query: { status: opts.status, limit: opts.limit, cursor: opts.cursor },
105
+ sandbox: g.sandbox,
106
+ });
107
+ if (g.json) {
108
+ output(result, { json: true });
109
+ }
110
+ else {
111
+ const cols = [
112
+ { key: "id", header: "ID", width: 24 },
113
+ { key: "requestedAt", header: "Requested", width: 20 },
114
+ { key: "amount", header: "Amount" },
115
+ { key: "currency", header: "Ccy" },
116
+ { key: "status", header: "Status", width: 12 },
117
+ { key: "bankName", header: "Bank", width: 16 },
118
+ { key: "reference", header: "Ref", width: 16 },
119
+ ];
120
+ output((result["data"] ?? result), { columns: cols });
121
+ }
122
+ }
123
+ catch (err) {
124
+ handleError(err, g.json);
125
+ }
126
+ });
127
+ payouts
128
+ .command("get <id>")
129
+ .description("Get a single payout")
130
+ .action(async (id, _opts, cmd) => {
131
+ const g = cmd.optsWithGlobals();
132
+ try {
133
+ const result = await apiRequest(`/payouts/${id}`, {
134
+ sandbox: g.sandbox,
135
+ });
136
+ output(result, { json: g.json });
137
+ }
138
+ catch (err) {
139
+ handleError(err, g.json);
140
+ }
141
+ });
142
+ payouts
143
+ .command("create")
144
+ .description("Request a new payout (uses default bank unless override passed)")
145
+ .requiredOption("--amount <n>", "Amount in smallest currency unit", parseInt)
146
+ .requiredOption("--currency <code>", "Currency code (IDR, USD)")
147
+ .option("--note <text>", "Free-text note on the payout")
148
+ .option("--bank-name <name>", "Override default bank name for this payout")
149
+ .option("--bank-number <number>", "Override default bank account number")
150
+ .option("--bank-holder <name>", "Override default account holder")
151
+ .option("--bank-code <code>", "Override default bank code")
152
+ .action(async (opts, cmd) => {
153
+ const g = cmd.optsWithGlobals();
154
+ try {
155
+ const body = {
156
+ amount: opts.amount,
157
+ currency: opts.currency,
158
+ };
159
+ if (opts.note)
160
+ body["note"] = opts.note;
161
+ if (opts.bankName)
162
+ body["bankName"] = opts.bankName;
163
+ if (opts.bankNumber)
164
+ body["bankAccountNumber"] = opts.bankNumber;
165
+ if (opts.bankHolder)
166
+ body["bankAccountHolder"] = opts.bankHolder;
167
+ if (opts.bankCode)
168
+ body["bankCode"] = opts.bankCode;
169
+ const result = await apiRequest("/payouts", {
170
+ method: "POST",
171
+ body,
172
+ sandbox: g.sandbox,
173
+ });
174
+ if (g.json) {
175
+ output(result, { json: true });
176
+ }
177
+ else {
178
+ const d = (result["data"] ?? result);
179
+ console.log(chalk.green(`Payout requested: ${String(d["id"])} (status: ${d["status"]})`));
180
+ }
181
+ }
182
+ catch (err) {
183
+ handleError(err, g.json);
184
+ }
185
+ });
186
+ payouts
187
+ .command("cancel <id>")
188
+ .description("Cancel a pending payout (fails if already processing)")
189
+ .action(async (id, _opts, cmd) => {
190
+ const g = cmd.optsWithGlobals();
191
+ try {
192
+ const result = await apiRequest(`/payouts/${id}/cancel`, {
193
+ method: "POST",
194
+ sandbox: g.sandbox,
195
+ });
196
+ if (g.json) {
197
+ output(result, { json: true });
198
+ }
199
+ else {
200
+ console.log(chalk.green(`Payout ${id} cancelled.`));
201
+ }
202
+ }
203
+ catch (err) {
204
+ handleError(err, g.json);
205
+ }
206
+ });
207
+ export { payouts };
208
+ //# sourceMappingURL=payouts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payouts.js","sourceRoot":"","sources":["../../src/commands/payouts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAe,MAAM,kBAAkB,CAAC;AAEvD;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C;KACtB,WAAW,CAAC,uDAAuD,CAAC;KACpE,MAAM,CAAC,KAAK,EAAE,EAAU,EAAE,KAAK,EAAE,GAAY,EAAE,EAAE;IAChD,MAAM,CAAC,GAAG,GAAG,CAAC,eAAe,EAAyC,CAAC;IACvE,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,UAAU,CAA0B,YAAY,EAAE,SAAS,EAAE;YAChF,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,CAAC,CAAC,OAAO;SACnB,CAAC,CAAC;QACH,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;YACX,MAAM,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QACjC,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,WAAW,CAAC,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;AACH,CAAC,CAAC,CAAC;AAEL,OAAO,EAAE,OAAO,EAAE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"sell.d.ts","sourceRoot":"","sources":["../../src/commands/sell.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAWpC;;;;GAIG;AACH,eAAO,MAAM,IAAI,SAAoF,CAAC"}
1
+ {"version":3,"file":"sell.d.ts","sourceRoot":"","sources":["../../src/commands/sell.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAapC;;;;GAIG;AACH,eAAO,MAAM,IAAI,SAAoF,CAAC"}
@@ -8,6 +8,8 @@ import { inventory } from "./inventory.js";
8
8
  import { shipping } from "./shipping.js";
9
9
  import { ledger } from "./ledger.js";
10
10
  import { reports } from "./reports.js";
11
+ import { payouts } from "./payouts.js";
12
+ import { discountCodes } from "./discount-codes.js";
11
13
  /**
12
14
  * `sell` — seller-side commands. Wraps existing command modules as
13
15
  * subcommands. 0.3.0 adds inventory (variants/warehouses/stock) and
@@ -21,6 +23,8 @@ sell.addCommand(inventory);
21
23
  sell.addCommand(shipping);
22
24
  sell.addCommand(ledger);
23
25
  sell.addCommand(reports);
26
+ sell.addCommand(payouts);
27
+ sell.addCommand(discountCodes);
24
28
  sell.addCommand(webhook);
25
29
  sell.addCommand(config);
26
30
  //# sourceMappingURL=sell.js.map
@@ -1 +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;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC;;;;GAIG;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,SAAS,CAAC,CAAC;AAC3B,IAAI,C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AC,QAAQ,CAAC,CAAC;AAC1B,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;AACxB,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;AACzB,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;AACzB,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;AAC/B,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;AACzB,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@forjio/storlaunch-cli",
3
- "version": "0.5.0",
4
- "description": "Storlaunch CLI — seller tools (storefronts, inventory, shipping, ledger, reports, payments, webhooks) and buyer tools (shop, orders, subs, invoices) in one CLI",
3
+ "version": "0.7.0",
4
+ "description": "Storlaunch CLI — seller tools (storefronts, inventory, shipping, ledger, reports, payouts, discount-codes, 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": {