@waffo/pancake-cli 0.0.0-stage → 0.0.1-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/CONTRIBUTING.md +38 -0
  3. package/LICENSE +21 -0
  4. package/README.md +230 -2
  5. package/SECURITY.md +23 -0
  6. package/SKILL.md +110 -0
  7. package/dist/adapters/browser-login.js +210 -0
  8. package/dist/adapters/config.js +180 -0
  9. package/dist/adapters/files.js +222 -0
  10. package/dist/adapters/loopback-forward.js +33 -0
  11. package/dist/adapters/operations.js +89 -0
  12. package/dist/adapters/pancake/client.js +235 -0
  13. package/dist/adapters/pancake/conflict-error.js +18 -0
  14. package/dist/adapters/pancake/graphql-errors.js +41 -0
  15. package/dist/adapters/pancake/http-error-reason.js +12 -0
  16. package/dist/adapters/pancake/queries.js +9 -0
  17. package/dist/adapters/pancake/safe-reason.js +23 -0
  18. package/dist/adapters/system-process.js +12 -0
  19. package/dist/application/action-auth.js +7 -0
  20. package/dist/application/action-result.js +40 -0
  21. package/dist/application/api-actions.js +80 -0
  22. package/dist/application/api-reads.js +56 -0
  23. package/dist/application/auth-context.js +34 -0
  24. package/dist/application/auth.js +115 -0
  25. package/dist/application/confirmation.js +14 -0
  26. package/dist/application/diagnostics.js +48 -0
  27. package/dist/application/dispatch.js +109 -0
  28. package/dist/application/idempotency.js +8 -0
  29. package/dist/application/listen.js +147 -0
  30. package/dist/application/local.js +35 -0
  31. package/dist/application/product-verification.js +96 -0
  32. package/dist/application/products.js +70 -0
  33. package/dist/application/queries.js +26 -0
  34. package/dist/application/read-handlers.js +30 -0
  35. package/dist/application/read-operation.js +30 -0
  36. package/dist/application/webhooks.js +56 -0
  37. package/dist/application/write-operation.js +26 -0
  38. package/dist/cli/guidance.js +29 -0
  39. package/dist/cli/human-output.js +44 -0
  40. package/dist/cli/input.js +62 -0
  41. package/dist/cli/listen-output.js +10 -0
  42. package/dist/cli/login-prompt.js +66 -0
  43. package/dist/cli/output.js +43 -0
  44. package/dist/cli/run.js +128 -0
  45. package/dist/commands/action-definitions.js +100 -0
  46. package/dist/commands/action-previews.js +12 -0
  47. package/dist/commands/action-schemas.js +47 -0
  48. package/dist/commands/action-values.js +11 -0
  49. package/dist/commands/api-coverage.js +25 -0
  50. package/dist/commands/checkout-action-schema.js +25 -0
  51. package/dist/commands/discount-definitions.js +47 -0
  52. package/dist/commands/discount-preview.js +17 -0
  53. package/dist/commands/discount-schemas.js +39 -0
  54. package/dist/commands/discount-validation.js +17 -0
  55. package/dist/commands/listen-input.js +12 -0
  56. package/dist/commands/operation-impact.js +16 -0
  57. package/dist/commands/product-action-schemas.js +26 -0
  58. package/dist/commands/product-preview.js +5 -0
  59. package/dist/commands/read-definitions.js +92 -0
  60. package/dist/commands/read-query.js +49 -0
  61. package/dist/commands/read-schemas.js +17 -0
  62. package/dist/commands/registry.js +45 -0
  63. package/dist/commands/schemas.js +94 -0
  64. package/dist/commands/webhook-preview.js +3 -0
  65. package/dist/contracts/action-routes.js +7 -0
  66. package/dist/contracts/command.js +1 -0
  67. package/dist/contracts/errors.js +26 -0
  68. package/dist/contracts/impact.js +1 -0
  69. package/dist/contracts/listen.js +1 -0
  70. package/dist/contracts/loopback-target.js +14 -0
  71. package/dist/contracts/types.js +1 -0
  72. package/dist/index.js +20 -0
  73. package/docs/api-coverage.md +154 -0
  74. package/docs/usage.md +458 -0
  75. package/package.json +60 -4
