@jinshuju/cli 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/commands/account.js +35 -0
- package/dist/commands/entry.js +12 -1
- package/dist/commands/index.js +11 -2
- package/dist/commands/sms.d.ts +2 -0
- package/dist/commands/sms.js +9 -0
- package/dist/commands/trade.d.ts +2 -0
- package/dist/commands/trade.js +185 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -186,6 +186,10 @@ jinshuju entry create --form Kp7mQ2 --json @entry.json
|
|
|
186
186
|
cat entry.json | jinshuju entry create --form Kp7mQ2 --json -
|
|
187
187
|
```
|
|
188
188
|
|
|
189
|
+
Creating, updating or getting one entry answers with a `url`: where that entry
|
|
190
|
+
opens in the Jinshuju data page, for whoever wrote it to check it there. A
|
|
191
|
+
`--batch` write answers without one.
|
|
192
|
+
|
|
189
193
|
## Writing
|
|
190
194
|
|
|
191
195
|
Apart from the settings-block dispatch described above, every write command
|
package/dist/commands/account.js
CHANGED
|
@@ -16,5 +16,40 @@ export const ACCOUNT = [
|
|
|
16
16
|
summary: 'List account members',
|
|
17
17
|
options: [LIMIT_OPTION],
|
|
18
18
|
request: (input) => ({ method: 'GET', path: `${API}/billing_account/users`, query: paging(input) })
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
path: ['account', 'invoice', 'list'],
|
|
22
|
+
summary: 'List e-invoices, and the amount not invoiced yet',
|
|
23
|
+
description: 'Account admins only, as in the web app; a member is refused with 403.',
|
|
24
|
+
request: () => ({ method: 'GET', path: `${API}/billing_account/invoices` })
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
path: ['account', 'payment', 'list'],
|
|
28
|
+
summary: 'List what the account spent or topped up on 金数据: SMS, AI points, plans, recharges',
|
|
29
|
+
description: 'Not what its payment forms collected from customers: that is transaction list. Newest first. ' +
|
|
30
|
+
'Account admins only, as in the web app; a member is refused with 403.',
|
|
31
|
+
options: [
|
|
32
|
+
{ name: '--from', type: 'string', placeholder: '<YYYY-MM-DD>', description: 'First day' },
|
|
33
|
+
{ name: '--to', type: 'string', placeholder: '<YYYY-MM-DD>', description: 'Last day, inclusive' },
|
|
34
|
+
{
|
|
35
|
+
name: '--verb',
|
|
36
|
+
type: 'string',
|
|
37
|
+
placeholder: '<verb>',
|
|
38
|
+
description: 'Only this kind of record, e.g. sms_charge'
|
|
39
|
+
},
|
|
40
|
+
{ ...LIMIT_OPTION, description: 'Records to return (default 50, up to 1000)' },
|
|
41
|
+
{ name: '--with-balance', type: 'boolean', description: 'Also return the current balance and quotas' }
|
|
42
|
+
],
|
|
43
|
+
request: (input) => ({
|
|
44
|
+
method: 'GET',
|
|
45
|
+
path: `${API}/billing_account/payment_histories`,
|
|
46
|
+
query: {
|
|
47
|
+
start_date: input.options.from,
|
|
48
|
+
end_date: input.options.to,
|
|
49
|
+
verb: input.options.verb,
|
|
50
|
+
limit: input.options.limit === undefined ? undefined : String(input.options.limit),
|
|
51
|
+
include_balance: input.options.with_balance ? 'true' : undefined
|
|
52
|
+
}
|
|
53
|
+
})
|
|
19
54
|
}
|
|
20
55
|
];
|
package/dist/commands/entry.js
CHANGED
|
@@ -15,6 +15,12 @@ function list(value) {
|
|
|
15
15
|
function labels(input) {
|
|
16
16
|
return input.options.labels ? 'true' : undefined;
|
|
17
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* The web host is not the API host on every environment, so the link is the
|
|
20
|
+
* server's to spell; all a command can do is say it is there and what it is for.
|
|
21
|
+
*/
|
|
22
|
+
const DETAIL_URL = 'One entry comes back with `url`, where it opens in the Jinshuju data page: hand it to the user ' +
|
|
23
|
+
'so they can check it.';
|
|
18
24
|
const LABELS_OPTION = {
|
|
19
25
|
name: '--labels',
|
|
20
26
|
type: 'boolean',
|
|
@@ -537,7 +543,9 @@ export const ENTRY = [
|
|
|
537
543
|
path: ['entry', 'create'],
|
|
538
544
|
summary: 'Create entries',
|
|
539
545
|
description: 'The payload is keyed by field api_code, not by field label. --batch takes a list of them and ' +
|
|
540
|
-
'writes them in one request. ' +
|
|
546
|
+
'writes them in one request, and answers without a `url` for each. ' +
|
|
547
|
+
DETAIL_URL +
|
|
548
|
+
' ' +
|
|
541
549
|
VALUE_SHAPES,
|
|
542
550
|
options: [...CONTAINER_OPTIONS, JSON_OPTION, BATCH_OPTION, ATTACH_OPTION],
|
|
543
551
|
run: async (input, client) => {
|
|
@@ -566,6 +574,8 @@ export const ENTRY = [
|
|
|
566
574
|
description: 'The payload merges onto the entry, leaving the fields it does not name alone; --replace ' +
|
|
567
575
|
'writes the entry as given, clearing the rest. --batch takes [{serial_number, entry}] and ' +
|
|
568
576
|
'always merges. ' +
|
|
577
|
+
DETAIL_URL +
|
|
578
|
+
' ' +
|
|
569
579
|
VALUE_SHAPES,
|
|
570
580
|
args: [{ name: 'serial', required: false, description: 'Entry serial number; leave out with --batch' }],
|
|
571
581
|
options: [
|
|
@@ -708,6 +718,7 @@ export const ENTRY = [
|
|
|
708
718
|
{
|
|
709
719
|
path: ['entry', 'get'],
|
|
710
720
|
summary: 'Show one entry',
|
|
721
|
+
description: DETAIL_URL,
|
|
711
722
|
args: [{ name: 'serial', required: true, description: 'Entry serial number' }],
|
|
712
723
|
options: [
|
|
713
724
|
...CONTAINER_OPTIONS,
|
package/dist/commands/index.js
CHANGED
|
@@ -15,7 +15,9 @@ import { FOLDER } from './folder.js';
|
|
|
15
15
|
import { FORM } from './form.js';
|
|
16
16
|
import { LOCAL } from './local.js';
|
|
17
17
|
import { OPENSEARCH } from './opensearch.js';
|
|
18
|
+
import { SMS } from './sms.js';
|
|
18
19
|
import { TABLE } from './table.js';
|
|
20
|
+
import { TRADE } from './trade.js';
|
|
19
21
|
import { VIEW } from './view.js';
|
|
20
22
|
/** Resource order in the root help, and the one-liner each gets. */
|
|
21
23
|
export const RESOURCES = [
|
|
@@ -25,7 +27,7 @@ export const RESOURCES = [
|
|
|
25
27
|
note: 'login is the browser flow. To use a token instead: `jinshuju config set access_token <token>`, ' +
|
|
26
28
|
'or set JINSHUJU_ACCESS_TOKEN. `auth status --verify` says which account the credential belongs to.'
|
|
27
29
|
},
|
|
28
|
-
{ name: 'account', summary: 'Account and
|
|
30
|
+
{ name: 'account', summary: 'Account, members, invoices and what the account paid' },
|
|
29
31
|
{ name: 'folder', summary: 'Manage folders' },
|
|
30
32
|
{
|
|
31
33
|
name: 'form',
|
|
@@ -39,6 +41,11 @@ export const RESOURCES = [
|
|
|
39
41
|
{ name: 'entry', summary: 'Manage entries' },
|
|
40
42
|
{ name: 'comment', summary: 'Manage entry comments' },
|
|
41
43
|
{ name: 'opensearch', summary: 'Manage public queries' },
|
|
44
|
+
{ name: 'merchant', summary: '小金商户: onboarding, balance and settlement' },
|
|
45
|
+
{ name: 'transaction', summary: 'Payment orders placed on payment forms' },
|
|
46
|
+
{ name: 'refund', summary: 'Refunds of payment orders' },
|
|
47
|
+
{ name: 'payout', summary: 'Payouts to the settlement account' },
|
|
48
|
+
{ name: 'sms', summary: 'SMS signature and template review' },
|
|
42
49
|
{ name: 'config', summary: 'Manage CLI configuration' }
|
|
43
50
|
];
|
|
44
51
|
export const COMMANDS = [
|
|
@@ -51,7 +58,9 @@ export const COMMANDS = [
|
|
|
51
58
|
...VIEW,
|
|
52
59
|
...ENTRY,
|
|
53
60
|
...COMMENT,
|
|
54
|
-
...OPENSEARCH
|
|
61
|
+
...OPENSEARCH,
|
|
62
|
+
...TRADE,
|
|
63
|
+
...SMS
|
|
55
64
|
];
|
|
56
65
|
/** The command whose path the words begin with, longest match first. */
|
|
57
66
|
export function findCommand(words, commands = COMMANDS) {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { API } from './shared.js';
|
|
2
|
+
export const SMS = [
|
|
3
|
+
{
|
|
4
|
+
path: ['sms', 'status'],
|
|
5
|
+
summary: 'List SMS signatures and templates with their review status and why a review failed',
|
|
6
|
+
description: 'Your own signatures and templates, not those of the rest of the account.',
|
|
7
|
+
request: () => ({ method: 'GET', path: `${API}/sms/audit_statuses` })
|
|
8
|
+
}
|
|
9
|
+
];
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { PAGINATION_OPTIONS } from '../options.js';
|
|
2
|
+
import { API, paging } from './shared.js';
|
|
3
|
+
/**
|
|
4
|
+
* The account's 小金商户: what its payment forms collected, refunded and paid
|
|
5
|
+
* out. An account collecting through its own bound WeChat / Alipay merchant
|
|
6
|
+
* (直连) has none of this in 金数据, and the reads below say so rather than
|
|
7
|
+
* answering with zeroes.
|
|
8
|
+
*/
|
|
9
|
+
const PAID_STATUSES = ['paid', 'unpaid', 'refunded', 'refunding', 'partial_refunded'];
|
|
10
|
+
const RECORD_STATUSES = ['processing', 'success', 'error'];
|
|
11
|
+
const DATE_OPTIONS = [
|
|
12
|
+
{
|
|
13
|
+
name: '--from',
|
|
14
|
+
type: 'string',
|
|
15
|
+
placeholder: '<YYYY-MM-DD>',
|
|
16
|
+
description: 'First day, Asia/Shanghai; give it with --to'
|
|
17
|
+
},
|
|
18
|
+
{ name: '--to', type: 'string', placeholder: '<YYYY-MM-DD>', description: 'Last day, inclusive; give it with --from' }
|
|
19
|
+
];
|
|
20
|
+
/** The CLI spells a dimension as its flag is spelled; the API names it by its parameter. */
|
|
21
|
+
const GROUP_BY = { time: 'time', 'paid-status': 'paid_status', channel: 'payment_channel' };
|
|
22
|
+
const ORDER_FILTER_OPTIONS = [
|
|
23
|
+
{
|
|
24
|
+
name: '--status',
|
|
25
|
+
type: 'string',
|
|
26
|
+
repeatable: true,
|
|
27
|
+
choices: PAID_STATUSES,
|
|
28
|
+
placeholder: '<status>',
|
|
29
|
+
description: 'Keep only these payment statuses, repeatable. Omitted, every status, unpaid included'
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: '--channel',
|
|
33
|
+
type: 'string',
|
|
34
|
+
choices: ['wxpay', 'alipay'],
|
|
35
|
+
placeholder: '<channel>',
|
|
36
|
+
description: 'Keep only orders paid through this channel: wxpay (微信) or alipay (支付宝)'
|
|
37
|
+
},
|
|
38
|
+
{ name: '--form', type: 'string', placeholder: '<token>', description: 'Keep only orders of this payment form' }
|
|
39
|
+
];
|
|
40
|
+
const INCLUDE_OPTION = {
|
|
41
|
+
name: '--include',
|
|
42
|
+
type: 'string',
|
|
43
|
+
choices: ['both', 'stats', 'records'],
|
|
44
|
+
placeholder: '<what>',
|
|
45
|
+
description: 'both (default), stats for the statistics alone, or records for the rows alone'
|
|
46
|
+
};
|
|
47
|
+
const DETAIL_LIMITS = 'Rows are capped at 90 days and 200 matching records per query; past either, no rows come back, ' +
|
|
48
|
+
'only detail_limit and the stats for the whole range. Narrow the range rather than splitting it.';
|
|
49
|
+
function dates(input) {
|
|
50
|
+
return {
|
|
51
|
+
start_date: input.options.from,
|
|
52
|
+
end_date: input.options.to
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function orderFilters(input) {
|
|
56
|
+
const statuses = input.options.status ?? [];
|
|
57
|
+
return {
|
|
58
|
+
paid_status: statuses.length > 0 ? statuses : undefined,
|
|
59
|
+
payment_channel: input.options.channel,
|
|
60
|
+
form_token: input.options.form
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
export const TRADE = [
|
|
64
|
+
{
|
|
65
|
+
path: ['merchant', 'get'],
|
|
66
|
+
summary: 'Show the 小金商户: where onboarding stands, balance, rate and settlement account',
|
|
67
|
+
description: 'Answers without a merchant too: merchant_stage says where the application stands. Bank card, phone, ' +
|
|
68
|
+
'email and ID numbers come back masked, as the product shows them.',
|
|
69
|
+
request: () => ({ method: 'GET', path: `${API}/trade/merchant` })
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
path: ['transaction', 'list'],
|
|
73
|
+
summary: 'List payment orders customers placed on payment forms',
|
|
74
|
+
description: 'Defaults to the last 90 days; --order-no alone searches all time. ' +
|
|
75
|
+
DETAIL_LIMITS +
|
|
76
|
+
' For totals or a breakdown, use transaction aggregate instead of adding up rows.',
|
|
77
|
+
options: [
|
|
78
|
+
...DATE_OPTIONS,
|
|
79
|
+
...ORDER_FILTER_OPTIONS,
|
|
80
|
+
{
|
|
81
|
+
name: '--order-no',
|
|
82
|
+
type: 'string',
|
|
83
|
+
placeholder: '<no>',
|
|
84
|
+
description: 'Exact match on 交易单号, 商户订单号 or 金数据单号'
|
|
85
|
+
},
|
|
86
|
+
...PAGINATION_OPTIONS
|
|
87
|
+
],
|
|
88
|
+
request: (input) => ({
|
|
89
|
+
method: 'GET',
|
|
90
|
+
path: `${API}/trade/transactions`,
|
|
91
|
+
query: {
|
|
92
|
+
...dates(input),
|
|
93
|
+
...orderFilters(input),
|
|
94
|
+
order_no: input.options.order_no,
|
|
95
|
+
...paging(input)
|
|
96
|
+
}
|
|
97
|
+
}),
|
|
98
|
+
paginate: { items: 'transactions', cursor: 'next' },
|
|
99
|
+
examples: [
|
|
100
|
+
'jinshuju transaction list --from 2026-09-01 --to 2026-09-28',
|
|
101
|
+
'jinshuju transaction list --order-no 1234567890',
|
|
102
|
+
'jinshuju transaction list --form Kp7mQ2 --status refunded --status partial_refunded --all'
|
|
103
|
+
]
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
path: ['transaction', 'aggregate'],
|
|
107
|
+
summary: 'Total the payment orders: amount, paid count and order count, optionally grouped',
|
|
108
|
+
description: 'Defaults to the last 30 days, up to 366. The totals cover the whole range whatever the paging of a listing.',
|
|
109
|
+
options: [
|
|
110
|
+
...DATE_OPTIONS,
|
|
111
|
+
{
|
|
112
|
+
name: '--group-by',
|
|
113
|
+
type: 'string',
|
|
114
|
+
choices: Object.keys(GROUP_BY),
|
|
115
|
+
placeholder: '<dimension>',
|
|
116
|
+
description: 'Break the totals down by one dimension; time picks day, week or month from the span'
|
|
117
|
+
},
|
|
118
|
+
...ORDER_FILTER_OPTIONS
|
|
119
|
+
],
|
|
120
|
+
request: (input) => ({
|
|
121
|
+
method: 'GET',
|
|
122
|
+
path: `${API}/trade/transactions/aggregate`,
|
|
123
|
+
query: { ...dates(input), group_by: GROUP_BY[input.options.group_by], ...orderFilters(input) }
|
|
124
|
+
}),
|
|
125
|
+
examples: ['jinshuju transaction aggregate --from 2026-09-01 --to 2026-09-28 --group-by channel']
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
path: ['refund', 'list'],
|
|
129
|
+
summary: 'List refunds, with their statistics',
|
|
130
|
+
description: 'Defaults to the last 90 days; --refund-no alone searches all time. ' + DETAIL_LIMITS,
|
|
131
|
+
options: [
|
|
132
|
+
...DATE_OPTIONS,
|
|
133
|
+
{
|
|
134
|
+
name: '--status',
|
|
135
|
+
type: 'string',
|
|
136
|
+
choices: RECORD_STATUSES,
|
|
137
|
+
placeholder: '<status>',
|
|
138
|
+
description: 'Keep only refunds in this state'
|
|
139
|
+
},
|
|
140
|
+
{ name: '--refund-no', type: 'string', placeholder: '<no>', description: 'Exact match on 退款流水号' },
|
|
141
|
+
INCLUDE_OPTION,
|
|
142
|
+
...PAGINATION_OPTIONS
|
|
143
|
+
],
|
|
144
|
+
request: (input) => ({
|
|
145
|
+
method: 'GET',
|
|
146
|
+
path: `${API}/trade/refunds`,
|
|
147
|
+
query: {
|
|
148
|
+
...dates(input),
|
|
149
|
+
status: input.options.status,
|
|
150
|
+
refund_no: input.options.refund_no,
|
|
151
|
+
include: input.options.include,
|
|
152
|
+
...paging(input)
|
|
153
|
+
}
|
|
154
|
+
}),
|
|
155
|
+
paginate: { items: 'refunds', cursor: 'next' }
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
path: ['payout', 'list'],
|
|
159
|
+
summary: 'List payouts (提现) to the settlement account, with their statistics',
|
|
160
|
+
description: 'Defaults to the last 90 days. ' + DETAIL_LIMITS,
|
|
161
|
+
options: [
|
|
162
|
+
...DATE_OPTIONS,
|
|
163
|
+
{
|
|
164
|
+
name: '--status',
|
|
165
|
+
type: 'string',
|
|
166
|
+
choices: RECORD_STATUSES,
|
|
167
|
+
placeholder: '<status>',
|
|
168
|
+
description: 'Keep only payouts in this state'
|
|
169
|
+
},
|
|
170
|
+
INCLUDE_OPTION,
|
|
171
|
+
...PAGINATION_OPTIONS
|
|
172
|
+
],
|
|
173
|
+
request: (input) => ({
|
|
174
|
+
method: 'GET',
|
|
175
|
+
path: `${API}/trade/payouts`,
|
|
176
|
+
query: {
|
|
177
|
+
...dates(input),
|
|
178
|
+
status: input.options.status,
|
|
179
|
+
include: input.options.include,
|
|
180
|
+
...paging(input)
|
|
181
|
+
}
|
|
182
|
+
}),
|
|
183
|
+
paginate: { items: 'payouts', cursor: 'next' }
|
|
184
|
+
}
|
|
185
|
+
];
|