@01.software/cli 0.2.0-dev.260306.4e16dd4 → 0.2.0-dev.260310.cf511cb
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 +7 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -371,13 +371,18 @@ function registerCrudCommands(program2, getClient2, getFormat2) {
|
|
|
371
371
|
// src/commands/order.ts
|
|
372
372
|
function registerOrderCommands(program2, getClient2, getFormat2) {
|
|
373
373
|
const order = program2.command("order").description("Order management");
|
|
374
|
-
order.command("create").description("Create a new order").
|
|
374
|
+
order.command("create").description("Create a new order").option("--payment-id <id>", "Payment ID").requiredOption("--order-number <num>", "Order number").requiredOption("--email <email>", "Customer email").option("--customer <id>", "Customer ID").option("--name <name>", "Customer name").option("--phone <phone>", "Customer phone").requiredOption("--shipping-address <json>", "Shipping address (JSON)").requiredOption("--products <json>", "Order products array (JSON)").requiredOption("--total-amount <n>", "Total amount", parseFloat).action(async (opts) => {
|
|
375
375
|
try {
|
|
376
376
|
const client = getClient2();
|
|
377
377
|
const result = await client.api.createOrder({
|
|
378
378
|
paymentId: opts.paymentId,
|
|
379
379
|
orderNumber: opts.orderNumber,
|
|
380
|
-
|
|
380
|
+
customerSnapshot: {
|
|
381
|
+
email: opts.email,
|
|
382
|
+
name: opts.name,
|
|
383
|
+
phone: opts.phone
|
|
384
|
+
},
|
|
385
|
+
customer: opts.customer,
|
|
381
386
|
shippingAddress: parseJson(opts.shippingAddress, "shipping-address"),
|
|
382
387
|
orderProducts: parseJsonArray(opts.products, "products"),
|
|
383
388
|
totalAmount: opts.totalAmount
|
package/dist/index.js.map
CHANGED
|
@@ -1 +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, loadLocalCredentials } 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: local credentials (./01software/credentials.json)\n if (!clientKey || !secretKey) {\n const local = loadLocalCredentials()\n if (local) {\n clientKey = local.clientKey\n secretKey = local.secretKey\n }\n }\n\n // Fallback: global credentials (~/.01software/credentials.json)\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, appendFileSync } from 'node:fs'\nimport { join } from 'node:path'\nimport { homedir } from 'node:os'\n\nexport interface StoredCredentials {\n clientKey: string\n secretKey: string\n tenantId?: string\n tenantName: string\n storedAt: string\n}\n\nexport interface TenantInfo {\n id: string\n name: string\n}\n\nconst DIR_NAME = '.01software'\nconst FILE_NAME = 'credentials.json'\nconst TENANTS_FILE = 'tenants.json'\n\n// ---------------------------------------------------------------------------\n// Global credentials (~/.01software/credentials.json)\n// ---------------------------------------------------------------------------\n\nexport function getCredentialsPath(): string {\n return join(homedir(), DIR_NAME, FILE_NAME)\n}\n\nexport function loadCredentials(): StoredCredentials | null {\n return loadCredentialsFrom(getCredentialsPath())\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\n// ---------------------------------------------------------------------------\n// Local credentials (./01software/credentials.json)\n// ---------------------------------------------------------------------------\n\nexport function getLocalCredentialsPath(): string {\n return join(process.cwd(), DIR_NAME, FILE_NAME)\n}\n\nexport function loadLocalCredentials(): StoredCredentials | null {\n return loadCredentialsFrom(getLocalCredentialsPath())\n}\n\nexport function saveLocalCredentials(creds: Omit<StoredCredentials, 'storedAt'>): void {\n const dir = join(process.cwd(), DIR_NAME)\n if (!existsSync(dir)) {\n mkdirSync(dir, { recursive: true, mode: 0o700 })\n }\n\n const filePath = getLocalCredentialsPath()\n const data: StoredCredentials = { ...creds, storedAt: new Date().toISOString() }\n writeFileSync(filePath, JSON.stringify(data, null, 2), { encoding: 'utf-8', mode: 0o600 })\n\n // Ensure .01software/ is in .gitignore\n ensureGitignore()\n}\n\n// ---------------------------------------------------------------------------\n// Tenant list cache (~/.01software/tenants.json)\n// ---------------------------------------------------------------------------\n\nexport function saveTenantList(tenants: TenantInfo[]): void {\n const dir = join(homedir(), DIR_NAME)\n if (!existsSync(dir)) {\n mkdirSync(dir, { recursive: true, mode: 0o700 })\n }\n\n const filePath = join(homedir(), DIR_NAME, TENANTS_FILE)\n writeFileSync(filePath, JSON.stringify(tenants, null, 2), { encoding: 'utf-8', mode: 0o600 })\n}\n\nexport function loadTenantList(): TenantInfo[] | null {\n const filePath = join(homedir(), DIR_NAME, TENANTS_FILE)\n if (!existsSync(filePath)) return null\n\n try {\n const raw = readFileSync(filePath, 'utf-8')\n const data = JSON.parse(raw)\n if (!Array.isArray(data)) return null\n const valid = data.filter(\n (t): t is TenantInfo => typeof t?.id === 'string' && typeof t?.name === 'string',\n )\n return valid.length > 0 ? valid : null\n } catch {\n return null\n }\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nfunction loadCredentialsFrom(filePath: string): StoredCredentials | null {\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\nfunction ensureGitignore(): void {\n const gitignorePath = join(process.cwd(), '.gitignore')\n const entry = '.01software/'\n\n if (existsSync(gitignorePath)) {\n const content = readFileSync(gitignorePath, 'utf-8')\n if (content.includes(entry)) return\n appendFileSync(gitignorePath, `\\n${entry}\\n`, 'utf-8')\n } else {\n writeFileSync(gitignorePath, `${entry}\\n`, 'utf-8')\n }\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 { readFileSync } from 'node:fs'\nimport { basename } from 'node:path'\nimport { 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\nfunction readFileAsBlob(filePath: string): { blob: Blob; filename: string } {\n const buffer = readFileSync(filePath)\n return { blob: new Blob([buffer]), filename: basename(filePath) }\n}\n\nfunction validateCollection(name: string): string {\n if (!(COLLECTIONS as readonly string[]).includes(name)) {\n const normalized = name.replace(/-/g, '').toLowerCase()\n const suggestions = COLLECTIONS.filter((c) => {\n const cn = c.replace(/-/g, '').toLowerCase()\n return cn.startsWith(normalized) || normalized.startsWith(cn) || (normalized.length >= 3 && cn.includes(normalized))\n }).slice(0, 5)\n const hint = suggestions.length > 0\n ? `Did you mean: ${suggestions.join(', ')}?`\n : 'Run \"01 --help\" for available collections.'\n throw new Error(`Unknown collection \"${name}\". ${hint}`)\n }\n return name\n}\n\nfunction parseSelect(input: string): Record<string, boolean> {\n return Object.fromEntries(input.split(',').map((f) => [f.trim(), true]))\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 .option('--depth <n>', 'Relationship depth (0 = no population)', (v: string) => parseInt(v, 10))\n .option('--select <fields>', 'Comma-separated fields to select')\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 if (opts.depth != null) options.depth = opts.depth\n if (opts.select) options.select = parseSelect(opts.select)\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 .option('--depth <n>', 'Relationship depth (0 = no population)', (v: string) => parseInt(v, 10))\n .option('--select <fields>', 'Comma-separated fields to select')\n .action(async (collection: string, id: string, opts) => {\n try {\n const col = validateCollection(collection)\n const client = getClient()\n const options: Record<string, unknown> = {}\n if (opts.depth != null) options.depth = opts.depth\n if (opts.select) options.select = parseSelect(opts.select)\n const result = await client.collections.from(col as typeof COLLECTIONS[number]).findById(id, options)\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 .option('--file <path>', 'File to upload (for upload collections)')\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 let fileOpts: { file: Blob; filename: string } | undefined\n if (opts.file) {\n const { blob, filename } = readFileAsBlob(opts.file)\n fileOpts = { file: blob, filename }\n }\n const result = await client.collections.from(col as typeof COLLECTIONS[number]).create(data, fileOpts)\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 .option('--file <path>', 'File to upload (for upload collections)')\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 let fileOpts: { file: Blob; filename: string } | undefined\n if (opts.file) {\n const { blob, filename } = readFileAsBlob(opts.file)\n fileOpts = { file: blob, filename }\n }\n const result = await client.collections.from(col as typeof COLLECTIONS[number]).update(id, data, fileOpts)\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 {\n loadCredentials,\n saveCredentials,\n deleteCredentials,\n getCredentialsPath,\n loadLocalCredentials,\n saveLocalCredentials,\n getLocalCredentialsPath,\n loadTenantList,\n saveTenantList,\n type TenantInfo,\n} 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\n/**\n * Start a local HTTP server that receives the OAuth-like callback from the browser.\n * Returns a promise that resolves with the received credentials, or rejects on error/timeout.\n */\nfunction startAuthServer(options: {\n state: string\n saveFn: (creds: { clientKey: string; secretKey: string; tenantId?: string; tenantName: string }) => void\n}): Promise<{ port: number; cleanup: (exitCode?: number) => void }> {\n return new Promise((resolve, reject) => {\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 tenantIdParam = url.searchParams.get('tenantId')\n const tenantsParam = url.searchParams.get('tenants')\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 !== options.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 // Save credentials using the provided save function\n options.saveFn({\n clientKey,\n secretKey,\n ...(tenantIdParam ? { tenantId: tenantIdParam } : {}),\n tenantName: tenant,\n })\n\n // Cache tenant list if provided\n if (tenantsParam) {\n try {\n const parsed = JSON.parse(tenantsParam)\n if (Array.isArray(parsed)) {\n const valid = parsed.filter(\n (t): t is TenantInfo => typeof t?.id === 'string' && typeof t?.name === 'string',\n )\n if (valid.length > 0) saveTenantList(valid)\n }\n } catch {\n // Ignore malformed tenants param\n }\n }\n\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 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 reject(new Error('Failed to start local server.'))\n return\n }\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 resolve({ port: addr.port, cleanup })\n })\n\n server.on('error', (err) => {\n reject(err)\n })\n })\n}\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 try {\n const { port } = await startAuthServer({\n state,\n saveFn: (creds) => {\n saveCredentials(creds)\n console.log(pc.dim(`Credentials saved to ${getCredentialsPath()}`))\n },\n })\n\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 } catch (err) {\n console.error(pc.red(`Server error: ${err instanceof Error ? err.message : String(err)}`))\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 // Check local credentials first\n const localCreds = loadLocalCredentials()\n const globalCreds = loadCredentials()\n const creds = localCreds || globalCreds\n const isLocal = !!localCreds\n\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 const scope = isLocal ? pc.cyan(' (local)') : ''\n console.log(`Tenant: ${pc.bold(creds.tenantName)}${scope}`)\n console.log(`Client Key: ${pc.dim(masked)}`)\n console.log(`Stored at: ${pc.dim(creds.storedAt)}`)\n console.log(`File: ${pc.dim(isLocal ? getLocalCredentialsPath() : getCredentialsPath())}`)\n })\n\n // -------------------------------------------------------------------------\n // tenant subcommands\n // -------------------------------------------------------------------------\n const tenant = program\n .command('tenant')\n .description('Manage tenant switching')\n\n tenant\n .command('list')\n .description('Show cached tenant list')\n .action(() => {\n const tenants = loadTenantList()\n if (!tenants || tenants.length === 0) {\n console.log(pc.dim('No cached tenants. Run \"01 login\" first.'))\n return\n }\n\n // Determine active tenant\n const localCreds = loadLocalCredentials()\n const globalCreds = loadCredentials()\n const activeCreds = localCreds || globalCreds\n const activeId = activeCreds?.tenantId\n const activeName = activeCreds?.tenantName\n\n console.log(pc.bold('Cached tenants:\\n'))\n for (const t of tenants) {\n const active = (activeId ? t.id === activeId : t.name === activeName)\n ? pc.green(' *')\n : ''\n console.log(` ${t.name}${active}`)\n }\n console.log()\n if (activeName) {\n const scope = localCreds ? '(local)' : '(global)'\n console.log(pc.dim(`* active ${scope}`))\n }\n })\n\n tenant\n .command('use <name>')\n .description('Switch to a different tenant via browser')\n .option('--local', 'Save credentials locally in the current project')\n .action(async (name: string, opts: { local?: boolean }) => {\n const tenants = loadTenantList()\n if (!tenants || tenants.length === 0) {\n console.error(pc.red('No cached tenants. Run \"01 login\" first.'))\n process.exit(1)\n }\n\n const match = tenants.find((t) => t.name.toLowerCase() === name.toLowerCase())\n if (!match) {\n console.error(pc.red(`Tenant \"${name}\" not found in cache.`))\n console.error(pc.dim(`Available: ${tenants.map((t) => t.name).join(', ')}`))\n process.exit(1)\n }\n\n const state = randomBytes(32).toString('hex')\n const isLocal = !!opts.local\n\n try {\n const { port } = await startAuthServer({\n state,\n saveFn: (creds) => {\n if (isLocal) {\n saveLocalCredentials(creds)\n console.log(pc.dim(`Credentials saved to ${getLocalCredentialsPath()}`))\n } else {\n saveCredentials(creds)\n console.log(pc.dim(`Credentials saved to ${getCredentialsPath()}`))\n }\n },\n })\n\n const params = new URLSearchParams({\n port: String(port),\n state,\n tenantId: match.id,\n })\n const loginUrl = `${WEB_URL}/cli-auth?${params.toString()}`\n\n console.log(pc.dim(`Switching to tenant \"${match.name}\"...`))\n console.log(pc.dim(`If the browser does not open, visit:\\n${loginUrl}`))\n openBrowser(loginUrl)\n } catch (err) {\n console.error(pc.red(`Server error: ${err instanceof Error ? err.message : String(err)}`))\n process.exit(1)\n }\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,YAAY,sBAAsB;AAC/F,SAAS,YAAY;AACrB,SAAS,eAAe;AAexB,IAAM,WAAW;AACjB,IAAM,YAAY;AAClB,IAAM,eAAe;AAMd,SAAS,qBAA6B;AAC3C,SAAO,KAAK,QAAQ,GAAG,UAAU,SAAS;AAC5C;AAEO,SAAS,kBAA4C;AAC1D,SAAO,oBAAoB,mBAAmB,CAAC;AACjD;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,QAAO;AAElC,aAAW,QAAQ;AACnB,SAAO;AACT;AAMO,SAAS,0BAAkC;AAChD,SAAO,KAAK,QAAQ,IAAI,GAAG,UAAU,SAAS;AAChD;AAEO,SAAS,uBAAiD;AAC/D,SAAO,oBAAoB,wBAAwB,CAAC;AACtD;AAEO,SAAS,qBAAqB,OAAkD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AAAA,EAAyC,QAAQ,EAAE,CAAC;AACvE,kBAAY,QAAQ;AAAA,IACtB,SAAS,KAAK;AACZ,cAAQ,MAAMA,IAAG,IAAI,iBAAiB,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,CAAC,EAAE,CAAC;AACzF,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF,CAAC;AACL;;;AX7TA,IAAME,WAAU,cAAc,YAAY,GAAG;AAC7C,IAAM,EAAE,QAAQ,IAAIA,SAAQ,iBAAiB;AAE7C,QAAQ,GAAG,sBAAsB,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","readFileSync","pc","readFileSync","program","getClient","getFormat","program","getClient","getFormat","program","getClient","getFormat","program","getClient","getFormat","program","getClient","getFormat","program","getClient","getFormat","pc","pc","program","require"]}
|
|
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, loadLocalCredentials } 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: local credentials (./01software/credentials.json)\n if (!clientKey || !secretKey) {\n const local = loadLocalCredentials()\n if (local) {\n clientKey = local.clientKey\n secretKey = local.secretKey\n }\n }\n\n // Fallback: global credentials (~/.01software/credentials.json)\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, appendFileSync } from 'node:fs'\nimport { join } from 'node:path'\nimport { homedir } from 'node:os'\n\nexport interface StoredCredentials {\n clientKey: string\n secretKey: string\n tenantId?: string\n tenantName: string\n storedAt: string\n}\n\nexport interface TenantInfo {\n id: string\n name: string\n}\n\nconst DIR_NAME = '.01software'\nconst FILE_NAME = 'credentials.json'\nconst TENANTS_FILE = 'tenants.json'\n\n// ---------------------------------------------------------------------------\n// Global credentials (~/.01software/credentials.json)\n// ---------------------------------------------------------------------------\n\nexport function getCredentialsPath(): string {\n return join(homedir(), DIR_NAME, FILE_NAME)\n}\n\nexport function loadCredentials(): StoredCredentials | null {\n return loadCredentialsFrom(getCredentialsPath())\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\n// ---------------------------------------------------------------------------\n// Local credentials (./01software/credentials.json)\n// ---------------------------------------------------------------------------\n\nexport function getLocalCredentialsPath(): string {\n return join(process.cwd(), DIR_NAME, FILE_NAME)\n}\n\nexport function loadLocalCredentials(): StoredCredentials | null {\n return loadCredentialsFrom(getLocalCredentialsPath())\n}\n\nexport function saveLocalCredentials(creds: Omit<StoredCredentials, 'storedAt'>): void {\n const dir = join(process.cwd(), DIR_NAME)\n if (!existsSync(dir)) {\n mkdirSync(dir, { recursive: true, mode: 0o700 })\n }\n\n const filePath = getLocalCredentialsPath()\n const data: StoredCredentials = { ...creds, storedAt: new Date().toISOString() }\n writeFileSync(filePath, JSON.stringify(data, null, 2), { encoding: 'utf-8', mode: 0o600 })\n\n // Ensure .01software/ is in .gitignore\n ensureGitignore()\n}\n\n// ---------------------------------------------------------------------------\n// Tenant list cache (~/.01software/tenants.json)\n// ---------------------------------------------------------------------------\n\nexport function saveTenantList(tenants: TenantInfo[]): void {\n const dir = join(homedir(), DIR_NAME)\n if (!existsSync(dir)) {\n mkdirSync(dir, { recursive: true, mode: 0o700 })\n }\n\n const filePath = join(homedir(), DIR_NAME, TENANTS_FILE)\n writeFileSync(filePath, JSON.stringify(tenants, null, 2), { encoding: 'utf-8', mode: 0o600 })\n}\n\nexport function loadTenantList(): TenantInfo[] | null {\n const filePath = join(homedir(), DIR_NAME, TENANTS_FILE)\n if (!existsSync(filePath)) return null\n\n try {\n const raw = readFileSync(filePath, 'utf-8')\n const data = JSON.parse(raw)\n if (!Array.isArray(data)) return null\n const valid = data.filter(\n (t): t is TenantInfo => typeof t?.id === 'string' && typeof t?.name === 'string',\n )\n return valid.length > 0 ? valid : null\n } catch {\n return null\n }\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nfunction loadCredentialsFrom(filePath: string): StoredCredentials | null {\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\nfunction ensureGitignore(): void {\n const gitignorePath = join(process.cwd(), '.gitignore')\n const entry = '.01software/'\n\n if (existsSync(gitignorePath)) {\n const content = readFileSync(gitignorePath, 'utf-8')\n if (content.includes(entry)) return\n appendFileSync(gitignorePath, `\\n${entry}\\n`, 'utf-8')\n } else {\n writeFileSync(gitignorePath, `${entry}\\n`, 'utf-8')\n }\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 { readFileSync } from 'node:fs'\nimport { basename } from 'node:path'\nimport { 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\nfunction readFileAsBlob(filePath: string): { blob: Blob; filename: string } {\n const buffer = readFileSync(filePath)\n return { blob: new Blob([buffer]), filename: basename(filePath) }\n}\n\nfunction validateCollection(name: string): string {\n if (!(COLLECTIONS as readonly string[]).includes(name)) {\n const normalized = name.replace(/-/g, '').toLowerCase()\n const suggestions = COLLECTIONS.filter((c) => {\n const cn = c.replace(/-/g, '').toLowerCase()\n return cn.startsWith(normalized) || normalized.startsWith(cn) || (normalized.length >= 3 && cn.includes(normalized))\n }).slice(0, 5)\n const hint = suggestions.length > 0\n ? `Did you mean: ${suggestions.join(', ')}?`\n : 'Run \"01 --help\" for available collections.'\n throw new Error(`Unknown collection \"${name}\". ${hint}`)\n }\n return name\n}\n\nfunction parseSelect(input: string): Record<string, boolean> {\n return Object.fromEntries(input.split(',').map((f) => [f.trim(), true]))\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 .option('--depth <n>', 'Relationship depth (0 = no population)', (v: string) => parseInt(v, 10))\n .option('--select <fields>', 'Comma-separated fields to select')\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 if (opts.depth != null) options.depth = opts.depth\n if (opts.select) options.select = parseSelect(opts.select)\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 .option('--depth <n>', 'Relationship depth (0 = no population)', (v: string) => parseInt(v, 10))\n .option('--select <fields>', 'Comma-separated fields to select')\n .action(async (collection: string, id: string, opts) => {\n try {\n const col = validateCollection(collection)\n const client = getClient()\n const options: Record<string, unknown> = {}\n if (opts.depth != null) options.depth = opts.depth\n if (opts.select) options.select = parseSelect(opts.select)\n const result = await client.collections.from(col as typeof COLLECTIONS[number]).findById(id, options)\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 .option('--file <path>', 'File to upload (for upload collections)')\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 let fileOpts: { file: Blob; filename: string } | undefined\n if (opts.file) {\n const { blob, filename } = readFileAsBlob(opts.file)\n fileOpts = { file: blob, filename }\n }\n const result = await client.collections.from(col as typeof COLLECTIONS[number]).create(data, fileOpts)\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 .option('--file <path>', 'File to upload (for upload collections)')\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 let fileOpts: { file: Blob; filename: string } | undefined\n if (opts.file) {\n const { blob, filename } = readFileAsBlob(opts.file)\n fileOpts = { file: blob, filename }\n }\n const result = await client.collections.from(col as typeof COLLECTIONS[number]).update(id, data, fileOpts)\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 .option('--payment-id <id>', 'Payment ID')\n .requiredOption('--order-number <num>', 'Order number')\n .requiredOption('--email <email>', 'Customer email')\n .option('--customer <id>', 'Customer ID')\n .option('--name <name>', 'Customer name')\n .option('--phone <phone>', 'Customer phone')\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 customerSnapshot: {\n email: opts.email,\n name: opts.name,\n phone: opts.phone,\n },\n customer: opts.customer,\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 {\n loadCredentials,\n saveCredentials,\n deleteCredentials,\n getCredentialsPath,\n loadLocalCredentials,\n saveLocalCredentials,\n getLocalCredentialsPath,\n loadTenantList,\n saveTenantList,\n type TenantInfo,\n} 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\n/**\n * Start a local HTTP server that receives the OAuth-like callback from the browser.\n * Returns a promise that resolves with the received credentials, or rejects on error/timeout.\n */\nfunction startAuthServer(options: {\n state: string\n saveFn: (creds: { clientKey: string; secretKey: string; tenantId?: string; tenantName: string }) => void\n}): Promise<{ port: number; cleanup: (exitCode?: number) => void }> {\n return new Promise((resolve, reject) => {\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 tenantIdParam = url.searchParams.get('tenantId')\n const tenantsParam = url.searchParams.get('tenants')\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 !== options.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 // Save credentials using the provided save function\n options.saveFn({\n clientKey,\n secretKey,\n ...(tenantIdParam ? { tenantId: tenantIdParam } : {}),\n tenantName: tenant,\n })\n\n // Cache tenant list if provided\n if (tenantsParam) {\n try {\n const parsed = JSON.parse(tenantsParam)\n if (Array.isArray(parsed)) {\n const valid = parsed.filter(\n (t): t is TenantInfo => typeof t?.id === 'string' && typeof t?.name === 'string',\n )\n if (valid.length > 0) saveTenantList(valid)\n }\n } catch {\n // Ignore malformed tenants param\n }\n }\n\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 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 reject(new Error('Failed to start local server.'))\n return\n }\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 resolve({ port: addr.port, cleanup })\n })\n\n server.on('error', (err) => {\n reject(err)\n })\n })\n}\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 try {\n const { port } = await startAuthServer({\n state,\n saveFn: (creds) => {\n saveCredentials(creds)\n console.log(pc.dim(`Credentials saved to ${getCredentialsPath()}`))\n },\n })\n\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 } catch (err) {\n console.error(pc.red(`Server error: ${err instanceof Error ? err.message : String(err)}`))\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 // Check local credentials first\n const localCreds = loadLocalCredentials()\n const globalCreds = loadCredentials()\n const creds = localCreds || globalCreds\n const isLocal = !!localCreds\n\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 const scope = isLocal ? pc.cyan(' (local)') : ''\n console.log(`Tenant: ${pc.bold(creds.tenantName)}${scope}`)\n console.log(`Client Key: ${pc.dim(masked)}`)\n console.log(`Stored at: ${pc.dim(creds.storedAt)}`)\n console.log(`File: ${pc.dim(isLocal ? getLocalCredentialsPath() : getCredentialsPath())}`)\n })\n\n // -------------------------------------------------------------------------\n // tenant subcommands\n // -------------------------------------------------------------------------\n const tenant = program\n .command('tenant')\n .description('Manage tenant switching')\n\n tenant\n .command('list')\n .description('Show cached tenant list')\n .action(() => {\n const tenants = loadTenantList()\n if (!tenants || tenants.length === 0) {\n console.log(pc.dim('No cached tenants. Run \"01 login\" first.'))\n return\n }\n\n // Determine active tenant\n const localCreds = loadLocalCredentials()\n const globalCreds = loadCredentials()\n const activeCreds = localCreds || globalCreds\n const activeId = activeCreds?.tenantId\n const activeName = activeCreds?.tenantName\n\n console.log(pc.bold('Cached tenants:\\n'))\n for (const t of tenants) {\n const active = (activeId ? t.id === activeId : t.name === activeName)\n ? pc.green(' *')\n : ''\n console.log(` ${t.name}${active}`)\n }\n console.log()\n if (activeName) {\n const scope = localCreds ? '(local)' : '(global)'\n console.log(pc.dim(`* active ${scope}`))\n }\n })\n\n tenant\n .command('use <name>')\n .description('Switch to a different tenant via browser')\n .option('--local', 'Save credentials locally in the current project')\n .action(async (name: string, opts: { local?: boolean }) => {\n const tenants = loadTenantList()\n if (!tenants || tenants.length === 0) {\n console.error(pc.red('No cached tenants. Run \"01 login\" first.'))\n process.exit(1)\n }\n\n const match = tenants.find((t) => t.name.toLowerCase() === name.toLowerCase())\n if (!match) {\n console.error(pc.red(`Tenant \"${name}\" not found in cache.`))\n console.error(pc.dim(`Available: ${tenants.map((t) => t.name).join(', ')}`))\n process.exit(1)\n }\n\n const state = randomBytes(32).toString('hex')\n const isLocal = !!opts.local\n\n try {\n const { port } = await startAuthServer({\n state,\n saveFn: (creds) => {\n if (isLocal) {\n saveLocalCredentials(creds)\n console.log(pc.dim(`Credentials saved to ${getLocalCredentialsPath()}`))\n } else {\n saveCredentials(creds)\n console.log(pc.dim(`Credentials saved to ${getCredentialsPath()}`))\n }\n },\n })\n\n const params = new URLSearchParams({\n port: String(port),\n state,\n tenantId: match.id,\n })\n const loginUrl = `${WEB_URL}/cli-auth?${params.toString()}`\n\n console.log(pc.dim(`Switching to tenant \"${match.name}\"...`))\n console.log(pc.dim(`If the browser does not open, visit:\\n${loginUrl}`))\n openBrowser(loginUrl)\n } catch (err) {\n console.error(pc.red(`Server error: ${err instanceof Error ? err.message : String(err)}`))\n process.exit(1)\n }\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,YAAY,sBAAsB;AAC/F,SAAS,YAAY;AACrB,SAAS,eAAe;AAexB,IAAM,WAAW;AACjB,IAAM,YAAY;AAClB,IAAM,eAAe;AAMd,SAAS,qBAA6B;AAC3C,SAAO,KAAK,QAAQ,GAAG,UAAU,SAAS;AAC5C;AAEO,SAAS,kBAA4C;AAC1D,SAAO,oBAAoB,mBAAmB,CAAC;AACjD;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,QAAO;AAElC,aAAW,QAAQ;AACnB,SAAO;AACT;AAMO,SAAS,0BAAkC;AAChD,SAAO,KAAK,QAAQ,IAAI,GAAG,UAAU,SAAS;AAChD;AAEO,SAAS,uBAAiD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,IAAI,gBAAgB;AAAA,QACjC,MAAM,OAAO,IAAI;AAAA,QACjB;AAAA,QACA,UAAU,MAAM;AAAA,MAClB,CAAC;AACD,YAAM,WAAW,GAAG,OAAO,aAAa,OAAO,SAAS,CAAC;AAEzD,cAAQ,IAAIA,IAAG,IAAI,wBAAwB,MAAM,IAAI,MAAM,CAAC;AAC5D,cAAQ,IAAIA,IAAG,IAAI;AAAA,EAAyC,QAAQ,EAAE,CAAC;AACvE,kBAAY,QAAQ;AAAA,IACtB,SAAS,KAAK;AACZ,cAAQ,MAAMA,IAAG,IAAI,iBAAiB,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,CAAC,EAAE,CAAC;AACzF,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF,CAAC;AACL;;;AX7TA,IAAME,WAAU,cAAc,YAAY,GAAG;AAC7C,IAAM,EAAE,QAAQ,IAAIA,SAAQ,iBAAiB;AAE7C,QAAQ,GAAG,sBAAsB,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","readFileSync","pc","readFileSync","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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@01.software/cli",
|
|
3
|
-
"version": "0.2.0-dev.
|
|
3
|
+
"version": "0.2.0-dev.260310.cf511cb",
|
|
4
4
|
"description": "CLI tool for 01.software platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"commander": "^14.0.3",
|
|
17
17
|
"picocolors": "^1.1.1",
|
|
18
|
-
"@01.software/sdk": "0.2.9-dev.
|
|
18
|
+
"@01.software/sdk": "0.2.9-dev.260310.cf511cb"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"tsup": "^8.5.0",
|