@kweaver-ai/kweaver-sdk 0.8.2 → 0.8.4
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 +26 -52
- package/README.zh.md +27 -46
- package/dist/api/agent-chat.d.ts +10 -2
- package/dist/api/agent-chat.js +19 -5
- package/dist/api/datasources.d.ts +14 -0
- package/dist/api/datasources.js +14 -0
- package/dist/api/resources.d.ts +94 -0
- package/dist/api/resources.js +166 -0
- package/dist/cli.js +103 -23
- package/dist/client.d.ts +10 -4
- package/dist/client.js +12 -6
- package/dist/commands/agent-members.js +27 -11
- package/dist/commands/agent.js +383 -272
- package/dist/commands/auth.js +184 -71
- package/dist/commands/bkn-metric.js +37 -16
- package/dist/commands/bkn-ops.d.ts +1 -1
- package/dist/commands/bkn-ops.js +192 -93
- package/dist/commands/bkn-query.js +99 -31
- package/dist/commands/bkn-schema.d.ts +3 -3
- package/dist/commands/bkn-schema.js +127 -86
- package/dist/commands/bkn.js +158 -116
- package/dist/commands/call.js +23 -13
- package/dist/commands/config.js +22 -12
- package/dist/commands/context-loader.js +98 -92
- package/dist/commands/dataflow.js +14 -6
- package/dist/commands/ds.d.ts +0 -31
- package/dist/commands/ds.js +18 -426
- package/dist/commands/explore-bkn.d.ts +7 -1
- package/dist/commands/explore-bkn.js +32 -3
- package/dist/commands/explore.js +18 -15
- package/dist/commands/model.js +53 -42
- package/dist/commands/resource.d.ts +1 -0
- package/dist/commands/{dataview.js → resource.js} +62 -84
- package/dist/commands/skill.js +201 -65
- package/dist/commands/token.js +11 -0
- package/dist/commands/tool.js +46 -29
- package/dist/commands/toolbox.js +31 -15
- package/dist/commands/vega.js +466 -250
- package/dist/help/format.d.ts +65 -0
- package/dist/help/format.js +141 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/resources/datasources.d.ts +7 -0
- package/dist/resources/datasources.js +7 -0
- package/dist/resources/{dataviews.d.ts → resources.d.ts} +10 -11
- package/dist/resources/{dataviews.js → resources.js} +12 -13
- package/dist/templates/explorer/bkn.js +860 -9
- package/dist/templates/explorer/index.html +1 -0
- package/dist/templates/explorer/style.css +225 -0
- package/dist/templates/explorer/vendor/g6.min.js +68 -0
- package/dist/trace-ai/eval-set/schemas.d.ts +1 -0
- package/dist/trace-ai/eval-set/schemas.js +4 -0
- package/dist/trace-ai/eval-set/types.d.ts +2 -0
- package/dist/trace-ai/exp/capture-fingerprint.d.ts +10 -0
- package/dist/trace-ai/exp/capture-fingerprint.js +12 -0
- package/dist/trace-ai/exp/context/context-assembler.d.ts +18 -0
- package/dist/trace-ai/exp/context/context-assembler.js +42 -0
- package/dist/trace-ai/exp/context/failure-analyzer.d.ts +22 -0
- package/dist/trace-ai/exp/context/failure-analyzer.js +59 -0
- package/dist/trace-ai/exp/context/kn-data-prober.d.ts +13 -0
- package/dist/trace-ai/exp/context/kn-data-prober.js +38 -0
- package/dist/trace-ai/exp/context/kn-schema-client.d.ts +14 -0
- package/dist/trace-ai/exp/context/kn-schema-client.js +41 -0
- package/dist/trace-ai/exp/context/retrieval-health.d.ts +32 -0
- package/dist/trace-ai/exp/context/retrieval-health.js +138 -0
- package/dist/trace-ai/exp/context/vega-catalog-client.d.ts +14 -0
- package/dist/trace-ai/exp/context/vega-catalog-client.js +15 -0
- package/dist/trace-ai/exp/coordinator.d.ts +34 -21
- package/dist/trace-ai/exp/coordinator.js +246 -24
- package/dist/trace-ai/exp/eval-runner.js +4 -2
- package/dist/trace-ai/exp/exp-store/events-jsonl.d.ts +1 -0
- package/dist/trace-ai/exp/exp-store/events-jsonl.js +18 -0
- package/dist/trace-ai/exp/exp-store/expected-fingerprint.d.ts +3 -0
- package/dist/trace-ai/exp/exp-store/expected-fingerprint.js +31 -0
- package/dist/trace-ai/exp/exp-store/index.d.ts +63 -2
- package/dist/trace-ai/exp/exp-store/index.js +2 -1
- package/dist/trace-ai/exp/exp-store/rollback-yaml.d.ts +12 -0
- package/dist/trace-ai/exp/exp-store/rollback-yaml.js +29 -0
- package/dist/trace-ai/exp/index.d.ts +2 -0
- package/dist/trace-ai/exp/index.js +68 -3
- package/dist/trace-ai/exp/info.js +1 -1
- package/dist/trace-ai/exp/patch/index.d.ts +13 -2
- package/dist/trace-ai/exp/patch/index.js +65 -10
- package/dist/trace-ai/exp/patch/kn-api-client.d.ts +40 -0
- package/dist/trace-ai/exp/patch/kn-api-client.js +14 -0
- package/dist/trace-ai/exp/patch/kn.d.ts +8 -0
- package/dist/trace-ai/exp/patch/kn.js +36 -0
- package/dist/trace-ai/exp/patch/skill-api-client.d.ts +17 -0
- package/dist/trace-ai/exp/patch/skill-api-client.js +14 -0
- package/dist/trace-ai/exp/patch/skill-content.d.ts +9 -0
- package/dist/trace-ai/exp/patch/skill-content.js +12 -0
- package/dist/trace-ai/exp/preflight.d.ts +77 -0
- package/dist/trace-ai/exp/preflight.js +148 -0
- package/dist/trace-ai/exp/providers/synthesizer-client.d.ts +3 -14
- package/dist/trace-ai/exp/providers/synthesizer-client.js +53 -35
- package/dist/trace-ai/exp/providers/triage-client.d.ts +15 -2
- package/dist/trace-ai/exp/providers/triage-client.js +143 -28
- package/dist/trace-ai/exp/run-preflight.d.ts +19 -0
- package/dist/trace-ai/exp/run-preflight.js +56 -0
- package/dist/trace-ai/exp/schemas.d.ts +402 -44
- package/dist/trace-ai/exp/schemas.js +131 -18
- package/dist/utils/deprecation.d.ts +1 -0
- package/dist/utils/deprecation.js +18 -0
- package/package.json +2 -1
- package/dist/api/dataviews.d.ts +0 -117
- package/dist/api/dataviews.js +0 -265
- package/dist/commands/dataview.d.ts +0 -8
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Help text formatter for the kweaver CLI.
|
|
3
|
+
*
|
|
4
|
+
* All `--help` output must go through `renderHelp()` to keep a consistent
|
|
5
|
+
* gh-style layout. See `docs/cli_conventions.md` §8 for the spec.
|
|
6
|
+
*/
|
|
7
|
+
export interface HelpItem {
|
|
8
|
+
name: string;
|
|
9
|
+
desc: string;
|
|
10
|
+
}
|
|
11
|
+
export interface HelpSection {
|
|
12
|
+
title: string;
|
|
13
|
+
items: HelpItem[];
|
|
14
|
+
}
|
|
15
|
+
export interface HelpFlag {
|
|
16
|
+
name: string;
|
|
17
|
+
desc: string;
|
|
18
|
+
}
|
|
19
|
+
export interface HelpFlagGroup {
|
|
20
|
+
title: string;
|
|
21
|
+
flags: HelpFlag[];
|
|
22
|
+
}
|
|
23
|
+
export interface RenderHelpOptions {
|
|
24
|
+
/** Optional one-line tagline shown at the very top. */
|
|
25
|
+
tagline?: string;
|
|
26
|
+
/** One or more USAGE lines (without the "USAGE" header). */
|
|
27
|
+
usage: string | string[];
|
|
28
|
+
/**
|
|
29
|
+
* Command / subcommand groupings (rendered as separate sections with
|
|
30
|
+
* two-column name:desc layout).
|
|
31
|
+
*/
|
|
32
|
+
sections?: HelpSection[];
|
|
33
|
+
/**
|
|
34
|
+
* Flags. Either a flat list (rendered under "FLAGS") or grouped sub-blocks
|
|
35
|
+
* (each rendered under its own title, e.g. "Login options").
|
|
36
|
+
*/
|
|
37
|
+
flags?: HelpFlag[] | HelpFlagGroup[];
|
|
38
|
+
/** One-line "INHERITED FLAGS" summary. Omitted if undefined. */
|
|
39
|
+
inheritedFlags?: string;
|
|
40
|
+
/** Environment variable docs. */
|
|
41
|
+
environment?: HelpFlag[];
|
|
42
|
+
/** Example invocations (prefix `$ ` added automatically if missing). */
|
|
43
|
+
examples?: string[];
|
|
44
|
+
/** Free-form "LEARN MORE" trailing lines. */
|
|
45
|
+
learnMore?: string[];
|
|
46
|
+
/** Override the wrap width (default 80). */
|
|
47
|
+
width?: number;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Render full help text per the §8 spec.
|
|
51
|
+
*/
|
|
52
|
+
export declare function renderHelp(opts: RenderHelpOptions): string;
|
|
53
|
+
/**
|
|
54
|
+
* Render a two-column name:desc list.
|
|
55
|
+
*
|
|
56
|
+
* Width policy: left column = max(name length) + 2 (capped at half the wrap
|
|
57
|
+
* width). Description wraps onto continuation lines aligned to the right
|
|
58
|
+
* column. `indent` controls the leading whitespace (default: 2 spaces).
|
|
59
|
+
*/
|
|
60
|
+
export declare function formatTwoColumn(items: HelpItem[], width?: number, indent?: string): string[];
|
|
61
|
+
/**
|
|
62
|
+
* Word-wrap a string at the given column. Preserves single newlines as
|
|
63
|
+
* explicit line breaks.
|
|
64
|
+
*/
|
|
65
|
+
export declare function wrap(text: string, width: number): string[];
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Help text formatter for the kweaver CLI.
|
|
3
|
+
*
|
|
4
|
+
* All `--help` output must go through `renderHelp()` to keep a consistent
|
|
5
|
+
* gh-style layout. See `docs/cli_conventions.md` §8 for the spec.
|
|
6
|
+
*/
|
|
7
|
+
const DEFAULT_WIDTH = 80;
|
|
8
|
+
const INDENT = " ";
|
|
9
|
+
/**
|
|
10
|
+
* Render full help text per the §8 spec.
|
|
11
|
+
*/
|
|
12
|
+
export function renderHelp(opts) {
|
|
13
|
+
const width = opts.width ?? DEFAULT_WIDTH;
|
|
14
|
+
const out = [];
|
|
15
|
+
if (opts.tagline) {
|
|
16
|
+
out.push(opts.tagline);
|
|
17
|
+
out.push("");
|
|
18
|
+
}
|
|
19
|
+
const usageLines = Array.isArray(opts.usage) ? opts.usage : [opts.usage];
|
|
20
|
+
out.push("USAGE");
|
|
21
|
+
for (const line of usageLines) {
|
|
22
|
+
out.push(INDENT + line);
|
|
23
|
+
}
|
|
24
|
+
out.push("");
|
|
25
|
+
if (opts.sections && opts.sections.length > 0) {
|
|
26
|
+
for (const section of opts.sections) {
|
|
27
|
+
out.push(section.title.toUpperCase());
|
|
28
|
+
out.push(...formatTwoColumn(section.items, width));
|
|
29
|
+
out.push("");
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (opts.flags) {
|
|
33
|
+
if (isFlagGroupArray(opts.flags)) {
|
|
34
|
+
out.push("FLAGS");
|
|
35
|
+
for (const group of opts.flags) {
|
|
36
|
+
out.push(INDENT + group.title);
|
|
37
|
+
out.push(...formatTwoColumn(group.flags.map((f) => ({ name: f.name, desc: f.desc })), width, INDENT.repeat(2)));
|
|
38
|
+
out.push("");
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
out.push("FLAGS");
|
|
43
|
+
out.push(...formatTwoColumn(opts.flags.map((f) => ({ name: f.name, desc: f.desc })), width));
|
|
44
|
+
out.push("");
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (opts.inheritedFlags) {
|
|
48
|
+
out.push("INHERITED FLAGS");
|
|
49
|
+
out.push(INDENT + opts.inheritedFlags);
|
|
50
|
+
out.push("");
|
|
51
|
+
}
|
|
52
|
+
if (opts.environment && opts.environment.length > 0) {
|
|
53
|
+
out.push("ENVIRONMENT");
|
|
54
|
+
out.push(...formatTwoColumn(opts.environment.map((e) => ({ name: e.name, desc: e.desc })), width));
|
|
55
|
+
out.push("");
|
|
56
|
+
}
|
|
57
|
+
if (opts.examples && opts.examples.length > 0) {
|
|
58
|
+
out.push("EXAMPLES");
|
|
59
|
+
for (const ex of opts.examples) {
|
|
60
|
+
const trimmed = ex.trimStart();
|
|
61
|
+
const line = trimmed.startsWith("$") ? trimmed : `$ ${trimmed}`;
|
|
62
|
+
out.push(INDENT + line);
|
|
63
|
+
}
|
|
64
|
+
out.push("");
|
|
65
|
+
}
|
|
66
|
+
if (opts.learnMore && opts.learnMore.length > 0) {
|
|
67
|
+
out.push("LEARN MORE");
|
|
68
|
+
for (const line of opts.learnMore) {
|
|
69
|
+
out.push(INDENT + line);
|
|
70
|
+
}
|
|
71
|
+
out.push("");
|
|
72
|
+
}
|
|
73
|
+
while (out.length > 0 && out[out.length - 1] === "")
|
|
74
|
+
out.pop();
|
|
75
|
+
return out.join("\n");
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Render a two-column name:desc list.
|
|
79
|
+
*
|
|
80
|
+
* Width policy: left column = max(name length) + 2 (capped at half the wrap
|
|
81
|
+
* width). Description wraps onto continuation lines aligned to the right
|
|
82
|
+
* column. `indent` controls the leading whitespace (default: 2 spaces).
|
|
83
|
+
*/
|
|
84
|
+
export function formatTwoColumn(items, width = DEFAULT_WIDTH, indent = INDENT) {
|
|
85
|
+
if (items.length === 0)
|
|
86
|
+
return [];
|
|
87
|
+
const maxName = items.reduce((m, i) => Math.max(m, i.name.length), 0);
|
|
88
|
+
const halfWidth = Math.floor(width / 2);
|
|
89
|
+
const colGap = Math.min(maxName + 2, halfWidth);
|
|
90
|
+
const descCol = indent.length + colGap;
|
|
91
|
+
const descWidth = Math.max(20, width - descCol);
|
|
92
|
+
const out = [];
|
|
93
|
+
for (const item of items) {
|
|
94
|
+
const namePadded = item.name.padEnd(colGap, " ");
|
|
95
|
+
const descLines = wrap(item.desc, descWidth);
|
|
96
|
+
if (descLines.length === 0) {
|
|
97
|
+
out.push(indent + item.name);
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
out.push(indent + namePadded + descLines[0]);
|
|
101
|
+
for (let i = 1; i < descLines.length; i++) {
|
|
102
|
+
out.push(" ".repeat(descCol) + descLines[i]);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return out;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Word-wrap a string at the given column. Preserves single newlines as
|
|
109
|
+
* explicit line breaks.
|
|
110
|
+
*/
|
|
111
|
+
export function wrap(text, width) {
|
|
112
|
+
if (!text)
|
|
113
|
+
return [];
|
|
114
|
+
const result = [];
|
|
115
|
+
for (const para of text.split("\n")) {
|
|
116
|
+
if (para.length <= width) {
|
|
117
|
+
result.push(para);
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
const words = para.split(/\s+/);
|
|
121
|
+
let line = "";
|
|
122
|
+
for (const word of words) {
|
|
123
|
+
if (line.length === 0) {
|
|
124
|
+
line = word;
|
|
125
|
+
}
|
|
126
|
+
else if (line.length + 1 + word.length <= width) {
|
|
127
|
+
line += " " + word;
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
result.push(line);
|
|
131
|
+
line = word;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (line.length > 0)
|
|
135
|
+
result.push(line);
|
|
136
|
+
}
|
|
137
|
+
return result;
|
|
138
|
+
}
|
|
139
|
+
function isFlagGroupArray(v) {
|
|
140
|
+
return v.length > 0 && "flags" in v[0];
|
|
141
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -59,9 +59,9 @@ export type { InvokeToolArgs } from "./resources/toolboxes.js";
|
|
|
59
59
|
export { ModelsResource, LlmModelsSubresource, SmallModelsSubresource, ModelInvocationSubresource, } from "./resources/models.js";
|
|
60
60
|
export type { SkillCategory, SkillEditableStatus, SkillStatus, SkillSummary, SkillInfo, SkillFileSummary, SkillContentIndex, SkillFileReadResult, RegisterSkillResult, DeleteSkillResult, UpdateSkillStatusResult, SkillListResult, ListSkillsOptions, ListSkillMarketOptions, GetSkillOptions, RegisterSkillContentOptions, RegisterSkillZipOptions, UpdateSkillMetadataOptions, UpdateSkillMetadataResult, UpdateSkillPackageContentOptions, UpdateSkillPackageZipOptions, UpdateSkillPackageResult, UpdateSkillStatusOptions, ReadSkillFileOptions, DownloadSkillOptions, DownloadedSkillArchive, SkillReleaseHistoryInfo, SkillHistoryVersionOptions, SkillManagementContentData, GetSkillManagementContentOptions, ReadSkillManagementFileOptions, DownloadSkillManagementOptions, } from "./api/skills.js";
|
|
61
61
|
export { listSkills, listSkillMarket, getSkill, getSkillMarketDetail, deleteSkill, updateSkillStatus, updateSkillMetadata, registerSkillContent, registerSkillZip, updateSkillPackageContent, updateSkillPackageZip, getSkillContentIndex, fetchSkillContent, readSkillFile, fetchSkillFile, downloadSkill, listSkillHistory, republishSkillHistory, publishSkillHistory, installSkillArchive, getSkillManagementContent, readSkillManagementFile, downloadSkillManagementArchive, } from "./api/skills.js";
|
|
62
|
-
export type { ViewField,
|
|
63
|
-
export {
|
|
64
|
-
export {
|
|
62
|
+
export type { ViewField, Resource, CreateResourceOptions, GetResourceOptions, ListResourcesOptions, DeleteResourceOptions, FindResourceOptions, QueryResourceOptions, ResourceQueryResult, } from "./api/resources.js";
|
|
63
|
+
export { parseResource, createResource, getResource, listResources, deleteResource, findResource, queryResource, } from "./api/resources.js";
|
|
64
|
+
export { ResourcesResource } from "./resources/resources.js";
|
|
65
65
|
export type { MfManagerBaseOptions, ListLlmModelsOptions, GetLlmModelOptions, AddLlmModelOptions, EditLlmModelOptions, DeleteLlmModelsOptions, TestLlmModelOptions, ListSmallModelsOptions, GetSmallModelOptions, AddSmallModelOptions, EditSmallModelOptions, DeleteSmallModelsOptions, TestSmallModelOptions, } from "./api/models.js";
|
|
66
66
|
export { MF_MODEL_MANAGER_PATH_PREFIX, assertSmallModelConfigAdapterExclusive, assertSmallModelEditBody, listLlmModels, getLlmModel, addLlmModel, editLlmModel, deleteLlmModels, testLlmModel, listSmallModels, getSmallModel, addSmallModel, editSmallModel, deleteSmallModels, testSmallModel, } from "./api/models.js";
|
|
67
67
|
export type { MfApiBaseOptions, ChatMessage, ModelChatCompletionsOptions, ModelChatResult, ModelEmbeddingOptions, ModelRerankOptions, } from "./api/model-invocation.js";
|
package/dist/index.js
CHANGED
|
@@ -45,8 +45,8 @@ export { SkillsResource } from "./resources/skills.js";
|
|
|
45
45
|
export { ToolboxesResource } from "./resources/toolboxes.js";
|
|
46
46
|
export { ModelsResource, LlmModelsSubresource, SmallModelsSubresource, ModelInvocationSubresource, } from "./resources/models.js";
|
|
47
47
|
export { listSkills, listSkillMarket, getSkill, getSkillMarketDetail, deleteSkill, updateSkillStatus, updateSkillMetadata, registerSkillContent, registerSkillZip, updateSkillPackageContent, updateSkillPackageZip, getSkillContentIndex, fetchSkillContent, readSkillFile, fetchSkillFile, downloadSkill, listSkillHistory, republishSkillHistory, publishSkillHistory, installSkillArchive, getSkillManagementContent, readSkillManagementFile, downloadSkillManagementArchive, } from "./api/skills.js";
|
|
48
|
-
export {
|
|
49
|
-
export {
|
|
48
|
+
export { parseResource, createResource, getResource, listResources, deleteResource, findResource, queryResource, } from "./api/resources.js";
|
|
49
|
+
export { ResourcesResource } from "./resources/resources.js";
|
|
50
50
|
export { MF_MODEL_MANAGER_PATH_PREFIX, assertSmallModelConfigAdapterExclusive, assertSmallModelEditBody, listLlmModels, getLlmModel, addLlmModel, editLlmModel, deleteLlmModels, testLlmModel, listSmallModels, getSmallModel, addSmallModel, editSmallModel, deleteSmallModels, testSmallModel, } from "./api/models.js";
|
|
51
51
|
export { MF_MODEL_API_PATH_PREFIX, consumeOpenAiSseText, modelChatCompletions, modelEmbedding, modelEmbeddings, modelRerank, } from "./api/model-invocation.js";
|
|
52
52
|
export { listBusinessDomains } from "./api/business-domains.js";
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import type { ClientContext } from "../client.js";
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated Datasource is a legacy concept. The platform has migrated
|
|
4
|
+
* data-connection management to vega catalogs. Use `client.vega.catalogs`
|
|
5
|
+
* for catalog CRUD and `client.resources` for resource queries instead.
|
|
6
|
+
* This class is kept as a thin back-compat layer and may be removed in a
|
|
7
|
+
* future major release.
|
|
8
|
+
*/
|
|
2
9
|
export declare class DataSourcesResource {
|
|
3
10
|
private readonly ctx;
|
|
4
11
|
constructor(ctx: ClientContext);
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { testDatasource, createDatasource, listDatasources, getDatasource, deleteDatasource, listTables, } from "../api/datasources.js";
|
|
2
2
|
import { listTablesWithColumns, scanMetadata } from "../api/vega.js";
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated Datasource is a legacy concept. The platform has migrated
|
|
5
|
+
* data-connection management to vega catalogs. Use `client.vega.catalogs`
|
|
6
|
+
* for catalog CRUD and `client.resources` for resource queries instead.
|
|
7
|
+
* This class is kept as a thin back-compat layer and may be removed in a
|
|
8
|
+
* future major release.
|
|
9
|
+
*/
|
|
3
10
|
export class DataSourcesResource {
|
|
4
11
|
ctx;
|
|
5
12
|
constructor(ctx) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Resource, ResourceQueryResult } from "../api/resources.js";
|
|
2
2
|
import type { ClientContext } from "../client.js";
|
|
3
|
-
export declare class
|
|
3
|
+
export declare class ResourcesResource {
|
|
4
4
|
private readonly ctx;
|
|
5
5
|
constructor(ctx: ClientContext);
|
|
6
6
|
create(opts: {
|
|
@@ -12,26 +12,25 @@ export declare class DataViewsResource {
|
|
|
12
12
|
type: string;
|
|
13
13
|
}>;
|
|
14
14
|
}): Promise<string>;
|
|
15
|
-
get(id: string): Promise<
|
|
15
|
+
get(id: string): Promise<Resource>;
|
|
16
16
|
list(opts?: {
|
|
17
17
|
datasourceId?: string;
|
|
18
|
-
|
|
18
|
+
category?: string;
|
|
19
19
|
limit?: number;
|
|
20
|
-
}): Promise<
|
|
20
|
+
}): Promise<Resource[]>;
|
|
21
21
|
find(name: string, opts?: {
|
|
22
22
|
datasourceId?: string;
|
|
23
23
|
exact?: boolean;
|
|
24
24
|
wait?: boolean;
|
|
25
25
|
timeoutMs?: number;
|
|
26
|
-
}): Promise<
|
|
26
|
+
}): Promise<Resource[]>;
|
|
27
27
|
delete(id: string): Promise<void>;
|
|
28
28
|
query(id: string, opts?: {
|
|
29
|
-
sql?: string;
|
|
30
29
|
offset?: number;
|
|
31
30
|
limit?: number;
|
|
32
31
|
needTotal?: boolean;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}): Promise<
|
|
32
|
+
filterCondition?: unknown;
|
|
33
|
+
sort?: string;
|
|
34
|
+
direction?: "asc" | "desc";
|
|
35
|
+
}): Promise<ResourceQueryResult>;
|
|
37
36
|
}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export class
|
|
1
|
+
import { RESOURCE_LIST_DEFAULT_LIMIT, createResource, deleteResource, findResource, getResource, listResources, queryResource, } from "../api/resources.js";
|
|
2
|
+
export class ResourcesResource {
|
|
3
3
|
ctx;
|
|
4
4
|
constructor(ctx) {
|
|
5
5
|
this.ctx = ctx;
|
|
6
6
|
}
|
|
7
7
|
async create(opts) {
|
|
8
|
-
return
|
|
8
|
+
return createResource({ ...this.ctx.base(), ...opts });
|
|
9
9
|
}
|
|
10
10
|
async get(id) {
|
|
11
|
-
return
|
|
11
|
+
return getResource({ ...this.ctx.base(), id });
|
|
12
12
|
}
|
|
13
13
|
async list(opts = {}) {
|
|
14
|
-
return
|
|
14
|
+
return listResources({
|
|
15
15
|
...this.ctx.base(),
|
|
16
16
|
datasourceId: opts.datasourceId,
|
|
17
|
-
|
|
18
|
-
limit: opts.limit,
|
|
17
|
+
category: opts.category,
|
|
18
|
+
limit: opts.limit ?? RESOURCE_LIST_DEFAULT_LIMIT,
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
21
|
async find(name, opts) {
|
|
22
|
-
return
|
|
22
|
+
return findResource({
|
|
23
23
|
...this.ctx.base(),
|
|
24
24
|
name,
|
|
25
25
|
datasourceId: opts?.datasourceId,
|
|
@@ -29,19 +29,18 @@ export class DataViewsResource {
|
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
31
|
async delete(id) {
|
|
32
|
-
await
|
|
32
|
+
await deleteResource({ ...this.ctx.base(), id });
|
|
33
33
|
}
|
|
34
34
|
async query(id, opts) {
|
|
35
|
-
return
|
|
35
|
+
return queryResource({
|
|
36
36
|
...this.ctx.base(),
|
|
37
37
|
id,
|
|
38
|
-
sql: opts?.sql,
|
|
39
38
|
offset: opts?.offset,
|
|
40
39
|
limit: opts?.limit,
|
|
41
40
|
needTotal: opts?.needTotal,
|
|
42
|
-
|
|
43
|
-
filters: opts?.filters,
|
|
41
|
+
filterCondition: opts?.filterCondition,
|
|
44
42
|
sort: opts?.sort,
|
|
43
|
+
direction: opts?.direction,
|
|
45
44
|
});
|
|
46
45
|
}
|
|
47
46
|
}
|