@@ -0,0 +1,45 @@
1
+ import { actionSpecs } from "./action-definitions.js";
2
+ import { readSpecs } from "./read-definitions.js";
3
+ import { objectSchema, productSchema, storeId, string, webhookSchemas } from "./schemas.js";
4
+ const noInput = objectSchema({});
5
+ export const globalOptions = [
6
+ ['--json', 'Output JSON (listen streams NDJSON)'], ['--no-interactive', 'Never prompt'],
7
+ ['--store-id <id>', 'Target store ID'], ['--yes', 'Confirm a remote change; does not bypass validation'],
8
+ ['--confirm-production', 'Explicitly allow this operation to affect Production; still requires --yes'],
9
+ ['--confirm-shared', 'Explicitly allow changes shared by Test and Production; still requires --yes'],
10
+ ['--debug', 'Write redacted request diagnostics to stderr'],
11
+ ];
12
+ const paginationOptions = [['--limit <number>', 'Page size, 1–100 (default 20)'], ['--offset <number>', 'Zero-based offset (default 0)'], ['--fields <names>', 'Comma-separated top-level result fields']];
13
+ export const definitions = [
14
+ { id: 'listen', path: 'listen', description: 'Forward temporary merchant event deliveries to a loopback receiver', schema: noInput, effect: 'read', options: [['--forward-to <url>', 'HTTP(S) loopback receiver URL (required)'], ['--events <names>', 'Comma-separated event names'], ['--live', 'Explicitly listen in production; defaults to test']], example: 'pancake listen --store-id STO_abc --forward-to http://localhost:3000/webhook --json' },
15
+ { id: 'commands', path: 'commands', description: 'List available commands (offline)', schema: noInput, effect: 'none', example: 'pancake commands --json' },
16
+ { id: 'schema', path: 'schema', argument: 'command', description: 'Show command fields, output format and an example', schema: objectSchema({ command: string }, ['command']), effect: 'none', example: 'pancake schema webhook.add --json' },
17
+ { id: 'login', path: 'login', description: 'Log in through your browser, or use an RSA key', schema: noInput, effect: 'local', options: [['--key-login', 'Enter an RSA key instead of opening a browser'], ['--api-url <origin>', 'Explicit API origin for browser login (HTTPS or local loopback)'], ['--dashboard-url <origin>', 'Explicit Dashboard origin for browser login (HTTPS or local loopback)'], ['--merchant-id <id>', 'Merchant ID for RSA login'], ['--private-key-file <path>', 'RSA private-key file path'], ['--key <value>', 'Auto-detect key or path; use the hidden prompt for secret contents']], example: 'pancake login --merchant-id MER_abc --private-key-file ./key.pem' },
18
+ { id: 'env', path: 'env', argument: 'environment', description: 'Verify and select test or prod for your browser login', schema: objectSchema({ environment: { type: 'string', enum: ['test', 'prod'] } }, ['environment']), effect: 'local', example: 'pancake env test' },
19
+ { id: 'whoami', path: 'whoami', description: 'Check your login and merchant identity', schema: noInput, effect: 'read', example: 'pancake whoami --json' },
20
+ { id: 'logout', path: 'logout', description: 'Clear your saved login', schema: noInput, effect: 'local', example: 'pancake logout --json' },
21
+ { id: 'config.show', path: 'config show', description: 'Show settings with secrets hidden', schema: noInput, effect: 'none', example: 'pancake config show --json' },
22
+ { id: 'doctor', path: 'doctor', description: 'Check settings, connection and identity', schema: noInput, effect: 'read', example: 'pancake doctor --json' },
23
+ { id: 'stores.list', path: 'stores list', description: 'Read one page of accessible stores', schema: noInput, options: paginationOptions, effect: 'read', example: 'pancake stores list --limit 20 --json' },
24
+ { id: 'products.get', path: 'products get', argument: 'id', description: 'Read an onetime or subscription product', schema: objectSchema({ id: { type: 'string', pattern: '^PROD_[A-Za-z0-9]+$' } }, ['id']), options: [['--type <type>', 'onetime or subscription (required)'], ['--fields <names>', 'Comma-separated top-level result fields']], effect: 'read', example: 'pancake products get PROD_abc --type onetime --json' },
25
+ { id: 'products.create', path: 'products create', description: 'Create an onetime or subscription product; requires --yes and may affect production', schema: productSchema, file: true, options: [['--type <type>', 'onetime or subscription (required)'], ['--dry-run', 'Validate and preview offline without any side effects'], ['--idempotency-key <key>', 'Unique operation key; used keys are never automatically replayed']], effect: 'write', example: 'pancake products create --type onetime --file product.json --dry-run --json' },
26
+ { id: 'webhook.list', path: 'webhook list', description: 'List the configured store webhooks with the secret field omitted', schema: objectSchema({ storeId }, ['storeId']), effect: 'read', example: 'pancake webhook list --store-id STO_abc --json' },
27
+ ...['add', 'update', 'remove'].map(action => ({
28
+ id: `webhook.${action}`, path: `webhook ${action}`, description: `${action} a test webhook using the existing API; requires --yes`,
29
+ schema: webhookSchemas[action], effect: 'write', argument: action === 'add' ? undefined : 'id', file: action !== 'remove',
30
+ options: [['--dry-run', 'Validate and preview offline without writing'], ['--idempotency-key <key>', 'Unique operation key; used keys are never automatically replayed']],
31
+ example: action === 'add' ? 'pancake webhook add --file webhook.json --yes --json' : `pancake webhook ${action} 11111111-2222-3333-4444-555555555555 --store-id STO_abc${action === 'update' ? ' --file changes.json' : ''} --yes --json`,
32
+ })),
33
+ { id: 'operations.list', path: 'operations list', description: 'List local operation records', schema: noInput, options: [['--limit <number>', 'Maximum records, 1–100 (default 20)']], effect: 'none', example: 'pancake operations list --json' },
34
+ { id: 'operations.show', path: 'operations show', argument: 'id', description: 'Show a local operation record', schema: objectSchema({ id: string }, ['id']), effect: 'none', example: 'pancake operations show <operation-id> --json' },
35
+ { id: 'diagnostics.export', path: 'diagnostics export', description: 'Save a private diagnostics file locally', schema: noInput, options: [['--operation <id>', 'Operation ID (required)'], ['--output <path>', 'New output file path (required)']], effect: 'local', example: 'pancake diagnostics export --operation <operation-id> --output ./diagnostics.json' },
36
+ ...actionSpecs.map(spec => spec.definition),
37
+ ...readSpecs.map(spec => spec.definition),
38
+ ];
39
+ export const outputContract = {
40
+ streams: { listen: { format: 'ndjson', envelope: 'one standard envelope per event or error', eventTypes: ['ready', 'delivery', 'stopped'], eventId: 'Stable delivery ID identifies the same event across retries', authentication: 'browser session only', defaultEnvironment: 'test', production: '--live' } },
41
+ schemaVersion: 1, fields: ['schemaVersion', 'ok', 'data', 'error', 'meta'],
42
+ errorFields: ['code', 'message', 'stage', 'recovery', 'details'],
43
+ metaFields: ['cliVersion', 'outcome', 'operationId', 'requestId', 'merchantId', 'source', 'actualEnvironment', 'environmentVerified', 'impact', 'impactPolicy', 'requiresProductionConfirmation', 'requiresSharedConfirmation'],
44
+ exitCodes: { success: 0, executionOrVerification: 1, argumentsOrConfiguration: 2, interrupted: 130 },
45
+ };
@@ -0,0 +1,94 @@
1
+ import { Ajv } from 'ajv';
2
+ import { argumentError } from "../contracts/errors.js";
3
+ export const string = { type: 'string', minLength: 1 };
4
+ export const storeId = { type: 'string', pattern: '^STO_[A-Za-z0-9]+$' };
5
+ export const merchantId = { type: 'string', pattern: '^MER_[A-Za-z0-9]+$' };
6
+ export const uuid = { type: 'string', pattern: '^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$' };
7
+ export const objectSchema = (properties, required = []) => ({ type: 'object', properties, required, additionalProperties: false });
8
+ const amount = { description: 'Exact decimal amount within the backend currency precision; excess nonzero decimal places are rejected without rounding.', type: 'string', pattern: '^\\d+(\\.\\d+)?$', maxLength: 64 };
9
+ const taxCategory = { enum: ['digital_goods', 'saas', 'software', 'ebook', 'online_course', 'consulting', 'professional_service'] };
10
+ const commonProduct = {
11
+ storeId, name: { type: 'string', minLength: 1, maxLength: 64 }, description: { type: ['string', 'null'] },
12
+ media: { type: 'array', items: objectSchema({ type: { enum: ['image', 'video'] }, url: string, alt: { type: 'string' }, thumbnail: string }, ['type', 'url']) },
13
+ successUrl: { anyOf: [{ type: 'string', format: 'http-url', maxLength: 512 }, { type: 'null' }] },
14
+ metadata: { type: 'object', additionalProperties: true },
15
+ };
16
+ const priceSchema = (subscription) => ({ type: 'object', minProperties: 1, propertyNames: { pattern: '^[A-Z]{3}$' }, additionalProperties: objectSchema({ amount, taxCategory, ...(subscription ? { trialAmount: amount } : {}) }, ['amount', 'taxCategory']) });
17
+ export const productSchema = { oneOf: [
18
+ objectSchema({ ...commonProduct, type: { const: 'onetime' }, prices: priceSchema(false) }, ['type', 'storeId', 'name', 'prices']),
19
+ objectSchema({ ...commonProduct, type: { const: 'subscription' }, prices: priceSchema(true), billingPeriod: { enum: ['weekly', 'monthly', 'quarterly', 'yearly'] } }, ['type', 'storeId', 'name', 'prices', 'billingPeriod']),
20
+ ] };
21
+ const url = { type: 'string', format: 'https-url' };
22
+ const events = { type: 'array', items: string };
23
+ export const webhookSchemas = {
24
+ add: objectSchema({ storeId, channel: { enum: ['http', 'feishu', 'discord', 'telegram', 'slack'] }, url, events, testMode: { const: true }, secret: { type: ['string', 'null'] } }, ['storeId', 'channel', 'url', 'events', 'testMode']),
25
+ update: { ...objectSchema({ storeId, id: uuid, url, events, secret: { type: ['string', 'null'] } }, ['storeId', 'id']), anyOf: [{ required: ['url'] }, { required: ['events'] }, { required: ['secret'] }] },
26
+ remove: objectSchema({ storeId, id: uuid }, ['storeId', 'id']),
27
+ };
28
+ function validUrl(value, httpsOnly) {
29
+ try {
30
+ const url = new URL(value);
31
+ return (httpsOnly ? url.protocol === 'https:' : ['https:', 'http:'].includes(url.protocol)) && !url.username && !url.password;
32
+ }
33
+ catch {
34
+ return false;
35
+ }
36
+ }
37
+ export function createValidator() {
38
+ const ajv = new Ajv({ allErrors: true, strict: false, multipleOfPrecision: 10 });
39
+ ajv.addFormat('http-url', value => validUrl(value, false));
40
+ ajv.addFormat('https-url', value => validUrl(value, true));
41
+ return (schema, input) => {
42
+ if (!ajv.validate(schema, input))
43
+ throw argumentError('Input does not match the command schema. Run pancake schema <command> for required fields, types and examples.');
44
+ };
45
+ }
46
+ export function validateTrial(input) {
47
+ if (input.type !== 'subscription')
48
+ return;
49
+ const metadata = (input.metadata ?? {});
50
+ const prices = input.prices;
51
+ if (metadata.trialDays !== undefined && (!Number.isSafeInteger(metadata.trialDays) || Number(metadata.trialDays) < 1))
52
+ throw argumentError('metadata.trialDays must be a positive integer.');
53
+ validateTrialPrices(input);
54
+ for (const info of Object.values(prices)) {
55
+ if (info.trialAmount === undefined)
56
+ continue;
57
+ if (metadata.trialDays === undefined)
58
+ throw argumentError('Trial prices require metadata.trialDays.');
59
+ }
60
+ }
61
+ export function validateTrialPrices(input) {
62
+ if (input.type !== 'subscription' || input.prices === undefined)
63
+ return;
64
+ const prices = input.prices;
65
+ for (const info of Object.values(prices)) {
66
+ if (info.trialAmount === undefined)
67
+ continue;
68
+ const digits = Math.max(info.amount.split('.')[1]?.length ?? 0, info.trialAmount.split('.')[1]?.length ?? 0);
69
+ const integer = (s) => { const [whole, fraction = ''] = s.split('.'); return BigInt(whole + fraction.padEnd(digits, '0')); };
70
+ if (integer(info.trialAmount) >= integer(info.amount))
71
+ throw argumentError('trialAmount must be less than the regular amount.');
72
+ }
73
+ }
74
+ // Matches resource-service app/lib/currency.ts, including its default exponent.
75
+ // This is the backend conversion contract, not an ISO currency-support list.
76
+ const currencyExponents = {
77
+ BHD: 3, KWD: 3, OMR: 3,
78
+ BIF: 0, CLP: 0, DJF: 0, GNF: 0, ISK: 0, JPY: 0, KMF: 0, KRW: 0,
79
+ PYG: 0, RWF: 0, UGX: 0, VND: 0, VUV: 0, XAF: 0, XOF: 0, XPF: 0,
80
+ };
81
+ export function validateProductPrices(input) {
82
+ const prices = input.prices;
83
+ for (const [currency, price] of Object.entries(prices ?? {})) {
84
+ const exponent = currencyExponents[currency] ?? 2;
85
+ for (const field of ['amount', 'trialAmount']) {
86
+ const value = price[field];
87
+ if (value === undefined)
88
+ continue;
89
+ const fraction = (value.split('.')[1] ?? '').replace(/0+$/, '');
90
+ if (fraction.length > exponent)
91
+ throw argumentError(`prices.${currency}.${field} allows at most ${exponent} decimal places; ${value} would be rounded by the API. Supply an exact amount.`);
92
+ }
93
+ }
94
+ }
@@ -0,0 +1,3 @@
1
+ export function webhookPreview(input) {
2
+ return { ...input, ...(input.url !== undefined ? { url: '[redacted]' } : {}), ...(input.secret !== undefined ? { secret: '[redacted]' } : {}) };
3
+ }
@@ -0,0 +1,7 @@
1
+ export const DEFAULT_API_ORIGIN = 'https://api.waffo.ai';
2
+ export function productCreateEndpoint(type) {
3
+ return `/v1/actions/${type}-product/create-product`;
4
+ }
5
+ export function webhookEndpoint(action) {
6
+ return `/v1/actions/store/${action}-webhook`;
7
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,26 @@
1
+ export class CliError extends Error {
2
+ code;
3
+ exitCode;
4
+ stage;
5
+ recovery;
6
+ outcome;
7
+ details;
8
+ constructor(code, message, options = {}) {
9
+ super(message);
10
+ this.name = 'CliError';
11
+ this.code = code;
12
+ this.exitCode = options.exitCode ?? 1;
13
+ this.stage = options.stage ?? 'execution';
14
+ this.recovery = options.recovery ?? 'Check the command schema and configuration before trying again.';
15
+ this.outcome = options.outcome ?? 'rejected';
16
+ this.details = options.details ?? {};
17
+ }
18
+ }
19
+ export function argumentError(message) {
20
+ return new CliError('INVALID_ARGUMENT', message, { exitCode: 2, stage: 'input' });
21
+ }
22
+ export function safeError(error) {
23
+ return error instanceof CliError ? error : new CliError('LOCAL_ERROR', 'The local operation failed.', {
24
+ recovery: 'Check local file access and run pancake doctor. Raw exception details are omitted to protect credentials.',
25
+ });
26
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,14 @@
1
+ import { argumentError } from "./errors.js";
2
+ export function loopbackTarget(value) {
3
+ let url;
4
+ try {
5
+ url = new URL(value ?? '');
6
+ }
7
+ catch {
8
+ throw argumentError('Provide --forward-to with an HTTP(S) loopback URL.');
9
+ }
10
+ if (!['http:', 'https:'].includes(url.protocol) || !['localhost', '127.0.0.1', '[::1]'].includes(url.hostname) || url.username || url.password || url.hash) {
11
+ throw argumentError('--forward-to must use HTTP(S) on localhost, 127.0.0.1 or [::1], without credentials or a fragment.');
12
+ }
13
+ return url.href;
14
+ }
@@ -0,0 +1 @@
1
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env node
2
+ import pkg from '../package.json' with { type: 'json' };
3
+ import { ConfigStore, configDirectory, resolveCredentials, hasEnvironmentCredentials } from "./adapters/config.js";
4
+ import { OperationStore, inputFingerprint } from "./adapters/operations.js";
5
+ import { exportPrivateFile, preparePrivateOutput } from "./adapters/files.js";
6
+ import { forwardLoopback } from "./adapters/loopback-forward.js";
7
+ import { browserLogin } from "./adapters/browser-login.js";
8
+ import { createGateway } from "./adapters/pancake/client.js";
9
+ import { createApplication } from "./application/dispatch.js";
10
+ import { runCli } from "./cli/run.js";
11
+ const directory = configDirectory();
12
+ const config = new ConfigStore(directory);
13
+ const execute = createApplication({
14
+ browserLogin, forwardLoopback, config, operations: new OperationStore(directory), cliVersion: pkg.version,
15
+ environmentCredentialsPresent: hasEnvironmentCredentials(process.env),
16
+ credentials: options => resolveCredentials(config, options, process.env), gateway: createGateway,
17
+ diagnostic: event => { process.stderr.write(`${JSON.stringify(event)}\n`); },
18
+ exportFile: exportPrivateFile, prepareOutput: preparePrivateOutput, fingerprint: inputFingerprint,
19
+ });
20
+ process.exitCode = await runCli(process.argv.slice(2), pkg.version, execute);
@@ -0,0 +1,154 @@
1
+ # 商户 API 覆盖矩阵
2
+
3
+ 折扣契约核对日期:2026-11-03;其余文档快照:2026-10-26。2026-11-05 同步当前注册表。适用版本:0.0.1-rc.2;以当前注册表和官方 API 文档索引为准。**62 条命令,覆盖 33 个商户 API-Key REST action 路由**。此处“覆盖”指已提供命令入口,不表示全部字段、客户身份接口或真实商户验收完成。
4
+
5
+ 本地前缀为 `pnpm cli`;安装后的命令前缀为 `pancake`;`pnpm dev` 只负责自动构建。下表商户业务 REST Actions 远端执行必须 `--yes`,新增 Actions 使用 `--file`,支持 `--idempotency-key`(未给时生成);建议显式传 key 并保留操作编号。输入以 `schema <命令 ID>` 为准。
6
+
7
+ 验证分为本地模拟测试和隔离 Test 环境远端证据。部分身份/资源读取、折扣、临时监听和 2026-11-04 登录/商品/错误反馈回归已验证;不代表全部命令、全部非空资源或生产环境验收。测试数量与检查结果以当前运行记录为准。
8
+
9
+ 官网商品 GraphQL 示例与本次服务端 schema 存在差异:商品列表的 `storeId` 是顶层参数,商品对象没有 `version` 字段;版本历史使用必填 `productId` 参数且不支持分页。CLI 已按真实 schema 修正,并加入 schema 快照回归测试。
10
+
11
+ ## REST Actions:33 个路由
12
+
13
+ | 命令 | POST 路由 | 核验与限制 | 官方来源 |
14
+ | --- | --- | --- | --- |
15
+ | `pnpm cli products create --type onetime` | `/v1/actions/onetime-product/create-product` | 回读核验;不接受 taxIncluded | [文档](https://docs.waffo.ai/api-reference/endpoints/onetime-products/create-product) |
16
+ | `pnpm cli products create --type subscription` | `/v1/actions/subscription-product/create-product` | 回读核验;不接受 taxIncluded | [文档](https://docs.waffo.ai/api-reference/endpoints/subscription-products/create-product) |
17
+ | `pnpm cli webhook add` | `/v1/actions/store/add-webhook` | 回读核验;仅测试回调资源;网页登录不能回读密钥 | [文档](https://docs.waffo.ai/api-reference/endpoints/webhooks/add-webhook) |
18
+ | `pnpm cli webhook update` | `/v1/actions/store/update-webhook` | 回读核验;仅测试回调资源;网页登录不能回读密钥 | [文档](https://docs.waffo.ai/api-reference/endpoints/webhooks/update-webhook) |
19
+ | `pnpm cli webhook remove` | `/v1/actions/store/remove-webhook` | 回读核验;仅测试回调资源;网页登录不能回读密钥 | [文档](https://docs.waffo.ai/api-reference/endpoints/webhooks/remove-webhook) |
20
+ | `pnpm cli stores create` | `/v1/actions/store/create-store` | 仅响应校验 | [文档](https://docs.waffo.ai/api-reference/endpoints/stores/create-store) |
21
+ | `pnpm cli stores update` | `/v1/actions/store/update-store` | 仅响应校验 | [文档](https://docs.waffo.ai/api-reference/endpoints/stores/update-store) |
22
+ | `pnpm cli stores delete` | `/v1/actions/store/delete-store` | 仅响应校验 | [文档](https://docs.waffo.ai/api-reference/endpoints/stores/delete-store) |
23
+ | `pnpm cli products update --type onetime` | `/v1/actions/onetime-product/update-product` | 仅响应校验;不接受 taxIncluded | [文档](https://docs.waffo.ai/api-reference/endpoints/onetime-products/update-product) |
24
+ | `pnpm cli products update --type subscription` | `/v1/actions/subscription-product/update-product` | 仅响应校验;不接受 taxIncluded | [文档](https://docs.waffo.ai/api-reference/endpoints/subscription-products/update-product) |
25
+ | `pnpm cli products publish --type onetime` | `/v1/actions/onetime-product/publish-product` | 仅响应校验;测试发布到生产 | [文档](https://docs.waffo.ai/api-reference/endpoints/onetime-products/publish-product) |
26
+ | `pnpm cli products publish --type subscription` | `/v1/actions/subscription-product/publish-product` | 仅响应校验;测试发布到生产 | [文档](https://docs.waffo.ai/api-reference/endpoints/subscription-products/publish-product) |
27
+ | `pnpm cli products set-status --type onetime` | `/v1/actions/onetime-product/update-status` | 仅响应校验 | [文档](https://docs.waffo.ai/api-reference/endpoints/onetime-products/update-status) |
28
+ | `pnpm cli products set-status --type subscription` | `/v1/actions/subscription-product/update-status` | 仅响应校验 | [文档](https://docs.waffo.ai/api-reference/endpoints/subscription-products/update-status) |
29
+ | `pnpm cli groups create` | `/v1/actions/subscription-product-group/create-group` | 仅响应校验 | [文档](https://docs.waffo.ai/api-reference/endpoints/subscription-products/create-group) |
30
+ | `pnpm cli groups update` | `/v1/actions/subscription-product-group/update-group` | 仅响应校验 | [文档](https://docs.waffo.ai/api-reference/endpoints/subscription-products/update-group) |
31
+ | `pnpm cli groups delete` | `/v1/actions/subscription-product-group/delete-group` | 仅接收确认 | [文档](https://docs.waffo.ai/api-reference/endpoints/subscription-products/delete-group) |
32
+ | `pnpm cli groups publish` | `/v1/actions/subscription-product-group/publish-group` | 仅接收确认;测试发布到生产 | [文档](https://docs.waffo.ai/api-reference/endpoints/subscription-products/publish-group) |
33
+ | `pnpm cli checkout create` | `/v1/actions/checkout/create-session` | 仅响应校验;执行必须 --output 新私有文件 | [文档](https://docs.waffo.ai/api-reference/endpoints/orders/create-checkout-session) |
34
+ | `pnpm cli subscriptions cancel` | `/v1/actions/subscription-order/cancel-order` | 仅响应校验 | [文档](https://docs.waffo.ai/api-reference/endpoints/subscriptions/cancel-subscription) |
35
+ | `pnpm cli refunds create` | `/v1/actions/refund-ticket/create-ticket` | 仅响应校验;工单受理不等于退款到账 | [文档](https://docs.waffo.ai/api-reference/endpoints/refunds/create-refund-ticket) |
36
+ | `pnpm cli refunds resubmit` | `/v1/actions/refund-ticket/resubmit-ticket` | 仅响应校验;工单受理不等于退款到账 | [文档](https://docs.waffo.ai/api-reference/endpoints/refunds/resubmit-refund-ticket) |
37
+ | `pnpm cli sessions create` | `/v1/actions/auth/issue-session-token` | 仅 RSA;仅响应校验;执行必须 --output 新私有文件 | [文档](https://docs.waffo.ai/api-reference/endpoints/auth/issue-session-token) |
38
+ | `pnpm cli recipients add` | `/v1/actions/store-notification-recipient/add-recipient` | 仅响应校验 | [文档](https://docs.waffo.ai/api-reference/endpoints/notification-recipients/add-recipient) |
39
+ | `pnpm cli recipients update` | `/v1/actions/store-notification-recipient/update-recipient` | 仅响应校验 | [文档](https://docs.waffo.ai/api-reference/endpoints/notification-recipients/update-recipient) |
40
+ | `pnpm cli recipients remove` | `/v1/actions/store-notification-recipient/remove-recipient` | 仅响应校验 | [文档](https://docs.waffo.ai/api-reference/endpoints/notification-recipients/remove-recipient) |
41
+ | `pnpm cli content scan` | `/v1/actions/verification/scan-prompt` | 仅响应校验 | [文档](https://docs.waffo.ai/api-reference/endpoints/content-safety/scan-prompt) |
42
+ | `pnpm cli coupons create` | `/v1/actions/coupon/create-coupon` | 仅响应校验;商户权限;已有隔离 Test 验收 | [使用说明](usage.md#discounts) |
43
+ | `pnpm cli coupons update` | `/v1/actions/coupon/update-coupon` | 仅响应校验;商户权限;已有隔离 Test 验收 | [使用说明](usage.md#discounts) |
44
+ | `pnpm cli coupons deactivate` | `/v1/actions/coupon/deactivate-coupon` | 仅响应校验;商户权限;已有隔离 Test 验收 | [使用说明](usage.md#discounts) |
45
+ | `pnpm cli promotion-codes create` | `/v1/actions/promotion-code/create-promotion-code` | 仅响应校验;商户权限;已有隔离 Test 验收 | [使用说明](usage.md#discounts) |
46
+ | `pnpm cli promotion-codes generate` | `/v1/actions/promotion-code/generate-promotion-codes` | 仅响应校验;商户权限;已有隔离 Test 验收 | [使用说明](usage.md#discounts) |
47
+ | `pnpm cli promotion-codes deactivate` | `/v1/actions/promotion-code/deactivate-promotion-code` | 仅响应校验;商户权限;已有隔离 Test 验收 | [使用说明](usage.md#discounts) |
48
+
49
+ CLI 支持商户 Session 和 RSA API Key,具体路由仍由服务端鉴权;`sessions create` 仍需要 RSA API Key。`content scan` 是无状态读取判定,但采用同样的确认、持久化记录和单次 POST 策略。新增 Actions 的响应校验不证明资源被回读。`sessions create` 只签发客户 Token,不改变 CLI 登录。
50
+
51
+ ## 全部 62 条命令
52
+
53
+ 此表直接按注册表排列。下列选项为命令专属;全局选项有 `--json`、`--no-interactive`、`--store-id`、`--yes`、`--confirm-production`、`--confirm-shared`、`--debug`,不代表每条命令都会使用每个选项。表中 `--file` 是否必需、字段及选择器规则以 schema 为准。
54
+
55
+ | 命令 | 参数与专属选项 | API / 本地行为 |
56
+ | --- | --- | --- |
57
+ | `pnpm cli listen` | `--forward-to <url>`, `--events <names>`, `--live` | `/v1/graphql` 与 4 个临时监听路由;仅浏览器会话 |
58
+ | `pnpm cli commands` | — | 本地;不调用业务 API |
59
+ | `pnpm cli schema` | `<command>` | 本地;不调用业务 API |
60
+ | `pnpm cli login` | `--key-login`, `--merchant-id <id>`, `--private-key-file <path>`, `--api-url <origin>`, `--dashboard-url <origin>` | `/v1/actions/auth/cli-device-start`, `/v1/actions/auth/cli-device-token`, `/v1/actions/auth/cli-device-complete`, `/v1/graphql` |
61
+ | `pnpm cli env` | `<environment>` (test/prod) | `/v1/graphql`;验证后保存浏览器会话环境 |
62
+ | `pnpm cli whoami` | — | `/v1/graphql` |
63
+ | `pnpm cli logout` | — | 浏览器会话:`/v1/actions/merchant/sign-out-session` 撤销当前 CLI 会话后清理本地;RSA:仅清理本地凭证,不撤销 API Key |
64
+ | `pnpm cli config show` | — | 本地;不调用业务 API |
65
+ | `pnpm cli doctor` | — | `/v1/graphql` |
66
+ | `pnpm cli stores list` | `--limit <number>`, `--offset <number>`, `--fields <names>` | `/v1/graphql` |
67
+ | `pnpm cli products get` | `<id>`, `--type <type>`, `--fields <names>` | `/v1/graphql` |
68
+ | `pnpm cli products create` | `--file <path / ->`, `--type <type>`, `--dry-run`, `--idempotency-key <key>` | `/v1/actions/onetime-product/create-product` / `/v1/actions/subscription-product/create-product` |
69
+ | `pnpm cli webhook list` | — | `/v1/graphql` |
70
+ | `pnpm cli webhook add` | `--file <path / ->`, `--dry-run`, `--idempotency-key <key>` | `/v1/actions/store/add-webhook` |
71
+ | `pnpm cli webhook update` | `<id>`, `--file <path / ->`, `--dry-run`, `--idempotency-key <key>` | `/v1/actions/store/update-webhook` |
72
+ | `pnpm cli webhook remove` | `<id>`, `--dry-run`, `--idempotency-key <key>` | `/v1/actions/store/remove-webhook` |
73
+ | `pnpm cli operations list` | `--limit <number>` | 本地;不调用业务 API |
74
+ | `pnpm cli operations show` | `<id>` | 本地;不调用业务 API |
75
+ | `pnpm cli diagnostics export` | `--operation <id>`, `--output <path>` | 本地;不调用业务 API |
76
+ | `pnpm cli stores create` | `--file <path / ->`, `--dry-run`, `--idempotency-key <key>`, `--output <path>` | `/v1/actions/store/create-store` |
77
+ | `pnpm cli stores update` | `--file <path / ->`, `--dry-run`, `--idempotency-key <key>`, `--output <path>` | `/v1/actions/store/update-store` |
78
+ | `pnpm cli stores delete` | `--file <path / ->`, `--dry-run`, `--idempotency-key <key>`, `--output <path>` | `/v1/actions/store/delete-store` |
79
+ | `pnpm cli products update` | `--file <path / ->`, `--type <type>`, `--dry-run`, `--idempotency-key <key>`, `--output <path>` | `/v1/actions/onetime-product/update-product` / `/v1/actions/subscription-product/update-product` |
80
+ | `pnpm cli products publish` | `--file <path / ->`, `--type <type>`, `--dry-run`, `--idempotency-key <key>`, `--output <path>` | `/v1/actions/onetime-product/publish-product` / `/v1/actions/subscription-product/publish-product` |
81
+ | `pnpm cli products set-status` | `--file <path / ->`, `--type <type>`, `--dry-run`, `--idempotency-key <key>`, `--output <path>` | `/v1/actions/onetime-product/update-status` / `/v1/actions/subscription-product/update-status` |
82
+ | `pnpm cli groups create` | `--file <path / ->`, `--dry-run`, `--idempotency-key <key>`, `--output <path>` | `/v1/actions/subscription-product-group/create-group` |
83
+ | `pnpm cli groups update` | `--file <path / ->`, `--dry-run`, `--idempotency-key <key>`, `--output <path>` | `/v1/actions/subscription-product-group/update-group` |
84
+ | `pnpm cli groups delete` | `--file <path / ->`, `--dry-run`, `--idempotency-key <key>`, `--output <path>` | `/v1/actions/subscription-product-group/delete-group` |
85
+ | `pnpm cli groups publish` | `--file <path / ->`, `--dry-run`, `--idempotency-key <key>`, `--output <path>` | `/v1/actions/subscription-product-group/publish-group` |
86
+ | `pnpm cli checkout create` | `--file <path / ->`, `--dry-run`, `--idempotency-key <key>`, `--output <path>` | `/v1/actions/checkout/create-session` |
87
+ | `pnpm cli subscriptions cancel` | `--file <path / ->`, `--dry-run`, `--idempotency-key <key>`, `--output <path>` | `/v1/actions/subscription-order/cancel-order` |
88
+ | `pnpm cli refunds create` | `--file <path / ->`, `--dry-run`, `--idempotency-key <key>`, `--output <path>` | `/v1/actions/refund-ticket/create-ticket` |
89
+ | `pnpm cli refunds resubmit` | `--file <path / ->`, `--dry-run`, `--idempotency-key <key>`, `--output <path>` | `/v1/actions/refund-ticket/resubmit-ticket` |
90
+ | `pnpm cli sessions create` | `--file <path / ->`, `--dry-run`, `--idempotency-key <key>`, `--output <path>` | `/v1/actions/auth/issue-session-token` |
91
+ | `pnpm cli recipients add` | `--file <path / ->`, `--dry-run`, `--idempotency-key <key>`, `--output <path>` | `/v1/actions/store-notification-recipient/add-recipient` |
92
+ | `pnpm cli recipients update` | `--file <path / ->`, `--dry-run`, `--idempotency-key <key>`, `--output <path>` | `/v1/actions/store-notification-recipient/update-recipient` |
93
+ | `pnpm cli recipients remove` | `--file <path / ->`, `--dry-run`, `--idempotency-key <key>`, `--output <path>` | `/v1/actions/store-notification-recipient/remove-recipient` |
94
+ | `pnpm cli content scan` | `--file <path / ->`, `--dry-run`, `--idempotency-key <key>`, `--output <path>` | `/v1/actions/verification/scan-prompt` |
95
+ | `pnpm cli stores get` | `<id>`, `--fields <names>`, `--dry-run` | `/v1/graphql` |
96
+ | `pnpm cli products list` | `--file <path / ->`, `--type <type>`, `--limit <number>`, `--offset <number>`, `--fields <names>`, `--dry-run` | `/v1/graphql` |
97
+ | `pnpm cli products versions` | `<id>`, `--type <type>`, `--fields <names>`, `--dry-run` | `/v1/graphql` |
98
+ | `pnpm cli orders list` | `--file <path / ->`, `--type <type>`, `--limit <number>`, `--offset <number>`, `--fields <names>`, `--dry-run` | `/v1/graphql` |
99
+ | `pnpm cli subscriptions list` | `--file <path / ->`, `--limit <number>`, `--offset <number>`, `--fields <names>`, `--dry-run` | `/v1/graphql` |
100
+ | `pnpm cli payments list` | `--file <path / ->`, `--limit <number>`, `--offset <number>`, `--fields <names>`, `--dry-run` | `/v1/graphql` |
101
+ | `pnpm cli payments get` | `<id>`, `--fields <names>`, `--dry-run` | `/v1/graphql` |
102
+ | `pnpm cli refunds list` | `--file <path / ->`, `--limit <number>`, `--offset <number>`, `--fields <names>`, `--dry-run` | `/v1/graphql` |
103
+ | `pnpm cli refunds get` | `<id>`, `--fields <names>`, `--dry-run` | `/v1/graphql` |
104
+ | `pnpm cli refund-tickets list` | `--file <path / ->`, `--limit <number>`, `--offset <number>`, `--fields <names>`, `--dry-run` | `/v1/graphql` |
105
+ | `pnpm cli recipients list` | `--file <path / ->`, `--limit <number>`, `--offset <number>`, `--fields <names>`, `--dry-run` | `/v1/graphql` |
106
+ | `pnpm cli merchants list` | `--file <path / ->`, `--limit <number>`, `--offset <number>`, `--fields <names>`, `--dry-run` | `/v1/graphql` |
107
+ | `pnpm cli merchants get` | `<id>`, `--fields <names>`, `--dry-run` | `/v1/graphql` |
108
+ | `pnpm cli graphql query` | `--file <path / ->`, `--dry-run`, `--output <path>` | `/v1/graphql` |
109
+ | `pnpm cli analytics query` | `--file <path / ->`, `--dry-run`, `--output <path>` | `/v1/graphql` |
110
+ | `pnpm cli coupons list` | `--file`, `--limit`, `--offset`, `--fields`, `--dry-run` | `/v1/graphql` |
111
+ | `pnpm cli coupons get` | `<id>`, `--fields`, `--dry-run` | `/v1/graphql` |
112
+ | `pnpm cli coupons create` | `--file`, `--dry-run`, `--yes`, `--idempotency-key`, `--output` | REST action(见上表) |
113
+ | `pnpm cli coupons update` | `--file`, `--dry-run`, `--yes`, `--idempotency-key`, `--output` | REST action(见上表) |
114
+ | `pnpm cli coupons deactivate` | `--file`, `--dry-run`, `--yes`, `--idempotency-key`, `--output` | REST action(见上表) |
115
+ | `pnpm cli promotion-codes list` | `--file`, `--limit`, `--offset`, `--fields`, `--dry-run` | `/v1/graphql` |
116
+ | `pnpm cli promotion-codes create` | `--file`, `--dry-run`, `--yes`, `--idempotency-key`, `--output` | REST action(见上表) |
117
+ | `pnpm cli promotion-codes generate` | `--file`, `--dry-run`, `--yes`, `--idempotency-key`, `--output` | REST action(见上表) |
118
+ | `pnpm cli promotion-codes deactivate` | `--file`, `--dry-run`, `--yes`, `--idempotency-key`, `--output` | REST action(见上表) |
119
+
120
+ ## GraphQL 读取范围
121
+
122
+ 所有资源读取使用 `/v1/graphql`。新增商品、订单、订阅、支付、退款、退款工单、联系人与商户列表支持单页读取和已声明字段;自定义 `graphql query` / `analytics query` 接受一个 query 操作及变量/fragment。执行必须 `--output`,dry-run 不写文件。mutation、subscription、多操作文档在凭证或网络访问前拒绝。
123
+
124
+ 没有 `groups list/get`、`orders get`、`subscriptions get` 等未注册入口。组查询需先用 GraphQL introspection/官方契约确认;不因存在组写入就猜测读取字段。分析查询保留官方嵌套 selection,由调用者在文件中明确提供。
125
+
126
+ 来源:[GraphQL 总览](https://docs.waffo.ai/api-reference/endpoints/graphql/overview)、[店铺与商品](https://docs.waffo.ai/api-reference/endpoints/graphql/stores-and-products)、[订单与支付](https://docs.waffo.ai/api-reference/endpoints/graphql/orders-and-payments)、[分析](https://docs.waffo.ai/api-reference/endpoints/graphql/analytics)。
127
+
128
+ ## 不属于商户认证覆盖的接口
129
+
130
+ | 客户侧能力 | 路由 | 范围 |
131
+ | --- | --- | --- |
132
+ | 一次性订单取消 | `/v1/actions/onetime-order/cancel-order` | Session Token;没有商户 CLI 命令 |
133
+ | 客户取消订阅 | `/v1/actions/subscription-order/cancel-order` | Session Token 语义;与已实现的商户 API-Key 取消分开 |
134
+ | 恢复订阅 | `/v1/actions/subscription-order/reactivate-order` | Session Token;没有商户 CLI 命令 |
135
+
136
+ 来源:[客户认证接口](https://docs.waffo.ai/api-reference/endpoints/auth/customer-endpoints)。商户可以签发 Token,但 CLI 不代客户执行这些接口。没有任意 REST POST 通道。
137
+
138
+ ## 验证与发布边界
139
+
140
+ 源定义:`src/commands/registry.ts`、`action-definitions.ts`、`read-definitions.ts`、`api-coverage.ts`。执行 `pnpm cli commands --json` 与 `pnpm cli schema <命令 ID> --json` 可取得实际契约。文档抓取快照为 2026-10-26,官方索引为 [llms.txt](https://docs.waffo.ai/llms.txt)。
141
+
142
+ 本地检查使用模拟 API,实际测试结果以本次 `pnpm run check`、打包及安装包验证结果为准;不在此固定测试数量。部分流程已有 Test 环境远端证据,跨平台 CI 与 Windows ACL 自动测试已通过。生产完整验收、真实 Windows 终端 Ctrl+C 及首次发布后的 npm 安装仍是独立验收事项。
143
+
144
+ ## 折扣命令补充
145
+
146
+ 本次新增 9 条命令、6 个 REST 路由,依据 product-service 请求 schema、graphql-service 类型及 gateway 路由源码核对,未猜测公开 API 文档地址。`coupons list/get/create/update/deactivate` 和 `promotion-codes list/create/generate/deactivate` 均已接入;列表/详情使用 `/v1/graphql`,支持离线 dry-run、schema 和 JSON。完整字段与示例见[折扣使用说明](usage.md#discounts)。
147
+
148
+ 创建券需要店铺 owner/admin;其他折扣路由接受商户身份并由服务端执行店铺和环境访问控制。JWT Session 与 RSA API Key 均在 gateway 配置中允许。折扣列表不返回买家邮箱;写入默认输出不带客户限制,显式私有文件导出保留完整响应。9 条折扣命令已有隔离 Test 环境商户验收证据,包括停用后的查询确认;命令自身写入核验仍为 response_only,部分 Production 折扣操作也已通过;不代表全部折扣操作或稳定版已验收。
149
+
150
+ ### Temporary event listener
151
+
152
+ `listen` verifies identity with `/v1/graphql`, then uses POST `/v1/actions/notification/cli-listen-start`, `cli-listen-poll`, `cli-listen-ack` and `cli-listen-stop`. All require merchant browser-session authorization and store access; RSA is unsupported. Test is default; production requires `--live`. Start/ACK are never retried automatically. Session TTL is 90 seconds, polling interval three seconds, delivery lease 30 seconds and maximum attempts three. No permanent webhook writes or event trigger routes are used. These four browser-session-only routes and the three device-login routes are separate from the 33 merchant API-Key REST action routes above. Relay/gateway support is deployed separately. Production listener startup, polling, mode isolation and cleanup passed with the published candidate; real Production payment delivery remains pending.
153
+
154
+ Browser sessions use the server-enforced CLI business permission preset in Test and Production. Existing merchant/store access still applies. Unlisted routes and GraphQL fields, Webhook `secret` fields, account/API Key/payout/bank operations and other-session management are denied. Own-session logout is allowed. RSA permissions are unchanged.