@reporting-bi/cli 0.1.9 → 0.1.10
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/dist/index.js +99 -38
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -10551,6 +10551,35 @@ function writeFileSync4(filePath, content4) {
|
|
|
10551
10551
|
function isInternalPath(relPath) {
|
|
10552
10552
|
return relPath === RPBI_DIR || relPath.startsWith(`${RPBI_DIR}/`);
|
|
10553
10553
|
}
|
|
10554
|
+
function optimizeForLlm(data) {
|
|
10555
|
+
if (data === null || data === void 0) return void 0;
|
|
10556
|
+
if (Array.isArray(data)) {
|
|
10557
|
+
const result = data.map((item) => optimizeForLlm(item)).filter((item) => item !== void 0);
|
|
10558
|
+
return result.length > 0 ? result : void 0;
|
|
10559
|
+
}
|
|
10560
|
+
if (typeof data === "object") {
|
|
10561
|
+
const result = {};
|
|
10562
|
+
let hasKeys = false;
|
|
10563
|
+
for (const [key, value] of Object.entries(data)) {
|
|
10564
|
+
const optimized = optimizeForLlm(value);
|
|
10565
|
+
if (optimized !== void 0) {
|
|
10566
|
+
result[key] = optimized;
|
|
10567
|
+
hasKeys = true;
|
|
10568
|
+
}
|
|
10569
|
+
}
|
|
10570
|
+
return hasKeys ? result : void 0;
|
|
10571
|
+
}
|
|
10572
|
+
return data;
|
|
10573
|
+
}
|
|
10574
|
+
function stripFields(obj, excludeFields) {
|
|
10575
|
+
const result = {};
|
|
10576
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
10577
|
+
if (!excludeFields.includes(key)) {
|
|
10578
|
+
result[key] = value;
|
|
10579
|
+
}
|
|
10580
|
+
}
|
|
10581
|
+
return result;
|
|
10582
|
+
}
|
|
10554
10583
|
function isNestedWorkspace(dir) {
|
|
10555
10584
|
return fs4.existsSync(path3.join(dir, RPBI_DIR, CONFIG_FILE));
|
|
10556
10585
|
}
|
|
@@ -11261,26 +11290,6 @@ var CONTEXT_SCHEMA_DIRS = {
|
|
|
11261
11290
|
"schema/db_super/procedures": { db: "db_super", objectType: "procedures" },
|
|
11262
11291
|
"schema/db_super/functions": { db: "db_super", objectType: "functions" }
|
|
11263
11292
|
};
|
|
11264
|
-
function optimizeForLlm(data) {
|
|
11265
|
-
if (data === null || data === void 0) return void 0;
|
|
11266
|
-
if (Array.isArray(data)) {
|
|
11267
|
-
const result = data.map((item) => optimizeForLlm(item)).filter((item) => item !== void 0);
|
|
11268
|
-
return result.length > 0 ? result : void 0;
|
|
11269
|
-
}
|
|
11270
|
-
if (typeof data === "object") {
|
|
11271
|
-
const result = {};
|
|
11272
|
-
let hasKeys = false;
|
|
11273
|
-
for (const [key, value] of Object.entries(data)) {
|
|
11274
|
-
const optimized = optimizeForLlm(value);
|
|
11275
|
-
if (optimized !== void 0) {
|
|
11276
|
-
result[key] = optimized;
|
|
11277
|
-
hasKeys = true;
|
|
11278
|
-
}
|
|
11279
|
-
}
|
|
11280
|
-
return hasKeys ? result : void 0;
|
|
11281
|
-
}
|
|
11282
|
-
return data;
|
|
11283
|
-
}
|
|
11284
11293
|
function getFilePath(description, extension = ".sql") {
|
|
11285
11294
|
const parts = description.split("/");
|
|
11286
11295
|
const name = parts.pop();
|
|
@@ -11309,15 +11318,6 @@ function threadToMetaPath(thread) {
|
|
|
11309
11318
|
const segments = getFilePath(thread.description || "", ".yaml");
|
|
11310
11319
|
return [".rpbi", "threads", typeToDirName(thread.type), ...segments].join("/");
|
|
11311
11320
|
}
|
|
11312
|
-
function stripFields(obj, excludeFields) {
|
|
11313
|
-
const result = {};
|
|
11314
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
11315
|
-
if (!excludeFields.includes(key)) {
|
|
11316
|
-
result[key] = value;
|
|
11317
|
-
}
|
|
11318
|
-
}
|
|
11319
|
-
return result;
|
|
11320
|
-
}
|
|
11321
11321
|
async function pull2(flags) {
|
|
11322
11322
|
const dir = path5.resolve(flags.dir || ".");
|
|
11323
11323
|
const conn = getActiveConnection(dir);
|
|
@@ -12199,7 +12199,9 @@ var path7 = __toESM(require("node:path"));
|
|
|
12199
12199
|
var QUERIES_DIR = "queries";
|
|
12200
12200
|
var RESOURCE_FIELDS = ["id_custom_resource", "id_custom_page", "name", "date_created"];
|
|
12201
12201
|
var QUERY_FIELDS = ["id_thread", "id_custom_page", "description", "type", "date_created"];
|
|
12202
|
-
var PROJECT_FIELDS = ["id_custom_page", "name"];
|
|
12202
|
+
var PROJECT_FIELDS = ["id_custom_page", "name", "description", "version"];
|
|
12203
|
+
var META_EXCLUDE_FIELDS = ["accounting", "id_custom_page", "idz", "validate_flag", "date_created", "who_created", "date_deleted", "who_deleted"];
|
|
12204
|
+
var PARAM_META_EXCLUDE_FIELDS = [...META_EXCLUDE_FIELDS, "id_thread", "content"];
|
|
12203
12205
|
function resourceToRelPath(projectName, resource) {
|
|
12204
12206
|
return `${projectName}/${resource.name}`;
|
|
12205
12207
|
}
|
|
@@ -12216,6 +12218,45 @@ function splitProjectPath(relPath) {
|
|
|
12216
12218
|
async function fetchProjects(service) {
|
|
12217
12219
|
return await service.get("projects", { fields: PROJECT_FIELDS }) || [];
|
|
12218
12220
|
}
|
|
12221
|
+
async function refreshProjectMeta(service, dir, project, queries2) {
|
|
12222
|
+
if (!project.id_custom_page || !project.name) return;
|
|
12223
|
+
const id = project.id_custom_page;
|
|
12224
|
+
try {
|
|
12225
|
+
if (!queries2) {
|
|
12226
|
+
queries2 = await service.get("queries", { fields: QUERY_FIELDS, where: { id_custom_page: id } }) || [];
|
|
12227
|
+
}
|
|
12228
|
+
const parameters = await service.get(`projects/${id}/parameters`) || [];
|
|
12229
|
+
const externalResources = await service.get(`externalResources/${id}`) || [];
|
|
12230
|
+
const dependencies = await service.get("queryDependencies", { where: { id_custom_page: id } }) || [];
|
|
12231
|
+
const paramsByThread = /* @__PURE__ */ new Map();
|
|
12232
|
+
for (const param of parameters) {
|
|
12233
|
+
if (!param.id_thread) continue;
|
|
12234
|
+
const list8 = paramsByThread.get(param.id_thread) || [];
|
|
12235
|
+
list8.push(stripFields(param, PARAM_META_EXCLUDE_FIELDS));
|
|
12236
|
+
paramsByThread.set(param.id_thread, list8);
|
|
12237
|
+
}
|
|
12238
|
+
const meta3 = {
|
|
12239
|
+
id_custom_page: id,
|
|
12240
|
+
name: project.name,
|
|
12241
|
+
description: project.description,
|
|
12242
|
+
version: project.version,
|
|
12243
|
+
queries: queries2.filter((q) => q.id_thread).map((q) => ({
|
|
12244
|
+
id_thread: q.id_thread,
|
|
12245
|
+
description: q.description,
|
|
12246
|
+
type: q.type,
|
|
12247
|
+
file: queryToRelPath(project.name, q),
|
|
12248
|
+
parameters: paramsByThread.get(q.id_thread)
|
|
12249
|
+
})),
|
|
12250
|
+
external_resources: externalResources.map((e) => stripFields(e, META_EXCLUDE_FIELDS)),
|
|
12251
|
+
dependencies: dependencies.map((d) => stripFields(d, META_EXCLUDE_FIELDS))
|
|
12252
|
+
};
|
|
12253
|
+
const optimized = optimizeForLlm(meta3);
|
|
12254
|
+
if (!optimized) return;
|
|
12255
|
+
writeFileSync4(path7.join(dir, ".rpbi", "projects", `${project.name}.yaml`), toYaml(optimized) + "\n");
|
|
12256
|
+
} catch (err) {
|
|
12257
|
+
console.error(` Failed to pull metadata for ${project.name}: ${err instanceof Error ? err.message : err}`);
|
|
12258
|
+
}
|
|
12259
|
+
}
|
|
12219
12260
|
function buildProjectMap(projects2) {
|
|
12220
12261
|
const map2 = /* @__PURE__ */ new Map();
|
|
12221
12262
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -12308,6 +12349,11 @@ async function pull4(flags) {
|
|
|
12308
12349
|
}
|
|
12309
12350
|
}
|
|
12310
12351
|
console.log(` Pulled ${pulledQueries} queries`);
|
|
12352
|
+
console.log("Pulling project metadata...");
|
|
12353
|
+
for (const project of projects2) {
|
|
12354
|
+
if (!project.id_custom_page || !project.name) continue;
|
|
12355
|
+
await refreshProjectMeta(service, dir, project, queries2.filter((q) => q.id_custom_page === project.id_custom_page));
|
|
12356
|
+
}
|
|
12311
12357
|
writeConfig(dir, {
|
|
12312
12358
|
domain: conn.domain,
|
|
12313
12359
|
accounting: conn.tokens.accounting,
|
|
@@ -12563,13 +12609,28 @@ async function content3(id, flags) {
|
|
|
12563
12609
|
}
|
|
12564
12610
|
async function params2(id, flags) {
|
|
12565
12611
|
const service = await createService("extensions", { cwd: flags.dir || "." });
|
|
12612
|
+
const refreshMeta = async () => {
|
|
12613
|
+
const root = findProjectRoot(flags.dir || ".");
|
|
12614
|
+
if (!root || readConfig(root)?.type !== "ext") return;
|
|
12615
|
+
try {
|
|
12616
|
+
const query = await service.get(`queries/${id}`, { fields: ["id_custom_page"] });
|
|
12617
|
+
if (!query?.id_custom_page) return;
|
|
12618
|
+
const project = await service.get(`projects/${query.id_custom_page}`);
|
|
12619
|
+
if (!project?.name) return;
|
|
12620
|
+
await refreshProjectMeta(service, root, project);
|
|
12621
|
+
console.error(`Updated .rpbi/projects/${project.name}.yaml`);
|
|
12622
|
+
} catch {
|
|
12623
|
+
}
|
|
12624
|
+
};
|
|
12566
12625
|
if (flags.save) {
|
|
12567
12626
|
const data = JSON.parse(fs12.readFileSync(flags.save, "utf-8"));
|
|
12568
12627
|
data.id_thread ??= parseInt(id);
|
|
12569
12628
|
const result = await service.post("parameters", data);
|
|
12629
|
+
await refreshMeta();
|
|
12570
12630
|
output(result, flags);
|
|
12571
12631
|
} else if (flags.delete) {
|
|
12572
12632
|
await service.delete(`parameters/${flags.delete}`);
|
|
12633
|
+
await refreshMeta();
|
|
12573
12634
|
console.log(`Parameter ${flags.delete} deleted.`);
|
|
12574
12635
|
} else {
|
|
12575
12636
|
const result = await service.get(`queries/${id}/parameters`);
|
|
@@ -36169,7 +36230,7 @@ function text(data) {
|
|
|
36169
36230
|
async function mcp() {
|
|
36170
36231
|
const server = new McpServer({
|
|
36171
36232
|
name: "reporting-bi",
|
|
36172
|
-
version: "0.1.
|
|
36233
|
+
version: "0.1.10"
|
|
36173
36234
|
});
|
|
36174
36235
|
server.tool(
|
|
36175
36236
|
"status",
|
|
@@ -36715,8 +36776,8 @@ async function checkForUpdate() {
|
|
|
36715
36776
|
saveUpdateCheck({ lastCheck: now });
|
|
36716
36777
|
const latest = await fetchLatestVersion();
|
|
36717
36778
|
if (!latest) return;
|
|
36718
|
-
if (!isNewer(latest, "0.1.
|
|
36719
|
-
console.log(`\x1B[33mUpdating ${PACKAGE_NAME} ${"0.1.
|
|
36779
|
+
if (!isNewer(latest, "0.1.10")) return;
|
|
36780
|
+
console.log(`\x1B[33mUpdating ${PACKAGE_NAME} ${"0.1.10"} \u2192 ${latest}...\x1B[0m`);
|
|
36720
36781
|
(0, import_node_child_process3.execSync)(npmInstallCmd(latest), { stdio: "inherit" });
|
|
36721
36782
|
console.log(`\x1B[32mUpdated to ${latest}.\x1B[0m`);
|
|
36722
36783
|
} catch {
|
|
@@ -36728,11 +36789,11 @@ async function forceUpdate() {
|
|
|
36728
36789
|
console.error("Could not fetch latest version from npm.");
|
|
36729
36790
|
process.exit(1);
|
|
36730
36791
|
}
|
|
36731
|
-
if (!isNewer(latest, "0.1.
|
|
36732
|
-
console.log(`Already up to date (${"0.1.
|
|
36792
|
+
if (!isNewer(latest, "0.1.10")) {
|
|
36793
|
+
console.log(`Already up to date (${"0.1.10"}).`);
|
|
36733
36794
|
return;
|
|
36734
36795
|
}
|
|
36735
|
-
console.log(`Updating ${PACKAGE_NAME} ${"0.1.
|
|
36796
|
+
console.log(`Updating ${PACKAGE_NAME} ${"0.1.10"} \u2192 ${latest}...`);
|
|
36736
36797
|
(0, import_node_child_process3.execSync)(npmInstallCmd(latest), { stdio: "inherit" });
|
|
36737
36798
|
console.log(`\x1B[32mUpdated to ${latest}.\x1B[0m`);
|
|
36738
36799
|
saveUpdateCheck({ lastCheck: Date.now() });
|
|
@@ -36786,7 +36847,7 @@ Extensions (requires the "custom.define" right):
|
|
|
36786
36847
|
ext content <id> [--query] Get resource content (--query for query SQL)
|
|
36787
36848
|
ext exec <query_id> [--sql "..."|--file f] Execute query (optionally with custom SQL)
|
|
36788
36849
|
ext params <query_id> [--save <json>|--delete <idz>] List, save or delete query parameters
|
|
36789
|
-
ext pull [--dir <path>] Pull all projects (resources &
|
|
36850
|
+
ext pull [--dir <path>] Pull all projects (resources, queries & project metadata) to local files
|
|
36790
36851
|
ext push [files...] [--dir <path>] [--force] Push modified/new files back to server
|
|
36791
36852
|
ext status [--dir <path>] [--remote] [--json] Show local changes (--remote compares with server)
|
|
36792
36853
|
ext watch [--dir <path>] [--debounce <ms>] Watch for file changes and auto-push
|
|
@@ -36906,7 +36967,7 @@ Examples:
|
|
|
36906
36967
|
(async () => {
|
|
36907
36968
|
const [command, ...args] = process.argv.slice(2);
|
|
36908
36969
|
if (command === "--version" || command === "-v") {
|
|
36909
|
-
console.log("0.1.
|
|
36970
|
+
console.log("0.1.10");
|
|
36910
36971
|
return;
|
|
36911
36972
|
}
|
|
36912
36973
|
await checkForUpdate();
|