@01.software/cli 0.1.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.
- package/dist/index.js +649 -0
- package/dist/index.js.map +1 -0
- package/package.json +38 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,649 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/index.ts
|
|
4
|
+
import { createRequire } from "module";
|
|
5
|
+
import { Command } from "commander";
|
|
6
|
+
|
|
7
|
+
// src/lib/client.ts
|
|
8
|
+
import { CollectionClient, OrderApi, CartApi, ProductApi, parseApiKey } from "@01.software/sdk";
|
|
9
|
+
import pc from "picocolors";
|
|
10
|
+
|
|
11
|
+
// src/lib/credentials.ts
|
|
12
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync, unlinkSync } from "fs";
|
|
13
|
+
import { join } from "path";
|
|
14
|
+
import { homedir } from "os";
|
|
15
|
+
var DIR_NAME = ".01software";
|
|
16
|
+
var FILE_NAME = "credentials.json";
|
|
17
|
+
function getCredentialsPath() {
|
|
18
|
+
return join(homedir(), DIR_NAME, FILE_NAME);
|
|
19
|
+
}
|
|
20
|
+
function loadCredentials() {
|
|
21
|
+
const filePath = getCredentialsPath();
|
|
22
|
+
if (!existsSync(filePath)) return null;
|
|
23
|
+
try {
|
|
24
|
+
const raw = readFileSync(filePath, "utf-8");
|
|
25
|
+
const data = JSON.parse(raw);
|
|
26
|
+
if (!data.clientKey || !data.secretKey) return null;
|
|
27
|
+
return data;
|
|
28
|
+
} catch {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function saveCredentials(creds) {
|
|
33
|
+
const dir = join(homedir(), DIR_NAME);
|
|
34
|
+
if (!existsSync(dir)) {
|
|
35
|
+
mkdirSync(dir, { recursive: true, mode: 448 });
|
|
36
|
+
}
|
|
37
|
+
const filePath = getCredentialsPath();
|
|
38
|
+
const data = { ...creds, storedAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
39
|
+
writeFileSync(filePath, JSON.stringify(data, null, 2), { encoding: "utf-8", mode: 384 });
|
|
40
|
+
}
|
|
41
|
+
function deleteCredentials() {
|
|
42
|
+
const filePath = getCredentialsPath();
|
|
43
|
+
if (!existsSync(filePath)) return false;
|
|
44
|
+
unlinkSync(filePath);
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// src/lib/client.ts
|
|
49
|
+
function resolveClient(apiKeyFlag) {
|
|
50
|
+
let clientKey;
|
|
51
|
+
let secretKey;
|
|
52
|
+
if (apiKeyFlag) {
|
|
53
|
+
try {
|
|
54
|
+
const parsed = parseApiKey(apiKeyFlag);
|
|
55
|
+
clientKey = parsed.clientKey;
|
|
56
|
+
secretKey = parsed.secretKey;
|
|
57
|
+
} catch {
|
|
58
|
+
console.error(pc.red('Invalid --api-key value. Expected Base64-encoded "clientKey:secretKey".'));
|
|
59
|
+
process.exit(1);
|
|
60
|
+
}
|
|
61
|
+
} else {
|
|
62
|
+
clientKey = process.env.SOFTWARE_CLIENT_KEY;
|
|
63
|
+
secretKey = process.env.SOFTWARE_SECRET_KEY;
|
|
64
|
+
}
|
|
65
|
+
if (!clientKey || !secretKey) {
|
|
66
|
+
const stored = loadCredentials();
|
|
67
|
+
if (stored) {
|
|
68
|
+
clientKey = stored.clientKey;
|
|
69
|
+
secretKey = stored.secretKey;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (!clientKey || !secretKey) {
|
|
73
|
+
console.error(pc.red("Authentication required."));
|
|
74
|
+
console.error(
|
|
75
|
+
pc.dim(
|
|
76
|
+
'Run "01 login" to authenticate via browser,\nor set SOFTWARE_CLIENT_KEY and SOFTWARE_SECRET_KEY environment variables,\nor use the --api-key <base64> flag.'
|
|
77
|
+
)
|
|
78
|
+
);
|
|
79
|
+
process.exit(1);
|
|
80
|
+
}
|
|
81
|
+
const apiOpts = { clientKey, secretKey };
|
|
82
|
+
return {
|
|
83
|
+
collections: new CollectionClient(clientKey, secretKey),
|
|
84
|
+
api: new OrderApi(apiOpts),
|
|
85
|
+
cart: new CartApi(apiOpts),
|
|
86
|
+
product: new ProductApi(apiOpts)
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// src/lib/output.ts
|
|
91
|
+
import pc2 from "picocolors";
|
|
92
|
+
function printJson(data) {
|
|
93
|
+
console.log(JSON.stringify(data, null, 2));
|
|
94
|
+
}
|
|
95
|
+
function printTable(data) {
|
|
96
|
+
if (Array.isArray(data)) {
|
|
97
|
+
if (data.length === 0) {
|
|
98
|
+
console.log(pc2.dim("(empty)"));
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const keys = Object.keys(data[0]);
|
|
102
|
+
const widths = keys.map(
|
|
103
|
+
(k) => Math.max(k.length, ...data.map((row) => String(row[k] ?? "").length))
|
|
104
|
+
);
|
|
105
|
+
console.log(keys.map((k, i) => k.padEnd(widths[i])).join(" "));
|
|
106
|
+
console.log(keys.map((_, i) => "-".repeat(widths[i])).join(" "));
|
|
107
|
+
for (const row of data) {
|
|
108
|
+
console.log(
|
|
109
|
+
keys.map((k, i) => String(row[k] ?? "").padEnd(widths[i])).join(" ")
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
} else if (data && typeof data === "object") {
|
|
113
|
+
const entries = Object.entries(data);
|
|
114
|
+
const maxKey = Math.max(...entries.map(([k]) => k.length));
|
|
115
|
+
for (const [key, value] of entries) {
|
|
116
|
+
const display = typeof value === "object" ? JSON.stringify(value) : String(value);
|
|
117
|
+
console.log(`${pc2.bold(key.padEnd(maxKey))} ${display}`);
|
|
118
|
+
}
|
|
119
|
+
} else {
|
|
120
|
+
console.log(String(data));
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
function printResult(data, format) {
|
|
124
|
+
if (format === "table") {
|
|
125
|
+
if (data && typeof data === "object" && "docs" in data) {
|
|
126
|
+
const resp = data;
|
|
127
|
+
printTable(resp.docs);
|
|
128
|
+
console.log(pc2.dim(`
|
|
129
|
+
${resp.totalDocs} total | page ${resp.page}/${resp.totalPages}`));
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
printTable(data);
|
|
133
|
+
} else {
|
|
134
|
+
printJson(data);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
function printError(error) {
|
|
138
|
+
if (error && typeof error === "object" && "message" in error) {
|
|
139
|
+
const err = error;
|
|
140
|
+
console.error(pc2.red(`Error: ${err.message}`));
|
|
141
|
+
if (err.code) console.error(pc2.dim(`Code: ${err.code}`));
|
|
142
|
+
if (err.status) console.error(pc2.dim(`Status: ${err.status}`));
|
|
143
|
+
if (err.suggestion) console.error(pc2.yellow(err.suggestion));
|
|
144
|
+
} else {
|
|
145
|
+
console.error(pc2.red(String(error)));
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// src/commands/crud.ts
|
|
150
|
+
import { COLLECTIONS } from "@01.software/sdk";
|
|
151
|
+
|
|
152
|
+
// src/lib/parse.ts
|
|
153
|
+
import pc3 from "picocolors";
|
|
154
|
+
function parseJson(value, label) {
|
|
155
|
+
try {
|
|
156
|
+
const parsed = JSON.parse(value);
|
|
157
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
158
|
+
console.error(pc3.red(`--${label} must be a JSON object.`));
|
|
159
|
+
process.exit(1);
|
|
160
|
+
}
|
|
161
|
+
return parsed;
|
|
162
|
+
} catch {
|
|
163
|
+
console.error(pc3.red(`Invalid JSON for --${label}: ${value}`));
|
|
164
|
+
process.exit(1);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
function parseJsonArray(value, label) {
|
|
168
|
+
try {
|
|
169
|
+
const parsed = JSON.parse(value);
|
|
170
|
+
if (!Array.isArray(parsed)) {
|
|
171
|
+
console.error(pc3.red(`--${label} must be a JSON array.`));
|
|
172
|
+
process.exit(1);
|
|
173
|
+
}
|
|
174
|
+
return parsed;
|
|
175
|
+
} catch {
|
|
176
|
+
console.error(pc3.red(`Invalid JSON for --${label}: ${value}`));
|
|
177
|
+
process.exit(1);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// src/commands/crud.ts
|
|
182
|
+
var collectionList = COLLECTIONS.join(", ");
|
|
183
|
+
function validateCollection(name) {
|
|
184
|
+
if (!COLLECTIONS.includes(name)) {
|
|
185
|
+
throw new Error(`Unknown collection "${name}". Available: ${collectionList}`);
|
|
186
|
+
}
|
|
187
|
+
return name;
|
|
188
|
+
}
|
|
189
|
+
function registerCrudCommands(program2, getClient2, getFormat2) {
|
|
190
|
+
program2.command("query <collection>").description("Query documents from a collection").option("--where <json>", "Filter conditions (JSON)").option("--limit <n>", "Max results", (v) => parseInt(v, 10)).option("--page <n>", "Page number", (v) => parseInt(v, 10)).option("--sort <field>", "Sort field (prefix with - for descending)").action(async (collection, opts) => {
|
|
191
|
+
try {
|
|
192
|
+
const col = validateCollection(collection);
|
|
193
|
+
const client = getClient2();
|
|
194
|
+
const options = {};
|
|
195
|
+
if (opts.where) options.where = parseJson(opts.where, "where");
|
|
196
|
+
if (opts.limit) options.limit = opts.limit;
|
|
197
|
+
if (opts.page) options.page = opts.page;
|
|
198
|
+
if (opts.sort) options.sort = opts.sort;
|
|
199
|
+
const result = await client.collections.from(col).find(options);
|
|
200
|
+
printResult(result, getFormat2());
|
|
201
|
+
} catch (e) {
|
|
202
|
+
printError(e);
|
|
203
|
+
process.exit(1);
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
program2.command("get <collection> <id>").description("Get a document by ID").action(async (collection, id) => {
|
|
207
|
+
try {
|
|
208
|
+
const col = validateCollection(collection);
|
|
209
|
+
const client = getClient2();
|
|
210
|
+
const result = await client.collections.from(col).findById(id);
|
|
211
|
+
printResult(result, getFormat2());
|
|
212
|
+
} catch (e) {
|
|
213
|
+
printError(e);
|
|
214
|
+
process.exit(1);
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
program2.command("create <collection>").description("Create a new document").requiredOption("--data <json>", "Document data (JSON)").action(async (collection, opts) => {
|
|
218
|
+
try {
|
|
219
|
+
const col = validateCollection(collection);
|
|
220
|
+
const client = getClient2();
|
|
221
|
+
const data = parseJson(opts.data, "data");
|
|
222
|
+
const result = await client.collections.from(col).create(data);
|
|
223
|
+
printResult(result, getFormat2());
|
|
224
|
+
} catch (e) {
|
|
225
|
+
printError(e);
|
|
226
|
+
process.exit(1);
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
program2.command("update <collection> <id>").description("Update a document by ID").requiredOption("--data <json>", "Document data (JSON)").action(async (collection, id, opts) => {
|
|
230
|
+
try {
|
|
231
|
+
const col = validateCollection(collection);
|
|
232
|
+
const client = getClient2();
|
|
233
|
+
const data = parseJson(opts.data, "data");
|
|
234
|
+
const result = await client.collections.from(col).update(id, data);
|
|
235
|
+
printResult(result, getFormat2());
|
|
236
|
+
} catch (e) {
|
|
237
|
+
printError(e);
|
|
238
|
+
process.exit(1);
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
program2.command("delete <collection> <id>").description("Delete a document by ID").action(async (collection, id) => {
|
|
242
|
+
try {
|
|
243
|
+
const col = validateCollection(collection);
|
|
244
|
+
const client = getClient2();
|
|
245
|
+
const result = await client.collections.from(col).remove(id);
|
|
246
|
+
printResult(result, getFormat2());
|
|
247
|
+
} catch (e) {
|
|
248
|
+
printError(e);
|
|
249
|
+
process.exit(1);
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
program2.command("update-many <collection>").description("Update multiple documents matching a filter").requiredOption("--where <json>", "Filter conditions (JSON)").requiredOption("--data <json>", "Update data (JSON)").action(async (collection, opts) => {
|
|
253
|
+
try {
|
|
254
|
+
const col = validateCollection(collection);
|
|
255
|
+
const client = getClient2();
|
|
256
|
+
const where = parseJson(opts.where, "where");
|
|
257
|
+
const data = parseJson(opts.data, "data");
|
|
258
|
+
const result = await client.collections.from(col).updateMany(where, data);
|
|
259
|
+
printResult(result, getFormat2());
|
|
260
|
+
} catch (e) {
|
|
261
|
+
printError(e);
|
|
262
|
+
process.exit(1);
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
program2.command("delete-many <collection>").description("Delete multiple documents matching a filter").requiredOption("--where <json>", "Filter conditions (JSON)").action(async (collection, opts) => {
|
|
266
|
+
try {
|
|
267
|
+
const col = validateCollection(collection);
|
|
268
|
+
const client = getClient2();
|
|
269
|
+
const where = parseJson(opts.where, "where");
|
|
270
|
+
const result = await client.collections.from(col).removeMany(where);
|
|
271
|
+
printResult(result, getFormat2());
|
|
272
|
+
} catch (e) {
|
|
273
|
+
printError(e);
|
|
274
|
+
process.exit(1);
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// src/commands/order.ts
|
|
280
|
+
function registerOrderCommands(program2, getClient2, getFormat2) {
|
|
281
|
+
const order = program2.command("order").description("Order management");
|
|
282
|
+
order.command("create").description("Create a new order").requiredOption("--payment-id <id>", "Payment ID").requiredOption("--order-number <num>", "Order number").requiredOption("--email <email>", "Customer email").requiredOption("--shipping-address <json>", "Shipping address (JSON)").requiredOption("--products <json>", "Order products array (JSON)").requiredOption("--total-amount <n>", "Total amount", parseFloat).action(async (opts) => {
|
|
283
|
+
try {
|
|
284
|
+
const client = getClient2();
|
|
285
|
+
const result = await client.api.createOrder({
|
|
286
|
+
paymentId: opts.paymentId,
|
|
287
|
+
orderNumber: opts.orderNumber,
|
|
288
|
+
email: opts.email,
|
|
289
|
+
shippingAddress: parseJson(opts.shippingAddress, "shipping-address"),
|
|
290
|
+
orderProducts: parseJsonArray(opts.products, "products"),
|
|
291
|
+
totalAmount: opts.totalAmount
|
|
292
|
+
});
|
|
293
|
+
printResult(result, getFormat2());
|
|
294
|
+
} catch (e) {
|
|
295
|
+
printError(e);
|
|
296
|
+
process.exit(1);
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
order.command("get <orderNumber>").description("Get an order by order number").action(async (orderNumber) => {
|
|
300
|
+
try {
|
|
301
|
+
const client = getClient2();
|
|
302
|
+
const result = await client.api.getOrder({ orderNumber });
|
|
303
|
+
printResult(result, getFormat2());
|
|
304
|
+
} catch (e) {
|
|
305
|
+
printError(e);
|
|
306
|
+
process.exit(1);
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
order.command("update <orderNumber>").description("Update order status").requiredOption("--status <status>", "New status").action(async (orderNumber, opts) => {
|
|
310
|
+
try {
|
|
311
|
+
const client = getClient2();
|
|
312
|
+
const result = await client.api.updateOrder({
|
|
313
|
+
orderNumber,
|
|
314
|
+
status: opts.status
|
|
315
|
+
});
|
|
316
|
+
printResult(result, getFormat2());
|
|
317
|
+
} catch (e) {
|
|
318
|
+
printError(e);
|
|
319
|
+
process.exit(1);
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
order.command("checkout").description("Convert a cart to an order").requiredOption("--cart-id <id>", "Cart ID").requiredOption("--payment-id <id>", "Payment ID").requiredOption("--order-number <num>", "Order number").requiredOption("--customer <json>", "Customer snapshot (JSON)").action(async (opts) => {
|
|
323
|
+
try {
|
|
324
|
+
const client = getClient2();
|
|
325
|
+
const result = await client.api.checkout({
|
|
326
|
+
cartId: opts.cartId,
|
|
327
|
+
paymentId: opts.paymentId,
|
|
328
|
+
orderNumber: opts.orderNumber,
|
|
329
|
+
customerSnapshot: parseJson(opts.customer, "customer")
|
|
330
|
+
});
|
|
331
|
+
printResult(result, getFormat2());
|
|
332
|
+
} catch (e) {
|
|
333
|
+
printError(e);
|
|
334
|
+
process.exit(1);
|
|
335
|
+
}
|
|
336
|
+
});
|
|
337
|
+
order.command("fulfill <orderNumber>").description("Create a fulfillment for an order").requiredOption("--items <json>", "Fulfillment items array (JSON)").option("--carrier <name>", "Shipping carrier").option("--tracking-number <num>", "Tracking number").action(async (orderNumber, opts) => {
|
|
338
|
+
try {
|
|
339
|
+
const client = getClient2();
|
|
340
|
+
const result = await client.api.createFulfillment({
|
|
341
|
+
orderNumber,
|
|
342
|
+
items: parseJsonArray(opts.items, "items"),
|
|
343
|
+
carrier: opts.carrier,
|
|
344
|
+
trackingNumber: opts.trackingNumber
|
|
345
|
+
});
|
|
346
|
+
printResult(result, getFormat2());
|
|
347
|
+
} catch (e) {
|
|
348
|
+
printError(e);
|
|
349
|
+
process.exit(1);
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
// src/commands/return.ts
|
|
355
|
+
function registerReturnCommands(program2, getClient2, getFormat2) {
|
|
356
|
+
const ret = program2.command("return").description("Return management");
|
|
357
|
+
ret.command("create <orderNumber>").description("Create a return request").requiredOption("--products <json>", "Return products array (JSON)").requiredOption("--refund-amount <n>", "Refund amount", parseFloat).option("--reason <reason>", "Return reason (change_of_mind, defective, wrong_delivery, damaged, other)").option("--reason-detail <text>", "Detailed reason").action(async (orderNumber, opts) => {
|
|
358
|
+
try {
|
|
359
|
+
const client = getClient2();
|
|
360
|
+
const result = await client.api.createReturn({
|
|
361
|
+
orderNumber,
|
|
362
|
+
returnProducts: parseJsonArray(opts.products, "products"),
|
|
363
|
+
refundAmount: opts.refundAmount,
|
|
364
|
+
reason: opts.reason,
|
|
365
|
+
reasonDetail: opts.reasonDetail
|
|
366
|
+
});
|
|
367
|
+
printResult(result, getFormat2());
|
|
368
|
+
} catch (e) {
|
|
369
|
+
printError(e);
|
|
370
|
+
process.exit(1);
|
|
371
|
+
}
|
|
372
|
+
});
|
|
373
|
+
ret.command("update <returnId>").description("Update return status").requiredOption("--status <status>", "New status (processing, approved, rejected, completed)").action(async (returnId, opts) => {
|
|
374
|
+
try {
|
|
375
|
+
const client = getClient2();
|
|
376
|
+
const result = await client.api.updateReturn({
|
|
377
|
+
returnId,
|
|
378
|
+
status: opts.status
|
|
379
|
+
});
|
|
380
|
+
printResult(result, getFormat2());
|
|
381
|
+
} catch (e) {
|
|
382
|
+
printError(e);
|
|
383
|
+
process.exit(1);
|
|
384
|
+
}
|
|
385
|
+
});
|
|
386
|
+
ret.command("refund <orderNumber>").description("Return with refund").requiredOption("--products <json>", "Return products array (JSON)").requiredOption("--refund-amount <n>", "Refund amount", parseFloat).requiredOption("--payment-id <id>", "Payment ID").option("--reason <reason>", "Return reason").option("--reason-detail <text>", "Detailed reason").option("--refund-receipt-url <url>", "Refund receipt URL").action(async (orderNumber, opts) => {
|
|
387
|
+
try {
|
|
388
|
+
const client = getClient2();
|
|
389
|
+
const result = await client.api.returnWithRefund({
|
|
390
|
+
orderNumber,
|
|
391
|
+
returnProducts: parseJsonArray(opts.products, "products"),
|
|
392
|
+
refundAmount: opts.refundAmount,
|
|
393
|
+
paymentId: opts.paymentId,
|
|
394
|
+
reason: opts.reason,
|
|
395
|
+
reasonDetail: opts.reasonDetail,
|
|
396
|
+
refundReceiptUrl: opts.refundReceiptUrl
|
|
397
|
+
});
|
|
398
|
+
printResult(result, getFormat2());
|
|
399
|
+
} catch (e) {
|
|
400
|
+
printError(e);
|
|
401
|
+
process.exit(1);
|
|
402
|
+
}
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
// src/commands/cart.ts
|
|
407
|
+
function registerCartCommands(program2, getClient2, getFormat2) {
|
|
408
|
+
const cart = program2.command("cart").description("Cart management");
|
|
409
|
+
cart.command("add <cartId>").description("Add an item to cart").requiredOption("--product <id>", "Product ID").requiredOption("--variant <id>", "Variant ID").requiredOption("--option <id>", "Option ID").requiredOption("--quantity <n>", "Quantity", (v) => parseInt(v, 10)).action(async (cartId, opts) => {
|
|
410
|
+
try {
|
|
411
|
+
const client = getClient2();
|
|
412
|
+
const result = await client.cart.addItem({
|
|
413
|
+
cartId,
|
|
414
|
+
product: opts.product,
|
|
415
|
+
variant: opts.variant,
|
|
416
|
+
option: opts.option,
|
|
417
|
+
quantity: opts.quantity
|
|
418
|
+
});
|
|
419
|
+
printResult(result, getFormat2());
|
|
420
|
+
} catch (e) {
|
|
421
|
+
printError(e);
|
|
422
|
+
process.exit(1);
|
|
423
|
+
}
|
|
424
|
+
});
|
|
425
|
+
cart.command("update <cartItemId>").description("Update cart item quantity").requiredOption("--quantity <n>", "New quantity", (v) => parseInt(v, 10)).action(async (cartItemId, opts) => {
|
|
426
|
+
try {
|
|
427
|
+
const client = getClient2();
|
|
428
|
+
const result = await client.cart.updateItem({
|
|
429
|
+
cartItemId,
|
|
430
|
+
quantity: opts.quantity
|
|
431
|
+
});
|
|
432
|
+
printResult(result, getFormat2());
|
|
433
|
+
} catch (e) {
|
|
434
|
+
printError(e);
|
|
435
|
+
process.exit(1);
|
|
436
|
+
}
|
|
437
|
+
});
|
|
438
|
+
cart.command("remove <cartItemId>").description("Remove an item from cart").action(async (cartItemId) => {
|
|
439
|
+
try {
|
|
440
|
+
const client = getClient2();
|
|
441
|
+
const result = await client.cart.removeItem({ cartItemId });
|
|
442
|
+
printResult(result, getFormat2());
|
|
443
|
+
} catch (e) {
|
|
444
|
+
printError(e);
|
|
445
|
+
process.exit(1);
|
|
446
|
+
}
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
// src/commands/stock.ts
|
|
451
|
+
function registerStockCommands(program2, getClient2, getFormat2) {
|
|
452
|
+
const stock = program2.command("stock").description("Stock management");
|
|
453
|
+
stock.command("check").description("Check stock availability").requiredOption("--items <json>", "Items to check (JSON array of { optionId, quantity })").action(async (opts) => {
|
|
454
|
+
try {
|
|
455
|
+
const client = getClient2();
|
|
456
|
+
const items = parseJsonArray(opts.items, "items");
|
|
457
|
+
const result = await client.product.stockCheck({ items });
|
|
458
|
+
printResult(result, getFormat2());
|
|
459
|
+
} catch (e) {
|
|
460
|
+
printError(e);
|
|
461
|
+
process.exit(1);
|
|
462
|
+
}
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
// src/commands/transaction.ts
|
|
467
|
+
function registerTransactionCommands(program2, getClient2, getFormat2) {
|
|
468
|
+
const tx = program2.command("transaction").description("Transaction management");
|
|
469
|
+
tx.command("update").description("Update transaction status").requiredOption("--payment-id <id>", "Payment ID").requiredOption("--status <status>", "New status (pending, paid, failed, canceled)").requiredOption("--payment-method <method>", "Payment method").requiredOption("--receipt-url <url>", "Receipt URL").action(async (opts) => {
|
|
470
|
+
try {
|
|
471
|
+
const client = getClient2();
|
|
472
|
+
const result = await client.api.updateTransaction({
|
|
473
|
+
paymentId: opts.paymentId,
|
|
474
|
+
status: opts.status,
|
|
475
|
+
paymentMethod: opts.paymentMethod,
|
|
476
|
+
receiptUrl: opts.receiptUrl
|
|
477
|
+
});
|
|
478
|
+
printResult(result, getFormat2());
|
|
479
|
+
} catch (e) {
|
|
480
|
+
printError(e);
|
|
481
|
+
process.exit(1);
|
|
482
|
+
}
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
// src/commands/auth.ts
|
|
487
|
+
import { randomBytes } from "crypto";
|
|
488
|
+
import { createServer } from "http";
|
|
489
|
+
import { execFile, exec } from "child_process";
|
|
490
|
+
import { platform } from "os";
|
|
491
|
+
import { URL } from "url";
|
|
492
|
+
import pc4 from "picocolors";
|
|
493
|
+
var WEB_URL = process.env.SOFTWARE_WEB_URL || "https://01.software";
|
|
494
|
+
var TIMEOUT_MS = 3 * 60 * 1e3;
|
|
495
|
+
function escapeHtml(s) {
|
|
496
|
+
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
497
|
+
}
|
|
498
|
+
function openBrowser(url) {
|
|
499
|
+
const os = platform();
|
|
500
|
+
const onError = () => {
|
|
501
|
+
console.log(pc4.yellow(`Could not open browser automatically. Open this URL manually:
|
|
502
|
+
${url}`));
|
|
503
|
+
};
|
|
504
|
+
if (os === "win32") {
|
|
505
|
+
exec(`start "" "${url}"`, (err) => {
|
|
506
|
+
if (err) onError();
|
|
507
|
+
});
|
|
508
|
+
} else {
|
|
509
|
+
const cmd = os === "darwin" ? "open" : "xdg-open";
|
|
510
|
+
execFile(cmd, [url], (err) => {
|
|
511
|
+
if (err) onError();
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
var PAGE_STYLE = `*{margin:0;box-sizing:border-box}
|
|
516
|
+
body{font-family:system-ui,-apple-system,sans-serif;display:flex;justify-content:center;align-items:center;min-height:100vh;background:#fff;color:#252525}
|
|
517
|
+
@media(prefers-color-scheme:dark){body{background:#252525;color:#f5f5f5}}
|
|
518
|
+
.card{text-align:center;padding:2rem 2.5rem;border-radius:10px;max-width:380px;width:100%}
|
|
519
|
+
.icon{width:40px;height:40px;margin:0 auto 1rem;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:1.25rem}
|
|
520
|
+
.icon.ok{background:rgba(0,0,0,.05);color:#252525}
|
|
521
|
+
.icon.err{background:rgba(220,38,38,.08);color:#dc2626}
|
|
522
|
+
@media(prefers-color-scheme:dark){.icon.ok{background:rgba(255,255,255,.08);color:#f5f5f5}}
|
|
523
|
+
h1{font-size:.875rem;font-weight:600;margin-bottom:.375rem}
|
|
524
|
+
p{font-size:.75rem;color:#737373;line-height:1.5}`;
|
|
525
|
+
var SUCCESS_HTML = `<!DOCTYPE html>
|
|
526
|
+
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width"><title>CLI Login</title>
|
|
527
|
+
<style>${PAGE_STYLE}</style>
|
|
528
|
+
</head><body><div class="card"><div class="icon ok">\u2713</div><h1>Authenticated</h1><p>You can close this tab and return to the terminal.</p></div></body></html>`;
|
|
529
|
+
var ERROR_HTML = (msg) => `<!DOCTYPE html>
|
|
530
|
+
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width"><title>CLI Login Error</title>
|
|
531
|
+
<style>${PAGE_STYLE}</style>
|
|
532
|
+
</head><body><div class="card"><div class="icon err">!</div><h1>Authentication failed</h1><p>${escapeHtml(msg)}</p></div></body></html>`;
|
|
533
|
+
function registerAuthCommands(program2) {
|
|
534
|
+
program2.command("login").description("Login via browser and store credentials").action(async () => {
|
|
535
|
+
const state = randomBytes(32).toString("hex");
|
|
536
|
+
const server = createServer((req, res) => {
|
|
537
|
+
if (!req.url) {
|
|
538
|
+
res.writeHead(400).end();
|
|
539
|
+
return;
|
|
540
|
+
}
|
|
541
|
+
const url = new URL(req.url, `http://localhost`);
|
|
542
|
+
if (url.pathname !== "/callback") {
|
|
543
|
+
res.writeHead(404).end();
|
|
544
|
+
return;
|
|
545
|
+
}
|
|
546
|
+
const receivedState = url.searchParams.get("state");
|
|
547
|
+
const clientKey = url.searchParams.get("clientKey");
|
|
548
|
+
const secretKey = url.searchParams.get("secretKey");
|
|
549
|
+
const tenant = url.searchParams.get("tenant");
|
|
550
|
+
const error = url.searchParams.get("error");
|
|
551
|
+
if (error) {
|
|
552
|
+
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" }).end(ERROR_HTML(error));
|
|
553
|
+
console.error(pc4.red(`Login failed: ${error}`));
|
|
554
|
+
cleanup(1);
|
|
555
|
+
return;
|
|
556
|
+
}
|
|
557
|
+
if (receivedState !== state) {
|
|
558
|
+
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" }).end(ERROR_HTML("State mismatch \u2014 possible CSRF attack."));
|
|
559
|
+
console.error(pc4.red("Login failed: state mismatch."));
|
|
560
|
+
cleanup(1);
|
|
561
|
+
return;
|
|
562
|
+
}
|
|
563
|
+
if (!clientKey || !secretKey || !tenant) {
|
|
564
|
+
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" }).end(ERROR_HTML("Missing credentials in callback."));
|
|
565
|
+
console.error(pc4.red("Login failed: missing credentials."));
|
|
566
|
+
cleanup(1);
|
|
567
|
+
return;
|
|
568
|
+
}
|
|
569
|
+
saveCredentials({ clientKey, secretKey, tenantName: tenant });
|
|
570
|
+
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" }).end(SUCCESS_HTML);
|
|
571
|
+
console.log(pc4.green(`
|
|
572
|
+
Logged in successfully!`));
|
|
573
|
+
console.log(pc4.dim(`Tenant: ${tenant}`));
|
|
574
|
+
console.log(pc4.dim(`Credentials saved to ${getCredentialsPath()}`));
|
|
575
|
+
cleanup(0);
|
|
576
|
+
});
|
|
577
|
+
let timeout;
|
|
578
|
+
let completed = false;
|
|
579
|
+
function cleanup(exitCode = 0) {
|
|
580
|
+
if (completed) return;
|
|
581
|
+
completed = true;
|
|
582
|
+
clearTimeout(timeout);
|
|
583
|
+
server.close(() => process.exit(exitCode));
|
|
584
|
+
}
|
|
585
|
+
server.listen(0, "127.0.0.1", () => {
|
|
586
|
+
const addr = server.address();
|
|
587
|
+
if (!addr || typeof addr === "string") {
|
|
588
|
+
console.error(pc4.red("Failed to start local server."));
|
|
589
|
+
process.exit(1);
|
|
590
|
+
}
|
|
591
|
+
const port = addr.port;
|
|
592
|
+
const params = new URLSearchParams({ port: String(port), state });
|
|
593
|
+
const loginUrl = `${WEB_URL}/cli-auth?${params.toString()}`;
|
|
594
|
+
console.log(pc4.dim("Opening browser for login..."));
|
|
595
|
+
console.log(pc4.dim(`If the browser does not open, visit:
|
|
596
|
+
${loginUrl}`));
|
|
597
|
+
openBrowser(loginUrl);
|
|
598
|
+
timeout = setTimeout(() => {
|
|
599
|
+
console.error(pc4.red("\nLogin timed out (3 minutes). Please try again."));
|
|
600
|
+
cleanup(1);
|
|
601
|
+
}, TIMEOUT_MS);
|
|
602
|
+
});
|
|
603
|
+
server.on("error", (err) => {
|
|
604
|
+
console.error(pc4.red(`Server error: ${err.message}`));
|
|
605
|
+
process.exit(1);
|
|
606
|
+
});
|
|
607
|
+
});
|
|
608
|
+
program2.command("logout").description("Remove stored credentials").action(() => {
|
|
609
|
+
const deleted = deleteCredentials();
|
|
610
|
+
if (deleted) {
|
|
611
|
+
console.log(pc4.green("Logged out. Credentials removed."));
|
|
612
|
+
} else {
|
|
613
|
+
console.log(pc4.dim("No stored credentials found."));
|
|
614
|
+
}
|
|
615
|
+
});
|
|
616
|
+
program2.command("whoami").description("Show current authentication status").action(() => {
|
|
617
|
+
const creds = loadCredentials();
|
|
618
|
+
if (!creds) {
|
|
619
|
+
console.log(pc4.dim('Not logged in. Run "01 login" to authenticate.'));
|
|
620
|
+
return;
|
|
621
|
+
}
|
|
622
|
+
const masked = creds.clientKey.length > 8 ? creds.clientKey.slice(0, 4) + "..." + creds.clientKey.slice(-4) : "****";
|
|
623
|
+
console.log(`Tenant: ${pc4.bold(creds.tenantName)}`);
|
|
624
|
+
console.log(`Client Key: ${pc4.dim(masked)}`);
|
|
625
|
+
console.log(`Stored at: ${pc4.dim(creds.storedAt)}`);
|
|
626
|
+
console.log(`File: ${pc4.dim(getCredentialsPath())}`);
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
// src/index.ts
|
|
631
|
+
var require2 = createRequire(import.meta.url);
|
|
632
|
+
var { version } = require2("../package.json");
|
|
633
|
+
process.on("unhandledRejection", (err) => {
|
|
634
|
+
printError(err);
|
|
635
|
+
process.exit(1);
|
|
636
|
+
});
|
|
637
|
+
var program = new Command();
|
|
638
|
+
program.name("01").description("CLI for the 01.software platform").version(version).option("--api-key <base64>", "Base64-encoded API key (clientKey:secretKey)").option("--format <format>", "Output format: json (default) or table", "json");
|
|
639
|
+
var getFormat = () => program.opts().format;
|
|
640
|
+
var getClient = () => resolveClient(program.opts().apiKey);
|
|
641
|
+
registerCrudCommands(program, getClient, getFormat);
|
|
642
|
+
registerOrderCommands(program, getClient, getFormat);
|
|
643
|
+
registerReturnCommands(program, getClient, getFormat);
|
|
644
|
+
registerCartCommands(program, getClient, getFormat);
|
|
645
|
+
registerStockCommands(program, getClient, getFormat);
|
|
646
|
+
registerTransactionCommands(program, getClient, getFormat);
|
|
647
|
+
registerAuthCommands(program);
|
|
648
|
+
program.parse();
|
|
649
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/lib/client.ts","../src/lib/credentials.ts","../src/lib/output.ts","../src/commands/crud.ts","../src/lib/parse.ts","../src/commands/order.ts","../src/commands/return.ts","../src/commands/cart.ts","../src/commands/stock.ts","../src/commands/transaction.ts","../src/commands/auth.ts"],"sourcesContent":["import { createRequire } from 'node:module'\nimport { Command } from 'commander'\nimport { resolveClient } from './lib/client.js'\nimport { printError } from './lib/output.js'\nimport { registerCrudCommands } from './commands/crud.js'\nimport { registerOrderCommands } from './commands/order.js'\nimport { registerReturnCommands } from './commands/return.js'\nimport { registerCartCommands } from './commands/cart.js'\nimport { registerStockCommands } from './commands/stock.js'\nimport { registerTransactionCommands } from './commands/transaction.js'\nimport { registerAuthCommands } from './commands/auth.js'\n\nconst require = createRequire(import.meta.url)\nconst { version } = require('../package.json') as { version: string }\n\nprocess.on('unhandledRejection', (err) => {\n printError(err)\n process.exit(1)\n})\n\nconst program = new Command()\n\nprogram\n .name('01')\n .description('CLI for the 01.software platform')\n .version(version)\n .option('--api-key <base64>', 'Base64-encoded API key (clientKey:secretKey)')\n .option('--format <format>', 'Output format: json (default) or table', 'json')\n\nconst getFormat = () => program.opts().format as string\nconst getClient = () => resolveClient(program.opts().apiKey as string | undefined)\n\nregisterCrudCommands(program, getClient, getFormat)\nregisterOrderCommands(program, getClient, getFormat)\nregisterReturnCommands(program, getClient, getFormat)\nregisterCartCommands(program, getClient, getFormat)\nregisterStockCommands(program, getClient, getFormat)\nregisterTransactionCommands(program, getClient, getFormat)\nregisterAuthCommands(program)\n\nprogram.parse()\n","import { CollectionClient, OrderApi, CartApi, ProductApi, parseApiKey } from '@01.software/sdk'\nimport pc from 'picocolors'\nimport { loadCredentials } from './credentials.js'\n\nexport interface ResolvedClient {\n collections: CollectionClient\n api: OrderApi\n cart: CartApi\n product: ProductApi\n}\n\nexport function resolveClient(apiKeyFlag?: string): ResolvedClient {\n let clientKey: string | undefined\n let secretKey: string | undefined\n\n if (apiKeyFlag) {\n try {\n const parsed = parseApiKey(apiKeyFlag)\n clientKey = parsed.clientKey\n secretKey = parsed.secretKey\n } catch {\n console.error(pc.red('Invalid --api-key value. Expected Base64-encoded \"clientKey:secretKey\".'))\n process.exit(1)\n }\n } else {\n clientKey = process.env.SOFTWARE_CLIENT_KEY\n secretKey = process.env.SOFTWARE_SECRET_KEY\n }\n\n // Fallback to stored credentials from \"01 login\"\n if (!clientKey || !secretKey) {\n const stored = loadCredentials()\n if (stored) {\n clientKey = stored.clientKey\n secretKey = stored.secretKey\n }\n }\n\n if (!clientKey || !secretKey) {\n console.error(pc.red('Authentication required.'))\n console.error(\n pc.dim(\n 'Run \"01 login\" to authenticate via browser,\\n' +\n 'or set SOFTWARE_CLIENT_KEY and SOFTWARE_SECRET_KEY environment variables,\\n' +\n 'or use the --api-key <base64> flag.',\n ),\n )\n process.exit(1)\n }\n\n const apiOpts = { clientKey, secretKey }\n\n return {\n collections: new CollectionClient(clientKey, secretKey),\n api: new OrderApi(apiOpts),\n cart: new CartApi(apiOpts),\n product: new ProductApi(apiOpts),\n }\n}\n","import { existsSync, mkdirSync, readFileSync, writeFileSync, unlinkSync } from 'node:fs'\nimport { join } from 'node:path'\nimport { homedir } from 'node:os'\n\nexport interface StoredCredentials {\n clientKey: string\n secretKey: string\n tenantName: string\n storedAt: string\n}\n\nconst DIR_NAME = '.01software'\nconst FILE_NAME = 'credentials.json'\n\nexport function getCredentialsPath(): string {\n return join(homedir(), DIR_NAME, FILE_NAME)\n}\n\nexport function loadCredentials(): StoredCredentials | null {\n const filePath = getCredentialsPath()\n if (!existsSync(filePath)) return null\n\n try {\n const raw = readFileSync(filePath, 'utf-8')\n const data = JSON.parse(raw) as StoredCredentials\n if (!data.clientKey || !data.secretKey) return null\n return data\n } catch {\n return null\n }\n}\n\nexport function saveCredentials(creds: Omit<StoredCredentials, 'storedAt'>): void {\n const dir = join(homedir(), DIR_NAME)\n if (!existsSync(dir)) {\n mkdirSync(dir, { recursive: true, mode: 0o700 })\n }\n\n const filePath = getCredentialsPath()\n const data: StoredCredentials = { ...creds, storedAt: new Date().toISOString() }\n writeFileSync(filePath, JSON.stringify(data, null, 2), { encoding: 'utf-8', mode: 0o600 })\n}\n\nexport function deleteCredentials(): boolean {\n const filePath = getCredentialsPath()\n if (!existsSync(filePath)) return false\n\n unlinkSync(filePath)\n return true\n}\n","import pc from 'picocolors'\n\nexport function printJson(data: unknown): void {\n console.log(JSON.stringify(data, null, 2))\n}\n\nexport function printTable(data: unknown): void {\n if (Array.isArray(data)) {\n if (data.length === 0) {\n console.log(pc.dim('(empty)'))\n return\n }\n const keys = Object.keys(data[0] as Record<string, unknown>)\n const widths = keys.map((k) =>\n Math.max(k.length, ...data.map((row) => String((row as Record<string, unknown>)[k] ?? '').length)),\n )\n\n // Header\n console.log(keys.map((k, i) => k.padEnd(widths[i]!)).join(' '))\n console.log(keys.map((_, i) => '-'.repeat(widths[i]!)).join(' '))\n\n // Rows\n for (const row of data) {\n console.log(\n keys.map((k, i) => String((row as Record<string, unknown>)[k] ?? '').padEnd(widths[i]!)).join(' '),\n )\n }\n } else if (data && typeof data === 'object') {\n const entries = Object.entries(data as Record<string, unknown>)\n const maxKey = Math.max(...entries.map(([k]) => k.length))\n for (const [key, value] of entries) {\n const display = typeof value === 'object' ? JSON.stringify(value) : String(value)\n console.log(`${pc.bold(key.padEnd(maxKey))} ${display}`)\n }\n } else {\n console.log(String(data))\n }\n}\n\nexport function printResult(data: unknown, format: string): void {\n if (format === 'table') {\n // For find responses with docs array, print the docs as table\n if (data && typeof data === 'object' && 'docs' in (data as Record<string, unknown>)) {\n const resp = data as { docs: unknown[]; totalDocs: number; page: number; totalPages: number }\n printTable(resp.docs)\n console.log(pc.dim(`\\n${resp.totalDocs} total | page ${resp.page}/${resp.totalPages}`))\n return\n }\n printTable(data)\n } else {\n printJson(data)\n }\n}\n\nexport function printError(error: unknown): void {\n if (error && typeof error === 'object' && 'message' in error) {\n const err = error as { message: string; code?: string; status?: number; suggestion?: string }\n console.error(pc.red(`Error: ${err.message}`))\n if (err.code) console.error(pc.dim(`Code: ${err.code}`))\n if (err.status) console.error(pc.dim(`Status: ${err.status}`))\n if (err.suggestion) console.error(pc.yellow(err.suggestion))\n } else {\n console.error(pc.red(String(error)))\n }\n}\n","import { Command } from 'commander'\nimport { COLLECTIONS } from '@01.software/sdk'\nimport type { ApiQueryOptions } from '@01.software/sdk'\nimport type { ResolvedClient } from '../lib/client.js'\nimport { printResult, printError } from '../lib/output.js'\nimport { parseJson } from '../lib/parse.js'\n\nconst collectionList = COLLECTIONS.join(', ')\n\nfunction validateCollection(name: string): string {\n if (!(COLLECTIONS as readonly string[]).includes(name)) {\n throw new Error(`Unknown collection \"${name}\". Available: ${collectionList}`)\n }\n return name\n}\n\nexport function registerCrudCommands(program: Command, getClient: () => ResolvedClient, getFormat: () => string) {\n program\n .command('query <collection>')\n .description('Query documents from a collection')\n .option('--where <json>', 'Filter conditions (JSON)')\n .option('--limit <n>', 'Max results', (v: string) => parseInt(v, 10))\n .option('--page <n>', 'Page number', (v: string) => parseInt(v, 10))\n .option('--sort <field>', 'Sort field (prefix with - for descending)')\n .action(async (collection: string, opts) => {\n try {\n const col = validateCollection(collection)\n const client = getClient()\n const options: Record<string, unknown> = {}\n if (opts.where) options.where = parseJson(opts.where, 'where')\n if (opts.limit) options.limit = opts.limit\n if (opts.page) options.page = opts.page\n if (opts.sort) options.sort = opts.sort\n const result = await client.collections.from(col as typeof COLLECTIONS[number]).find(options)\n printResult(result, getFormat())\n } catch (e) {\n printError(e)\n process.exit(1)\n }\n })\n\n program\n .command('get <collection> <id>')\n .description('Get a document by ID')\n .action(async (collection: string, id: string) => {\n try {\n const col = validateCollection(collection)\n const client = getClient()\n const result = await client.collections.from(col as typeof COLLECTIONS[number]).findById(id)\n printResult(result, getFormat())\n } catch (e) {\n printError(e)\n process.exit(1)\n }\n })\n\n program\n .command('create <collection>')\n .description('Create a new document')\n .requiredOption('--data <json>', 'Document data (JSON)')\n .action(async (collection: string, opts) => {\n try {\n const col = validateCollection(collection)\n const client = getClient()\n const data = parseJson(opts.data, 'data')\n const result = await client.collections.from(col as typeof COLLECTIONS[number]).create(data)\n printResult(result, getFormat())\n } catch (e) {\n printError(e)\n process.exit(1)\n }\n })\n\n program\n .command('update <collection> <id>')\n .description('Update a document by ID')\n .requiredOption('--data <json>', 'Document data (JSON)')\n .action(async (collection: string, id: string, opts) => {\n try {\n const col = validateCollection(collection)\n const client = getClient()\n const data = parseJson(opts.data, 'data')\n const result = await client.collections.from(col as typeof COLLECTIONS[number]).update(id, data)\n printResult(result, getFormat())\n } catch (e) {\n printError(e)\n process.exit(1)\n }\n })\n\n program\n .command('delete <collection> <id>')\n .description('Delete a document by ID')\n .action(async (collection: string, id: string) => {\n try {\n const col = validateCollection(collection)\n const client = getClient()\n const result = await client.collections.from(col as typeof COLLECTIONS[number]).remove(id)\n printResult(result, getFormat())\n } catch (e) {\n printError(e)\n process.exit(1)\n }\n })\n\n program\n .command('update-many <collection>')\n .description('Update multiple documents matching a filter')\n .requiredOption('--where <json>', 'Filter conditions (JSON)')\n .requiredOption('--data <json>', 'Update data (JSON)')\n .action(async (collection: string, opts) => {\n try {\n const col = validateCollection(collection)\n const client = getClient()\n const where = parseJson(opts.where, 'where') as ApiQueryOptions['where']\n const data = parseJson(opts.data, 'data')\n const result = await client.collections.from(col as typeof COLLECTIONS[number]).updateMany(where, data)\n printResult(result, getFormat())\n } catch (e) {\n printError(e)\n process.exit(1)\n }\n })\n\n program\n .command('delete-many <collection>')\n .description('Delete multiple documents matching a filter')\n .requiredOption('--where <json>', 'Filter conditions (JSON)')\n .action(async (collection: string, opts) => {\n try {\n const col = validateCollection(collection)\n const client = getClient()\n const where = parseJson(opts.where, 'where') as ApiQueryOptions['where']\n const result = await client.collections.from(col as typeof COLLECTIONS[number]).removeMany(where)\n printResult(result, getFormat())\n } catch (e) {\n printError(e)\n process.exit(1)\n }\n })\n}\n","import pc from 'picocolors'\n\nexport function parseJson(value: string, label: string): Record<string, unknown> {\n try {\n const parsed = JSON.parse(value)\n if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {\n console.error(pc.red(`--${label} must be a JSON object.`))\n process.exit(1)\n }\n return parsed as Record<string, unknown>\n } catch {\n console.error(pc.red(`Invalid JSON for --${label}: ${value}`))\n process.exit(1)\n }\n}\n\nexport function parseJsonArray(value: string, label: string): unknown[] {\n try {\n const parsed = JSON.parse(value)\n if (!Array.isArray(parsed)) {\n console.error(pc.red(`--${label} must be a JSON array.`))\n process.exit(1)\n }\n return parsed\n } catch {\n console.error(pc.red(`Invalid JSON for --${label}: ${value}`))\n process.exit(1)\n }\n}\n","import { Command } from 'commander'\nimport type { ResolvedClient } from '../lib/client.js'\nimport { printResult, printError } from '../lib/output.js'\nimport { parseJson, parseJsonArray } from '../lib/parse.js'\n\nexport function registerOrderCommands(program: Command, getClient: () => ResolvedClient, getFormat: () => string) {\n const order = program.command('order').description('Order management')\n\n order\n .command('create')\n .description('Create a new order')\n .requiredOption('--payment-id <id>', 'Payment ID')\n .requiredOption('--order-number <num>', 'Order number')\n .requiredOption('--email <email>', 'Customer email')\n .requiredOption('--shipping-address <json>', 'Shipping address (JSON)')\n .requiredOption('--products <json>', 'Order products array (JSON)')\n .requiredOption('--total-amount <n>', 'Total amount', parseFloat)\n .action(async (opts) => {\n try {\n const client = getClient()\n const result = await client.api.createOrder({\n paymentId: opts.paymentId,\n orderNumber: opts.orderNumber,\n email: opts.email,\n shippingAddress: parseJson(opts.shippingAddress, 'shipping-address'),\n orderProducts: parseJsonArray(opts.products, 'products') as Parameters<typeof client.api.createOrder>[0]['orderProducts'],\n totalAmount: opts.totalAmount,\n })\n printResult(result, getFormat())\n } catch (e) {\n printError(e)\n process.exit(1)\n }\n })\n\n order\n .command('get <orderNumber>')\n .description('Get an order by order number')\n .action(async (orderNumber: string) => {\n try {\n const client = getClient()\n const result = await client.api.getOrder({ orderNumber })\n printResult(result, getFormat())\n } catch (e) {\n printError(e)\n process.exit(1)\n }\n })\n\n order\n .command('update <orderNumber>')\n .description('Update order status')\n .requiredOption('--status <status>', 'New status')\n .action(async (orderNumber: string, opts) => {\n try {\n const client = getClient()\n const result = await client.api.updateOrder({\n orderNumber,\n status: opts.status,\n })\n printResult(result, getFormat())\n } catch (e) {\n printError(e)\n process.exit(1)\n }\n })\n\n order\n .command('checkout')\n .description('Convert a cart to an order')\n .requiredOption('--cart-id <id>', 'Cart ID')\n .requiredOption('--payment-id <id>', 'Payment ID')\n .requiredOption('--order-number <num>', 'Order number')\n .requiredOption('--customer <json>', 'Customer snapshot (JSON)')\n .action(async (opts) => {\n try {\n const client = getClient()\n const result = await client.api.checkout({\n cartId: opts.cartId,\n paymentId: opts.paymentId,\n orderNumber: opts.orderNumber,\n customerSnapshot: parseJson(opts.customer, 'customer') as Parameters<typeof client.api.checkout>[0]['customerSnapshot'],\n })\n printResult(result, getFormat())\n } catch (e) {\n printError(e)\n process.exit(1)\n }\n })\n\n order\n .command('fulfill <orderNumber>')\n .description('Create a fulfillment for an order')\n .requiredOption('--items <json>', 'Fulfillment items array (JSON)')\n .option('--carrier <name>', 'Shipping carrier')\n .option('--tracking-number <num>', 'Tracking number')\n .action(async (orderNumber: string, opts) => {\n try {\n const client = getClient()\n const result = await client.api.createFulfillment({\n orderNumber,\n items: parseJsonArray(opts.items, 'items') as Parameters<typeof client.api.createFulfillment>[0]['items'],\n carrier: opts.carrier,\n trackingNumber: opts.trackingNumber,\n })\n printResult(result, getFormat())\n } catch (e) {\n printError(e)\n process.exit(1)\n }\n })\n}\n","import { Command } from 'commander'\nimport type { ResolvedClient } from '../lib/client.js'\nimport { printResult, printError } from '../lib/output.js'\nimport { parseJsonArray } from '../lib/parse.js'\n\nexport function registerReturnCommands(program: Command, getClient: () => ResolvedClient, getFormat: () => string) {\n const ret = program.command('return').description('Return management')\n\n ret\n .command('create <orderNumber>')\n .description('Create a return request')\n .requiredOption('--products <json>', 'Return products array (JSON)')\n .requiredOption('--refund-amount <n>', 'Refund amount', parseFloat)\n .option('--reason <reason>', 'Return reason (change_of_mind, defective, wrong_delivery, damaged, other)')\n .option('--reason-detail <text>', 'Detailed reason')\n .action(async (orderNumber: string, opts) => {\n try {\n const client = getClient()\n const result = await client.api.createReturn({\n orderNumber,\n returnProducts: parseJsonArray(opts.products, 'products') as Parameters<typeof client.api.createReturn>[0]['returnProducts'],\n refundAmount: opts.refundAmount,\n reason: opts.reason,\n reasonDetail: opts.reasonDetail,\n })\n printResult(result, getFormat())\n } catch (e) {\n printError(e)\n process.exit(1)\n }\n })\n\n ret\n .command('update <returnId>')\n .description('Update return status')\n .requiredOption('--status <status>', 'New status (processing, approved, rejected, completed)')\n .action(async (returnId: string, opts) => {\n try {\n const client = getClient()\n const result = await client.api.updateReturn({\n returnId,\n status: opts.status,\n })\n printResult(result, getFormat())\n } catch (e) {\n printError(e)\n process.exit(1)\n }\n })\n\n ret\n .command('refund <orderNumber>')\n .description('Return with refund')\n .requiredOption('--products <json>', 'Return products array (JSON)')\n .requiredOption('--refund-amount <n>', 'Refund amount', parseFloat)\n .requiredOption('--payment-id <id>', 'Payment ID')\n .option('--reason <reason>', 'Return reason')\n .option('--reason-detail <text>', 'Detailed reason')\n .option('--refund-receipt-url <url>', 'Refund receipt URL')\n .action(async (orderNumber: string, opts) => {\n try {\n const client = getClient()\n const result = await client.api.returnWithRefund({\n orderNumber,\n returnProducts: parseJsonArray(opts.products, 'products') as Parameters<typeof client.api.returnWithRefund>[0]['returnProducts'],\n refundAmount: opts.refundAmount,\n paymentId: opts.paymentId,\n reason: opts.reason,\n reasonDetail: opts.reasonDetail,\n refundReceiptUrl: opts.refundReceiptUrl,\n })\n printResult(result, getFormat())\n } catch (e) {\n printError(e)\n process.exit(1)\n }\n })\n}\n","import { Command } from 'commander'\nimport type { ResolvedClient } from '../lib/client.js'\nimport { printResult, printError } from '../lib/output.js'\n\nexport function registerCartCommands(program: Command, getClient: () => ResolvedClient, getFormat: () => string) {\n const cart = program.command('cart').description('Cart management')\n\n cart\n .command('add <cartId>')\n .description('Add an item to cart')\n .requiredOption('--product <id>', 'Product ID')\n .requiredOption('--variant <id>', 'Variant ID')\n .requiredOption('--option <id>', 'Option ID')\n .requiredOption('--quantity <n>', 'Quantity', (v: string) => parseInt(v, 10))\n .action(async (cartId: string, opts) => {\n try {\n const client = getClient()\n const result = await client.cart.addItem({\n cartId,\n product: opts.product,\n variant: opts.variant,\n option: opts.option,\n quantity: opts.quantity,\n })\n printResult(result, getFormat())\n } catch (e) {\n printError(e)\n process.exit(1)\n }\n })\n\n cart\n .command('update <cartItemId>')\n .description('Update cart item quantity')\n .requiredOption('--quantity <n>', 'New quantity', (v: string) => parseInt(v, 10))\n .action(async (cartItemId: string, opts) => {\n try {\n const client = getClient()\n const result = await client.cart.updateItem({\n cartItemId,\n quantity: opts.quantity,\n })\n printResult(result, getFormat())\n } catch (e) {\n printError(e)\n process.exit(1)\n }\n })\n\n cart\n .command('remove <cartItemId>')\n .description('Remove an item from cart')\n .action(async (cartItemId: string) => {\n try {\n const client = getClient()\n const result = await client.cart.removeItem({ cartItemId })\n printResult(result, getFormat())\n } catch (e) {\n printError(e)\n process.exit(1)\n }\n })\n}\n","import { Command } from 'commander'\nimport type { ResolvedClient } from '../lib/client.js'\nimport { printResult, printError } from '../lib/output.js'\nimport { parseJsonArray } from '../lib/parse.js'\n\nexport function registerStockCommands(program: Command, getClient: () => ResolvedClient, getFormat: () => string) {\n const stock = program.command('stock').description('Stock management')\n\n stock\n .command('check')\n .description('Check stock availability')\n .requiredOption('--items <json>', 'Items to check (JSON array of { optionId, quantity })')\n .action(async (opts) => {\n try {\n const client = getClient()\n const items = parseJsonArray(opts.items, 'items') as Parameters<typeof client.product.stockCheck>[0]['items']\n const result = await client.product.stockCheck({ items })\n printResult(result, getFormat())\n } catch (e) {\n printError(e)\n process.exit(1)\n }\n })\n}\n","import { Command } from 'commander'\nimport type { ResolvedClient } from '../lib/client.js'\nimport { printResult, printError } from '../lib/output.js'\n\nexport function registerTransactionCommands(program: Command, getClient: () => ResolvedClient, getFormat: () => string) {\n const tx = program.command('transaction').description('Transaction management')\n\n tx\n .command('update')\n .description('Update transaction status')\n .requiredOption('--payment-id <id>', 'Payment ID')\n .requiredOption('--status <status>', 'New status (pending, paid, failed, canceled)')\n .requiredOption('--payment-method <method>', 'Payment method')\n .requiredOption('--receipt-url <url>', 'Receipt URL')\n .action(async (opts) => {\n try {\n const client = getClient()\n const result = await client.api.updateTransaction({\n paymentId: opts.paymentId,\n status: opts.status,\n paymentMethod: opts.paymentMethod,\n receiptUrl: opts.receiptUrl,\n })\n printResult(result, getFormat())\n } catch (e) {\n printError(e)\n process.exit(1)\n }\n })\n}\n","import { randomBytes } from 'node:crypto'\nimport { createServer } from 'node:http'\nimport { execFile, exec } from 'node:child_process'\nimport { platform } from 'node:os'\nimport { URL } from 'node:url'\nimport type { Command } from 'commander'\nimport pc from 'picocolors'\nimport { loadCredentials, saveCredentials, deleteCredentials, getCredentialsPath } from '../lib/credentials.js'\n\nconst WEB_URL = process.env.SOFTWARE_WEB_URL || 'https://01.software'\nconst TIMEOUT_MS = 3 * 60 * 1000 // 3 minutes\n\nfunction escapeHtml(s: string): string {\n return s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/\"/g, '"')\n}\n\nfunction openBrowser(url: string): void {\n const os = platform()\n\n const onError = () => {\n console.log(pc.yellow(`Could not open browser automatically. Open this URL manually:\\n${url}`))\n }\n\n if (os === 'win32') {\n exec(`start \"\" \"${url}\"`, (err) => { if (err) onError() })\n } else {\n const cmd = os === 'darwin' ? 'open' : 'xdg-open'\n execFile(cmd, [url], (err) => { if (err) onError() })\n }\n}\n\nconst PAGE_STYLE = `*{margin:0;box-sizing:border-box}\nbody{font-family:system-ui,-apple-system,sans-serif;display:flex;justify-content:center;align-items:center;min-height:100vh;background:#fff;color:#252525}\n@media(prefers-color-scheme:dark){body{background:#252525;color:#f5f5f5}}\n.card{text-align:center;padding:2rem 2.5rem;border-radius:10px;max-width:380px;width:100%}\n.icon{width:40px;height:40px;margin:0 auto 1rem;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:1.25rem}\n.icon.ok{background:rgba(0,0,0,.05);color:#252525}\n.icon.err{background:rgba(220,38,38,.08);color:#dc2626}\n@media(prefers-color-scheme:dark){.icon.ok{background:rgba(255,255,255,.08);color:#f5f5f5}}\nh1{font-size:.875rem;font-weight:600;margin-bottom:.375rem}\np{font-size:.75rem;color:#737373;line-height:1.5}`\n\nconst SUCCESS_HTML = `<!DOCTYPE html>\n<html lang=\"en\"><head><meta charset=\"utf-8\"><meta name=\"viewport\" content=\"width=device-width\"><title>CLI Login</title>\n<style>${PAGE_STYLE}</style>\n</head><body><div class=\"card\"><div class=\"icon ok\">\\u2713</div><h1>Authenticated</h1><p>You can close this tab and return to the terminal.</p></div></body></html>`\n\nconst ERROR_HTML = (msg: string) => `<!DOCTYPE html>\n<html lang=\"en\"><head><meta charset=\"utf-8\"><meta name=\"viewport\" content=\"width=device-width\"><title>CLI Login Error</title>\n<style>${PAGE_STYLE}</style>\n</head><body><div class=\"card\"><div class=\"icon err\">!</div><h1>Authentication failed</h1><p>${escapeHtml(msg)}</p></div></body></html>`\n\nexport function registerAuthCommands(program: Command): void {\n program\n .command('login')\n .description('Login via browser and store credentials')\n .action(async () => {\n const state = randomBytes(32).toString('hex')\n\n const server = createServer((req, res) => {\n if (!req.url) {\n res.writeHead(400).end()\n return\n }\n\n const url = new URL(req.url, `http://localhost`)\n\n if (url.pathname !== '/callback') {\n res.writeHead(404).end()\n return\n }\n\n const receivedState = url.searchParams.get('state')\n const clientKey = url.searchParams.get('clientKey')\n const secretKey = url.searchParams.get('secretKey')\n const tenant = url.searchParams.get('tenant')\n const error = url.searchParams.get('error')\n\n if (error) {\n res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' }).end(ERROR_HTML(error))\n console.error(pc.red(`Login failed: ${error}`))\n cleanup(1)\n return\n }\n\n if (receivedState !== state) {\n res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' }).end(ERROR_HTML('State mismatch — possible CSRF attack.'))\n console.error(pc.red('Login failed: state mismatch.'))\n cleanup(1)\n return\n }\n\n if (!clientKey || !secretKey || !tenant) {\n res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' }).end(ERROR_HTML('Missing credentials in callback.'))\n console.error(pc.red('Login failed: missing credentials.'))\n cleanup(1)\n return\n }\n\n saveCredentials({ clientKey, secretKey, tenantName: tenant })\n res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' }).end(SUCCESS_HTML)\n\n console.log(pc.green(`\\nLogged in successfully!`))\n console.log(pc.dim(`Tenant: ${tenant}`))\n console.log(pc.dim(`Credentials saved to ${getCredentialsPath()}`))\n cleanup(0)\n })\n\n let timeout: ReturnType<typeof setTimeout>\n let completed = false\n\n function cleanup(exitCode = 0) {\n if (completed) return\n completed = true\n clearTimeout(timeout)\n server.close(() => process.exit(exitCode))\n }\n\n server.listen(0, '127.0.0.1', () => {\n const addr = server.address()\n if (!addr || typeof addr === 'string') {\n console.error(pc.red('Failed to start local server.'))\n process.exit(1)\n }\n\n const port = addr.port\n const params = new URLSearchParams({ port: String(port), state })\n const loginUrl = `${WEB_URL}/cli-auth?${params.toString()}`\n\n console.log(pc.dim('Opening browser for login...'))\n console.log(pc.dim(`If the browser does not open, visit:\\n${loginUrl}`))\n openBrowser(loginUrl)\n\n timeout = setTimeout(() => {\n console.error(pc.red('\\nLogin timed out (3 minutes). Please try again.'))\n cleanup(1)\n }, TIMEOUT_MS)\n })\n\n server.on('error', (err) => {\n console.error(pc.red(`Server error: ${err.message}`))\n process.exit(1)\n })\n })\n\n program\n .command('logout')\n .description('Remove stored credentials')\n .action(() => {\n const deleted = deleteCredentials()\n if (deleted) {\n console.log(pc.green('Logged out. Credentials removed.'))\n } else {\n console.log(pc.dim('No stored credentials found.'))\n }\n })\n\n program\n .command('whoami')\n .description('Show current authentication status')\n .action(() => {\n const creds = loadCredentials()\n if (!creds) {\n console.log(pc.dim('Not logged in. Run \"01 login\" to authenticate.'))\n return\n }\n\n const masked = creds.clientKey.length > 8\n ? creds.clientKey.slice(0, 4) + '...' + creds.clientKey.slice(-4)\n : '****'\n\n console.log(`Tenant: ${pc.bold(creds.tenantName)}`)\n console.log(`Client Key: ${pc.dim(masked)}`)\n console.log(`Stored at: ${pc.dim(creds.storedAt)}`)\n console.log(`File: ${pc.dim(getCredentialsPath())}`)\n })\n}\n"],"mappings":";;;AAAA,SAAS,qBAAqB;AAC9B,SAAS,eAAe;;;ACDxB,SAAS,kBAAkB,UAAU,SAAS,YAAY,mBAAmB;AAC7E,OAAO,QAAQ;;;ACDf,SAAS,YAAY,WAAW,cAAc,eAAe,kBAAkB;AAC/E,SAAS,YAAY;AACrB,SAAS,eAAe;AASxB,IAAM,WAAW;AACjB,IAAM,YAAY;AAEX,SAAS,qBAA6B;AAC3C,SAAO,KAAK,QAAQ,GAAG,UAAU,SAAS;AAC5C;AAEO,SAAS,kBAA4C;AAC1D,QAAM,WAAW,mBAAmB;AACpC,MAAI,CAAC,WAAW,QAAQ,EAAG,QAAO;AAElC,MAAI;AACF,UAAM,MAAM,aAAa,UAAU,OAAO;AAC1C,UAAM,OAAO,KAAK,MAAM,GAAG;AAC3B,QAAI,CAAC,KAAK,aAAa,CAAC,KAAK,UAAW,QAAO;AAC/C,WAAO;AAAA,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEO,SAAS,gBAAgB,OAAkD;AAChF,QAAM,MAAM,KAAK,QAAQ,GAAG,QAAQ;AACpC,MAAI,CAAC,WAAW,GAAG,GAAG;AACpB,cAAU,KAAK,EAAE,WAAW,MAAM,MAAM,IAAM,CAAC;AAAA,EACjD;AAEA,QAAM,WAAW,mBAAmB;AACpC,QAAM,OAA0B,EAAE,GAAG,OAAO,WAAU,oBAAI,KAAK,GAAE,YAAY,EAAE;AAC/E,gBAAc,UAAU,KAAK,UAAU,MAAM,MAAM,CAAC,GAAG,EAAE,UAAU,SAAS,MAAM,IAAM,CAAC;AAC3F;AAEO,SAAS,oBAA6B;AAC3C,QAAM,WAAW,mBAAmB;AACpC,MAAI,CAAC,WAAW,QAAQ,EAAG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,CAAC,QAAQ;AACxC,aAAW,GAAG;AACd,UAAQ,KAAK,CAAC;AAChB,CAAC;AAED,IAAM,UAAU,IAAI,QAAQ;AAE5B,QACG,KAAK,IAAI,EACT,YAAY,kCAAkC,EAC9C,QAAQ,OAAO,EACf,OAAO,sBAAsB,8CAA8C,EAC3E,OAAO,qBAAqB,0CAA0C,MAAM;AAE/E,IAAM,YAAY,MAAM,QAAQ,KAAK,EAAE;AACvC,IAAM,YAAY,MAAM,cAAc,QAAQ,KAAK,EAAE,MAA4B;AAEjF,qBAAqB,SAAS,WAAW,SAAS;AAClD,sBAAsB,SAAS,WAAW,SAAS;AACnD,uBAAuB,SAAS,WAAW,SAAS;AACpD,qBAAqB,SAAS,WAAW,SAAS;AAClD,sBAAsB,SAAS,WAAW,SAAS;AACnD,4BAA4B,SAAS,WAAW,SAAS;AACzD,qBAAqB,OAAO;AAE5B,QAAQ,MAAM;","names":["pc","pc","program","getClient","getFormat","program","getClient","getFormat","program","getClient","getFormat","program","getClient","getFormat","program","getClient","getFormat","program","getClient","getFormat","pc","pc","program","require"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@01.software/cli",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "CLI tool for 01.software platform",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"01": "./dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=18.0.0"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"commander": "^14.0.3",
|
|
17
|
+
"picocolors": "^1.1.1",
|
|
18
|
+
"@01.software/sdk": "0.2.8"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"tsup": "^8.5.0",
|
|
22
|
+
"typescript": "^5.9.3"
|
|
23
|
+
},
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "tsup",
|
|
29
|
+
"dev": "tsup --watch",
|
|
30
|
+
"check-types": "tsc --noEmit",
|
|
31
|
+
"version:dev": "node ../../scripts/update-version.js",
|
|
32
|
+
"publish:dev": "pnpm run version:dev && pnpm publish --no-git-checks --access public --tag dev",
|
|
33
|
+
"version:patch": "pnpm version patch --no-git-tag-version",
|
|
34
|
+
"version:minor": "pnpm version minor --no-git-tag-version",
|
|
35
|
+
"version:major": "pnpm version major --no-git-tag-version",
|
|
36
|
+
"publish:prod": "pnpm publish --access public"
|
|
37
|
+
}
|
|
38
|
+
}
|