@ty_krystal/sei-ai 0.1.8 → 0.1.13

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 (59) hide show
  1. package/README.md +34 -65
  2. package/dist/commands/api-docs.d.ts +1 -2
  3. package/dist/commands/api-docs.js +1 -1
  4. package/dist/commands/call.d.ts +1 -2
  5. package/dist/commands/call.js +1 -1
  6. package/dist/commands/dict/add-category.d.ts +1 -2
  7. package/dist/commands/dict/add-category.js +1 -1
  8. package/dist/commands/dict/add-item.d.ts +1 -2
  9. package/dist/commands/dict/add-item.js +1 -1
  10. package/dist/commands/dict/list.d.ts +1 -2
  11. package/dist/commands/dict/list.js +1 -1
  12. package/dist/commands/init/base-data.d.ts +1 -2
  13. package/dist/commands/init/base-data.js +1 -1
  14. package/dist/commands/query-sql.d.ts +1 -2
  15. package/dist/commands/query-sql.js +1 -1
  16. package/dist/commands/query.d.ts +1 -2
  17. package/dist/commands/query.js +1 -1
  18. package/dist/commands/relogin.d.ts +1 -2
  19. package/dist/commands/relogin.js +1 -1
  20. package/dist/commands/save.d.ts +1 -2
  21. package/dist/commands/save.js +1 -1
  22. package/dist/commands.d.ts +24 -0
  23. package/dist/commands.js +23 -0
  24. package/dist/core/cli-actions.d.ts +94 -0
  25. package/dist/core/cli-actions.js +155 -0
  26. package/dist/core/cli-helpers.d.ts +39 -0
  27. package/dist/core/cli-helpers.js +246 -0
  28. package/dist/core/command-base/context.d.ts +6 -0
  29. package/dist/core/command-base/context.js +10 -0
  30. package/dist/core/command-base/output.d.ts +2 -0
  31. package/dist/core/command-base/output.js +6 -0
  32. package/dist/core/command-base/payload.d.ts +7 -0
  33. package/dist/core/command-base/payload.js +33 -0
  34. package/dist/core/command-base/sei-command.d.ts +40 -0
  35. package/dist/core/command-base/sei-command.js +85 -0
  36. package/dist/core/config.d.ts +3 -0
  37. package/dist/core/config.js +80 -0
  38. package/dist/core/constants.d.ts +35 -0
  39. package/dist/core/constants.js +48 -0
  40. package/dist/core/env.d.ts +1 -0
  41. package/dist/core/env.js +55 -0
  42. package/dist/core/errors.d.ts +10 -0
  43. package/dist/core/errors.js +55 -0
  44. package/dist/core/index.d.ts +14 -0
  45. package/dist/core/index.js +14 -0
  46. package/dist/core/logger.d.ts +2 -0
  47. package/dist/core/logger.js +71 -0
  48. package/dist/core/openapi.d.ts +2 -0
  49. package/dist/core/openapi.js +261 -0
  50. package/dist/core/sei-client.d.ts +25 -0
  51. package/dist/core/sei-client.js +524 -0
  52. package/dist/core/types.d.ts +135 -0
  53. package/dist/core/types.js +1 -0
  54. package/dist/core/utils.d.ts +12 -0
  55. package/dist/core/utils.js +53 -0
  56. package/dist/hooks/command_not_found.d.ts +3 -0
  57. package/dist/hooks/command_not_found.js +36 -0
  58. package/oclif.manifest.json +361 -423
  59. package/package.json +18 -8
