@hithink-tech/hithink-finance-cli 0.1.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/CHANGELOG.md +5 -0
- package/LICENSE +21 -0
- package/README.md +161 -0
- package/SECURITY.md +3 -0
- package/dist/application/config.d.ts +44 -0
- package/dist/application/config.js +111 -0
- package/dist/application/ports/auth-provider.d.ts +23 -0
- package/dist/application/ports/auth-provider.js +2 -0
- package/dist/application/source-policy.d.ts +13 -0
- package/dist/application/source-policy.js +31 -0
- package/dist/application/use-cases/data-clean.d.ts +2 -0
- package/dist/application/use-cases/data-clean.js +18 -0
- package/dist/application/use-cases/data-init.d.ts +4 -0
- package/dist/application/use-cases/data-init.js +9 -0
- package/dist/application/use-cases/data-remove.d.ts +2 -0
- package/dist/application/use-cases/data-remove.js +27 -0
- package/dist/application/use-cases/data-repair.d.ts +5 -0
- package/dist/application/use-cases/data-repair.js +5 -0
- package/dist/application/use-cases/data-sync.d.ts +25 -0
- package/dist/application/use-cases/data-sync.js +55 -0
- package/dist/application/use-cases/local-query.d.ts +4 -0
- package/dist/application/use-cases/local-query.js +88 -0
- package/dist/application/use-cases/market-history.d.ts +8 -0
- package/dist/application/use-cases/market-history.js +16 -0
- package/dist/application/use-cases/market-panel.d.ts +3 -0
- package/dist/application/use-cases/market-panel.js +5 -0
- package/dist/application/use-cases/remote-query.d.ts +4 -0
- package/dist/application/use-cases/remote-query.js +66 -0
- package/dist/cli/context.d.ts +17 -0
- package/dist/cli/context.js +52 -0
- package/dist/cli/i18n.d.ts +23 -0
- package/dist/cli/i18n.js +150 -0
- package/dist/cli/main.d.ts +3 -0
- package/dist/cli/main.js +80 -0
- package/dist/cli/program.d.ts +20 -0
- package/dist/cli/program.js +111 -0
- package/dist/commands/auth/index.d.ts +10 -0
- package/dist/commands/auth/index.js +131 -0
- package/dist/commands/config/index.d.ts +13 -0
- package/dist/commands/config/index.js +26 -0
- package/dist/commands/data/index.d.ts +10 -0
- package/dist/commands/data/index.js +185 -0
- package/dist/commands/db/index.d.ts +4 -0
- package/dist/commands/db/index.js +72 -0
- package/dist/commands/financials/index.d.ts +5 -0
- package/dist/commands/financials/index.js +6 -0
- package/dist/commands/index/index.d.ts +5 -0
- package/dist/commands/index/index.js +6 -0
- package/dist/commands/market/index.d.ts +5 -0
- package/dist/commands/market/index.js +6 -0
- package/dist/commands/market/local.d.ts +4 -0
- package/dist/commands/market/local.js +97 -0
- package/dist/commands/remote.d.ts +11 -0
- package/dist/commands/remote.js +195 -0
- package/dist/commands/skills/index.d.ts +4 -0
- package/dist/commands/skills/index.js +43 -0
- package/dist/commands/special/index.d.ts +5 -0
- package/dist/commands/special/index.js +6 -0
- package/dist/commands/symbol/index.d.ts +5 -0
- package/dist/commands/symbol/index.js +6 -0
- package/dist/commands/system/capabilities.d.ts +4 -0
- package/dist/commands/system/capabilities.js +24 -0
- package/dist/commands/system/doctor.d.ts +4 -0
- package/dist/commands/system/doctor.js +15 -0
- package/dist/commands/system/schema.d.ts +4 -0
- package/dist/commands/system/schema.js +47 -0
- package/dist/commands/system/uninstall.d.ts +11 -0
- package/dist/commands/system/uninstall.js +68 -0
- package/dist/commands/system/update.d.ts +11 -0
- package/dist/commands/system/update.js +72 -0
- package/dist/contracts/envelope.d.ts +37 -0
- package/dist/contracts/envelope.js +36 -0
- package/dist/contracts/errors.d.ts +23 -0
- package/dist/contracts/errors.js +33 -0
- package/dist/contracts/local-capabilities.d.ts +13 -0
- package/dist/contracts/local-capabilities.js +37 -0
- package/dist/contracts/registry.d.ts +9 -0
- package/dist/contracts/registry.js +4 -0
- package/dist/contracts/remote-capabilities.d.ts +24 -0
- package/dist/contracts/remote-capabilities.js +667 -0
- package/dist/domains/financials/types.d.ts +6 -0
- package/dist/domains/financials/types.js +2 -0
- package/dist/domains/index/types.d.ts +6 -0
- package/dist/domains/index/types.js +2 -0
- package/dist/domains/market/types.d.ts +6 -0
- package/dist/domains/market/types.js +2 -0
- package/dist/domains/special/types.d.ts +5 -0
- package/dist/domains/special/types.js +2 -0
- package/dist/domains/symbol/types.d.ts +6 -0
- package/dist/domains/symbol/types.js +2 -0
- package/dist/infrastructure/credentials/api-key-provider.d.ts +14 -0
- package/dist/infrastructure/credentials/api-key-provider.js +102 -0
- package/dist/infrastructure/credentials/keyring.d.ts +15 -0
- package/dist/infrastructure/credentials/keyring.js +21 -0
- package/dist/infrastructure/credentials/redact.d.ts +3 -0
- package/dist/infrastructure/credentials/redact.js +26 -0
- package/dist/infrastructure/duckdb/connection.d.ts +8 -0
- package/dist/infrastructure/duckdb/connection.js +18 -0
- package/dist/infrastructure/duckdb/dump-client.d.ts +20 -0
- package/dist/infrastructure/duckdb/dump-client.js +66 -0
- package/dist/infrastructure/duckdb/factors.d.ts +3 -0
- package/dist/infrastructure/duckdb/factors.js +83 -0
- package/dist/infrastructure/duckdb/importer.d.ts +11 -0
- package/dist/infrastructure/duckdb/importer.js +105 -0
- package/dist/infrastructure/duckdb/migrations.d.ts +17 -0
- package/dist/infrastructure/duckdb/migrations.js +92 -0
- package/dist/infrastructure/duckdb/quality.d.ts +12 -0
- package/dist/infrastructure/duckdb/quality.js +56 -0
- package/dist/infrastructure/duckdb/schema.d.ts +4 -0
- package/dist/infrastructure/duckdb/schema.js +14 -0
- package/dist/infrastructure/filesystem/atomic-file.d.ts +2 -0
- package/dist/infrastructure/filesystem/atomic-file.js +38 -0
- package/dist/infrastructure/filesystem/platform-paths.d.ts +15 -0
- package/dist/infrastructure/filesystem/platform-paths.js +42 -0
- package/dist/infrastructure/filesystem/process-lock.d.ts +6 -0
- package/dist/infrastructure/filesystem/process-lock.js +56 -0
- package/dist/infrastructure/filesystem/stdin.d.ts +5 -0
- package/dist/infrastructure/filesystem/stdin.js +9 -0
- package/dist/infrastructure/fuyao/client.d.ts +31 -0
- package/dist/infrastructure/fuyao/client.js +145 -0
- package/dist/infrastructure/fuyao/envelope.d.ts +9 -0
- package/dist/infrastructure/fuyao/envelope.js +8 -0
- package/dist/infrastructure/fuyao/pagination.d.ts +16 -0
- package/dist/infrastructure/fuyao/pagination.js +44 -0
- package/dist/infrastructure/fuyao/retry.d.ts +5 -0
- package/dist/infrastructure/fuyao/retry.js +18 -0
- package/dist/infrastructure/fuyao/windowing.d.ts +8 -0
- package/dist/infrastructure/fuyao/windowing.js +25 -0
- package/dist/infrastructure/skills/drift.d.ts +3 -0
- package/dist/infrastructure/skills/drift.js +8 -0
- package/dist/infrastructure/skills/installer.d.ts +13 -0
- package/dist/infrastructure/skills/installer.js +48 -0
- package/dist/infrastructure/skills/manifest.d.ts +11 -0
- package/dist/infrastructure/skills/manifest.js +62 -0
- package/dist/infrastructure/updater/cache.d.ts +15 -0
- package/dist/infrastructure/updater/cache.js +76 -0
- package/dist/infrastructure/updater/check.d.ts +13 -0
- package/dist/infrastructure/updater/check.js +51 -0
- package/dist/infrastructure/updater/install.d.ts +4 -0
- package/dist/infrastructure/updater/install.js +39 -0
- package/dist/output/json.d.ts +3 -0
- package/dist/output/json.js +16 -0
- package/dist/output/renderer.d.ts +4 -0
- package/dist/output/renderer.js +47 -0
- package/dist/output/table.d.ts +2 -0
- package/dist/output/table.js +31 -0
- package/migrations/001-initial.sql +95 -0
- package/migrations/manifest.json +12 -0
- package/package.json +66 -0
- package/schemas/capabilities.json +290 -0
- package/schemas/command-envelope.schema.json +12 -0
- package/scripts/postinstall.mjs +27 -0
- package/scripts/update-check.mjs +23 -0
- package/skills/hithink-finance-data/SKILL.md +74 -0
- package/skills/hithink-finance-data/references/data-clean.md +33 -0
- package/skills/hithink-finance-data/references/data-init.md +35 -0
- package/skills/hithink-finance-data/references/data-migrate.md +33 -0
- package/skills/hithink-finance-data/references/data-remove.md +33 -0
- package/skills/hithink-finance-data/references/data-repair.md +33 -0
- package/skills/hithink-finance-data/references/data-status.md +33 -0
- package/skills/hithink-finance-data/references/data-sync.md +34 -0
- package/skills/hithink-finance-data/references/data-validate.md +33 -0
- package/skills/hithink-finance-data/references/db-describe.md +33 -0
- package/skills/hithink-finance-data/references/db-export.md +33 -0
- package/skills/hithink-finance-data/references/db-query.md +33 -0
- package/skills/hithink-finance-financials/SKILL.md +59 -0
- package/skills/hithink-finance-financials/references/financials-balance-sheet.md +40 -0
- package/skills/hithink-finance-financials/references/financials-cash-flow.md +40 -0
- package/skills/hithink-finance-financials/references/financials-income.md +40 -0
- package/skills/hithink-finance-financials/references/financials-indicators.md +37 -0
- package/skills/hithink-finance-index/SKILL.md +59 -0
- package/skills/hithink-finance-index/references/index-catalog.md +36 -0
- package/skills/hithink-finance-index/references/index-constituents.md +36 -0
- package/skills/hithink-finance-index/references/index-history.md +38 -0
- package/skills/hithink-finance-index/references/index-snapshot.md +37 -0
- package/skills/hithink-finance-market/SKILL.md +63 -0
- package/skills/hithink-finance-market/references/market-adjustment-factors.md +33 -0
- package/skills/hithink-finance-market/references/market-calendar.md +35 -0
- package/skills/hithink-finance-market/references/market-corporate-actions.md +38 -0
- package/skills/hithink-finance-market/references/market-history.md +39 -0
- package/skills/hithink-finance-market/references/market-panel.md +33 -0
- package/skills/hithink-finance-market/references/market-snapshot.md +39 -0
- package/skills/hithink-finance-research/SKILL.md +58 -0
- package/skills/hithink-finance-research/references/research-workflow.md +34 -0
- package/skills/hithink-finance-shared/SKILL.md +55 -0
- package/skills/hithink-finance-shared/references/auth-and-config.md +31 -0
- package/skills/hithink-finance-shared/references/global-rules.md +21 -0
- package/skills/hithink-finance-shared/references/lifecycle.md +23 -0
- package/skills/hithink-finance-shared/references/skills-management.md +22 -0
- package/skills/hithink-finance-special-data/SKILL.md +68 -0
- package/skills/hithink-finance-special-data/references/special-anomaly-list.md +36 -0
- package/skills/hithink-finance-special-data/references/special-anomaly-stock.md +37 -0
- package/skills/hithink-finance-special-data/references/special-dragon-tiger.md +37 -0
- package/skills/hithink-finance-special-data/references/special-hot-stock-history.md +36 -0
- package/skills/hithink-finance-special-data/references/special-hot-stock-trend.md +38 -0
- package/skills/hithink-finance-special-data/references/special-hot-stock.md +36 -0
- package/skills/hithink-finance-special-data/references/special-limit-up-ladder.md +35 -0
- package/skills/hithink-finance-special-data/references/special-limit-up-pool.md +40 -0
- package/skills/hithink-finance-special-data/references/special-skyrocket.md +36 -0
- package/skills/hithink-finance-symbol/SKILL.md +56 -0
- package/skills/hithink-finance-symbol/references/symbol-list.md +39 -0
- package/skills/hithink-finance-symbol/references/symbol-search.md +39 -0
- package/skills/manifest.json +55 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { localizeText } from '../../cli/i18n.js';
|
|
2
|
+
import { successEnvelope } from '../../contracts/envelope.js';
|
|
3
|
+
import { CliError } from '../../contracts/errors.js';
|
|
4
|
+
import { installGlobalPackage, runExecutable } from '../../infrastructure/updater/install.js';
|
|
5
|
+
import { renderResult } from '../../output/renderer.js';
|
|
6
|
+
import { readUpdateCache, scheduleUpdateCheck } from '../../infrastructure/updater/check.js';
|
|
7
|
+
import { updateCacheDecision } from '../../infrastructure/updater/cache.js';
|
|
8
|
+
import path from 'node:path';
|
|
9
|
+
export function registerUpdateCommand(program, context, metadata, dependencies) {
|
|
10
|
+
const command = program
|
|
11
|
+
.command('update')
|
|
12
|
+
.description(localizeText(context.language, 'Check or repair the installed CLI version'))
|
|
13
|
+
.option('--check', localizeText(context.language, 'Check for a newer version without installing'))
|
|
14
|
+
.option('--repair', localizeText(context.language, 'Repair the current or target installation'))
|
|
15
|
+
.option('--target-version <version>', localizeText(context.language, 'Install a specific SemVer version'));
|
|
16
|
+
command.action(async () => {
|
|
17
|
+
const options = command.opts();
|
|
18
|
+
if (options.check === true) {
|
|
19
|
+
const cacheFile = path.join(dependencies.platformPaths.stateDir, 'update-cache.json');
|
|
20
|
+
const cached = await readUpdateCache(cacheFile);
|
|
21
|
+
const decision = updateCacheDecision(cached, Date.now(), !dependencies.resolvedConfig.updateCheck);
|
|
22
|
+
if (decision === 'refresh')
|
|
23
|
+
scheduleUpdateCheck(dependencies.packageRoot, metadata.name, cacheFile);
|
|
24
|
+
await renderResult(successEnvelope('update.check', {
|
|
25
|
+
currentVersion: metadata.version,
|
|
26
|
+
latestVersion: cached?.latestVersion,
|
|
27
|
+
cacheStatus: decision,
|
|
28
|
+
refreshScheduled: decision === 'refresh',
|
|
29
|
+
networkUsed: false,
|
|
30
|
+
}, { requestId: context.requestId }), context);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const version = options.targetVersion ?? metadata.version;
|
|
34
|
+
if (!/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/u.test(version)) {
|
|
35
|
+
throw new CliError({
|
|
36
|
+
code: 'CLI_BAD_ARGUMENT',
|
|
37
|
+
category: 'validation',
|
|
38
|
+
message: 'Update version must be a valid SemVer value.',
|
|
39
|
+
hint: 'Use a version such as 1.2.3 or 1.2.3-next.1.',
|
|
40
|
+
retryable: false,
|
|
41
|
+
exitCode: 2,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
const npm = process.env.HITHINK_FINANCE_NPM_EXECUTABLE ??
|
|
45
|
+
(process.platform === 'win32' ? 'npm.cmd' : 'npm');
|
|
46
|
+
const code = await installGlobalPackage(npm, metadata.name, version);
|
|
47
|
+
if (code !== 0)
|
|
48
|
+
throw new CliError({
|
|
49
|
+
code: 'UPDATE_INSTALL_FAILED',
|
|
50
|
+
category: 'internal',
|
|
51
|
+
message: 'npm global installation failed.',
|
|
52
|
+
hint: 'Run update --repair after checking npm permissions.',
|
|
53
|
+
retryable: true,
|
|
54
|
+
exitCode: 1,
|
|
55
|
+
});
|
|
56
|
+
const cli = process.env.HITHINK_FINANCE_CLI_EXECUTABLE ??
|
|
57
|
+
(process.platform === 'win32' ? 'hithink-finance.cmd' : 'hithink-finance');
|
|
58
|
+
const skillsCode = await runExecutable(cli, ['skills', 'sync', '--repair', '--yes']);
|
|
59
|
+
const doctorCode = await runExecutable(cli, ['doctor', '--format', 'json']);
|
|
60
|
+
if (skillsCode !== 0 || doctorCode !== 0)
|
|
61
|
+
throw new CliError({
|
|
62
|
+
code: 'UPDATE_REPAIR_PARTIAL',
|
|
63
|
+
category: 'internal',
|
|
64
|
+
message: 'The package updated, but Skill synchronization or doctor failed.',
|
|
65
|
+
hint: 'Run `hithink-finance update --repair`.',
|
|
66
|
+
retryable: true,
|
|
67
|
+
exitCode: 6,
|
|
68
|
+
});
|
|
69
|
+
await renderResult(successEnvelope('update', { version, repaired: options.repair === true }, { requestId: context.requestId }), context);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=update.js.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { CliError, type ErrorCategory } from './errors.js';
|
|
2
|
+
export interface ResultMeta {
|
|
3
|
+
source?: 'local' | 'remote';
|
|
4
|
+
count?: number;
|
|
5
|
+
asOf?: string;
|
|
6
|
+
adjust?: string;
|
|
7
|
+
truncated: boolean;
|
|
8
|
+
requestId: string;
|
|
9
|
+
schemaVersion: '1';
|
|
10
|
+
}
|
|
11
|
+
export interface ResultEnvelope<T> {
|
|
12
|
+
ok: true;
|
|
13
|
+
command: string;
|
|
14
|
+
data: T;
|
|
15
|
+
meta: ResultMeta;
|
|
16
|
+
}
|
|
17
|
+
export interface ErrorBody {
|
|
18
|
+
code: string;
|
|
19
|
+
category: ErrorCategory;
|
|
20
|
+
message: string;
|
|
21
|
+
hint: string;
|
|
22
|
+
retryable: boolean;
|
|
23
|
+
requestId?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface ErrorEnvelope {
|
|
26
|
+
ok: false;
|
|
27
|
+
command: string;
|
|
28
|
+
error: ErrorBody;
|
|
29
|
+
meta: {
|
|
30
|
+
cliVersion: string;
|
|
31
|
+
schemaVersion: '1';
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export type Envelope<T = unknown> = ResultEnvelope<T> | ErrorEnvelope;
|
|
35
|
+
export declare function successEnvelope<T>(command: string, data: T, meta: Partial<ResultMeta> & Pick<ResultMeta, 'requestId'>): ResultEnvelope<T>;
|
|
36
|
+
export declare function errorEnvelope(command: string, error: CliError, cliVersion: string): ErrorEnvelope;
|
|
37
|
+
//# sourceMappingURL=envelope.d.ts.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { CliError } from './errors.js';
|
|
2
|
+
import { redactText } from '../infrastructure/credentials/redact.js';
|
|
3
|
+
export function successEnvelope(command, data, meta) {
|
|
4
|
+
return {
|
|
5
|
+
ok: true,
|
|
6
|
+
command,
|
|
7
|
+
data,
|
|
8
|
+
meta: {
|
|
9
|
+
...meta,
|
|
10
|
+
truncated: meta.truncated ?? false,
|
|
11
|
+
schemaVersion: '1',
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export function errorEnvelope(command, error, cliVersion) {
|
|
16
|
+
const body = {
|
|
17
|
+
code: error.code,
|
|
18
|
+
category: error.category,
|
|
19
|
+
message: redactText(error.message),
|
|
20
|
+
hint: redactText(error.hint),
|
|
21
|
+
retryable: error.retryable,
|
|
22
|
+
};
|
|
23
|
+
if (error.requestId !== undefined) {
|
|
24
|
+
body.requestId = error.requestId;
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
ok: false,
|
|
28
|
+
command,
|
|
29
|
+
error: body,
|
|
30
|
+
meta: {
|
|
31
|
+
cliVersion,
|
|
32
|
+
schemaVersion: '1',
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=envelope.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type ErrorCategory = 'validation' | 'authentication' | 'upstream' | 'local-data' | 'internal';
|
|
2
|
+
export type ExitCode = 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
3
|
+
export { redactText } from '../infrastructure/credentials/redact.js';
|
|
4
|
+
export interface CliErrorOptions {
|
|
5
|
+
code: string;
|
|
6
|
+
category: ErrorCategory;
|
|
7
|
+
message: string;
|
|
8
|
+
hint: string;
|
|
9
|
+
retryable: boolean;
|
|
10
|
+
exitCode: Exclude<ExitCode, 0>;
|
|
11
|
+
requestId?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare class CliError extends Error {
|
|
14
|
+
readonly code: string;
|
|
15
|
+
readonly category: ErrorCategory;
|
|
16
|
+
readonly hint: string;
|
|
17
|
+
readonly retryable: boolean;
|
|
18
|
+
readonly exitCode: Exclude<ExitCode, 0>;
|
|
19
|
+
readonly requestId: string | undefined;
|
|
20
|
+
constructor(options: CliErrorOptions);
|
|
21
|
+
}
|
|
22
|
+
export declare function internalError(error: unknown): CliError;
|
|
23
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export { redactText } from '../infrastructure/credentials/redact.js';
|
|
2
|
+
export class CliError extends Error {
|
|
3
|
+
code;
|
|
4
|
+
category;
|
|
5
|
+
hint;
|
|
6
|
+
retryable;
|
|
7
|
+
exitCode;
|
|
8
|
+
requestId;
|
|
9
|
+
constructor(options) {
|
|
10
|
+
super(options.message);
|
|
11
|
+
this.name = 'CliError';
|
|
12
|
+
this.code = options.code;
|
|
13
|
+
this.category = options.category;
|
|
14
|
+
this.hint = options.hint;
|
|
15
|
+
this.retryable = options.retryable;
|
|
16
|
+
this.exitCode = options.exitCode;
|
|
17
|
+
this.requestId = options.requestId;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export function internalError(error) {
|
|
21
|
+
if (error instanceof CliError) {
|
|
22
|
+
return error;
|
|
23
|
+
}
|
|
24
|
+
return new CliError({
|
|
25
|
+
code: 'CLI_INTERNAL_ERROR',
|
|
26
|
+
category: 'internal',
|
|
27
|
+
message: error instanceof Error ? error.message : 'Unexpected internal error.',
|
|
28
|
+
hint: 'Run the command again with --debug and report the request ID if the error persists.',
|
|
29
|
+
retryable: false,
|
|
30
|
+
exitCode: 1,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface LocalCapabilityDescriptor {
|
|
2
|
+
id: string;
|
|
3
|
+
command: readonly [string, string];
|
|
4
|
+
description: string;
|
|
5
|
+
options?: readonly LocalCapabilityOption[];
|
|
6
|
+
}
|
|
7
|
+
export interface LocalCapabilityOption {
|
|
8
|
+
flags: string;
|
|
9
|
+
required?: boolean;
|
|
10
|
+
description?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare const localCapabilities: readonly LocalCapabilityDescriptor[];
|
|
13
|
+
//# sourceMappingURL=local-capabilities.d.ts.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export const localCapabilities = [
|
|
2
|
+
descriptor('data.init', 'data', 'init'),
|
|
3
|
+
descriptor('data.sync', 'data', 'sync'),
|
|
4
|
+
descriptor('data.status', 'data', 'status'),
|
|
5
|
+
descriptor('data.validate', 'data', 'validate'),
|
|
6
|
+
descriptor('data.repair', 'data', 'repair'),
|
|
7
|
+
descriptor('data.migrate', 'data', 'migrate'),
|
|
8
|
+
descriptor('data.clean', 'data', 'clean'),
|
|
9
|
+
descriptor('data.remove', 'data', 'remove'),
|
|
10
|
+
descriptor('db.describe', 'db', 'describe'),
|
|
11
|
+
descriptor('db.query', 'db', 'query', [{ flags: '--sql <sql>', required: true }]),
|
|
12
|
+
descriptor('db.export', 'db', 'export', [
|
|
13
|
+
{ flags: '--sql <sql>', required: true },
|
|
14
|
+
{ flags: '--output <path>', required: true },
|
|
15
|
+
{ flags: '--file-format <format>', required: false },
|
|
16
|
+
]),
|
|
17
|
+
descriptor('market.panel', 'market', 'panel', [
|
|
18
|
+
{ flags: '--start <date>', required: true },
|
|
19
|
+
{ flags: '--end <date>', required: true },
|
|
20
|
+
{ flags: '--output <path>', required: true },
|
|
21
|
+
{ flags: '--file-format <format>', required: false },
|
|
22
|
+
]),
|
|
23
|
+
descriptor('market.adjustment-factors', 'market', 'adjustment-factors', [
|
|
24
|
+
{ flags: '--thscode <code>', required: true },
|
|
25
|
+
{ flags: '--start <date>', required: false },
|
|
26
|
+
{ flags: '--end <date>', required: false },
|
|
27
|
+
]),
|
|
28
|
+
];
|
|
29
|
+
function descriptor(id, group, leaf, options) {
|
|
30
|
+
return {
|
|
31
|
+
id,
|
|
32
|
+
command: [group, leaf],
|
|
33
|
+
description: `Local capability ${id}`,
|
|
34
|
+
...(options === undefined ? {} : { options }),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=local-capabilities.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Command } from 'commander';
|
|
2
|
+
export interface CommandDescriptor {
|
|
3
|
+
id: string;
|
|
4
|
+
path: readonly string[];
|
|
5
|
+
describe: (language: 'zh-CN' | 'en') => string;
|
|
6
|
+
register: (program: Command) => void;
|
|
7
|
+
}
|
|
8
|
+
export declare function commandPath(descriptor: Pick<CommandDescriptor, 'path'>): string;
|
|
9
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type ZodType } from 'zod';
|
|
2
|
+
export interface RemoteOptionDescriptor {
|
|
3
|
+
flags: string;
|
|
4
|
+
description: string;
|
|
5
|
+
type: 'string' | 'integer' | 'boolean';
|
|
6
|
+
required?: boolean;
|
|
7
|
+
choices?: readonly string[];
|
|
8
|
+
defaultValue?: string | number | boolean;
|
|
9
|
+
queryName?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface RemoteCapabilityDescriptor {
|
|
12
|
+
id: string;
|
|
13
|
+
command: readonly [string, string];
|
|
14
|
+
description: string;
|
|
15
|
+
endpoint: string;
|
|
16
|
+
method: 'GET';
|
|
17
|
+
inputSchema: ZodType<Record<string, unknown>>;
|
|
18
|
+
outputSchema: ZodType<unknown>;
|
|
19
|
+
options: readonly RemoteOptionDescriptor[];
|
|
20
|
+
paging: 'none' | 'offset' | 'page';
|
|
21
|
+
window: 'none' | 'ten-years' | 'one-year' | 'today-only';
|
|
22
|
+
}
|
|
23
|
+
export declare const remoteCapabilities: readonly RemoteCapabilityDescriptor[];
|
|
24
|
+
//# sourceMappingURL=remote-capabilities.d.ts.map
|