@reporting-bi/cli 0.1.10 → 0.1.11
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 +88 -30
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4776,9 +4776,9 @@ var require_keyword = __commonJS({
|
|
|
4776
4776
|
if (Array.isArray(def2.keyword) ? !def2.keyword.includes(keyword) : def2.keyword !== keyword) {
|
|
4777
4777
|
throw new Error("ajv implementation error");
|
|
4778
4778
|
}
|
|
4779
|
-
const
|
|
4780
|
-
if (
|
|
4781
|
-
throw new Error(`parent schema must have dependencies of ${keyword}: ${
|
|
4779
|
+
const deps2 = def2.dependencies;
|
|
4780
|
+
if (deps2 === null || deps2 === void 0 ? void 0 : deps2.some((kwd) => !Object.prototype.hasOwnProperty.call(schema, kwd))) {
|
|
4781
|
+
throw new Error(`parent schema must have dependencies of ${keyword}: ${deps2.join(",")}`);
|
|
4782
4782
|
}
|
|
4783
4783
|
if (def2.validateSchema) {
|
|
4784
4784
|
const valid = def2.validateSchema(schema[keyword]);
|
|
@@ -8198,14 +8198,14 @@ var require_dependencies = __commonJS({
|
|
|
8198
8198
|
var util_1 = require_util();
|
|
8199
8199
|
var code_1 = require_code2();
|
|
8200
8200
|
exports2.error = {
|
|
8201
|
-
message: ({ params: { property, depsCount, deps } }) => {
|
|
8201
|
+
message: ({ params: { property, depsCount, deps: deps2 } }) => {
|
|
8202
8202
|
const property_ies = depsCount === 1 ? "property" : "properties";
|
|
8203
|
-
return (0, codegen_1.str)`must have ${property_ies} ${
|
|
8203
|
+
return (0, codegen_1.str)`must have ${property_ies} ${deps2} when property ${property} is present`;
|
|
8204
8204
|
},
|
|
8205
|
-
params: ({ params: { property, depsCount, deps, missingProperty } }) => (0, codegen_1._)`{property: ${property},
|
|
8205
|
+
params: ({ params: { property, depsCount, deps: deps2, missingProperty } }) => (0, codegen_1._)`{property: ${property},
|
|
8206
8206
|
missingProperty: ${missingProperty},
|
|
8207
8207
|
depsCount: ${depsCount},
|
|
8208
|
-
deps: ${
|
|
8208
|
+
deps: ${deps2}}`
|
|
8209
8209
|
// TODO change to reference
|
|
8210
8210
|
};
|
|
8211
8211
|
var def2 = {
|
|
@@ -8225,8 +8225,8 @@ var require_dependencies = __commonJS({
|
|
|
8225
8225
|
for (const key in schema) {
|
|
8226
8226
|
if (key === "__proto__")
|
|
8227
8227
|
continue;
|
|
8228
|
-
const
|
|
8229
|
-
|
|
8228
|
+
const deps2 = Array.isArray(schema[key]) ? propertyDeps : schemaDeps;
|
|
8229
|
+
deps2[key] = schema[key];
|
|
8230
8230
|
}
|
|
8231
8231
|
return [propertyDeps, schemaDeps];
|
|
8232
8232
|
}
|
|
@@ -8236,23 +8236,23 @@ var require_dependencies = __commonJS({
|
|
|
8236
8236
|
return;
|
|
8237
8237
|
const missing = gen.let("missing");
|
|
8238
8238
|
for (const prop in propertyDeps) {
|
|
8239
|
-
const
|
|
8240
|
-
if (
|
|
8239
|
+
const deps2 = propertyDeps[prop];
|
|
8240
|
+
if (deps2.length === 0)
|
|
8241
8241
|
continue;
|
|
8242
8242
|
const hasProperty = (0, code_1.propertyInData)(gen, data, prop, it.opts.ownProperties);
|
|
8243
8243
|
cxt.setParams({
|
|
8244
8244
|
property: prop,
|
|
8245
|
-
depsCount:
|
|
8246
|
-
deps:
|
|
8245
|
+
depsCount: deps2.length,
|
|
8246
|
+
deps: deps2.join(", ")
|
|
8247
8247
|
});
|
|
8248
8248
|
if (it.allErrors) {
|
|
8249
8249
|
gen.if(hasProperty, () => {
|
|
8250
|
-
for (const depProp of
|
|
8250
|
+
for (const depProp of deps2) {
|
|
8251
8251
|
(0, code_1.checkReportMissingProp)(cxt, depProp);
|
|
8252
8252
|
}
|
|
8253
8253
|
});
|
|
8254
8254
|
} else {
|
|
8255
|
-
gen.if((0, codegen_1._)`${hasProperty} && (${(0, code_1.checkMissingProp)(cxt,
|
|
8255
|
+
gen.if((0, codegen_1._)`${hasProperty} && (${(0, code_1.checkMissingProp)(cxt, deps2, missing)})`);
|
|
8256
8256
|
(0, code_1.reportMissingProp)(cxt, missing);
|
|
8257
8257
|
gen.else();
|
|
8258
8258
|
}
|
|
@@ -12607,18 +12607,24 @@ async function content3(id, flags) {
|
|
|
12607
12607
|
const text2 = await service.get(endpoint, void 0, { parseResponse: false });
|
|
12608
12608
|
process.stdout.write(text2 || "");
|
|
12609
12609
|
}
|
|
12610
|
+
async function refreshMetaForProject(service, flags, idProject) {
|
|
12611
|
+
if (!idProject) return;
|
|
12612
|
+
const root = findProjectRoot(flags.dir || ".");
|
|
12613
|
+
if (!root || readConfig(root)?.type !== "ext") return;
|
|
12614
|
+
try {
|
|
12615
|
+
const project = await service.get(`projects/${idProject}`);
|
|
12616
|
+
if (!project?.name) return;
|
|
12617
|
+
await refreshProjectMeta(service, root, project);
|
|
12618
|
+
console.error(`Updated .rpbi/projects/${project.name}.yaml`);
|
|
12619
|
+
} catch {
|
|
12620
|
+
}
|
|
12621
|
+
}
|
|
12610
12622
|
async function params2(id, flags) {
|
|
12611
12623
|
const service = await createService("extensions", { cwd: flags.dir || "." });
|
|
12612
12624
|
const refreshMeta = async () => {
|
|
12613
|
-
const root = findProjectRoot(flags.dir || ".");
|
|
12614
|
-
if (!root || readConfig(root)?.type !== "ext") return;
|
|
12615
12625
|
try {
|
|
12616
12626
|
const query = await service.get(`queries/${id}`, { fields: ["id_custom_page"] });
|
|
12617
|
-
|
|
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`);
|
|
12627
|
+
await refreshMetaForProject(service, flags, query?.id_custom_page);
|
|
12622
12628
|
} catch {
|
|
12623
12629
|
}
|
|
12624
12630
|
};
|
|
@@ -12637,6 +12643,53 @@ async function params2(id, flags) {
|
|
|
12637
12643
|
output(result || [], flags);
|
|
12638
12644
|
}
|
|
12639
12645
|
}
|
|
12646
|
+
var DEFAULT_DEP_FIELDS = ["idz", "id_custom_page", "id_custom_resource", "resource_name", "id_thread", "thread_name"];
|
|
12647
|
+
async function deps(flags) {
|
|
12648
|
+
const service = await createService("extensions", { cwd: flags.dir || "." });
|
|
12649
|
+
if (flags.add) {
|
|
12650
|
+
if (!flags.query && !flags.resource) {
|
|
12651
|
+
console.error("Usage: rpbi ext deps --query <id> --add <resource_id> | --resource <id> --add <query_id>");
|
|
12652
|
+
process.exit(1);
|
|
12653
|
+
}
|
|
12654
|
+
const idThread = flags.query ? parseInt(flags.query) : parseInt(flags.add);
|
|
12655
|
+
const idResource = flags.resource ? parseInt(flags.resource) : parseInt(flags.add);
|
|
12656
|
+
const created = await service.post("queryDependencies", {
|
|
12657
|
+
id_thread: idThread,
|
|
12658
|
+
id_custom_resource: idResource
|
|
12659
|
+
});
|
|
12660
|
+
try {
|
|
12661
|
+
const query = await service.get(`queries/${idThread}`, { fields: ["id_custom_page"] });
|
|
12662
|
+
await refreshMetaForProject(service, flags, query?.id_custom_page);
|
|
12663
|
+
} catch {
|
|
12664
|
+
}
|
|
12665
|
+
output(created, flags);
|
|
12666
|
+
} else if (flags.remove) {
|
|
12667
|
+
let idProject;
|
|
12668
|
+
try {
|
|
12669
|
+
const rows = await service.get("queryDependencies", { where: { idz: parseInt(flags.remove) } });
|
|
12670
|
+
idProject = rows?.[0]?.id_custom_page;
|
|
12671
|
+
} catch {
|
|
12672
|
+
}
|
|
12673
|
+
await service.delete(`queryDependencies/${flags.remove}`);
|
|
12674
|
+
await refreshMetaForProject(service, flags, idProject);
|
|
12675
|
+
console.log(`Dependency ${flags.remove} deleted.`);
|
|
12676
|
+
} else {
|
|
12677
|
+
let where = null;
|
|
12678
|
+
if (flags.query) where = { id_thread: parseInt(flags.query) };
|
|
12679
|
+
else if (flags.resource) where = { id_custom_resource: parseInt(flags.resource) };
|
|
12680
|
+
else if (flags.project) where = { id_custom_page: parseInt(flags.project) };
|
|
12681
|
+
if (!where) {
|
|
12682
|
+
console.error("Usage: rpbi ext deps --project <id> | --query <id> | --resource <id> [--add <id>] [--remove <idz>]");
|
|
12683
|
+
process.exit(1);
|
|
12684
|
+
}
|
|
12685
|
+
const result = await service.get("queryDependencies", {
|
|
12686
|
+
...getListParams(flags, DEFAULT_DEP_FIELDS),
|
|
12687
|
+
where,
|
|
12688
|
+
order: [["resource_name", "asc"], ["thread_name", "asc"]]
|
|
12689
|
+
});
|
|
12690
|
+
output(result || [], flags);
|
|
12691
|
+
}
|
|
12692
|
+
}
|
|
12640
12693
|
async function exec4(id, flags) {
|
|
12641
12694
|
const service = await createService("extensions", { cwd: flags.dir || "." });
|
|
12642
12695
|
let body = void 0;
|
|
@@ -12692,6 +12745,8 @@ async function ext(args) {
|
|
|
12692
12745
|
process.exit(1);
|
|
12693
12746
|
}
|
|
12694
12747
|
return params2(rest[0], flags);
|
|
12748
|
+
case "deps":
|
|
12749
|
+
return deps(flags);
|
|
12695
12750
|
case "pull":
|
|
12696
12751
|
return pull4(flags);
|
|
12697
12752
|
case "push":
|
|
@@ -12701,7 +12756,7 @@ async function ext(args) {
|
|
|
12701
12756
|
case "watch":
|
|
12702
12757
|
return watch6(flags);
|
|
12703
12758
|
default:
|
|
12704
|
-
console.log("Usage: rpbi ext <projects|resources|queries|content|exec|params|pull|push|status|watch> [options]");
|
|
12759
|
+
console.log("Usage: rpbi ext <projects|resources|queries|content|exec|params|deps|pull|push|status|watch> [options]");
|
|
12705
12760
|
break;
|
|
12706
12761
|
}
|
|
12707
12762
|
}
|
|
@@ -36230,7 +36285,7 @@ function text(data) {
|
|
|
36230
36285
|
async function mcp() {
|
|
36231
36286
|
const server = new McpServer({
|
|
36232
36287
|
name: "reporting-bi",
|
|
36233
|
-
version: "0.1.
|
|
36288
|
+
version: "0.1.11"
|
|
36234
36289
|
});
|
|
36235
36290
|
server.tool(
|
|
36236
36291
|
"status",
|
|
@@ -36776,8 +36831,8 @@ async function checkForUpdate() {
|
|
|
36776
36831
|
saveUpdateCheck({ lastCheck: now });
|
|
36777
36832
|
const latest = await fetchLatestVersion();
|
|
36778
36833
|
if (!latest) return;
|
|
36779
|
-
if (!isNewer(latest, "0.1.
|
|
36780
|
-
console.log(`\x1B[33mUpdating ${PACKAGE_NAME} ${"0.1.
|
|
36834
|
+
if (!isNewer(latest, "0.1.11")) return;
|
|
36835
|
+
console.log(`\x1B[33mUpdating ${PACKAGE_NAME} ${"0.1.11"} \u2192 ${latest}...\x1B[0m`);
|
|
36781
36836
|
(0, import_node_child_process3.execSync)(npmInstallCmd(latest), { stdio: "inherit" });
|
|
36782
36837
|
console.log(`\x1B[32mUpdated to ${latest}.\x1B[0m`);
|
|
36783
36838
|
} catch {
|
|
@@ -36789,11 +36844,11 @@ async function forceUpdate() {
|
|
|
36789
36844
|
console.error("Could not fetch latest version from npm.");
|
|
36790
36845
|
process.exit(1);
|
|
36791
36846
|
}
|
|
36792
|
-
if (!isNewer(latest, "0.1.
|
|
36793
|
-
console.log(`Already up to date (${"0.1.
|
|
36847
|
+
if (!isNewer(latest, "0.1.11")) {
|
|
36848
|
+
console.log(`Already up to date (${"0.1.11"}).`);
|
|
36794
36849
|
return;
|
|
36795
36850
|
}
|
|
36796
|
-
console.log(`Updating ${PACKAGE_NAME} ${"0.1.
|
|
36851
|
+
console.log(`Updating ${PACKAGE_NAME} ${"0.1.11"} \u2192 ${latest}...`);
|
|
36797
36852
|
(0, import_node_child_process3.execSync)(npmInstallCmd(latest), { stdio: "inherit" });
|
|
36798
36853
|
console.log(`\x1B[32mUpdated to ${latest}.\x1B[0m`);
|
|
36799
36854
|
saveUpdateCheck({ lastCheck: Date.now() });
|
|
@@ -36847,6 +36902,9 @@ Extensions (requires the "custom.define" right):
|
|
|
36847
36902
|
ext content <id> [--query] Get resource content (--query for query SQL)
|
|
36848
36903
|
ext exec <query_id> [--sql "..."|--file f] Execute query (optionally with custom SQL)
|
|
36849
36904
|
ext params <query_id> [--save <json>|--delete <idz>] List, save or delete query parameters
|
|
36905
|
+
ext deps --project <id>|--query <id>|--resource <id> List SQL dependencies (resource \u2194 query links)
|
|
36906
|
+
ext deps --query <id> --add <resource_id> Link a query to a resource (or --resource <id> --add <query_id>)
|
|
36907
|
+
ext deps --remove <idz> Unlink a dependency
|
|
36850
36908
|
ext pull [--dir <path>] Pull all projects (resources, queries & project metadata) to local files
|
|
36851
36909
|
ext push [files...] [--dir <path>] [--force] Push modified/new files back to server
|
|
36852
36910
|
ext status [--dir <path>] [--remote] [--json] Show local changes (--remote compares with server)
|
|
@@ -36967,7 +37025,7 @@ Examples:
|
|
|
36967
37025
|
(async () => {
|
|
36968
37026
|
const [command, ...args] = process.argv.slice(2);
|
|
36969
37027
|
if (command === "--version" || command === "-v") {
|
|
36970
|
-
console.log("0.1.
|
|
37028
|
+
console.log("0.1.11");
|
|
36971
37029
|
return;
|
|
36972
37030
|
}
|
|
36973
37031
|
await checkForUpdate();
|