@@ -0,0 +1,53 @@
1
+ export function isObject(value) {
2
+ return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
3
+ }
4
+ export function toTrimmedString(value) {
5
+ return typeof value === 'string' ? value.trim() : '';
6
+ }
7
+ export function stringifySafe(value) {
8
+ try {
9
+ return JSON.stringify(value, null, 2);
10
+ }
11
+ catch {
12
+ return String(value);
13
+ }
14
+ }
15
+ export function truncateText(value, limit) {
16
+ const text = String(value ?? '');
17
+ return text.length > limit ? `${text.slice(0, limit)}...` : text;
18
+ }
19
+ export function uniqueStrings(values) {
20
+ return [...new Set([...values].map((value) => value.trim()).filter(Boolean))];
21
+ }
22
+ export function normalizeBaseUrl(value) {
23
+ const text = toTrimmedString(value);
24
+ if (!text) {
25
+ throw new Error('base URL 不能为空');
26
+ }
27
+ return text.replace(/\/+$/, '');
28
+ }
29
+ export function normalizePath(value) {
30
+ const text = toTrimmedString(value);
31
+ if (!text) {
32
+ return '/';
33
+ }
34
+ if (text.startsWith('http://') || text.startsWith('https://')) {
35
+ try {
36
+ return new URL(text).pathname || '/';
37
+ }
38
+ catch {
39
+ return '/';
40
+ }
41
+ }
42
+ return text.startsWith('/') ? text : `/${text}`;
43
+ }
44
+ export function makeUrl(baseUrl, path) {
45
+ if (path.startsWith('http://') || path.startsWith('https://')) {
46
+ return path;
47
+ }
48
+ return `${normalizeBaseUrl(baseUrl)}${normalizePath(path)}`;
49
+ }
50
+ export function toPositiveInteger(value, fallback) {
51
+ const parsed = Number(value);
52
+ return Number.isInteger(parsed) && parsed > 0 ? parsed : fallback;
53
+ }
@@ -0,0 +1,3 @@
1
+ import type { Hook } from '@oclif/core';
2
+ declare const hook: Hook.CommandNotFound;
3
+ export default hook;
@@ -0,0 +1,36 @@
1
+ import { cyan, yellow } from 'ansis';
2
+ const hook = async function (options) {
3
+ const commandIDs = [...options.config.commandIDs, ...options.config.commands.flatMap((command) => command.aliases)];
4
+ if (commandIDs.length === 0) {
5
+ this.warn(`${yellow(options.id)} is not a ${options.config.bin} command.`);
6
+ this.error(`Run ${cyan.bold(`${options.config.bin} help`)} for a list of available commands.`, { exit: 127 });
7
+ return;
8
+ }
9
+ const suggestion = commandIDs
10
+ .map((command) => ({ command, distance: levenshteinDistance(options.id, command) }))
11
+ .sort((left, right) => left.distance - right.distance || left.command.localeCompare(right.command))[0]?.command;
12
+ this.warn(`${yellow(options.id)} is not a ${options.config.bin} command.`);
13
+ if (suggestion && suggestion !== options.id) {
14
+ this.warn(`Did you mean ${cyan.bold(suggestion)}?`);
15
+ }
16
+ this.error(`Run ${cyan.bold(`${options.config.bin} help`)} for a list of available commands.`, { exit: 127 });
17
+ };
18
+ export default hook;
19
+ function levenshteinDistance(left, right) {
20
+ const rows = left.length + 1;
21
+ const cols = right.length + 1;
22
+ const matrix = Array.from({ length: rows }, () => new Array(cols).fill(0));
23
+ for (let row = 0; row < rows; row += 1) {
24
+ matrix[row][0] = row;
25
+ }
26
+ for (let col = 0; col < cols; col += 1) {
27
+ matrix[0][col] = col;
28
+ }
29
+ for (let row = 1; row < rows; row += 1) {
30
+ for (let col = 1; col < cols; col += 1) {
31
+ const substitutionCost = left[row - 1] === right[col - 1] ? 0 : 1;
32
+ matrix[row][col] = Math.min(matrix[row - 1][col] + 1, matrix[row][col - 1] + 1, matrix[row - 1][col - 1] + substitutionCost);
33
+ }
34
+ }
35
+ return matrix[rows - 1][cols - 1];
36
+ }