@reporting-bi/cli 0.1.1 → 0.1.3
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 +955 -378
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2032,9 +2032,9 @@ var require_stringify = __commonJS({
|
|
|
2032
2032
|
}
|
|
2033
2033
|
};
|
|
2034
2034
|
var isArray = Array.isArray;
|
|
2035
|
-
var
|
|
2035
|
+
var push3 = Array.prototype.push;
|
|
2036
2036
|
var pushToArray = function(arr, valueOrArray) {
|
|
2037
|
-
|
|
2037
|
+
push3.apply(arr, isArray(valueOrArray) ? valueOrArray : [valueOrArray]);
|
|
2038
2038
|
};
|
|
2039
2039
|
var toISO = Date.prototype.toISOString;
|
|
2040
2040
|
var defaultFormat = formats["default"];
|
|
@@ -2602,7 +2602,7 @@ var require_service = __commonJS({
|
|
|
2602
2602
|
return mod && mod.__esModule ? mod : { "default": mod };
|
|
2603
2603
|
};
|
|
2604
2604
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
2605
|
-
exports2.Service = exports2.ServiceAuthException = exports2.ServiceException = exports2.serializeRequestParams = void 0;
|
|
2605
|
+
exports2.Service = exports2.ServiceAuthException = exports2.ServiceEvent = exports2.ServiceException = exports2.serializeRequestParams = void 0;
|
|
2606
2606
|
var qs_1 = __importDefault(require_lib());
|
|
2607
2607
|
var cache_1 = require_cache();
|
|
2608
2608
|
function isObject2(value) {
|
|
@@ -2624,16 +2624,23 @@ var require_service = __commonJS({
|
|
|
2624
2624
|
}
|
|
2625
2625
|
exports2.serializeRequestParams = serializeRequestParams;
|
|
2626
2626
|
var ServiceException = class extends Error {
|
|
2627
|
-
constructor(
|
|
2628
|
-
super(data
|
|
2629
|
-
this
|
|
2627
|
+
constructor(args) {
|
|
2628
|
+
super(args?.data?.message || "Unknown error");
|
|
2629
|
+
Object.assign(this, args);
|
|
2630
2630
|
}
|
|
2631
2631
|
};
|
|
2632
2632
|
exports2.ServiceException = ServiceException;
|
|
2633
|
+
var ServiceEvent2 = class extends Event {
|
|
2634
|
+
constructor(name, args) {
|
|
2635
|
+
super(name);
|
|
2636
|
+
Object.assign(this, args);
|
|
2637
|
+
}
|
|
2638
|
+
};
|
|
2639
|
+
exports2.ServiceEvent = ServiceEvent2;
|
|
2633
2640
|
var ServiceAuthException = class extends Error {
|
|
2634
2641
|
};
|
|
2635
2642
|
exports2.ServiceAuthException = ServiceAuthException;
|
|
2636
|
-
var Service2 = class {
|
|
2643
|
+
var Service2 = class extends EventTarget {
|
|
2637
2644
|
get a() {
|
|
2638
2645
|
return this.accountingProvider?.a;
|
|
2639
2646
|
}
|
|
@@ -2646,6 +2653,7 @@ var require_service = __commonJS({
|
|
|
2646
2653
|
return this._cache;
|
|
2647
2654
|
}
|
|
2648
2655
|
constructor(options) {
|
|
2656
|
+
super();
|
|
2649
2657
|
this.accountingProvider = null;
|
|
2650
2658
|
this.tokenProvider = null;
|
|
2651
2659
|
this._cache = null;
|
|
@@ -2654,7 +2662,7 @@ var require_service = __commonJS({
|
|
|
2654
2662
|
this.options.baseUrl = `https://${this.options.baseUrl}`;
|
|
2655
2663
|
}
|
|
2656
2664
|
}
|
|
2657
|
-
createUrl(
|
|
2665
|
+
createUrl(path7 = "", params) {
|
|
2658
2666
|
if (this.options.xdebugSession) {
|
|
2659
2667
|
params = params || {};
|
|
2660
2668
|
params.XDEBUG_SESSION = this.options.xdebugSession === true ? "1" : this.options.xdebugSession.toString();
|
|
@@ -2662,10 +2670,12 @@ var require_service = __commonJS({
|
|
|
2662
2670
|
if (this.options.params && Object.keys(this.options.params).length > 0) {
|
|
2663
2671
|
params = { ...this.options.params, ...params };
|
|
2664
2672
|
}
|
|
2665
|
-
|
|
2673
|
+
let queryString = params ? serializeRequestParams(params) : "";
|
|
2674
|
+
if (queryString)
|
|
2675
|
+
queryString = `?${queryString}`;
|
|
2666
2676
|
const a = params && params.accounting ? params.accounting.toString() : this.a ? this.a.toString() : null;
|
|
2667
|
-
|
|
2668
|
-
const parts = [this.options.baseUrl, a, this.options.name,
|
|
2677
|
+
path7 = path7.replace(/^\//, "");
|
|
2678
|
+
const parts = [this.options.baseUrl, a, this.options.name, path7];
|
|
2669
2679
|
return parts.filter((p) => p != null && p !== "").join("/") + queryString;
|
|
2670
2680
|
}
|
|
2671
2681
|
async createHeaders(headers) {
|
|
@@ -2691,7 +2701,7 @@ var require_service = __commonJS({
|
|
|
2691
2701
|
error48 = { status: response.status, message: "Unknown error", error: "unknown" };
|
|
2692
2702
|
}
|
|
2693
2703
|
if (this.options.throwExceptions) {
|
|
2694
|
-
throw new ServiceException(error48);
|
|
2704
|
+
throw new ServiceException({ data: error48, url: response.url });
|
|
2695
2705
|
}
|
|
2696
2706
|
}
|
|
2697
2707
|
async handleResponse(response, parse3) {
|
|
@@ -2706,28 +2716,32 @@ var require_service = __commonJS({
|
|
|
2706
2716
|
return await response.text();
|
|
2707
2717
|
}
|
|
2708
2718
|
}
|
|
2709
|
-
async getRaw(
|
|
2710
|
-
|
|
2719
|
+
async getRaw(path7, params, options) {
|
|
2720
|
+
const url2 = this.createUrl(path7, params);
|
|
2721
|
+
this.dispatchEvent(new ServiceEvent2("beforeRequest", { url: url2, params, options, method: "GET" }));
|
|
2722
|
+
return fetch(url2, {
|
|
2711
2723
|
headers: await this.createHeaders(options?.headers),
|
|
2712
2724
|
credentials: this.credentials
|
|
2713
2725
|
});
|
|
2714
2726
|
}
|
|
2715
|
-
async get(
|
|
2727
|
+
async get(path7, params, options) {
|
|
2716
2728
|
if (options?.cache) {
|
|
2717
|
-
const cachedData = this.cache.get({ path:
|
|
2729
|
+
const cachedData = this.cache.get({ path: path7, params });
|
|
2718
2730
|
if (cachedData)
|
|
2719
2731
|
return cachedData;
|
|
2720
2732
|
}
|
|
2721
|
-
const response = await this.getRaw(
|
|
2733
|
+
const response = await this.getRaw(path7, params, options);
|
|
2722
2734
|
const responseData = await this.handleResponse(response, options?.parseResponse);
|
|
2723
2735
|
if (options?.cache && responseData) {
|
|
2724
|
-
this.cache.set({ path:
|
|
2736
|
+
this.cache.set({ path: path7, params }, responseData);
|
|
2725
2737
|
}
|
|
2726
2738
|
return responseData;
|
|
2727
2739
|
}
|
|
2728
|
-
async postRaw(
|
|
2740
|
+
async postRaw(path7, data, params, options) {
|
|
2741
|
+
const url2 = this.createUrl(path7, params);
|
|
2742
|
+
this.dispatchEvent(new ServiceEvent2("beforeRequest", { url: url2, params, options, method: "POST" }));
|
|
2729
2743
|
const json3 = isObject2(data) || Array.isArray(data);
|
|
2730
|
-
return fetch(
|
|
2744
|
+
return fetch(url2, {
|
|
2731
2745
|
method: "POST",
|
|
2732
2746
|
body: json3 ? JSON.stringify(data) : data,
|
|
2733
2747
|
headers: await this.createHeaders({
|
|
@@ -2737,24 +2751,28 @@ var require_service = __commonJS({
|
|
|
2737
2751
|
credentials: this.credentials
|
|
2738
2752
|
});
|
|
2739
2753
|
}
|
|
2740
|
-
async post(
|
|
2741
|
-
const response = await this.postRaw(
|
|
2754
|
+
async post(path7, data, params, options) {
|
|
2755
|
+
const response = await this.postRaw(path7, data, params, options);
|
|
2742
2756
|
return this.handleResponse(response);
|
|
2743
2757
|
}
|
|
2744
|
-
async deleteRaw(
|
|
2745
|
-
|
|
2758
|
+
async deleteRaw(path7, params, options) {
|
|
2759
|
+
const url2 = this.createUrl(path7, params);
|
|
2760
|
+
this.dispatchEvent(new ServiceEvent2("beforeRequest", { url: url2, params, options, method: "DELETE" }));
|
|
2761
|
+
return fetch(url2, {
|
|
2746
2762
|
method: "DELETE",
|
|
2747
2763
|
headers: await this.createHeaders(options?.headers),
|
|
2748
2764
|
credentials: this.credentials
|
|
2749
2765
|
});
|
|
2750
2766
|
}
|
|
2751
|
-
async delete(
|
|
2752
|
-
const response = await this.deleteRaw(
|
|
2767
|
+
async delete(path7, params, options) {
|
|
2768
|
+
const response = await this.deleteRaw(path7, params, options);
|
|
2753
2769
|
return this.handleResponse(response);
|
|
2754
2770
|
}
|
|
2755
|
-
async putRaw(
|
|
2771
|
+
async putRaw(path7, data, params, options) {
|
|
2772
|
+
const url2 = this.createUrl(path7, params);
|
|
2773
|
+
this.dispatchEvent(new ServiceEvent2("beforeRequest", { url: url2, params, options, method: "PUT" }));
|
|
2756
2774
|
const json3 = isObject2(data) || Array.isArray(data);
|
|
2757
|
-
return fetch(
|
|
2775
|
+
return fetch(url2, {
|
|
2758
2776
|
method: "PUT",
|
|
2759
2777
|
body: json3 ? JSON.stringify(data) : data,
|
|
2760
2778
|
headers: await this.createHeaders({
|
|
@@ -2764,8 +2782,8 @@ var require_service = __commonJS({
|
|
|
2764
2782
|
credentials: this.credentials
|
|
2765
2783
|
});
|
|
2766
2784
|
}
|
|
2767
|
-
async put(
|
|
2768
|
-
const response = await this.putRaw(
|
|
2785
|
+
async put(path7, data, params, options) {
|
|
2786
|
+
const response = await this.putRaw(path7, data, params, options);
|
|
2769
2787
|
return this.handleResponse(response);
|
|
2770
2788
|
}
|
|
2771
2789
|
};
|
|
@@ -5752,7 +5770,7 @@ var require_compile = __commonJS({
|
|
|
5752
5770
|
const schOrFunc = root.refs[ref];
|
|
5753
5771
|
if (schOrFunc)
|
|
5754
5772
|
return schOrFunc;
|
|
5755
|
-
let _sch =
|
|
5773
|
+
let _sch = resolve5.call(this, root, ref);
|
|
5756
5774
|
if (_sch === void 0) {
|
|
5757
5775
|
const schema = (_a2 = root.localRefs) === null || _a2 === void 0 ? void 0 : _a2[ref];
|
|
5758
5776
|
const { schemaId } = this.opts;
|
|
@@ -5779,7 +5797,7 @@ var require_compile = __commonJS({
|
|
|
5779
5797
|
function sameSchemaEnv(s1, s2) {
|
|
5780
5798
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
5781
5799
|
}
|
|
5782
|
-
function
|
|
5800
|
+
function resolve5(root, ref) {
|
|
5783
5801
|
let sch;
|
|
5784
5802
|
while (typeof (sch = this.refs[ref]) == "string")
|
|
5785
5803
|
ref = sch;
|
|
@@ -5994,8 +6012,8 @@ var require_utils2 = __commonJS({
|
|
|
5994
6012
|
}
|
|
5995
6013
|
return ind;
|
|
5996
6014
|
}
|
|
5997
|
-
function removeDotSegments(
|
|
5998
|
-
let input =
|
|
6015
|
+
function removeDotSegments(path7) {
|
|
6016
|
+
let input = path7;
|
|
5999
6017
|
const output2 = [];
|
|
6000
6018
|
let nextSlash = -1;
|
|
6001
6019
|
let len = 0;
|
|
@@ -6194,8 +6212,8 @@ var require_schemes = __commonJS({
|
|
|
6194
6212
|
wsComponent.secure = void 0;
|
|
6195
6213
|
}
|
|
6196
6214
|
if (wsComponent.resourceName) {
|
|
6197
|
-
const [
|
|
6198
|
-
wsComponent.path =
|
|
6215
|
+
const [path7, query] = wsComponent.resourceName.split("?");
|
|
6216
|
+
wsComponent.path = path7 && path7 !== "/" ? path7 : void 0;
|
|
6199
6217
|
wsComponent.query = query;
|
|
6200
6218
|
wsComponent.resourceName = void 0;
|
|
6201
6219
|
}
|
|
@@ -6354,55 +6372,55 @@ var require_fast_uri = __commonJS({
|
|
|
6354
6372
|
}
|
|
6355
6373
|
return uri;
|
|
6356
6374
|
}
|
|
6357
|
-
function
|
|
6375
|
+
function resolve5(baseURI, relativeURI, options) {
|
|
6358
6376
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
6359
6377
|
const resolved = resolveComponent(parse3(baseURI, schemelessOptions), parse3(relativeURI, schemelessOptions), schemelessOptions, true);
|
|
6360
6378
|
schemelessOptions.skipEscape = true;
|
|
6361
6379
|
return serialize(resolved, schemelessOptions);
|
|
6362
6380
|
}
|
|
6363
|
-
function resolveComponent(base,
|
|
6381
|
+
function resolveComponent(base, relative4, options, skipNormalization) {
|
|
6364
6382
|
const target = {};
|
|
6365
6383
|
if (!skipNormalization) {
|
|
6366
6384
|
base = parse3(serialize(base, options), options);
|
|
6367
|
-
|
|
6385
|
+
relative4 = parse3(serialize(relative4, options), options);
|
|
6368
6386
|
}
|
|
6369
6387
|
options = options || {};
|
|
6370
|
-
if (!options.tolerant &&
|
|
6371
|
-
target.scheme =
|
|
6372
|
-
target.userinfo =
|
|
6373
|
-
target.host =
|
|
6374
|
-
target.port =
|
|
6375
|
-
target.path = removeDotSegments(
|
|
6376
|
-
target.query =
|
|
6388
|
+
if (!options.tolerant && relative4.scheme) {
|
|
6389
|
+
target.scheme = relative4.scheme;
|
|
6390
|
+
target.userinfo = relative4.userinfo;
|
|
6391
|
+
target.host = relative4.host;
|
|
6392
|
+
target.port = relative4.port;
|
|
6393
|
+
target.path = removeDotSegments(relative4.path || "");
|
|
6394
|
+
target.query = relative4.query;
|
|
6377
6395
|
} else {
|
|
6378
|
-
if (
|
|
6379
|
-
target.userinfo =
|
|
6380
|
-
target.host =
|
|
6381
|
-
target.port =
|
|
6382
|
-
target.path = removeDotSegments(
|
|
6383
|
-
target.query =
|
|
6396
|
+
if (relative4.userinfo !== void 0 || relative4.host !== void 0 || relative4.port !== void 0) {
|
|
6397
|
+
target.userinfo = relative4.userinfo;
|
|
6398
|
+
target.host = relative4.host;
|
|
6399
|
+
target.port = relative4.port;
|
|
6400
|
+
target.path = removeDotSegments(relative4.path || "");
|
|
6401
|
+
target.query = relative4.query;
|
|
6384
6402
|
} else {
|
|
6385
|
-
if (!
|
|
6403
|
+
if (!relative4.path) {
|
|
6386
6404
|
target.path = base.path;
|
|
6387
|
-
if (
|
|
6388
|
-
target.query =
|
|
6405
|
+
if (relative4.query !== void 0) {
|
|
6406
|
+
target.query = relative4.query;
|
|
6389
6407
|
} else {
|
|
6390
6408
|
target.query = base.query;
|
|
6391
6409
|
}
|
|
6392
6410
|
} else {
|
|
6393
|
-
if (
|
|
6394
|
-
target.path = removeDotSegments(
|
|
6411
|
+
if (relative4.path[0] === "/") {
|
|
6412
|
+
target.path = removeDotSegments(relative4.path);
|
|
6395
6413
|
} else {
|
|
6396
6414
|
if ((base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0) && !base.path) {
|
|
6397
|
-
target.path = "/" +
|
|
6415
|
+
target.path = "/" + relative4.path;
|
|
6398
6416
|
} else if (!base.path) {
|
|
6399
|
-
target.path =
|
|
6417
|
+
target.path = relative4.path;
|
|
6400
6418
|
} else {
|
|
6401
|
-
target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) +
|
|
6419
|
+
target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative4.path;
|
|
6402
6420
|
}
|
|
6403
6421
|
target.path = removeDotSegments(target.path);
|
|
6404
6422
|
}
|
|
6405
|
-
target.query =
|
|
6423
|
+
target.query = relative4.query;
|
|
6406
6424
|
}
|
|
6407
6425
|
target.userinfo = base.userinfo;
|
|
6408
6426
|
target.host = base.host;
|
|
@@ -6410,7 +6428,7 @@ var require_fast_uri = __commonJS({
|
|
|
6410
6428
|
}
|
|
6411
6429
|
target.scheme = base.scheme;
|
|
6412
6430
|
}
|
|
6413
|
-
target.fragment =
|
|
6431
|
+
target.fragment = relative4.fragment;
|
|
6414
6432
|
return target;
|
|
6415
6433
|
}
|
|
6416
6434
|
function equal(uriA, uriB, options) {
|
|
@@ -6581,7 +6599,7 @@ var require_fast_uri = __commonJS({
|
|
|
6581
6599
|
var fastUri = {
|
|
6582
6600
|
SCHEMES,
|
|
6583
6601
|
normalize,
|
|
6584
|
-
resolve:
|
|
6602
|
+
resolve: resolve5,
|
|
6585
6603
|
resolveComponent,
|
|
6586
6604
|
equal,
|
|
6587
6605
|
serialize,
|
|
@@ -9557,12 +9575,12 @@ var require_dist2 = __commonJS({
|
|
|
9557
9575
|
throw new Error(`Unknown format "${name}"`);
|
|
9558
9576
|
return f;
|
|
9559
9577
|
};
|
|
9560
|
-
function addFormats(ajv, list7,
|
|
9578
|
+
function addFormats(ajv, list7, fs10, exportName) {
|
|
9561
9579
|
var _a2;
|
|
9562
9580
|
var _b;
|
|
9563
9581
|
(_a2 = (_b = ajv.opts.code).formats) !== null && _a2 !== void 0 ? _a2 : _b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
|
|
9564
9582
|
for (const f of list7)
|
|
9565
|
-
ajv.addFormat(f,
|
|
9583
|
+
ajv.addFormat(f, fs10[f]);
|
|
9566
9584
|
}
|
|
9567
9585
|
module2.exports = exports2 = formatsPlugin;
|
|
9568
9586
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
@@ -9962,6 +9980,12 @@ async function createService(name, options) {
|
|
|
9962
9980
|
ap.a = accounting2;
|
|
9963
9981
|
service.accountingProvider = ap;
|
|
9964
9982
|
}
|
|
9983
|
+
if (process.argv.includes("--verbose")) {
|
|
9984
|
+
service.addEventListener("beforeRequest", (e) => {
|
|
9985
|
+
const ev = e;
|
|
9986
|
+
console.error(`${ev.method} ${decodeURIComponent(ev.url || "")}`);
|
|
9987
|
+
});
|
|
9988
|
+
}
|
|
9965
9989
|
return service;
|
|
9966
9990
|
}
|
|
9967
9991
|
function getFields(flags, defaults) {
|
|
@@ -10146,8 +10170,8 @@ var callback_default = `<!DOCTYPE html>
|
|
|
10146
10170
|
`;
|
|
10147
10171
|
|
|
10148
10172
|
// src/commands/login.ts
|
|
10149
|
-
function renderCallback(
|
|
10150
|
-
return callback_default.replace("{{status}}",
|
|
10173
|
+
function renderCallback(status4, title, message) {
|
|
10174
|
+
return callback_default.replace("{{status}}", status4).replace("{{title}}", title).replace("{{message}}", message);
|
|
10151
10175
|
}
|
|
10152
10176
|
function openBrowser(url2) {
|
|
10153
10177
|
const platform = process.platform;
|
|
@@ -10191,12 +10215,12 @@ async function login(args) {
|
|
|
10191
10215
|
}
|
|
10192
10216
|
}
|
|
10193
10217
|
function getAuthorizationCode(domain2) {
|
|
10194
|
-
return new Promise((
|
|
10218
|
+
return new Promise((resolve5) => {
|
|
10195
10219
|
let timeout;
|
|
10196
10220
|
const done = (result) => {
|
|
10197
10221
|
clearTimeout(timeout);
|
|
10198
10222
|
server.close();
|
|
10199
|
-
|
|
10223
|
+
resolve5(result);
|
|
10200
10224
|
};
|
|
10201
10225
|
const server = http.createServer((req, res) => {
|
|
10202
10226
|
const url2 = new URL(req.url || "", "http://localhost");
|
|
@@ -10331,7 +10355,579 @@ async function use(args) {
|
|
|
10331
10355
|
}
|
|
10332
10356
|
|
|
10333
10357
|
// src/commands/wiki.ts
|
|
10358
|
+
var fs6 = __toESM(require("node:fs"));
|
|
10359
|
+
|
|
10360
|
+
// src/commands/wiki-sync.ts
|
|
10361
|
+
var fs5 = __toESM(require("node:fs"));
|
|
10362
|
+
var path4 = __toESM(require("node:path"));
|
|
10363
|
+
|
|
10364
|
+
// src/manifest.ts
|
|
10334
10365
|
var fs3 = __toESM(require("node:fs"));
|
|
10366
|
+
var path2 = __toESM(require("node:path"));
|
|
10367
|
+
var crypto2 = __toESM(require("node:crypto"));
|
|
10368
|
+
var RPBI_DIR = ".rpbi";
|
|
10369
|
+
var CONFIG_FILE = "config.json";
|
|
10370
|
+
var INDEX_FILE = "index.json";
|
|
10371
|
+
function computeHash(content2) {
|
|
10372
|
+
return crypto2.createHash("sha256").update(content2, "utf-8").digest("hex");
|
|
10373
|
+
}
|
|
10374
|
+
function getConfigPath(dir) {
|
|
10375
|
+
return path2.join(dir, RPBI_DIR, CONFIG_FILE);
|
|
10376
|
+
}
|
|
10377
|
+
function getIndexPath(dir) {
|
|
10378
|
+
return path2.join(dir, RPBI_DIR, INDEX_FILE);
|
|
10379
|
+
}
|
|
10380
|
+
function readConfig(dir) {
|
|
10381
|
+
try {
|
|
10382
|
+
const data = fs3.readFileSync(getConfigPath(dir), "utf-8");
|
|
10383
|
+
return JSON.parse(data);
|
|
10384
|
+
} catch {
|
|
10385
|
+
return null;
|
|
10386
|
+
}
|
|
10387
|
+
}
|
|
10388
|
+
function writeConfig(dir, config2) {
|
|
10389
|
+
const rpbiDir = path2.join(dir, RPBI_DIR);
|
|
10390
|
+
fs3.mkdirSync(rpbiDir, { recursive: true });
|
|
10391
|
+
fs3.writeFileSync(
|
|
10392
|
+
path2.join(rpbiDir, CONFIG_FILE),
|
|
10393
|
+
JSON.stringify(config2, null, 2)
|
|
10394
|
+
);
|
|
10395
|
+
}
|
|
10396
|
+
function readIndex(dir) {
|
|
10397
|
+
try {
|
|
10398
|
+
const data = fs3.readFileSync(getIndexPath(dir), "utf-8");
|
|
10399
|
+
return JSON.parse(data);
|
|
10400
|
+
} catch {
|
|
10401
|
+
return [];
|
|
10402
|
+
}
|
|
10403
|
+
}
|
|
10404
|
+
function writeIndex(dir, index) {
|
|
10405
|
+
const rpbiDir = path2.join(dir, RPBI_DIR);
|
|
10406
|
+
fs3.mkdirSync(rpbiDir, { recursive: true });
|
|
10407
|
+
fs3.writeFileSync(
|
|
10408
|
+
path2.join(rpbiDir, INDEX_FILE),
|
|
10409
|
+
JSON.stringify(index, null, 2)
|
|
10410
|
+
);
|
|
10411
|
+
}
|
|
10412
|
+
function findProjectRoot(startDir) {
|
|
10413
|
+
let dir = path2.resolve(startDir);
|
|
10414
|
+
while (true) {
|
|
10415
|
+
if (fs3.existsSync(getConfigPath(dir))) return dir;
|
|
10416
|
+
const parent = path2.dirname(dir);
|
|
10417
|
+
if (parent === dir) return null;
|
|
10418
|
+
dir = parent;
|
|
10419
|
+
}
|
|
10420
|
+
}
|
|
10421
|
+
|
|
10422
|
+
// src/commands/sync-core.ts
|
|
10423
|
+
var fs4 = __toESM(require("node:fs"));
|
|
10424
|
+
var path3 = __toESM(require("node:path"));
|
|
10425
|
+
function writeFileSync4(filePath, content2) {
|
|
10426
|
+
fs4.mkdirSync(path3.dirname(filePath), { recursive: true });
|
|
10427
|
+
fs4.writeFileSync(filePath, content2);
|
|
10428
|
+
}
|
|
10429
|
+
function walkDir(dir, root, knownPaths, result) {
|
|
10430
|
+
const entries = fs4.readdirSync(dir, { withFileTypes: true });
|
|
10431
|
+
for (const entry of entries) {
|
|
10432
|
+
const full = path3.join(dir, entry.name);
|
|
10433
|
+
if (entry.isDirectory()) {
|
|
10434
|
+
walkDir(full, root, knownPaths, result);
|
|
10435
|
+
} else if (!entry.name.startsWith(".")) {
|
|
10436
|
+
const rel = path3.relative(root, full).replace(/\\/g, "/");
|
|
10437
|
+
if (!knownPaths.has(rel)) {
|
|
10438
|
+
result.push(rel);
|
|
10439
|
+
}
|
|
10440
|
+
}
|
|
10441
|
+
}
|
|
10442
|
+
}
|
|
10443
|
+
function detectModifiedFiles(root, index, getPath, computeCurrentHash, getStoredHash) {
|
|
10444
|
+
const modified = [];
|
|
10445
|
+
for (const entry of index) {
|
|
10446
|
+
const relPath = getPath(entry);
|
|
10447
|
+
const absPath = path3.join(root, relPath);
|
|
10448
|
+
if (!fs4.existsSync(absPath)) {
|
|
10449
|
+
modified.push(relPath);
|
|
10450
|
+
continue;
|
|
10451
|
+
}
|
|
10452
|
+
if (computeCurrentHash(absPath) !== getStoredHash(entry)) {
|
|
10453
|
+
modified.push(relPath);
|
|
10454
|
+
}
|
|
10455
|
+
}
|
|
10456
|
+
return modified;
|
|
10457
|
+
}
|
|
10458
|
+
function detectNewFiles(root, index, getPath) {
|
|
10459
|
+
const newFiles = [];
|
|
10460
|
+
const knownPaths = new Set(index.map((e) => getPath(e)));
|
|
10461
|
+
const entries = fs4.readdirSync(root, { withFileTypes: true });
|
|
10462
|
+
for (const entry of entries) {
|
|
10463
|
+
if (!entry.isDirectory() || entry.name.startsWith(".")) continue;
|
|
10464
|
+
walkDir(path3.join(root, entry.name), root, knownPaths, newFiles);
|
|
10465
|
+
}
|
|
10466
|
+
return newFiles;
|
|
10467
|
+
}
|
|
10468
|
+
async function watch2(type, flags, pushFn) {
|
|
10469
|
+
const startDir = flags.dir || ".";
|
|
10470
|
+
const root = findProjectRoot(startDir);
|
|
10471
|
+
if (!root) {
|
|
10472
|
+
console.error(`No .rpbi/config.json found. Run "rpbi ${type} pull" first.`);
|
|
10473
|
+
process.exit(1);
|
|
10474
|
+
}
|
|
10475
|
+
const debounceMs = parseInt(flags.debounce || "500");
|
|
10476
|
+
console.log(`Watching ${root} for changes...`);
|
|
10477
|
+
console.log("Press Ctrl+C to stop.\n");
|
|
10478
|
+
const pending = /* @__PURE__ */ new Map();
|
|
10479
|
+
const watcher = fs4.watch(root, { recursive: true }, (_event, filename) => {
|
|
10480
|
+
if (!filename) return;
|
|
10481
|
+
const relPath = filename.replace(/\\/g, "/");
|
|
10482
|
+
if (relPath.startsWith(".rpbi/") || relPath.startsWith(".")) return;
|
|
10483
|
+
const existing = pending.get(relPath);
|
|
10484
|
+
if (existing) clearTimeout(existing);
|
|
10485
|
+
pending.set(relPath, setTimeout(async () => {
|
|
10486
|
+
pending.delete(relPath);
|
|
10487
|
+
try {
|
|
10488
|
+
await pushFn(flags, [relPath]);
|
|
10489
|
+
} catch (err) {
|
|
10490
|
+
console.error(`Watch push failed for ${relPath}: ${err instanceof Error ? err.message : err}`);
|
|
10491
|
+
}
|
|
10492
|
+
}, debounceMs));
|
|
10493
|
+
});
|
|
10494
|
+
process.on("SIGINT", () => {
|
|
10495
|
+
watcher.close();
|
|
10496
|
+
console.log("\nWatch stopped.");
|
|
10497
|
+
process.exit(0);
|
|
10498
|
+
});
|
|
10499
|
+
await new Promise(() => {
|
|
10500
|
+
});
|
|
10501
|
+
}
|
|
10502
|
+
function printLocalStatus(label, root, config2, flags, modified, newFiles) {
|
|
10503
|
+
const deleted = modified.filter((f) => !fs4.existsSync(path3.join(root, f)));
|
|
10504
|
+
const changed = modified.filter((f) => fs4.existsSync(path3.join(root, f)));
|
|
10505
|
+
if (flags.json === "true") {
|
|
10506
|
+
console.log(JSON.stringify({ modified: changed, new: newFiles, deleted }));
|
|
10507
|
+
return;
|
|
10508
|
+
}
|
|
10509
|
+
console.log(`${label} workspace: ${root}`);
|
|
10510
|
+
console.log(`Domain: ${config2?.domain} | Accounting: ${config2?.accounting}`);
|
|
10511
|
+
if (config2?.pulledAt) console.log(`Pulled at: ${config2.pulledAt}`);
|
|
10512
|
+
console.log("");
|
|
10513
|
+
if (changed.length === 0 && newFiles.length === 0 && deleted.length === 0) {
|
|
10514
|
+
console.log("No changes.");
|
|
10515
|
+
return;
|
|
10516
|
+
}
|
|
10517
|
+
if (changed.length > 0) {
|
|
10518
|
+
console.log("Modified:");
|
|
10519
|
+
for (const f of changed) console.log(` M ${f}`);
|
|
10520
|
+
}
|
|
10521
|
+
if (newFiles.length > 0) {
|
|
10522
|
+
console.log("New (untracked):");
|
|
10523
|
+
for (const f of newFiles) console.log(` + ${f}`);
|
|
10524
|
+
}
|
|
10525
|
+
if (deleted.length > 0) {
|
|
10526
|
+
console.log("Deleted locally:");
|
|
10527
|
+
for (const f of deleted) console.log(` - ${f}`);
|
|
10528
|
+
}
|
|
10529
|
+
}
|
|
10530
|
+
function printRemoteStatus(label, root, config2, flags, result) {
|
|
10531
|
+
const { modifiedLocally, modifiedOnServer, conflict, new: newFiles, localOnly, serverOnly } = result;
|
|
10532
|
+
if (flags.json === "true") {
|
|
10533
|
+
console.log(JSON.stringify(result));
|
|
10534
|
+
return;
|
|
10535
|
+
}
|
|
10536
|
+
console.log(`${label} workspace: ${root}`);
|
|
10537
|
+
console.log(`Domain: ${config2?.domain} | Accounting: ${config2?.accounting}`);
|
|
10538
|
+
console.log("");
|
|
10539
|
+
const total = modifiedLocally.length + modifiedOnServer.length + conflict.length + newFiles.length + localOnly.length + serverOnly.length;
|
|
10540
|
+
if (total === 0) {
|
|
10541
|
+
console.log("In sync with server.");
|
|
10542
|
+
return;
|
|
10543
|
+
}
|
|
10544
|
+
if (conflict.length > 0) {
|
|
10545
|
+
console.log("Conflict (changed locally AND on server):");
|
|
10546
|
+
for (const f of conflict) console.log(` ! ${f}`);
|
|
10547
|
+
}
|
|
10548
|
+
if (modifiedLocally.length > 0) {
|
|
10549
|
+
console.log("Modified locally:");
|
|
10550
|
+
for (const f of modifiedLocally) console.log(` M ${f}`);
|
|
10551
|
+
}
|
|
10552
|
+
if (modifiedOnServer.length > 0) {
|
|
10553
|
+
console.log("Modified on server:");
|
|
10554
|
+
for (const f of modifiedOnServer) console.log(` S ${f}`);
|
|
10555
|
+
}
|
|
10556
|
+
if (newFiles.length > 0) {
|
|
10557
|
+
console.log("New (untracked):");
|
|
10558
|
+
for (const f of newFiles) console.log(` + ${f}`);
|
|
10559
|
+
}
|
|
10560
|
+
if (localOnly.length > 0) {
|
|
10561
|
+
console.log("Local only (deleted on server):");
|
|
10562
|
+
for (const f of localOnly) console.log(` - ${f}`);
|
|
10563
|
+
}
|
|
10564
|
+
if (serverOnly.length > 0) {
|
|
10565
|
+
console.log("Server only (not pulled):");
|
|
10566
|
+
for (const f of serverOnly) console.log(` \u2193 ${f}`);
|
|
10567
|
+
}
|
|
10568
|
+
}
|
|
10569
|
+
|
|
10570
|
+
// src/commands/wiki-sync.ts
|
|
10571
|
+
var SYNC_LANGS = ["cs", "en"];
|
|
10572
|
+
function pageToRelPath(page) {
|
|
10573
|
+
const name = page.name || "untitled";
|
|
10574
|
+
return `${page.lang}/${name}.md`;
|
|
10575
|
+
}
|
|
10576
|
+
function fileToRelPath(file2) {
|
|
10577
|
+
const filename = file2.filename || "untitled";
|
|
10578
|
+
return `${file2.lang}/${filename}`;
|
|
10579
|
+
}
|
|
10580
|
+
function pathToLangAndName(relPath) {
|
|
10581
|
+
const parts = relPath.split("/");
|
|
10582
|
+
const lang = parts[0];
|
|
10583
|
+
const rest = parts.slice(1).join("/");
|
|
10584
|
+
return { lang, name: rest };
|
|
10585
|
+
}
|
|
10586
|
+
function isPageFile(relPath) {
|
|
10587
|
+
return relPath.endsWith(".md");
|
|
10588
|
+
}
|
|
10589
|
+
function computeFileHash(absPath) {
|
|
10590
|
+
const buf = fs5.readFileSync(absPath);
|
|
10591
|
+
return computeHash(buf.toString("base64"));
|
|
10592
|
+
}
|
|
10593
|
+
function computePageHash(absPath) {
|
|
10594
|
+
const content2 = fs5.readFileSync(absPath, "utf-8");
|
|
10595
|
+
return computeHash(content2);
|
|
10596
|
+
}
|
|
10597
|
+
async function pull(flags) {
|
|
10598
|
+
const dir = path4.resolve(flags.dir || ".");
|
|
10599
|
+
const conn = getActiveConnection(dir);
|
|
10600
|
+
if (!conn) {
|
|
10601
|
+
console.error('Not logged in. Run "rpbi login" first.');
|
|
10602
|
+
process.exit(1);
|
|
10603
|
+
}
|
|
10604
|
+
const wikiService = await createService("wiki", { cwd: dir });
|
|
10605
|
+
const langs = flags.langs ? flags.langs.split(",") : SYNC_LANGS;
|
|
10606
|
+
console.log(`Pulling wiki to ${dir}...`);
|
|
10607
|
+
const index = [];
|
|
10608
|
+
for (const lang of langs) {
|
|
10609
|
+
console.log(`Pulling pages for language: ${lang}`);
|
|
10610
|
+
const pages = await wikiService.get("pages", {
|
|
10611
|
+
fields: ["id_wiki_page", "name", "lang", "date_created"],
|
|
10612
|
+
where: { lang }
|
|
10613
|
+
}) || [];
|
|
10614
|
+
console.log(` Found ${pages.length} pages`);
|
|
10615
|
+
let pulled = 0;
|
|
10616
|
+
for (const page of pages) {
|
|
10617
|
+
if (!page.id_wiki_page || !page.name) continue;
|
|
10618
|
+
const relPath = pageToRelPath({ ...page, lang });
|
|
10619
|
+
const absPath = path4.join(dir, relPath);
|
|
10620
|
+
try {
|
|
10621
|
+
const content2 = await wikiService.get(
|
|
10622
|
+
`pageContent/${lang}/${page.id_wiki_page}`,
|
|
10623
|
+
void 0,
|
|
10624
|
+
{ parseResponse: false }
|
|
10625
|
+
) || "";
|
|
10626
|
+
writeFileSync4(absPath, content2);
|
|
10627
|
+
index.push({
|
|
10628
|
+
path: relPath,
|
|
10629
|
+
type: "page",
|
|
10630
|
+
id: page.id_wiki_page,
|
|
10631
|
+
lang,
|
|
10632
|
+
hash: computeHash(content2),
|
|
10633
|
+
serverDate: page.date_created
|
|
10634
|
+
});
|
|
10635
|
+
pulled++;
|
|
10636
|
+
if (pulled % 50 === 0) console.log(` ${pulled}/${pages.length} pages...`);
|
|
10637
|
+
} catch (err) {
|
|
10638
|
+
console.error(` Failed to pull ${relPath}: ${err instanceof Error ? err.message : err}`);
|
|
10639
|
+
}
|
|
10640
|
+
}
|
|
10641
|
+
console.log(` Pulled ${pulled} pages`);
|
|
10642
|
+
}
|
|
10643
|
+
console.log("Pulling files...");
|
|
10644
|
+
const files = await wikiService.get("files", {
|
|
10645
|
+
fields: ["id_wiki_file", "filename", "size", "lang", "date_created"]
|
|
10646
|
+
}) || [];
|
|
10647
|
+
console.log(` Found ${files.length} files`);
|
|
10648
|
+
let pulledFiles = 0;
|
|
10649
|
+
for (const file2 of files) {
|
|
10650
|
+
if (!file2.id_wiki_file || !file2.filename) continue;
|
|
10651
|
+
const lang = file2.lang || "cs";
|
|
10652
|
+
const relPath = fileToRelPath({ ...file2, lang });
|
|
10653
|
+
const absPath = path4.join(dir, relPath);
|
|
10654
|
+
try {
|
|
10655
|
+
const response = await wikiService.getRaw(`download/${file2.id_wiki_file}`);
|
|
10656
|
+
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
|
10657
|
+
const buf = Buffer.from(await response.arrayBuffer());
|
|
10658
|
+
writeFileSync4(absPath, buf);
|
|
10659
|
+
index.push({
|
|
10660
|
+
path: relPath,
|
|
10661
|
+
type: "file",
|
|
10662
|
+
id: file2.id_wiki_file,
|
|
10663
|
+
lang,
|
|
10664
|
+
hash: computeHash(buf.toString("base64")),
|
|
10665
|
+
serverDate: file2.date_created
|
|
10666
|
+
});
|
|
10667
|
+
pulledFiles++;
|
|
10668
|
+
} catch (err) {
|
|
10669
|
+
console.error(` Failed to pull ${relPath}: ${err instanceof Error ? err.message : err}`);
|
|
10670
|
+
}
|
|
10671
|
+
}
|
|
10672
|
+
console.log(` Pulled ${pulledFiles} files`);
|
|
10673
|
+
writeConfig(dir, {
|
|
10674
|
+
domain: conn.domain,
|
|
10675
|
+
accounting: conn.tokens.accounting,
|
|
10676
|
+
type: "wiki",
|
|
10677
|
+
pulledAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
10678
|
+
});
|
|
10679
|
+
writeIndex(dir, index);
|
|
10680
|
+
console.log(`Done. Pulled ${index.length} items to ${dir}`);
|
|
10681
|
+
}
|
|
10682
|
+
async function push(flags, files) {
|
|
10683
|
+
const startDir = flags.dir || ".";
|
|
10684
|
+
const root = findProjectRoot(startDir);
|
|
10685
|
+
if (!root) {
|
|
10686
|
+
console.error('No .rpbi/config.json found. Run "rpbi wiki pull" first.');
|
|
10687
|
+
process.exit(1);
|
|
10688
|
+
}
|
|
10689
|
+
const index = readIndex(root);
|
|
10690
|
+
const indexMap = new Map(index.map((e) => [e.path, e]));
|
|
10691
|
+
const wikiService = await createService("wiki", { cwd: root });
|
|
10692
|
+
const force = flags.force === "true";
|
|
10693
|
+
let filesToPush;
|
|
10694
|
+
if (files.length > 0) {
|
|
10695
|
+
filesToPush = files.map((f) => path4.relative(root, path4.resolve(f)).replace(/\\/g, "/"));
|
|
10696
|
+
} else {
|
|
10697
|
+
filesToPush = [
|
|
10698
|
+
...detectModifiedFiles2(root, index),
|
|
10699
|
+
...detectNewFiles2(root, index)
|
|
10700
|
+
];
|
|
10701
|
+
}
|
|
10702
|
+
if (filesToPush.length === 0) {
|
|
10703
|
+
console.log("Nothing to push.");
|
|
10704
|
+
return;
|
|
10705
|
+
}
|
|
10706
|
+
console.log(`Pushing ${filesToPush.length} file(s)...`);
|
|
10707
|
+
for (const relPath of filesToPush) {
|
|
10708
|
+
const absPath = path4.join(root, relPath);
|
|
10709
|
+
if (!fs5.existsSync(absPath)) {
|
|
10710
|
+
const entry2 = indexMap.get(relPath);
|
|
10711
|
+
if (entry2) {
|
|
10712
|
+
try {
|
|
10713
|
+
if (entry2.type === "page") {
|
|
10714
|
+
await wikiService.delete(`page/${entry2.lang}/${entry2.id}`);
|
|
10715
|
+
} else {
|
|
10716
|
+
await wikiService.delete(`file/${entry2.id}`);
|
|
10717
|
+
}
|
|
10718
|
+
const idx = index.indexOf(entry2);
|
|
10719
|
+
if (idx !== -1) index.splice(idx, 1);
|
|
10720
|
+
indexMap.delete(relPath);
|
|
10721
|
+
console.log(` Deleted: ${relPath}`);
|
|
10722
|
+
} catch (err) {
|
|
10723
|
+
console.error(` Failed to delete ${relPath}: ${err instanceof Error ? err.message : err}`);
|
|
10724
|
+
}
|
|
10725
|
+
} else {
|
|
10726
|
+
console.log(` Skipping ${relPath} (file not found, not in index)`);
|
|
10727
|
+
}
|
|
10728
|
+
continue;
|
|
10729
|
+
}
|
|
10730
|
+
const entry = indexMap.get(relPath);
|
|
10731
|
+
const { lang, name } = pathToLangAndName(relPath);
|
|
10732
|
+
if (isPageFile(relPath)) {
|
|
10733
|
+
const localContent = fs5.readFileSync(absPath, "utf-8");
|
|
10734
|
+
const pageName = name.replace(/\.md$/, "");
|
|
10735
|
+
if (entry) {
|
|
10736
|
+
if (!force) {
|
|
10737
|
+
try {
|
|
10738
|
+
const serverContent = await wikiService.get(
|
|
10739
|
+
`pageContent/${entry.lang}/${entry.id}`,
|
|
10740
|
+
void 0,
|
|
10741
|
+
{ parseResponse: false }
|
|
10742
|
+
) || "";
|
|
10743
|
+
const serverHash = computeHash(serverContent);
|
|
10744
|
+
if (serverHash !== entry.hash) {
|
|
10745
|
+
console.error(` CONFLICT: ${relPath} was modified on server. Use --force to overwrite.`);
|
|
10746
|
+
continue;
|
|
10747
|
+
}
|
|
10748
|
+
} catch {
|
|
10749
|
+
}
|
|
10750
|
+
}
|
|
10751
|
+
const updated = await wikiService.post("page", {
|
|
10752
|
+
id_wiki_page: entry.id,
|
|
10753
|
+
lang: entry.lang,
|
|
10754
|
+
name: pageName,
|
|
10755
|
+
content: localContent
|
|
10756
|
+
});
|
|
10757
|
+
entry.hash = computeHash(localContent);
|
|
10758
|
+
if (updated?.date_created) entry.serverDate = updated.date_created;
|
|
10759
|
+
console.log(` Updated: ${relPath}`);
|
|
10760
|
+
} else {
|
|
10761
|
+
const result = await wikiService.post("page", {
|
|
10762
|
+
lang,
|
|
10763
|
+
name: pageName,
|
|
10764
|
+
content: localContent
|
|
10765
|
+
});
|
|
10766
|
+
if (result?.id_wiki_page) {
|
|
10767
|
+
index.push({
|
|
10768
|
+
path: relPath,
|
|
10769
|
+
type: "page",
|
|
10770
|
+
id: result.id_wiki_page,
|
|
10771
|
+
lang,
|
|
10772
|
+
hash: computeHash(localContent),
|
|
10773
|
+
serverDate: result.date_created
|
|
10774
|
+
});
|
|
10775
|
+
console.log(` Created: ${relPath} (page #${result.id_wiki_page})`);
|
|
10776
|
+
} else {
|
|
10777
|
+
console.error(` Failed to create page for ${relPath}`);
|
|
10778
|
+
}
|
|
10779
|
+
}
|
|
10780
|
+
} else {
|
|
10781
|
+
const buf = fs5.readFileSync(absPath);
|
|
10782
|
+
const b64Content = buf.toString("base64");
|
|
10783
|
+
if (entry) {
|
|
10784
|
+
const updated = await wikiService.post("file", {
|
|
10785
|
+
id_wiki_file: entry.id,
|
|
10786
|
+
filename: name,
|
|
10787
|
+
content: b64Content,
|
|
10788
|
+
lang: entry.lang
|
|
10789
|
+
});
|
|
10790
|
+
entry.hash = computeHash(b64Content);
|
|
10791
|
+
if (updated?.date_created) entry.serverDate = updated.date_created;
|
|
10792
|
+
console.log(` Updated: ${relPath}`);
|
|
10793
|
+
} else {
|
|
10794
|
+
const result = await wikiService.post("file", {
|
|
10795
|
+
lang,
|
|
10796
|
+
filename: name,
|
|
10797
|
+
content: b64Content
|
|
10798
|
+
});
|
|
10799
|
+
if (result?.id_wiki_file) {
|
|
10800
|
+
index.push({
|
|
10801
|
+
path: relPath,
|
|
10802
|
+
type: "file",
|
|
10803
|
+
id: result.id_wiki_file,
|
|
10804
|
+
lang,
|
|
10805
|
+
hash: computeHash(b64Content),
|
|
10806
|
+
serverDate: result.date_created
|
|
10807
|
+
});
|
|
10808
|
+
console.log(` Created: ${relPath} (file #${result.id_wiki_file})`);
|
|
10809
|
+
} else {
|
|
10810
|
+
console.error(` Failed to create file for ${relPath}`);
|
|
10811
|
+
}
|
|
10812
|
+
}
|
|
10813
|
+
}
|
|
10814
|
+
}
|
|
10815
|
+
writeIndex(path4.resolve(root), index);
|
|
10816
|
+
console.log("Push complete.");
|
|
10817
|
+
}
|
|
10818
|
+
function detectModifiedFiles2(root, index) {
|
|
10819
|
+
const typeMap = new Map(index.map((e) => [path4.join(root, e.path), e.type]));
|
|
10820
|
+
return detectModifiedFiles(
|
|
10821
|
+
root,
|
|
10822
|
+
index,
|
|
10823
|
+
(e) => e.path,
|
|
10824
|
+
(absPath) => typeMap.get(absPath) === "page" ? computePageHash(absPath) : computeFileHash(absPath),
|
|
10825
|
+
(e) => e.hash
|
|
10826
|
+
);
|
|
10827
|
+
}
|
|
10828
|
+
function detectNewFiles2(root, index) {
|
|
10829
|
+
return detectNewFiles(root, index, (e) => e.path);
|
|
10830
|
+
}
|
|
10831
|
+
async function status2(flags) {
|
|
10832
|
+
const startDir = flags.dir || ".";
|
|
10833
|
+
const root = findProjectRoot(startDir);
|
|
10834
|
+
if (!root) {
|
|
10835
|
+
console.error('No .rpbi/config.json found. Run "rpbi wiki pull" first.');
|
|
10836
|
+
process.exit(1);
|
|
10837
|
+
}
|
|
10838
|
+
const config2 = readConfig(root);
|
|
10839
|
+
const index = readIndex(root);
|
|
10840
|
+
if (flags.remote === "true") {
|
|
10841
|
+
return statusRemote(root, config2, index, flags);
|
|
10842
|
+
}
|
|
10843
|
+
const modified = detectModifiedFiles2(root, index);
|
|
10844
|
+
const newFiles = detectNewFiles2(root, index);
|
|
10845
|
+
printLocalStatus("Wiki", root, config2, flags, modified, newFiles);
|
|
10846
|
+
}
|
|
10847
|
+
async function statusRemote(root, config2, index, flags) {
|
|
10848
|
+
const wikiService = await createService("wiki", { cwd: root });
|
|
10849
|
+
const langs = flags.langs ? flags.langs.split(",") : SYNC_LANGS;
|
|
10850
|
+
const localPages = /* @__PURE__ */ new Map();
|
|
10851
|
+
const localFiles = /* @__PURE__ */ new Map();
|
|
10852
|
+
for (const entry of index) {
|
|
10853
|
+
if (entry.type === "page") localPages.set(entry.path, entry);
|
|
10854
|
+
else localFiles.set(entry.path, entry);
|
|
10855
|
+
}
|
|
10856
|
+
const modifiedLocally = [];
|
|
10857
|
+
const modifiedOnServer = [];
|
|
10858
|
+
const conflict = [];
|
|
10859
|
+
const localOnly = [];
|
|
10860
|
+
const serverOnly = [];
|
|
10861
|
+
for (const lang of langs) {
|
|
10862
|
+
const serverPages = await wikiService.get("pages", {
|
|
10863
|
+
fields: ["id_wiki_page", "name", "lang", "date_created"],
|
|
10864
|
+
where: { lang }
|
|
10865
|
+
}) || [];
|
|
10866
|
+
const serverPagePaths = /* @__PURE__ */ new Set();
|
|
10867
|
+
for (const page of serverPages) {
|
|
10868
|
+
if (!page.id_wiki_page || !page.name) continue;
|
|
10869
|
+
const relPath = pageToRelPath({ ...page, lang });
|
|
10870
|
+
serverPagePaths.add(relPath);
|
|
10871
|
+
const localEntry = localPages.get(relPath);
|
|
10872
|
+
if (!localEntry) {
|
|
10873
|
+
serverOnly.push(relPath);
|
|
10874
|
+
} else {
|
|
10875
|
+
const absPath = path4.join(root, relPath);
|
|
10876
|
+
const localChanged = fs5.existsSync(absPath) && computePageHash(absPath) !== localEntry.hash;
|
|
10877
|
+
const serverChanged = page.date_created != null && localEntry.serverDate != null && page.date_created !== localEntry.serverDate;
|
|
10878
|
+
if (localChanged && serverChanged) {
|
|
10879
|
+
conflict.push(relPath);
|
|
10880
|
+
} else if (localChanged) {
|
|
10881
|
+
modifiedLocally.push(relPath);
|
|
10882
|
+
} else if (serverChanged) {
|
|
10883
|
+
modifiedOnServer.push(relPath);
|
|
10884
|
+
}
|
|
10885
|
+
}
|
|
10886
|
+
}
|
|
10887
|
+
for (const [relPath, entry] of localPages) {
|
|
10888
|
+
if (entry.lang === lang && !serverPagePaths.has(relPath)) {
|
|
10889
|
+
localOnly.push(relPath);
|
|
10890
|
+
}
|
|
10891
|
+
}
|
|
10892
|
+
}
|
|
10893
|
+
const serverFiles = await wikiService.get("files", {
|
|
10894
|
+
fields: ["id_wiki_file", "filename", "lang", "date_created"]
|
|
10895
|
+
}) || [];
|
|
10896
|
+
const serverFilePaths = /* @__PURE__ */ new Set();
|
|
10897
|
+
for (const file2 of serverFiles) {
|
|
10898
|
+
if (!file2.id_wiki_file || !file2.filename) continue;
|
|
10899
|
+
const lang = file2.lang || "cs";
|
|
10900
|
+
const relPath = fileToRelPath({ ...file2, lang });
|
|
10901
|
+
serverFilePaths.add(relPath);
|
|
10902
|
+
const localEntry = localFiles.get(relPath);
|
|
10903
|
+
if (!localEntry) {
|
|
10904
|
+
serverOnly.push(relPath);
|
|
10905
|
+
} else {
|
|
10906
|
+
const absPath = path4.join(root, relPath);
|
|
10907
|
+
const localChanged = fs5.existsSync(absPath) && computeFileHash(absPath) !== localEntry.hash;
|
|
10908
|
+
const serverChanged = file2.date_created != null && localEntry.serverDate != null && file2.date_created !== localEntry.serverDate;
|
|
10909
|
+
if (localChanged && serverChanged) {
|
|
10910
|
+
conflict.push(relPath);
|
|
10911
|
+
} else if (localChanged) {
|
|
10912
|
+
modifiedLocally.push(relPath);
|
|
10913
|
+
} else if (serverChanged) {
|
|
10914
|
+
modifiedOnServer.push(relPath);
|
|
10915
|
+
}
|
|
10916
|
+
}
|
|
10917
|
+
}
|
|
10918
|
+
for (const [relPath] of localFiles) {
|
|
10919
|
+
if (!serverFilePaths.has(relPath)) {
|
|
10920
|
+
localOnly.push(relPath);
|
|
10921
|
+
}
|
|
10922
|
+
}
|
|
10923
|
+
const newFiles = detectNewFiles2(root, index);
|
|
10924
|
+
printRemoteStatus("Wiki", root, config2, flags, { modifiedLocally, modifiedOnServer, conflict, new: newFiles, localOnly, serverOnly });
|
|
10925
|
+
}
|
|
10926
|
+
function watch3(flags) {
|
|
10927
|
+
return watch2("wiki", flags, push);
|
|
10928
|
+
}
|
|
10929
|
+
|
|
10930
|
+
// src/commands/wiki.ts
|
|
10335
10931
|
var DEFAULT_LANG = "cs";
|
|
10336
10932
|
async function list2(flags) {
|
|
10337
10933
|
const service = await createService("wiki");
|
|
@@ -10357,17 +10953,17 @@ async function search(query, flags) {
|
|
|
10357
10953
|
}
|
|
10358
10954
|
async function readContent(flags) {
|
|
10359
10955
|
if (flags.file) {
|
|
10360
|
-
return
|
|
10956
|
+
return fs6.readFileSync(flags.file, "utf-8");
|
|
10361
10957
|
}
|
|
10362
10958
|
if (flags.content) {
|
|
10363
10959
|
return flags.content;
|
|
10364
10960
|
}
|
|
10365
10961
|
if (!process.stdin.isTTY) {
|
|
10366
|
-
return new Promise((
|
|
10962
|
+
return new Promise((resolve5) => {
|
|
10367
10963
|
let data = "";
|
|
10368
10964
|
process.stdin.setEncoding("utf-8");
|
|
10369
10965
|
process.stdin.on("data", (chunk) => data += chunk);
|
|
10370
|
-
process.stdin.on("end", () =>
|
|
10966
|
+
process.stdin.on("end", () => resolve5(data));
|
|
10371
10967
|
});
|
|
10372
10968
|
}
|
|
10373
10969
|
console.error("No content provided. Use --file, --content, or pipe to stdin.");
|
|
@@ -10424,76 +11020,26 @@ async function wiki(args) {
|
|
|
10424
11020
|
process.exit(1);
|
|
10425
11021
|
}
|
|
10426
11022
|
return del(rest[0], flags);
|
|
11023
|
+
case "pull":
|
|
11024
|
+
return pull(flags);
|
|
11025
|
+
case "push":
|
|
11026
|
+
return push(flags, rest);
|
|
11027
|
+
case "status":
|
|
11028
|
+
return status2(flags);
|
|
11029
|
+
case "watch":
|
|
11030
|
+
return watch3(flags);
|
|
10427
11031
|
default:
|
|
10428
|
-
console.log("Usage: rpbi wiki <list|get|read|search|save|delete> [options]");
|
|
11032
|
+
console.log("Usage: rpbi wiki <list|get|read|search|save|delete|pull|push|status|watch> [options]");
|
|
10429
11033
|
break;
|
|
10430
11034
|
}
|
|
10431
11035
|
}
|
|
10432
11036
|
|
|
10433
11037
|
// src/commands/etl.ts
|
|
10434
|
-
var
|
|
11038
|
+
var fs8 = __toESM(require("node:fs"));
|
|
10435
11039
|
|
|
10436
11040
|
// src/commands/etl-sync.ts
|
|
10437
|
-
var
|
|
10438
|
-
var
|
|
10439
|
-
|
|
10440
|
-
// src/manifest.ts
|
|
10441
|
-
var fs4 = __toESM(require("node:fs"));
|
|
10442
|
-
var path2 = __toESM(require("node:path"));
|
|
10443
|
-
var crypto2 = __toESM(require("node:crypto"));
|
|
10444
|
-
var RPBI_DIR = ".rpbi";
|
|
10445
|
-
var CONFIG_FILE = "config.json";
|
|
10446
|
-
var INDEX_FILE = "index.json";
|
|
10447
|
-
function computeHash(content2) {
|
|
10448
|
-
return crypto2.createHash("sha256").update(content2, "utf-8").digest("hex");
|
|
10449
|
-
}
|
|
10450
|
-
function getConfigPath(dir) {
|
|
10451
|
-
return path2.join(dir, RPBI_DIR, CONFIG_FILE);
|
|
10452
|
-
}
|
|
10453
|
-
function getIndexPath(dir) {
|
|
10454
|
-
return path2.join(dir, RPBI_DIR, INDEX_FILE);
|
|
10455
|
-
}
|
|
10456
|
-
function readConfig(dir) {
|
|
10457
|
-
try {
|
|
10458
|
-
const data = fs4.readFileSync(getConfigPath(dir), "utf-8");
|
|
10459
|
-
return JSON.parse(data);
|
|
10460
|
-
} catch {
|
|
10461
|
-
return null;
|
|
10462
|
-
}
|
|
10463
|
-
}
|
|
10464
|
-
function writeConfig(dir, config2) {
|
|
10465
|
-
const rpbiDir = path2.join(dir, RPBI_DIR);
|
|
10466
|
-
fs4.mkdirSync(rpbiDir, { recursive: true });
|
|
10467
|
-
fs4.writeFileSync(
|
|
10468
|
-
path2.join(rpbiDir, CONFIG_FILE),
|
|
10469
|
-
JSON.stringify(config2, null, 2)
|
|
10470
|
-
);
|
|
10471
|
-
}
|
|
10472
|
-
function readIndex(dir) {
|
|
10473
|
-
try {
|
|
10474
|
-
const data = fs4.readFileSync(getIndexPath(dir), "utf-8");
|
|
10475
|
-
return JSON.parse(data);
|
|
10476
|
-
} catch {
|
|
10477
|
-
return [];
|
|
10478
|
-
}
|
|
10479
|
-
}
|
|
10480
|
-
function writeIndex(dir, index) {
|
|
10481
|
-
const rpbiDir = path2.join(dir, RPBI_DIR);
|
|
10482
|
-
fs4.mkdirSync(rpbiDir, { recursive: true });
|
|
10483
|
-
fs4.writeFileSync(
|
|
10484
|
-
path2.join(rpbiDir, INDEX_FILE),
|
|
10485
|
-
JSON.stringify(index, null, 2)
|
|
10486
|
-
);
|
|
10487
|
-
}
|
|
10488
|
-
function findEtlRoot(startDir) {
|
|
10489
|
-
let dir = path2.resolve(startDir);
|
|
10490
|
-
while (true) {
|
|
10491
|
-
if (fs4.existsSync(getConfigPath(dir))) return dir;
|
|
10492
|
-
const parent = path2.dirname(dir);
|
|
10493
|
-
if (parent === dir) return null;
|
|
10494
|
-
dir = parent;
|
|
10495
|
-
}
|
|
10496
|
-
}
|
|
11041
|
+
var fs7 = __toESM(require("node:fs"));
|
|
11042
|
+
var path5 = __toESM(require("node:path"));
|
|
10497
11043
|
|
|
10498
11044
|
// src/yaml.ts
|
|
10499
11045
|
function toYaml(data, indent = 0) {
|
|
@@ -10622,10 +11168,6 @@ function threadToMetaPath(thread) {
|
|
|
10622
11168
|
const segments = getFilePath(thread.description || "", ".yaml");
|
|
10623
11169
|
return [".rpbi", "threads", typeToDirName(thread.type), ...segments].join("/");
|
|
10624
11170
|
}
|
|
10625
|
-
function writeFileSync4(filePath, content2) {
|
|
10626
|
-
fs5.mkdirSync(path3.dirname(filePath), { recursive: true });
|
|
10627
|
-
fs5.writeFileSync(filePath, content2, "utf-8");
|
|
10628
|
-
}
|
|
10629
11171
|
function stripFields(obj, excludeFields) {
|
|
10630
11172
|
const result = {};
|
|
10631
11173
|
for (const [key, value] of Object.entries(obj)) {
|
|
@@ -10635,8 +11177,8 @@ function stripFields(obj, excludeFields) {
|
|
|
10635
11177
|
}
|
|
10636
11178
|
return result;
|
|
10637
11179
|
}
|
|
10638
|
-
async function
|
|
10639
|
-
const dir =
|
|
11180
|
+
async function pull2(flags) {
|
|
11181
|
+
const dir = path5.resolve(flags.dir || ".");
|
|
10640
11182
|
const conn = getActiveConnection(dir);
|
|
10641
11183
|
if (!conn) {
|
|
10642
11184
|
console.error('Not logged in. Run "rpbi login" first.');
|
|
@@ -10646,7 +11188,7 @@ async function pull(flags) {
|
|
|
10646
11188
|
const defService = await createService("definition", { cwd: dir });
|
|
10647
11189
|
console.log(`Pulling ETL threads to ${dir}...`);
|
|
10648
11190
|
const threads = await etlService.get("threads", {
|
|
10649
|
-
fields: ["id_thread", "description", "type", "enabled", "ord_num", "module"],
|
|
11191
|
+
fields: ["id_thread", "description", "type", "enabled", "ord_num", "module", "date_created"],
|
|
10650
11192
|
order: [["type", "asc"], ["description", "asc"]]
|
|
10651
11193
|
}) || [];
|
|
10652
11194
|
console.log(`Found ${threads.length} threads`);
|
|
@@ -10655,7 +11197,7 @@ async function pull(flags) {
|
|
|
10655
11197
|
for (const thread of threads) {
|
|
10656
11198
|
if (!thread.id_thread || !thread.type || !thread.description) continue;
|
|
10657
11199
|
const relPath = threadToRelPath(thread);
|
|
10658
|
-
const absPath =
|
|
11200
|
+
const absPath = path5.join(dir, relPath);
|
|
10659
11201
|
try {
|
|
10660
11202
|
const content2 = await etlService.get(
|
|
10661
11203
|
`threadContent/${thread.id_thread}`,
|
|
@@ -10667,7 +11209,8 @@ async function pull(flags) {
|
|
|
10667
11209
|
path: relPath,
|
|
10668
11210
|
id_thread: thread.id_thread,
|
|
10669
11211
|
hash: computeHash(content2),
|
|
10670
|
-
type: thread.type
|
|
11212
|
+
type: thread.type,
|
|
11213
|
+
serverDate: thread.date_created
|
|
10671
11214
|
});
|
|
10672
11215
|
pulled++;
|
|
10673
11216
|
if (pulled % 50 === 0) console.log(` ${pulled}/${threads.length} threads...`);
|
|
@@ -10686,7 +11229,7 @@ async function pull(flags) {
|
|
|
10686
11229
|
const cleaned = params.map((p) => stripFields(p, PARAMETER_EXCLUDE_FIELDS));
|
|
10687
11230
|
const optimized = optimizeForLlm(cleaned);
|
|
10688
11231
|
if (!optimized || !Array.isArray(optimized) || optimized.length === 0) continue;
|
|
10689
|
-
const paramPath =
|
|
11232
|
+
const paramPath = path5.join(dir, threadToParamPath(thread));
|
|
10690
11233
|
writeFileSync4(paramPath, toYaml(optimized) + "\n");
|
|
10691
11234
|
} catch {
|
|
10692
11235
|
}
|
|
@@ -10700,7 +11243,7 @@ async function pull(flags) {
|
|
|
10700
11243
|
const cleaned = stripFields(full, THREAD_EXCLUDE_FIELDS);
|
|
10701
11244
|
const optimized = optimizeForLlm(cleaned);
|
|
10702
11245
|
if (!optimized || Object.keys(optimized).length === 0) continue;
|
|
10703
|
-
const metaPath =
|
|
11246
|
+
const metaPath = path5.join(dir, threadToMetaPath(thread));
|
|
10704
11247
|
writeFileSync4(metaPath, toYaml(optimized) + "\n");
|
|
10705
11248
|
} catch {
|
|
10706
11249
|
}
|
|
@@ -10716,9 +11259,9 @@ async function pull(flags) {
|
|
|
10716
11259
|
writeIndex(dir, index);
|
|
10717
11260
|
console.log(`Done. Pulled ${pulled} threads to ${dir}`);
|
|
10718
11261
|
}
|
|
10719
|
-
async function
|
|
11262
|
+
async function push2(flags, files) {
|
|
10720
11263
|
const startDir = flags.dir || ".";
|
|
10721
|
-
const root =
|
|
11264
|
+
const root = findProjectRoot(startDir);
|
|
10722
11265
|
if (!root) {
|
|
10723
11266
|
console.error('No .rpbi/config.json found. Run "rpbi etl pull" first.');
|
|
10724
11267
|
process.exit(1);
|
|
@@ -10729,9 +11272,9 @@ async function push(flags, files) {
|
|
|
10729
11272
|
const force = flags.force === "true";
|
|
10730
11273
|
let filesToPush;
|
|
10731
11274
|
if (files.length > 0) {
|
|
10732
|
-
filesToPush = files.map((f) =>
|
|
11275
|
+
filesToPush = files.map((f) => path5.relative(root, path5.resolve(f)).replace(/\\/g, "/"));
|
|
10733
11276
|
} else {
|
|
10734
|
-
filesToPush =
|
|
11277
|
+
filesToPush = detectModifiedFiles3(root, index);
|
|
10735
11278
|
}
|
|
10736
11279
|
if (filesToPush.length === 0) {
|
|
10737
11280
|
console.log("Nothing to push.");
|
|
@@ -10739,12 +11282,25 @@ async function push(flags, files) {
|
|
|
10739
11282
|
}
|
|
10740
11283
|
console.log(`Pushing ${filesToPush.length} file(s)...`);
|
|
10741
11284
|
for (const relPath of filesToPush) {
|
|
10742
|
-
const absPath =
|
|
10743
|
-
if (!
|
|
10744
|
-
|
|
11285
|
+
const absPath = path5.join(root, relPath);
|
|
11286
|
+
if (!fs7.existsSync(absPath)) {
|
|
11287
|
+
const entry2 = indexMap.get(relPath);
|
|
11288
|
+
if (entry2) {
|
|
11289
|
+
try {
|
|
11290
|
+
await etlService.delete(`threads/${entry2.id_thread}`);
|
|
11291
|
+
const idx = index.indexOf(entry2);
|
|
11292
|
+
if (idx !== -1) index.splice(idx, 1);
|
|
11293
|
+
indexMap.delete(relPath);
|
|
11294
|
+
console.log(` Deleted: ${relPath}`);
|
|
11295
|
+
} catch (err) {
|
|
11296
|
+
console.error(` Failed to delete ${relPath}: ${err instanceof Error ? err.message : err}`);
|
|
11297
|
+
}
|
|
11298
|
+
} else {
|
|
11299
|
+
console.log(` Skipping ${relPath} (file not found, not in index)`);
|
|
11300
|
+
}
|
|
10745
11301
|
continue;
|
|
10746
11302
|
}
|
|
10747
|
-
const localContent =
|
|
11303
|
+
const localContent = fs7.readFileSync(absPath, "utf-8");
|
|
10748
11304
|
const entry = indexMap.get(relPath);
|
|
10749
11305
|
if (entry) {
|
|
10750
11306
|
if (!force) {
|
|
@@ -10764,6 +11320,11 @@ async function push(flags, files) {
|
|
|
10764
11320
|
}
|
|
10765
11321
|
await etlService.post(`threadContent/${entry.id_thread}`, localContent);
|
|
10766
11322
|
entry.hash = computeHash(localContent);
|
|
11323
|
+
try {
|
|
11324
|
+
const meta3 = await etlService.get(`threads/${entry.id_thread}`, { fields: ["date_created"] });
|
|
11325
|
+
if (meta3?.date_created) entry.serverDate = meta3.date_created;
|
|
11326
|
+
} catch {
|
|
11327
|
+
}
|
|
10767
11328
|
console.log(` Updated: ${relPath}`);
|
|
10768
11329
|
} else {
|
|
10769
11330
|
const parts = relPath.split("/");
|
|
@@ -10785,7 +11346,8 @@ async function push(flags, files) {
|
|
|
10785
11346
|
path: relPath,
|
|
10786
11347
|
id_thread: newThread.id_thread,
|
|
10787
11348
|
hash: computeHash(localContent),
|
|
10788
|
-
type
|
|
11349
|
+
type,
|
|
11350
|
+
serverDate: newThread.date_created
|
|
10789
11351
|
});
|
|
10790
11352
|
console.log(` Created: ${relPath} (thread #${newThread.id_thread})`);
|
|
10791
11353
|
} else {
|
|
@@ -10793,18 +11355,18 @@ async function push(flags, files) {
|
|
|
10793
11355
|
}
|
|
10794
11356
|
}
|
|
10795
11357
|
}
|
|
10796
|
-
writeIndex(
|
|
11358
|
+
writeIndex(path5.resolve(root), index);
|
|
10797
11359
|
console.log("Push complete.");
|
|
10798
11360
|
}
|
|
10799
11361
|
async function pullContext(dir, etlService, defService) {
|
|
10800
|
-
const contextDir =
|
|
11362
|
+
const contextDir = path5.join(dir, ".rpbi", "context");
|
|
10801
11363
|
console.log("Pulling context (schema & modules)...");
|
|
10802
11364
|
try {
|
|
10803
11365
|
const modules2 = await defService.get("accountingModules");
|
|
10804
11366
|
if (modules2) {
|
|
10805
11367
|
const optimized = optimizeForLlm(modules2);
|
|
10806
11368
|
writeFileSync4(
|
|
10807
|
-
|
|
11369
|
+
path5.join(contextDir, "modules.json"),
|
|
10808
11370
|
JSON.stringify(optimized, null, 2)
|
|
10809
11371
|
);
|
|
10810
11372
|
}
|
|
@@ -10819,7 +11381,7 @@ async function pullContext(dir, etlService, defService) {
|
|
|
10819
11381
|
if (!name) continue;
|
|
10820
11382
|
const optimized = optimizeForLlm(item);
|
|
10821
11383
|
writeFileSync4(
|
|
10822
|
-
|
|
11384
|
+
path5.join(contextDir, dirPath, `${name}.json`),
|
|
10823
11385
|
JSON.stringify(optimized, null, 2)
|
|
10824
11386
|
);
|
|
10825
11387
|
}
|
|
@@ -10828,84 +11390,83 @@ async function pullContext(dir, etlService, defService) {
|
|
|
10828
11390
|
}
|
|
10829
11391
|
}
|
|
10830
11392
|
async function context(flags) {
|
|
10831
|
-
const dir =
|
|
11393
|
+
const dir = path5.resolve(flags.dir || ".");
|
|
10832
11394
|
const etlService = await createService("etl", { cwd: dir });
|
|
10833
11395
|
const defService = await createService("definition", { cwd: dir });
|
|
10834
11396
|
await pullContext(dir, etlService, defService);
|
|
10835
11397
|
console.log("Context pull complete.");
|
|
10836
11398
|
}
|
|
10837
|
-
function
|
|
10838
|
-
|
|
10839
|
-
|
|
10840
|
-
|
|
10841
|
-
|
|
10842
|
-
|
|
10843
|
-
|
|
10844
|
-
|
|
10845
|
-
const content2 = fs5.readFileSync(absPath, "utf-8");
|
|
10846
|
-
if (computeHash(content2) !== entry.hash) {
|
|
10847
|
-
modified.push(entry.path);
|
|
10848
|
-
}
|
|
10849
|
-
}
|
|
10850
|
-
return modified;
|
|
10851
|
-
}
|
|
10852
|
-
function detectNewFiles(root, index) {
|
|
10853
|
-
const newFiles = [];
|
|
10854
|
-
const knownPaths = new Set(index.map((e) => e.path));
|
|
10855
|
-
const entries = fs5.readdirSync(root, { withFileTypes: true });
|
|
10856
|
-
for (const entry of entries) {
|
|
10857
|
-
if (!entry.isDirectory() || entry.name.startsWith(".")) continue;
|
|
10858
|
-
walkDir(path3.join(root, entry.name), root, knownPaths, newFiles);
|
|
10859
|
-
}
|
|
10860
|
-
return newFiles;
|
|
11399
|
+
function detectModifiedFiles3(root, index) {
|
|
11400
|
+
return detectModifiedFiles(
|
|
11401
|
+
root,
|
|
11402
|
+
index,
|
|
11403
|
+
(e) => e.path,
|
|
11404
|
+
(absPath) => computeHash(fs7.readFileSync(absPath, "utf-8")),
|
|
11405
|
+
(e) => e.hash
|
|
11406
|
+
);
|
|
10861
11407
|
}
|
|
10862
|
-
function
|
|
10863
|
-
|
|
10864
|
-
for (const entry of entries) {
|
|
10865
|
-
const full = path3.join(dir, entry.name);
|
|
10866
|
-
if (entry.isDirectory()) {
|
|
10867
|
-
walkDir(full, root, knownPaths, result);
|
|
10868
|
-
} else if (entry.name.endsWith(".sql")) {
|
|
10869
|
-
const rel = path3.relative(root, full).replace(/\\/g, "/");
|
|
10870
|
-
if (!knownPaths.has(rel)) {
|
|
10871
|
-
result.push(rel);
|
|
10872
|
-
}
|
|
10873
|
-
}
|
|
10874
|
-
}
|
|
11408
|
+
function detectNewFiles3(root, index) {
|
|
11409
|
+
return detectNewFiles(root, index, (e) => e.path);
|
|
10875
11410
|
}
|
|
10876
|
-
async function
|
|
11411
|
+
async function status3(flags) {
|
|
10877
11412
|
const startDir = flags.dir || ".";
|
|
10878
|
-
const root =
|
|
11413
|
+
const root = findProjectRoot(startDir);
|
|
10879
11414
|
if (!root) {
|
|
10880
11415
|
console.error('No .rpbi/config.json found. Run "rpbi etl pull" first.');
|
|
10881
11416
|
process.exit(1);
|
|
10882
11417
|
}
|
|
10883
11418
|
const config2 = readConfig(root);
|
|
10884
11419
|
const index = readIndex(root);
|
|
10885
|
-
|
|
10886
|
-
|
|
10887
|
-
console.log(`Pulled at: ${config2?.pulledAt}`);
|
|
10888
|
-
console.log("");
|
|
10889
|
-
const modified = detectModifiedFiles(root, index);
|
|
10890
|
-
const newFiles = detectNewFiles(root, index);
|
|
10891
|
-
const deleted = modified.filter((f) => !fs5.existsSync(path3.join(root, f)));
|
|
10892
|
-
const changed = modified.filter((f) => fs5.existsSync(path3.join(root, f)));
|
|
10893
|
-
if (changed.length === 0 && newFiles.length === 0 && deleted.length === 0) {
|
|
10894
|
-
console.log("No changes.");
|
|
10895
|
-
return;
|
|
10896
|
-
}
|
|
10897
|
-
if (changed.length > 0) {
|
|
10898
|
-
console.log("Modified:");
|
|
10899
|
-
for (const f of changed) console.log(` M ${f}`);
|
|
11420
|
+
if (flags.remote === "true") {
|
|
11421
|
+
return statusRemote2(root, config2, index, flags);
|
|
10900
11422
|
}
|
|
10901
|
-
|
|
10902
|
-
|
|
10903
|
-
|
|
11423
|
+
const modified = detectModifiedFiles3(root, index);
|
|
11424
|
+
const newFiles = detectNewFiles3(root, index);
|
|
11425
|
+
printLocalStatus("ETL", root, config2, flags, modified, newFiles);
|
|
11426
|
+
}
|
|
11427
|
+
async function statusRemote2(root, config2, index, flags) {
|
|
11428
|
+
const etlService = await createService("etl", { cwd: root });
|
|
11429
|
+
const indexMap = new Map(index.map((e) => [e.path, e]));
|
|
11430
|
+
const threads = await etlService.get("threads", {
|
|
11431
|
+
fields: ["id_thread", "description", "type", "date_created"],
|
|
11432
|
+
order: [["type", "asc"], ["description", "asc"]]
|
|
11433
|
+
}) || [];
|
|
11434
|
+
const modifiedLocally = [];
|
|
11435
|
+
const modifiedOnServer = [];
|
|
11436
|
+
const conflict = [];
|
|
11437
|
+
const localOnly = [];
|
|
11438
|
+
const serverOnly = [];
|
|
11439
|
+
const serverPaths = /* @__PURE__ */ new Set();
|
|
11440
|
+
for (const thread of threads) {
|
|
11441
|
+
if (!thread.id_thread || !thread.type || !thread.description) continue;
|
|
11442
|
+
const relPath = threadToRelPath(thread);
|
|
11443
|
+
serverPaths.add(relPath);
|
|
11444
|
+
const localEntry = indexMap.get(relPath);
|
|
11445
|
+
if (!localEntry) {
|
|
11446
|
+
serverOnly.push(relPath);
|
|
11447
|
+
} else {
|
|
11448
|
+
const absPath = path5.join(root, relPath);
|
|
11449
|
+
const localChanged = fs7.existsSync(absPath) && computeHash(fs7.readFileSync(absPath, "utf-8")) !== localEntry.hash;
|
|
11450
|
+
const serverChanged = thread.date_created != null && localEntry.serverDate != null && thread.date_created !== localEntry.serverDate;
|
|
11451
|
+
if (localChanged && serverChanged) {
|
|
11452
|
+
conflict.push(relPath);
|
|
11453
|
+
} else if (localChanged) {
|
|
11454
|
+
modifiedLocally.push(relPath);
|
|
11455
|
+
} else if (serverChanged) {
|
|
11456
|
+
modifiedOnServer.push(relPath);
|
|
11457
|
+
}
|
|
11458
|
+
}
|
|
10904
11459
|
}
|
|
10905
|
-
|
|
10906
|
-
|
|
10907
|
-
|
|
11460
|
+
for (const entry of index) {
|
|
11461
|
+
if (!serverPaths.has(entry.path)) {
|
|
11462
|
+
localOnly.push(entry.path);
|
|
11463
|
+
}
|
|
10908
11464
|
}
|
|
11465
|
+
const newFiles = detectNewFiles3(root, index);
|
|
11466
|
+
printRemoteStatus("ETL", root, config2, flags, { modifiedLocally, modifiedOnServer, conflict, new: newFiles, localOnly, serverOnly });
|
|
11467
|
+
}
|
|
11468
|
+
function watch4(flags) {
|
|
11469
|
+
return watch2("etl", flags, push2);
|
|
10909
11470
|
}
|
|
10910
11471
|
|
|
10911
11472
|
// src/commands/etl.ts
|
|
@@ -10929,7 +11490,7 @@ async function exec2(id, flags) {
|
|
|
10929
11490
|
const service = await createService("etl", { cwd: flags.dir || "." });
|
|
10930
11491
|
let body = void 0;
|
|
10931
11492
|
if (flags.file) {
|
|
10932
|
-
body =
|
|
11493
|
+
body = fs8.readFileSync(flags.file, "utf-8");
|
|
10933
11494
|
} else if (flags.sql) {
|
|
10934
11495
|
body = flags.sql;
|
|
10935
11496
|
}
|
|
@@ -10972,15 +11533,17 @@ async function etl(args) {
|
|
|
10972
11533
|
}
|
|
10973
11534
|
return search2(rest[0], flags);
|
|
10974
11535
|
case "pull":
|
|
10975
|
-
return
|
|
11536
|
+
return pull2(flags);
|
|
10976
11537
|
case "push":
|
|
10977
|
-
return
|
|
11538
|
+
return push2(flags, rest);
|
|
10978
11539
|
case "context":
|
|
10979
11540
|
return context(flags);
|
|
10980
11541
|
case "status":
|
|
10981
|
-
return
|
|
11542
|
+
return status3(flags);
|
|
11543
|
+
case "watch":
|
|
11544
|
+
return watch4(flags);
|
|
10982
11545
|
default:
|
|
10983
|
-
console.log("Usage: rpbi etl <list|get|content|exec|search|pull|push|context|status> [options]");
|
|
11546
|
+
console.log("Usage: rpbi etl <list|get|content|exec|search|pull|push|context|status|watch> [options]");
|
|
10984
11547
|
break;
|
|
10985
11548
|
}
|
|
10986
11549
|
}
|
|
@@ -11684,8 +12247,8 @@ function getErrorMap() {
|
|
|
11684
12247
|
|
|
11685
12248
|
// ../../.yarn/cache/zod-npm-4.3.6-a096e305e6-860d25a81a.zip/node_modules/zod/v3/helpers/parseUtil.js
|
|
11686
12249
|
var makeIssue = (params) => {
|
|
11687
|
-
const { data, path:
|
|
11688
|
-
const fullPath = [...
|
|
12250
|
+
const { data, path: path7, errorMaps, issueData } = params;
|
|
12251
|
+
const fullPath = [...path7, ...issueData.path || []];
|
|
11689
12252
|
const fullIssue = {
|
|
11690
12253
|
...issueData,
|
|
11691
12254
|
path: fullPath
|
|
@@ -11739,18 +12302,18 @@ var ParseStatus = class _ParseStatus {
|
|
|
11739
12302
|
if (this.value !== "aborted")
|
|
11740
12303
|
this.value = "aborted";
|
|
11741
12304
|
}
|
|
11742
|
-
static mergeArray(
|
|
12305
|
+
static mergeArray(status4, results) {
|
|
11743
12306
|
const arrayValue = [];
|
|
11744
12307
|
for (const s of results) {
|
|
11745
12308
|
if (s.status === "aborted")
|
|
11746
12309
|
return INVALID;
|
|
11747
12310
|
if (s.status === "dirty")
|
|
11748
|
-
|
|
12311
|
+
status4.dirty();
|
|
11749
12312
|
arrayValue.push(s.value);
|
|
11750
12313
|
}
|
|
11751
|
-
return { status:
|
|
12314
|
+
return { status: status4.value, value: arrayValue };
|
|
11752
12315
|
}
|
|
11753
|
-
static async mergeObjectAsync(
|
|
12316
|
+
static async mergeObjectAsync(status4, pairs) {
|
|
11754
12317
|
const syncPairs = [];
|
|
11755
12318
|
for (const pair of pairs) {
|
|
11756
12319
|
const key = await pair.key;
|
|
@@ -11760,9 +12323,9 @@ var ParseStatus = class _ParseStatus {
|
|
|
11760
12323
|
value
|
|
11761
12324
|
});
|
|
11762
12325
|
}
|
|
11763
|
-
return _ParseStatus.mergeObjectSync(
|
|
12326
|
+
return _ParseStatus.mergeObjectSync(status4, syncPairs);
|
|
11764
12327
|
}
|
|
11765
|
-
static mergeObjectSync(
|
|
12328
|
+
static mergeObjectSync(status4, pairs) {
|
|
11766
12329
|
const finalObject = {};
|
|
11767
12330
|
for (const pair of pairs) {
|
|
11768
12331
|
const { key, value } = pair;
|
|
@@ -11771,14 +12334,14 @@ var ParseStatus = class _ParseStatus {
|
|
|
11771
12334
|
if (value.status === "aborted")
|
|
11772
12335
|
return INVALID;
|
|
11773
12336
|
if (key.status === "dirty")
|
|
11774
|
-
|
|
12337
|
+
status4.dirty();
|
|
11775
12338
|
if (value.status === "dirty")
|
|
11776
|
-
|
|
12339
|
+
status4.dirty();
|
|
11777
12340
|
if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
|
|
11778
12341
|
finalObject[key.value] = value.value;
|
|
11779
12342
|
}
|
|
11780
12343
|
}
|
|
11781
|
-
return { status:
|
|
12344
|
+
return { status: status4.value, value: finalObject };
|
|
11782
12345
|
}
|
|
11783
12346
|
};
|
|
11784
12347
|
var INVALID = Object.freeze({
|
|
@@ -11800,11 +12363,11 @@ var errorUtil;
|
|
|
11800
12363
|
|
|
11801
12364
|
// ../../.yarn/cache/zod-npm-4.3.6-a096e305e6-860d25a81a.zip/node_modules/zod/v3/types.js
|
|
11802
12365
|
var ParseInputLazyPath = class {
|
|
11803
|
-
constructor(parent, value,
|
|
12366
|
+
constructor(parent, value, path7, key) {
|
|
11804
12367
|
this._cachedPath = [];
|
|
11805
12368
|
this.parent = parent;
|
|
11806
12369
|
this.data = value;
|
|
11807
|
-
this._path =
|
|
12370
|
+
this._path = path7;
|
|
11808
12371
|
this._key = key;
|
|
11809
12372
|
}
|
|
11810
12373
|
get path() {
|
|
@@ -12238,7 +12801,7 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
12238
12801
|
});
|
|
12239
12802
|
return INVALID;
|
|
12240
12803
|
}
|
|
12241
|
-
const
|
|
12804
|
+
const status4 = new ParseStatus();
|
|
12242
12805
|
let ctx = void 0;
|
|
12243
12806
|
for (const check2 of this._def.checks) {
|
|
12244
12807
|
if (check2.kind === "min") {
|
|
@@ -12252,7 +12815,7 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
12252
12815
|
exact: false,
|
|
12253
12816
|
message: check2.message
|
|
12254
12817
|
});
|
|
12255
|
-
|
|
12818
|
+
status4.dirty();
|
|
12256
12819
|
}
|
|
12257
12820
|
} else if (check2.kind === "max") {
|
|
12258
12821
|
if (input.data.length > check2.value) {
|
|
@@ -12265,7 +12828,7 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
12265
12828
|
exact: false,
|
|
12266
12829
|
message: check2.message
|
|
12267
12830
|
});
|
|
12268
|
-
|
|
12831
|
+
status4.dirty();
|
|
12269
12832
|
}
|
|
12270
12833
|
} else if (check2.kind === "length") {
|
|
12271
12834
|
const tooBig = input.data.length > check2.value;
|
|
@@ -12291,7 +12854,7 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
12291
12854
|
message: check2.message
|
|
12292
12855
|
});
|
|
12293
12856
|
}
|
|
12294
|
-
|
|
12857
|
+
status4.dirty();
|
|
12295
12858
|
}
|
|
12296
12859
|
} else if (check2.kind === "email") {
|
|
12297
12860
|
if (!emailRegex.test(input.data)) {
|
|
@@ -12301,7 +12864,7 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
12301
12864
|
code: ZodIssueCode.invalid_string,
|
|
12302
12865
|
message: check2.message
|
|
12303
12866
|
});
|
|
12304
|
-
|
|
12867
|
+
status4.dirty();
|
|
12305
12868
|
}
|
|
12306
12869
|
} else if (check2.kind === "emoji") {
|
|
12307
12870
|
if (!emojiRegex) {
|
|
@@ -12314,7 +12877,7 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
12314
12877
|
code: ZodIssueCode.invalid_string,
|
|
12315
12878
|
message: check2.message
|
|
12316
12879
|
});
|
|
12317
|
-
|
|
12880
|
+
status4.dirty();
|
|
12318
12881
|
}
|
|
12319
12882
|
} else if (check2.kind === "uuid") {
|
|
12320
12883
|
if (!uuidRegex.test(input.data)) {
|
|
@@ -12324,7 +12887,7 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
12324
12887
|
code: ZodIssueCode.invalid_string,
|
|
12325
12888
|
message: check2.message
|
|
12326
12889
|
});
|
|
12327
|
-
|
|
12890
|
+
status4.dirty();
|
|
12328
12891
|
}
|
|
12329
12892
|
} else if (check2.kind === "nanoid") {
|
|
12330
12893
|
if (!nanoidRegex.test(input.data)) {
|
|
@@ -12334,7 +12897,7 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
12334
12897
|
code: ZodIssueCode.invalid_string,
|
|
12335
12898
|
message: check2.message
|
|
12336
12899
|
});
|
|
12337
|
-
|
|
12900
|
+
status4.dirty();
|
|
12338
12901
|
}
|
|
12339
12902
|
} else if (check2.kind === "cuid") {
|
|
12340
12903
|
if (!cuidRegex.test(input.data)) {
|
|
@@ -12344,7 +12907,7 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
12344
12907
|
code: ZodIssueCode.invalid_string,
|
|
12345
12908
|
message: check2.message
|
|
12346
12909
|
});
|
|
12347
|
-
|
|
12910
|
+
status4.dirty();
|
|
12348
12911
|
}
|
|
12349
12912
|
} else if (check2.kind === "cuid2") {
|
|
12350
12913
|
if (!cuid2Regex.test(input.data)) {
|
|
@@ -12354,7 +12917,7 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
12354
12917
|
code: ZodIssueCode.invalid_string,
|
|
12355
12918
|
message: check2.message
|
|
12356
12919
|
});
|
|
12357
|
-
|
|
12920
|
+
status4.dirty();
|
|
12358
12921
|
}
|
|
12359
12922
|
} else if (check2.kind === "ulid") {
|
|
12360
12923
|
if (!ulidRegex.test(input.data)) {
|
|
@@ -12364,7 +12927,7 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
12364
12927
|
code: ZodIssueCode.invalid_string,
|
|
12365
12928
|
message: check2.message
|
|
12366
12929
|
});
|
|
12367
|
-
|
|
12930
|
+
status4.dirty();
|
|
12368
12931
|
}
|
|
12369
12932
|
} else if (check2.kind === "url") {
|
|
12370
12933
|
try {
|
|
@@ -12376,7 +12939,7 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
12376
12939
|
code: ZodIssueCode.invalid_string,
|
|
12377
12940
|
message: check2.message
|
|
12378
12941
|
});
|
|
12379
|
-
|
|
12942
|
+
status4.dirty();
|
|
12380
12943
|
}
|
|
12381
12944
|
} else if (check2.kind === "regex") {
|
|
12382
12945
|
check2.regex.lastIndex = 0;
|
|
@@ -12388,7 +12951,7 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
12388
12951
|
code: ZodIssueCode.invalid_string,
|
|
12389
12952
|
message: check2.message
|
|
12390
12953
|
});
|
|
12391
|
-
|
|
12954
|
+
status4.dirty();
|
|
12392
12955
|
}
|
|
12393
12956
|
} else if (check2.kind === "trim") {
|
|
12394
12957
|
input.data = input.data.trim();
|
|
@@ -12400,7 +12963,7 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
12400
12963
|
validation: { includes: check2.value, position: check2.position },
|
|
12401
12964
|
message: check2.message
|
|
12402
12965
|
});
|
|
12403
|
-
|
|
12966
|
+
status4.dirty();
|
|
12404
12967
|
}
|
|
12405
12968
|
} else if (check2.kind === "toLowerCase") {
|
|
12406
12969
|
input.data = input.data.toLowerCase();
|
|
@@ -12414,7 +12977,7 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
12414
12977
|
validation: { startsWith: check2.value },
|
|
12415
12978
|
message: check2.message
|
|
12416
12979
|
});
|
|
12417
|
-
|
|
12980
|
+
status4.dirty();
|
|
12418
12981
|
}
|
|
12419
12982
|
} else if (check2.kind === "endsWith") {
|
|
12420
12983
|
if (!input.data.endsWith(check2.value)) {
|
|
@@ -12424,7 +12987,7 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
12424
12987
|
validation: { endsWith: check2.value },
|
|
12425
12988
|
message: check2.message
|
|
12426
12989
|
});
|
|
12427
|
-
|
|
12990
|
+
status4.dirty();
|
|
12428
12991
|
}
|
|
12429
12992
|
} else if (check2.kind === "datetime") {
|
|
12430
12993
|
const regex = datetimeRegex(check2);
|
|
@@ -12435,7 +12998,7 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
12435
12998
|
validation: "datetime",
|
|
12436
12999
|
message: check2.message
|
|
12437
13000
|
});
|
|
12438
|
-
|
|
13001
|
+
status4.dirty();
|
|
12439
13002
|
}
|
|
12440
13003
|
} else if (check2.kind === "date") {
|
|
12441
13004
|
const regex = dateRegex;
|
|
@@ -12446,7 +13009,7 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
12446
13009
|
validation: "date",
|
|
12447
13010
|
message: check2.message
|
|
12448
13011
|
});
|
|
12449
|
-
|
|
13012
|
+
status4.dirty();
|
|
12450
13013
|
}
|
|
12451
13014
|
} else if (check2.kind === "time") {
|
|
12452
13015
|
const regex = timeRegex(check2);
|
|
@@ -12457,7 +13020,7 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
12457
13020
|
validation: "time",
|
|
12458
13021
|
message: check2.message
|
|
12459
13022
|
});
|
|
12460
|
-
|
|
13023
|
+
status4.dirty();
|
|
12461
13024
|
}
|
|
12462
13025
|
} else if (check2.kind === "duration") {
|
|
12463
13026
|
if (!durationRegex.test(input.data)) {
|
|
@@ -12467,7 +13030,7 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
12467
13030
|
code: ZodIssueCode.invalid_string,
|
|
12468
13031
|
message: check2.message
|
|
12469
13032
|
});
|
|
12470
|
-
|
|
13033
|
+
status4.dirty();
|
|
12471
13034
|
}
|
|
12472
13035
|
} else if (check2.kind === "ip") {
|
|
12473
13036
|
if (!isValidIP(input.data, check2.version)) {
|
|
@@ -12477,7 +13040,7 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
12477
13040
|
code: ZodIssueCode.invalid_string,
|
|
12478
13041
|
message: check2.message
|
|
12479
13042
|
});
|
|
12480
|
-
|
|
13043
|
+
status4.dirty();
|
|
12481
13044
|
}
|
|
12482
13045
|
} else if (check2.kind === "jwt") {
|
|
12483
13046
|
if (!isValidJWT(input.data, check2.alg)) {
|
|
@@ -12487,7 +13050,7 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
12487
13050
|
code: ZodIssueCode.invalid_string,
|
|
12488
13051
|
message: check2.message
|
|
12489
13052
|
});
|
|
12490
|
-
|
|
13053
|
+
status4.dirty();
|
|
12491
13054
|
}
|
|
12492
13055
|
} else if (check2.kind === "cidr") {
|
|
12493
13056
|
if (!isValidCidr(input.data, check2.version)) {
|
|
@@ -12497,7 +13060,7 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
12497
13060
|
code: ZodIssueCode.invalid_string,
|
|
12498
13061
|
message: check2.message
|
|
12499
13062
|
});
|
|
12500
|
-
|
|
13063
|
+
status4.dirty();
|
|
12501
13064
|
}
|
|
12502
13065
|
} else if (check2.kind === "base64") {
|
|
12503
13066
|
if (!base64Regex.test(input.data)) {
|
|
@@ -12507,7 +13070,7 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
12507
13070
|
code: ZodIssueCode.invalid_string,
|
|
12508
13071
|
message: check2.message
|
|
12509
13072
|
});
|
|
12510
|
-
|
|
13073
|
+
status4.dirty();
|
|
12511
13074
|
}
|
|
12512
13075
|
} else if (check2.kind === "base64url") {
|
|
12513
13076
|
if (!base64urlRegex.test(input.data)) {
|
|
@@ -12517,13 +13080,13 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
12517
13080
|
code: ZodIssueCode.invalid_string,
|
|
12518
13081
|
message: check2.message
|
|
12519
13082
|
});
|
|
12520
|
-
|
|
13083
|
+
status4.dirty();
|
|
12521
13084
|
}
|
|
12522
13085
|
} else {
|
|
12523
13086
|
util.assertNever(check2);
|
|
12524
13087
|
}
|
|
12525
13088
|
}
|
|
12526
|
-
return { status:
|
|
13089
|
+
return { status: status4.value, value: input.data };
|
|
12527
13090
|
}
|
|
12528
13091
|
_regex(regex, validation, message) {
|
|
12529
13092
|
return this.refinement((data) => regex.test(data), {
|
|
@@ -12799,7 +13362,7 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
12799
13362
|
return INVALID;
|
|
12800
13363
|
}
|
|
12801
13364
|
let ctx = void 0;
|
|
12802
|
-
const
|
|
13365
|
+
const status4 = new ParseStatus();
|
|
12803
13366
|
for (const check2 of this._def.checks) {
|
|
12804
13367
|
if (check2.kind === "int") {
|
|
12805
13368
|
if (!util.isInteger(input.data)) {
|
|
@@ -12810,7 +13373,7 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
12810
13373
|
received: "float",
|
|
12811
13374
|
message: check2.message
|
|
12812
13375
|
});
|
|
12813
|
-
|
|
13376
|
+
status4.dirty();
|
|
12814
13377
|
}
|
|
12815
13378
|
} else if (check2.kind === "min") {
|
|
12816
13379
|
const tooSmall = check2.inclusive ? input.data < check2.value : input.data <= check2.value;
|
|
@@ -12824,7 +13387,7 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
12824
13387
|
exact: false,
|
|
12825
13388
|
message: check2.message
|
|
12826
13389
|
});
|
|
12827
|
-
|
|
13390
|
+
status4.dirty();
|
|
12828
13391
|
}
|
|
12829
13392
|
} else if (check2.kind === "max") {
|
|
12830
13393
|
const tooBig = check2.inclusive ? input.data > check2.value : input.data >= check2.value;
|
|
@@ -12838,7 +13401,7 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
12838
13401
|
exact: false,
|
|
12839
13402
|
message: check2.message
|
|
12840
13403
|
});
|
|
12841
|
-
|
|
13404
|
+
status4.dirty();
|
|
12842
13405
|
}
|
|
12843
13406
|
} else if (check2.kind === "multipleOf") {
|
|
12844
13407
|
if (floatSafeRemainder(input.data, check2.value) !== 0) {
|
|
@@ -12848,7 +13411,7 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
12848
13411
|
multipleOf: check2.value,
|
|
12849
13412
|
message: check2.message
|
|
12850
13413
|
});
|
|
12851
|
-
|
|
13414
|
+
status4.dirty();
|
|
12852
13415
|
}
|
|
12853
13416
|
} else if (check2.kind === "finite") {
|
|
12854
13417
|
if (!Number.isFinite(input.data)) {
|
|
@@ -12857,13 +13420,13 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
12857
13420
|
code: ZodIssueCode.not_finite,
|
|
12858
13421
|
message: check2.message
|
|
12859
13422
|
});
|
|
12860
|
-
|
|
13423
|
+
status4.dirty();
|
|
12861
13424
|
}
|
|
12862
13425
|
} else {
|
|
12863
13426
|
util.assertNever(check2);
|
|
12864
13427
|
}
|
|
12865
13428
|
}
|
|
12866
|
-
return { status:
|
|
13429
|
+
return { status: status4.value, value: input.data };
|
|
12867
13430
|
}
|
|
12868
13431
|
gte(value, message) {
|
|
12869
13432
|
return this.setLimit("min", value, true, errorUtil.toString(message));
|
|
@@ -13028,7 +13591,7 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
|
13028
13591
|
return this._getInvalidInput(input);
|
|
13029
13592
|
}
|
|
13030
13593
|
let ctx = void 0;
|
|
13031
|
-
const
|
|
13594
|
+
const status4 = new ParseStatus();
|
|
13032
13595
|
for (const check2 of this._def.checks) {
|
|
13033
13596
|
if (check2.kind === "min") {
|
|
13034
13597
|
const tooSmall = check2.inclusive ? input.data < check2.value : input.data <= check2.value;
|
|
@@ -13041,7 +13604,7 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
|
13041
13604
|
inclusive: check2.inclusive,
|
|
13042
13605
|
message: check2.message
|
|
13043
13606
|
});
|
|
13044
|
-
|
|
13607
|
+
status4.dirty();
|
|
13045
13608
|
}
|
|
13046
13609
|
} else if (check2.kind === "max") {
|
|
13047
13610
|
const tooBig = check2.inclusive ? input.data > check2.value : input.data >= check2.value;
|
|
@@ -13054,7 +13617,7 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
|
13054
13617
|
inclusive: check2.inclusive,
|
|
13055
13618
|
message: check2.message
|
|
13056
13619
|
});
|
|
13057
|
-
|
|
13620
|
+
status4.dirty();
|
|
13058
13621
|
}
|
|
13059
13622
|
} else if (check2.kind === "multipleOf") {
|
|
13060
13623
|
if (input.data % check2.value !== BigInt(0)) {
|
|
@@ -13064,13 +13627,13 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
|
13064
13627
|
multipleOf: check2.value,
|
|
13065
13628
|
message: check2.message
|
|
13066
13629
|
});
|
|
13067
|
-
|
|
13630
|
+
status4.dirty();
|
|
13068
13631
|
}
|
|
13069
13632
|
} else {
|
|
13070
13633
|
util.assertNever(check2);
|
|
13071
13634
|
}
|
|
13072
13635
|
}
|
|
13073
|
-
return { status:
|
|
13636
|
+
return { status: status4.value, value: input.data };
|
|
13074
13637
|
}
|
|
13075
13638
|
_getInvalidInput(input) {
|
|
13076
13639
|
const ctx = this._getOrReturnCtx(input);
|
|
@@ -13228,7 +13791,7 @@ var ZodDate = class _ZodDate extends ZodType {
|
|
|
13228
13791
|
});
|
|
13229
13792
|
return INVALID;
|
|
13230
13793
|
}
|
|
13231
|
-
const
|
|
13794
|
+
const status4 = new ParseStatus();
|
|
13232
13795
|
let ctx = void 0;
|
|
13233
13796
|
for (const check2 of this._def.checks) {
|
|
13234
13797
|
if (check2.kind === "min") {
|
|
@@ -13242,7 +13805,7 @@ var ZodDate = class _ZodDate extends ZodType {
|
|
|
13242
13805
|
minimum: check2.value,
|
|
13243
13806
|
type: "date"
|
|
13244
13807
|
});
|
|
13245
|
-
|
|
13808
|
+
status4.dirty();
|
|
13246
13809
|
}
|
|
13247
13810
|
} else if (check2.kind === "max") {
|
|
13248
13811
|
if (input.data.getTime() > check2.value) {
|
|
@@ -13255,14 +13818,14 @@ var ZodDate = class _ZodDate extends ZodType {
|
|
|
13255
13818
|
maximum: check2.value,
|
|
13256
13819
|
type: "date"
|
|
13257
13820
|
});
|
|
13258
|
-
|
|
13821
|
+
status4.dirty();
|
|
13259
13822
|
}
|
|
13260
13823
|
} else {
|
|
13261
13824
|
util.assertNever(check2);
|
|
13262
13825
|
}
|
|
13263
13826
|
}
|
|
13264
13827
|
return {
|
|
13265
|
-
status:
|
|
13828
|
+
status: status4.value,
|
|
13266
13829
|
value: new Date(input.data.getTime())
|
|
13267
13830
|
};
|
|
13268
13831
|
}
|
|
@@ -13448,7 +14011,7 @@ ZodVoid.create = (params) => {
|
|
|
13448
14011
|
};
|
|
13449
14012
|
var ZodArray = class _ZodArray extends ZodType {
|
|
13450
14013
|
_parse(input) {
|
|
13451
|
-
const { ctx, status:
|
|
14014
|
+
const { ctx, status: status4 } = this._processInputParams(input);
|
|
13452
14015
|
const def2 = this._def;
|
|
13453
14016
|
if (ctx.parsedType !== ZodParsedType.array) {
|
|
13454
14017
|
addIssueToContext(ctx, {
|
|
@@ -13471,7 +14034,7 @@ var ZodArray = class _ZodArray extends ZodType {
|
|
|
13471
14034
|
exact: true,
|
|
13472
14035
|
message: def2.exactLength.message
|
|
13473
14036
|
});
|
|
13474
|
-
|
|
14037
|
+
status4.dirty();
|
|
13475
14038
|
}
|
|
13476
14039
|
}
|
|
13477
14040
|
if (def2.minLength !== null) {
|
|
@@ -13484,7 +14047,7 @@ var ZodArray = class _ZodArray extends ZodType {
|
|
|
13484
14047
|
exact: false,
|
|
13485
14048
|
message: def2.minLength.message
|
|
13486
14049
|
});
|
|
13487
|
-
|
|
14050
|
+
status4.dirty();
|
|
13488
14051
|
}
|
|
13489
14052
|
}
|
|
13490
14053
|
if (def2.maxLength !== null) {
|
|
@@ -13497,20 +14060,20 @@ var ZodArray = class _ZodArray extends ZodType {
|
|
|
13497
14060
|
exact: false,
|
|
13498
14061
|
message: def2.maxLength.message
|
|
13499
14062
|
});
|
|
13500
|
-
|
|
14063
|
+
status4.dirty();
|
|
13501
14064
|
}
|
|
13502
14065
|
}
|
|
13503
14066
|
if (ctx.common.async) {
|
|
13504
14067
|
return Promise.all([...ctx.data].map((item, i) => {
|
|
13505
14068
|
return def2.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));
|
|
13506
14069
|
})).then((result2) => {
|
|
13507
|
-
return ParseStatus.mergeArray(
|
|
14070
|
+
return ParseStatus.mergeArray(status4, result2);
|
|
13508
14071
|
});
|
|
13509
14072
|
}
|
|
13510
14073
|
const result = [...ctx.data].map((item, i) => {
|
|
13511
14074
|
return def2.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));
|
|
13512
14075
|
});
|
|
13513
|
-
return ParseStatus.mergeArray(
|
|
14076
|
+
return ParseStatus.mergeArray(status4, result);
|
|
13514
14077
|
}
|
|
13515
14078
|
get element() {
|
|
13516
14079
|
return this._def.type;
|
|
@@ -13599,7 +14162,7 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
|
13599
14162
|
});
|
|
13600
14163
|
return INVALID;
|
|
13601
14164
|
}
|
|
13602
|
-
const { status:
|
|
14165
|
+
const { status: status4, ctx } = this._processInputParams(input);
|
|
13603
14166
|
const { shape, keys: shapeKeys } = this._getCached();
|
|
13604
14167
|
const extraKeys = [];
|
|
13605
14168
|
if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) {
|
|
@@ -13634,7 +14197,7 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
|
13634
14197
|
code: ZodIssueCode.unrecognized_keys,
|
|
13635
14198
|
keys: extraKeys
|
|
13636
14199
|
});
|
|
13637
|
-
|
|
14200
|
+
status4.dirty();
|
|
13638
14201
|
}
|
|
13639
14202
|
} else if (unknownKeys === "strip") {
|
|
13640
14203
|
} else {
|
|
@@ -13668,10 +14231,10 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
|
13668
14231
|
}
|
|
13669
14232
|
return syncPairs;
|
|
13670
14233
|
}).then((syncPairs) => {
|
|
13671
|
-
return ParseStatus.mergeObjectSync(
|
|
14234
|
+
return ParseStatus.mergeObjectSync(status4, syncPairs);
|
|
13672
14235
|
});
|
|
13673
14236
|
} else {
|
|
13674
|
-
return ParseStatus.mergeObjectSync(
|
|
14237
|
+
return ParseStatus.mergeObjectSync(status4, pairs);
|
|
13675
14238
|
}
|
|
13676
14239
|
}
|
|
13677
14240
|
get shape() {
|
|
@@ -14149,7 +14712,7 @@ function mergeValues(a, b) {
|
|
|
14149
14712
|
}
|
|
14150
14713
|
var ZodIntersection = class extends ZodType {
|
|
14151
14714
|
_parse(input) {
|
|
14152
|
-
const { status:
|
|
14715
|
+
const { status: status4, ctx } = this._processInputParams(input);
|
|
14153
14716
|
const handleParsed = (parsedLeft, parsedRight) => {
|
|
14154
14717
|
if (isAborted(parsedLeft) || isAborted(parsedRight)) {
|
|
14155
14718
|
return INVALID;
|
|
@@ -14162,9 +14725,9 @@ var ZodIntersection = class extends ZodType {
|
|
|
14162
14725
|
return INVALID;
|
|
14163
14726
|
}
|
|
14164
14727
|
if (isDirty(parsedLeft) || isDirty(parsedRight)) {
|
|
14165
|
-
|
|
14728
|
+
status4.dirty();
|
|
14166
14729
|
}
|
|
14167
|
-
return { status:
|
|
14730
|
+
return { status: status4.value, value: merged.data };
|
|
14168
14731
|
};
|
|
14169
14732
|
if (ctx.common.async) {
|
|
14170
14733
|
return Promise.all([
|
|
@@ -14202,7 +14765,7 @@ ZodIntersection.create = (left, right, params) => {
|
|
|
14202
14765
|
};
|
|
14203
14766
|
var ZodTuple = class _ZodTuple extends ZodType {
|
|
14204
14767
|
_parse(input) {
|
|
14205
|
-
const { status:
|
|
14768
|
+
const { status: status4, ctx } = this._processInputParams(input);
|
|
14206
14769
|
if (ctx.parsedType !== ZodParsedType.array) {
|
|
14207
14770
|
addIssueToContext(ctx, {
|
|
14208
14771
|
code: ZodIssueCode.invalid_type,
|
|
@@ -14230,7 +14793,7 @@ var ZodTuple = class _ZodTuple extends ZodType {
|
|
|
14230
14793
|
exact: false,
|
|
14231
14794
|
type: "array"
|
|
14232
14795
|
});
|
|
14233
|
-
|
|
14796
|
+
status4.dirty();
|
|
14234
14797
|
}
|
|
14235
14798
|
const items = [...ctx.data].map((item, itemIndex) => {
|
|
14236
14799
|
const schema = this._def.items[itemIndex] || this._def.rest;
|
|
@@ -14240,10 +14803,10 @@ var ZodTuple = class _ZodTuple extends ZodType {
|
|
|
14240
14803
|
}).filter((x) => !!x);
|
|
14241
14804
|
if (ctx.common.async) {
|
|
14242
14805
|
return Promise.all(items).then((results) => {
|
|
14243
|
-
return ParseStatus.mergeArray(
|
|
14806
|
+
return ParseStatus.mergeArray(status4, results);
|
|
14244
14807
|
});
|
|
14245
14808
|
} else {
|
|
14246
|
-
return ParseStatus.mergeArray(
|
|
14809
|
+
return ParseStatus.mergeArray(status4, items);
|
|
14247
14810
|
}
|
|
14248
14811
|
}
|
|
14249
14812
|
get items() {
|
|
@@ -14275,7 +14838,7 @@ var ZodRecord = class _ZodRecord extends ZodType {
|
|
|
14275
14838
|
return this._def.valueType;
|
|
14276
14839
|
}
|
|
14277
14840
|
_parse(input) {
|
|
14278
|
-
const { status:
|
|
14841
|
+
const { status: status4, ctx } = this._processInputParams(input);
|
|
14279
14842
|
if (ctx.parsedType !== ZodParsedType.object) {
|
|
14280
14843
|
addIssueToContext(ctx, {
|
|
14281
14844
|
code: ZodIssueCode.invalid_type,
|
|
@@ -14295,9 +14858,9 @@ var ZodRecord = class _ZodRecord extends ZodType {
|
|
|
14295
14858
|
});
|
|
14296
14859
|
}
|
|
14297
14860
|
if (ctx.common.async) {
|
|
14298
|
-
return ParseStatus.mergeObjectAsync(
|
|
14861
|
+
return ParseStatus.mergeObjectAsync(status4, pairs);
|
|
14299
14862
|
} else {
|
|
14300
|
-
return ParseStatus.mergeObjectSync(
|
|
14863
|
+
return ParseStatus.mergeObjectSync(status4, pairs);
|
|
14301
14864
|
}
|
|
14302
14865
|
}
|
|
14303
14866
|
get element() {
|
|
@@ -14328,7 +14891,7 @@ var ZodMap = class extends ZodType {
|
|
|
14328
14891
|
return this._def.valueType;
|
|
14329
14892
|
}
|
|
14330
14893
|
_parse(input) {
|
|
14331
|
-
const { status:
|
|
14894
|
+
const { status: status4, ctx } = this._processInputParams(input);
|
|
14332
14895
|
if (ctx.parsedType !== ZodParsedType.map) {
|
|
14333
14896
|
addIssueToContext(ctx, {
|
|
14334
14897
|
code: ZodIssueCode.invalid_type,
|
|
@@ -14355,11 +14918,11 @@ var ZodMap = class extends ZodType {
|
|
|
14355
14918
|
return INVALID;
|
|
14356
14919
|
}
|
|
14357
14920
|
if (key.status === "dirty" || value.status === "dirty") {
|
|
14358
|
-
|
|
14921
|
+
status4.dirty();
|
|
14359
14922
|
}
|
|
14360
14923
|
finalMap.set(key.value, value.value);
|
|
14361
14924
|
}
|
|
14362
|
-
return { status:
|
|
14925
|
+
return { status: status4.value, value: finalMap };
|
|
14363
14926
|
});
|
|
14364
14927
|
} else {
|
|
14365
14928
|
const finalMap = /* @__PURE__ */ new Map();
|
|
@@ -14370,11 +14933,11 @@ var ZodMap = class extends ZodType {
|
|
|
14370
14933
|
return INVALID;
|
|
14371
14934
|
}
|
|
14372
14935
|
if (key.status === "dirty" || value.status === "dirty") {
|
|
14373
|
-
|
|
14936
|
+
status4.dirty();
|
|
14374
14937
|
}
|
|
14375
14938
|
finalMap.set(key.value, value.value);
|
|
14376
14939
|
}
|
|
14377
|
-
return { status:
|
|
14940
|
+
return { status: status4.value, value: finalMap };
|
|
14378
14941
|
}
|
|
14379
14942
|
}
|
|
14380
14943
|
};
|
|
@@ -14388,7 +14951,7 @@ ZodMap.create = (keyType, valueType, params) => {
|
|
|
14388
14951
|
};
|
|
14389
14952
|
var ZodSet = class _ZodSet extends ZodType {
|
|
14390
14953
|
_parse(input) {
|
|
14391
|
-
const { status:
|
|
14954
|
+
const { status: status4, ctx } = this._processInputParams(input);
|
|
14392
14955
|
if (ctx.parsedType !== ZodParsedType.set) {
|
|
14393
14956
|
addIssueToContext(ctx, {
|
|
14394
14957
|
code: ZodIssueCode.invalid_type,
|
|
@@ -14408,7 +14971,7 @@ var ZodSet = class _ZodSet extends ZodType {
|
|
|
14408
14971
|
exact: false,
|
|
14409
14972
|
message: def2.minSize.message
|
|
14410
14973
|
});
|
|
14411
|
-
|
|
14974
|
+
status4.dirty();
|
|
14412
14975
|
}
|
|
14413
14976
|
}
|
|
14414
14977
|
if (def2.maxSize !== null) {
|
|
@@ -14421,7 +14984,7 @@ var ZodSet = class _ZodSet extends ZodType {
|
|
|
14421
14984
|
exact: false,
|
|
14422
14985
|
message: def2.maxSize.message
|
|
14423
14986
|
});
|
|
14424
|
-
|
|
14987
|
+
status4.dirty();
|
|
14425
14988
|
}
|
|
14426
14989
|
}
|
|
14427
14990
|
const valueType = this._def.valueType;
|
|
@@ -14431,10 +14994,10 @@ var ZodSet = class _ZodSet extends ZodType {
|
|
|
14431
14994
|
if (element.status === "aborted")
|
|
14432
14995
|
return INVALID;
|
|
14433
14996
|
if (element.status === "dirty")
|
|
14434
|
-
|
|
14997
|
+
status4.dirty();
|
|
14435
14998
|
parsedSet.add(element.value);
|
|
14436
14999
|
}
|
|
14437
|
-
return { status:
|
|
15000
|
+
return { status: status4.value, value: parsedSet };
|
|
14438
15001
|
}
|
|
14439
15002
|
const elements = [...ctx.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i)));
|
|
14440
15003
|
if (ctx.common.async) {
|
|
@@ -14765,15 +15328,15 @@ var ZodEffects = class extends ZodType {
|
|
|
14765
15328
|
return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
|
|
14766
15329
|
}
|
|
14767
15330
|
_parse(input) {
|
|
14768
|
-
const { status:
|
|
15331
|
+
const { status: status4, ctx } = this._processInputParams(input);
|
|
14769
15332
|
const effect = this._def.effect || null;
|
|
14770
15333
|
const checkCtx = {
|
|
14771
15334
|
addIssue: (arg) => {
|
|
14772
15335
|
addIssueToContext(ctx, arg);
|
|
14773
15336
|
if (arg.fatal) {
|
|
14774
|
-
|
|
15337
|
+
status4.abort();
|
|
14775
15338
|
} else {
|
|
14776
|
-
|
|
15339
|
+
status4.dirty();
|
|
14777
15340
|
}
|
|
14778
15341
|
},
|
|
14779
15342
|
get path() {
|
|
@@ -14785,7 +15348,7 @@ var ZodEffects = class extends ZodType {
|
|
|
14785
15348
|
const processed = effect.transform(ctx.data, checkCtx);
|
|
14786
15349
|
if (ctx.common.async) {
|
|
14787
15350
|
return Promise.resolve(processed).then(async (processed2) => {
|
|
14788
|
-
if (
|
|
15351
|
+
if (status4.value === "aborted")
|
|
14789
15352
|
return INVALID;
|
|
14790
15353
|
const result = await this._def.schema._parseAsync({
|
|
14791
15354
|
data: processed2,
|
|
@@ -14796,12 +15359,12 @@ var ZodEffects = class extends ZodType {
|
|
|
14796
15359
|
return INVALID;
|
|
14797
15360
|
if (result.status === "dirty")
|
|
14798
15361
|
return DIRTY(result.value);
|
|
14799
|
-
if (
|
|
15362
|
+
if (status4.value === "dirty")
|
|
14800
15363
|
return DIRTY(result.value);
|
|
14801
15364
|
return result;
|
|
14802
15365
|
});
|
|
14803
15366
|
} else {
|
|
14804
|
-
if (
|
|
15367
|
+
if (status4.value === "aborted")
|
|
14805
15368
|
return INVALID;
|
|
14806
15369
|
const result = this._def.schema._parseSync({
|
|
14807
15370
|
data: processed,
|
|
@@ -14812,7 +15375,7 @@ var ZodEffects = class extends ZodType {
|
|
|
14812
15375
|
return INVALID;
|
|
14813
15376
|
if (result.status === "dirty")
|
|
14814
15377
|
return DIRTY(result.value);
|
|
14815
|
-
if (
|
|
15378
|
+
if (status4.value === "dirty")
|
|
14816
15379
|
return DIRTY(result.value);
|
|
14817
15380
|
return result;
|
|
14818
15381
|
}
|
|
@@ -14837,17 +15400,17 @@ var ZodEffects = class extends ZodType {
|
|
|
14837
15400
|
if (inner.status === "aborted")
|
|
14838
15401
|
return INVALID;
|
|
14839
15402
|
if (inner.status === "dirty")
|
|
14840
|
-
|
|
15403
|
+
status4.dirty();
|
|
14841
15404
|
executeRefinement(inner.value);
|
|
14842
|
-
return { status:
|
|
15405
|
+
return { status: status4.value, value: inner.value };
|
|
14843
15406
|
} else {
|
|
14844
15407
|
return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => {
|
|
14845
15408
|
if (inner.status === "aborted")
|
|
14846
15409
|
return INVALID;
|
|
14847
15410
|
if (inner.status === "dirty")
|
|
14848
|
-
|
|
15411
|
+
status4.dirty();
|
|
14849
15412
|
return executeRefinement(inner.value).then(() => {
|
|
14850
|
-
return { status:
|
|
15413
|
+
return { status: status4.value, value: inner.value };
|
|
14851
15414
|
});
|
|
14852
15415
|
});
|
|
14853
15416
|
}
|
|
@@ -14865,13 +15428,13 @@ var ZodEffects = class extends ZodType {
|
|
|
14865
15428
|
if (result instanceof Promise) {
|
|
14866
15429
|
throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
|
|
14867
15430
|
}
|
|
14868
|
-
return { status:
|
|
15431
|
+
return { status: status4.value, value: result };
|
|
14869
15432
|
} else {
|
|
14870
15433
|
return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => {
|
|
14871
15434
|
if (!isValid(base))
|
|
14872
15435
|
return INVALID;
|
|
14873
15436
|
return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({
|
|
14874
|
-
status:
|
|
15437
|
+
status: status4.value,
|
|
14875
15438
|
value: result
|
|
14876
15439
|
}));
|
|
14877
15440
|
});
|
|
@@ -15050,7 +15613,7 @@ var ZodBranded = class extends ZodType {
|
|
|
15050
15613
|
};
|
|
15051
15614
|
var ZodPipeline = class _ZodPipeline extends ZodType {
|
|
15052
15615
|
_parse(input) {
|
|
15053
|
-
const { status:
|
|
15616
|
+
const { status: status4, ctx } = this._processInputParams(input);
|
|
15054
15617
|
if (ctx.common.async) {
|
|
15055
15618
|
const handleAsync = async () => {
|
|
15056
15619
|
const inResult = await this._def.in._parseAsync({
|
|
@@ -15061,7 +15624,7 @@ var ZodPipeline = class _ZodPipeline extends ZodType {
|
|
|
15061
15624
|
if (inResult.status === "aborted")
|
|
15062
15625
|
return INVALID;
|
|
15063
15626
|
if (inResult.status === "dirty") {
|
|
15064
|
-
|
|
15627
|
+
status4.dirty();
|
|
15065
15628
|
return DIRTY(inResult.value);
|
|
15066
15629
|
} else {
|
|
15067
15630
|
return this._def.out._parseAsync({
|
|
@@ -15081,7 +15644,7 @@ var ZodPipeline = class _ZodPipeline extends ZodType {
|
|
|
15081
15644
|
if (inResult.status === "aborted")
|
|
15082
15645
|
return INVALID;
|
|
15083
15646
|
if (inResult.status === "dirty") {
|
|
15084
|
-
|
|
15647
|
+
status4.dirty();
|
|
15085
15648
|
return {
|
|
15086
15649
|
status: "dirty",
|
|
15087
15650
|
value: inResult.value
|
|
@@ -15728,10 +16291,10 @@ function mergeDefs(...defs) {
|
|
|
15728
16291
|
function cloneDef(schema) {
|
|
15729
16292
|
return mergeDefs(schema._zod.def);
|
|
15730
16293
|
}
|
|
15731
|
-
function getElementAtPath(obj,
|
|
15732
|
-
if (!
|
|
16294
|
+
function getElementAtPath(obj, path7) {
|
|
16295
|
+
if (!path7)
|
|
15733
16296
|
return obj;
|
|
15734
|
-
return
|
|
16297
|
+
return path7.reduce((acc, key) => acc?.[key], obj);
|
|
15735
16298
|
}
|
|
15736
16299
|
function promiseAllObject(promisesObj) {
|
|
15737
16300
|
const keys = Object.keys(promisesObj);
|
|
@@ -16114,11 +16677,11 @@ function aborted(x, startIndex = 0) {
|
|
|
16114
16677
|
}
|
|
16115
16678
|
return false;
|
|
16116
16679
|
}
|
|
16117
|
-
function prefixIssues(
|
|
16680
|
+
function prefixIssues(path7, issues) {
|
|
16118
16681
|
return issues.map((iss) => {
|
|
16119
16682
|
var _a2;
|
|
16120
16683
|
(_a2 = iss).path ?? (_a2.path = []);
|
|
16121
|
-
iss.path.unshift(
|
|
16684
|
+
iss.path.unshift(path7);
|
|
16122
16685
|
return iss;
|
|
16123
16686
|
});
|
|
16124
16687
|
}
|
|
@@ -16301,7 +16864,7 @@ function formatError(error48, mapper = (issue2) => issue2.message) {
|
|
|
16301
16864
|
}
|
|
16302
16865
|
function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
16303
16866
|
const result = { errors: [] };
|
|
16304
|
-
const processError = (error49,
|
|
16867
|
+
const processError = (error49, path7 = []) => {
|
|
16305
16868
|
var _a2, _b;
|
|
16306
16869
|
for (const issue2 of error49.issues) {
|
|
16307
16870
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
@@ -16311,7 +16874,7 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
|
16311
16874
|
} else if (issue2.code === "invalid_element") {
|
|
16312
16875
|
processError({ issues: issue2.issues }, issue2.path);
|
|
16313
16876
|
} else {
|
|
16314
|
-
const fullpath = [...
|
|
16877
|
+
const fullpath = [...path7, ...issue2.path];
|
|
16315
16878
|
if (fullpath.length === 0) {
|
|
16316
16879
|
result.errors.push(mapper(issue2));
|
|
16317
16880
|
continue;
|
|
@@ -16343,8 +16906,8 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
|
16343
16906
|
}
|
|
16344
16907
|
function toDotPath(_path) {
|
|
16345
16908
|
const segs = [];
|
|
16346
|
-
const
|
|
16347
|
-
for (const seg of
|
|
16909
|
+
const path7 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
16910
|
+
for (const seg of path7) {
|
|
16348
16911
|
if (typeof seg === "number")
|
|
16349
16912
|
segs.push(`[${seg}]`);
|
|
16350
16913
|
else if (typeof seg === "symbol")
|
|
@@ -28750,13 +29313,13 @@ function resolveRef(ref, ctx) {
|
|
|
28750
29313
|
if (!ref.startsWith("#")) {
|
|
28751
29314
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
28752
29315
|
}
|
|
28753
|
-
const
|
|
28754
|
-
if (
|
|
29316
|
+
const path7 = ref.slice(1).split("/").filter(Boolean);
|
|
29317
|
+
if (path7.length === 0) {
|
|
28755
29318
|
return ctx.rootSchema;
|
|
28756
29319
|
}
|
|
28757
29320
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
28758
|
-
if (
|
|
28759
|
-
const key =
|
|
29321
|
+
if (path7[0] === defsKey) {
|
|
29322
|
+
const key = path7[1];
|
|
28760
29323
|
if (!key || !ctx.defs[key]) {
|
|
28761
29324
|
throw new Error(`Reference not found: ${ref}`);
|
|
28762
29325
|
}
|
|
@@ -30677,8 +31240,8 @@ var UrlElicitationRequiredError = class extends McpError {
|
|
|
30677
31240
|
};
|
|
30678
31241
|
|
|
30679
31242
|
// ../../.yarn/__virtual__/@modelcontextprotocol-sdk-virtual-4beea6215a/0/cache/@modelcontextprotocol-sdk-npm-1.26.0-380479a6f8-b4098789d9.zip/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/interfaces.js
|
|
30680
|
-
function isTerminal(
|
|
30681
|
-
return
|
|
31243
|
+
function isTerminal(status4) {
|
|
31244
|
+
return status4 === "completed" || status4 === "failed" || status4 === "cancelled";
|
|
30682
31245
|
}
|
|
30683
31246
|
|
|
30684
31247
|
// ../../.yarn/__virtual__/zod-to-json-schema-virtual-00ec010bf6/0/cache/zod-to-json-schema-npm-3.25.1-850d9216b4-711b30e34d.zip/node_modules/zod-to-json-schema/dist/esm/Options.js
|
|
@@ -32501,7 +33064,7 @@ var Protocol = class {
|
|
|
32501
33064
|
return;
|
|
32502
33065
|
}
|
|
32503
33066
|
const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
|
|
32504
|
-
await new Promise((
|
|
33067
|
+
await new Promise((resolve5) => setTimeout(resolve5, pollInterval));
|
|
32505
33068
|
options?.signal?.throwIfAborted();
|
|
32506
33069
|
}
|
|
32507
33070
|
} catch (error48) {
|
|
@@ -32518,7 +33081,7 @@ var Protocol = class {
|
|
|
32518
33081
|
*/
|
|
32519
33082
|
request(request, resultSchema, options) {
|
|
32520
33083
|
const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
|
|
32521
|
-
return new Promise((
|
|
33084
|
+
return new Promise((resolve5, reject) => {
|
|
32522
33085
|
const earlyReject = (error48) => {
|
|
32523
33086
|
reject(error48);
|
|
32524
33087
|
};
|
|
@@ -32596,7 +33159,7 @@ var Protocol = class {
|
|
|
32596
33159
|
if (!parseResult.success) {
|
|
32597
33160
|
reject(parseResult.error);
|
|
32598
33161
|
} else {
|
|
32599
|
-
|
|
33162
|
+
resolve5(parseResult.data);
|
|
32600
33163
|
}
|
|
32601
33164
|
} catch (error48) {
|
|
32602
33165
|
reject(error48);
|
|
@@ -32857,12 +33420,12 @@ var Protocol = class {
|
|
|
32857
33420
|
}
|
|
32858
33421
|
} catch {
|
|
32859
33422
|
}
|
|
32860
|
-
return new Promise((
|
|
33423
|
+
return new Promise((resolve5, reject) => {
|
|
32861
33424
|
if (signal.aborted) {
|
|
32862
33425
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
32863
33426
|
return;
|
|
32864
33427
|
}
|
|
32865
|
-
const timeoutId = setTimeout(
|
|
33428
|
+
const timeoutId = setTimeout(resolve5, interval);
|
|
32866
33429
|
signal.addEventListener("abort", () => {
|
|
32867
33430
|
clearTimeout(timeoutId);
|
|
32868
33431
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
@@ -32891,8 +33454,8 @@ var Protocol = class {
|
|
|
32891
33454
|
}
|
|
32892
33455
|
return task;
|
|
32893
33456
|
},
|
|
32894
|
-
storeTaskResult: async (taskId,
|
|
32895
|
-
await taskStore.storeTaskResult(taskId,
|
|
33457
|
+
storeTaskResult: async (taskId, status4, result) => {
|
|
33458
|
+
await taskStore.storeTaskResult(taskId, status4, result, sessionId);
|
|
32896
33459
|
const task = await taskStore.getTask(taskId, sessionId);
|
|
32897
33460
|
if (task) {
|
|
32898
33461
|
const notification = TaskStatusNotificationSchema.parse({
|
|
@@ -32908,15 +33471,15 @@ var Protocol = class {
|
|
|
32908
33471
|
getTaskResult: (taskId) => {
|
|
32909
33472
|
return taskStore.getTaskResult(taskId, sessionId);
|
|
32910
33473
|
},
|
|
32911
|
-
updateTaskStatus: async (taskId,
|
|
33474
|
+
updateTaskStatus: async (taskId, status4, statusMessage) => {
|
|
32912
33475
|
const task = await taskStore.getTask(taskId, sessionId);
|
|
32913
33476
|
if (!task) {
|
|
32914
33477
|
throw new McpError(ErrorCode.InvalidParams, `Task "${taskId}" not found - it may have been cleaned up`);
|
|
32915
33478
|
}
|
|
32916
33479
|
if (isTerminal(task.status)) {
|
|
32917
|
-
throw new McpError(ErrorCode.InvalidParams, `Cannot update task "${taskId}" from terminal status "${task.status}" to "${
|
|
33480
|
+
throw new McpError(ErrorCode.InvalidParams, `Cannot update task "${taskId}" from terminal status "${task.status}" to "${status4}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);
|
|
32918
33481
|
}
|
|
32919
|
-
await taskStore.updateTaskStatus(taskId,
|
|
33482
|
+
await taskStore.updateTaskStatus(taskId, status4, statusMessage, sessionId);
|
|
32920
33483
|
const updatedTask = await taskStore.getTask(taskId, sessionId);
|
|
32921
33484
|
if (updatedTask) {
|
|
32922
33485
|
const notification = TaskStatusNotificationSchema.parse({
|
|
@@ -33821,7 +34384,7 @@ var McpServer = class {
|
|
|
33821
34384
|
let task = createTaskResult.task;
|
|
33822
34385
|
const pollInterval = task.pollInterval ?? 5e3;
|
|
33823
34386
|
while (task.status !== "completed" && task.status !== "failed" && task.status !== "cancelled") {
|
|
33824
|
-
await new Promise((
|
|
34387
|
+
await new Promise((resolve5) => setTimeout(resolve5, pollInterval));
|
|
33825
34388
|
const updatedTask = await extra.taskStore.getTask(taskId);
|
|
33826
34389
|
if (!updatedTask) {
|
|
33827
34390
|
throw new McpError(ErrorCode.InternalError, `Task ${taskId} not found during polling`);
|
|
@@ -34464,12 +35027,12 @@ var StdioServerTransport = class {
|
|
|
34464
35027
|
this.onclose?.();
|
|
34465
35028
|
}
|
|
34466
35029
|
send(message) {
|
|
34467
|
-
return new Promise((
|
|
35030
|
+
return new Promise((resolve5) => {
|
|
34468
35031
|
const json3 = serializeMessage(message);
|
|
34469
35032
|
if (this._stdout.write(json3)) {
|
|
34470
|
-
|
|
35033
|
+
resolve5();
|
|
34471
35034
|
} else {
|
|
34472
|
-
this._stdout.once("drain",
|
|
35035
|
+
this._stdout.once("drain", resolve5);
|
|
34473
35036
|
}
|
|
34474
35037
|
});
|
|
34475
35038
|
}
|
|
@@ -34509,7 +35072,7 @@ function text(data) {
|
|
|
34509
35072
|
async function mcp() {
|
|
34510
35073
|
const server = new McpServer({
|
|
34511
35074
|
name: "reporting-bi",
|
|
34512
|
-
version: "0.1.
|
|
35075
|
+
version: "0.1.3"
|
|
34513
35076
|
});
|
|
34514
35077
|
server.tool(
|
|
34515
35078
|
"status",
|
|
@@ -34960,9 +35523,11 @@ function init(args) {
|
|
|
34960
35523
|
process.exit(1);
|
|
34961
35524
|
}
|
|
34962
35525
|
const existing = readConfig(process.cwd());
|
|
35526
|
+
const type = flags.type || existing?.type;
|
|
34963
35527
|
const config2 = {
|
|
34964
35528
|
domain: domain2,
|
|
34965
35529
|
accounting: flags.accounting ? parseInt(flags.accounting) : existing?.accounting ?? creds.connections[domain2].accounting ?? 0,
|
|
35530
|
+
...type && { type },
|
|
34966
35531
|
...existing?.pulledAt && { pulledAt: existing.pulledAt }
|
|
34967
35532
|
};
|
|
34968
35533
|
writeConfig(process.cwd(), config2);
|
|
@@ -34972,20 +35537,20 @@ function init(args) {
|
|
|
34972
35537
|
}
|
|
34973
35538
|
|
|
34974
35539
|
// src/autoupdate.ts
|
|
34975
|
-
var
|
|
34976
|
-
var
|
|
35540
|
+
var fs9 = __toESM(require("node:fs"));
|
|
35541
|
+
var path6 = __toESM(require("node:path"));
|
|
34977
35542
|
var os3 = __toESM(require("node:os"));
|
|
34978
35543
|
var https = __toESM(require("node:https"));
|
|
34979
35544
|
var import_node_child_process3 = require("node:child_process");
|
|
34980
|
-
var CONFIG_DIR2 =
|
|
34981
|
-
var UPDATE_CHECK_FILE =
|
|
35545
|
+
var CONFIG_DIR2 = path6.join(os3.homedir(), ".config", "reporting-bi");
|
|
35546
|
+
var UPDATE_CHECK_FILE = path6.join(CONFIG_DIR2, "update-check.json");
|
|
34982
35547
|
var CHECK_INTERVAL = 60 * 60 * 1e3;
|
|
34983
35548
|
var PACKAGE_NAME = "@reporting-bi/cli";
|
|
34984
35549
|
var INSTALL_PREFIX = detectPrefix();
|
|
34985
35550
|
function detectPrefix() {
|
|
34986
35551
|
try {
|
|
34987
|
-
const realPath =
|
|
34988
|
-
const libIndex = realPath.indexOf(
|
|
35552
|
+
const realPath = fs9.realpathSync(process.argv[1]);
|
|
35553
|
+
const libIndex = realPath.indexOf(path6.join("lib", "node_modules"));
|
|
34989
35554
|
if (libIndex > 0) {
|
|
34990
35555
|
const prefix = realPath.slice(0, libIndex - 1);
|
|
34991
35556
|
if (prefix !== "/usr" && prefix !== "/usr/local") return prefix;
|
|
@@ -35000,36 +35565,36 @@ function npmInstallCmd(version2) {
|
|
|
35000
35565
|
}
|
|
35001
35566
|
function loadUpdateCheck() {
|
|
35002
35567
|
try {
|
|
35003
|
-
return JSON.parse(
|
|
35568
|
+
return JSON.parse(fs9.readFileSync(UPDATE_CHECK_FILE, "utf-8"));
|
|
35004
35569
|
} catch {
|
|
35005
35570
|
return { lastCheck: 0 };
|
|
35006
35571
|
}
|
|
35007
35572
|
}
|
|
35008
35573
|
function saveUpdateCheck(data) {
|
|
35009
|
-
|
|
35010
|
-
|
|
35574
|
+
fs9.mkdirSync(CONFIG_DIR2, { recursive: true });
|
|
35575
|
+
fs9.writeFileSync(UPDATE_CHECK_FILE, JSON.stringify(data, null, 2));
|
|
35011
35576
|
}
|
|
35012
35577
|
function fetchLatestVersion() {
|
|
35013
|
-
return new Promise((
|
|
35578
|
+
return new Promise((resolve5) => {
|
|
35014
35579
|
const req = https.get(`https://registry.npmjs.org/${PACKAGE_NAME}/latest`, { timeout: 5e3 }, (res) => {
|
|
35015
35580
|
if (res.statusCode !== 200) {
|
|
35016
35581
|
res.resume();
|
|
35017
|
-
return
|
|
35582
|
+
return resolve5(null);
|
|
35018
35583
|
}
|
|
35019
35584
|
let body = "";
|
|
35020
35585
|
res.on("data", (chunk) => body += chunk);
|
|
35021
35586
|
res.on("end", () => {
|
|
35022
35587
|
try {
|
|
35023
|
-
|
|
35588
|
+
resolve5(JSON.parse(body).version ?? null);
|
|
35024
35589
|
} catch {
|
|
35025
|
-
|
|
35590
|
+
resolve5(null);
|
|
35026
35591
|
}
|
|
35027
35592
|
});
|
|
35028
35593
|
});
|
|
35029
|
-
req.on("error", () =>
|
|
35594
|
+
req.on("error", () => resolve5(null));
|
|
35030
35595
|
req.on("timeout", () => {
|
|
35031
35596
|
req.destroy();
|
|
35032
|
-
|
|
35597
|
+
resolve5(null);
|
|
35033
35598
|
});
|
|
35034
35599
|
});
|
|
35035
35600
|
}
|
|
@@ -35053,8 +35618,8 @@ async function checkForUpdate() {
|
|
|
35053
35618
|
saveUpdateCheck({ lastCheck: now });
|
|
35054
35619
|
const latest = await fetchLatestVersion();
|
|
35055
35620
|
if (!latest) return;
|
|
35056
|
-
if (!isNewer(latest, "0.1.
|
|
35057
|
-
console.log(`\x1B[33mUpdating ${PACKAGE_NAME} ${"0.1.
|
|
35621
|
+
if (!isNewer(latest, "0.1.3")) return;
|
|
35622
|
+
console.log(`\x1B[33mUpdating ${PACKAGE_NAME} ${"0.1.3"} \u2192 ${latest}...\x1B[0m`);
|
|
35058
35623
|
(0, import_node_child_process3.execSync)(npmInstallCmd(latest), { stdio: "inherit" });
|
|
35059
35624
|
console.log(`\x1B[32mUpdated to ${latest}.\x1B[0m`);
|
|
35060
35625
|
} catch {
|
|
@@ -35066,11 +35631,11 @@ async function forceUpdate() {
|
|
|
35066
35631
|
console.error("Could not fetch latest version from npm.");
|
|
35067
35632
|
process.exit(1);
|
|
35068
35633
|
}
|
|
35069
|
-
if (!isNewer(latest, "0.1.
|
|
35070
|
-
console.log(`Already up to date (${"0.1.
|
|
35634
|
+
if (!isNewer(latest, "0.1.3")) {
|
|
35635
|
+
console.log(`Already up to date (${"0.1.3"}).`);
|
|
35071
35636
|
return;
|
|
35072
35637
|
}
|
|
35073
|
-
console.log(`Updating ${PACKAGE_NAME} ${"0.1.
|
|
35638
|
+
console.log(`Updating ${PACKAGE_NAME} ${"0.1.3"} \u2192 ${latest}...`);
|
|
35074
35639
|
(0, import_node_child_process3.execSync)(npmInstallCmd(latest), { stdio: "inherit" });
|
|
35075
35640
|
console.log(`\x1B[32mUpdated to ${latest}.\x1B[0m`);
|
|
35076
35641
|
saveUpdateCheck({ lastCheck: Date.now() });
|
|
@@ -35086,7 +35651,7 @@ Commands:
|
|
|
35086
35651
|
logout [domain] Logout and revoke tokens (default: active connection)
|
|
35087
35652
|
use <domain> [--accounting <id>] Switch active connection and/or set accounting
|
|
35088
35653
|
status Show all connections and active status
|
|
35089
|
-
init [--connection <domain>] [--accounting <id>] Initialize .rpbi/config.json in current directory
|
|
35654
|
+
init [--connection <domain>] [--accounting <id>] [--type etl|wiki] Initialize .rpbi/config.json in current directory
|
|
35090
35655
|
update Force update to latest version from npm
|
|
35091
35656
|
mcp Start MCP server (for AI agents, stdio transport)
|
|
35092
35657
|
|
|
@@ -35101,8 +35666,9 @@ ETL:
|
|
|
35101
35666
|
etl search <query> Search threads
|
|
35102
35667
|
etl pull [--dir <path>] [--no-context] Pull all ETL threads, parameters, metadata & schema to local files
|
|
35103
35668
|
etl push [files...] [--dir <path>] [--force] Push modified/new .sql files back to server
|
|
35104
|
-
etl status [--dir <path>]
|
|
35669
|
+
etl status [--dir <path>] [--remote] [--json] Show local changes (--remote compares with server)
|
|
35105
35670
|
etl context [--dir <path>] Pull context only (schema & modules)
|
|
35671
|
+
etl watch [--dir <path>] [--debounce <ms>] Watch for file changes and auto-push (default debounce: 500ms)
|
|
35106
35672
|
|
|
35107
35673
|
Jobs:
|
|
35108
35674
|
jobs list List available jobs
|
|
@@ -35152,6 +35718,10 @@ Wiki:
|
|
|
35152
35718
|
wiki search <query> Search pages
|
|
35153
35719
|
wiki save [id] [--lang cs] [--name n] Save/create a page (content from --file, --content, or stdin)
|
|
35154
35720
|
wiki delete <id> [--lang cs] Delete a page
|
|
35721
|
+
wiki pull [--dir <path>] [--langs cs,en] Pull all wiki pages & files to local directory
|
|
35722
|
+
wiki push [files...] [--dir <path>] [--force] Push modified/new pages & files back to server
|
|
35723
|
+
wiki status [--dir <path>] [--remote] [--json] Show local changes (--remote compares with server)
|
|
35724
|
+
wiki watch [--dir <path>] [--debounce <ms>] Watch for file changes and auto-push (default debounce: 500ms)
|
|
35155
35725
|
|
|
35156
35726
|
Global options:
|
|
35157
35727
|
--json Output raw JSON instead of table format
|
|
@@ -35160,6 +35730,7 @@ Global options:
|
|
|
35160
35730
|
--limit <n> Limit to N results
|
|
35161
35731
|
--sort <col>[,col2,...] Sort by columns (prefix with - for desc)
|
|
35162
35732
|
--filter <expression> Filter results (server-side where clause)
|
|
35733
|
+
--verbose Show API request URLs for debugging
|
|
35163
35734
|
|
|
35164
35735
|
Default domain: https://reporting.bi
|
|
35165
35736
|
Default language: cs
|
|
@@ -35202,13 +35773,19 @@ Examples:
|
|
|
35202
35773
|
rpbi wiki search "query"
|
|
35203
35774
|
rpbi wiki save 42 --file ./page.md
|
|
35204
35775
|
cat doc.md | rpbi wiki save 42
|
|
35776
|
+
rpbi wiki pull
|
|
35777
|
+
rpbi wiki push
|
|
35778
|
+
rpbi wiki status --remote
|
|
35779
|
+
|
|
35780
|
+
rpbi etl watch
|
|
35781
|
+
rpbi wiki watch --debounce 1000
|
|
35205
35782
|
`;
|
|
35206
35783
|
|
|
35207
35784
|
// src/index.ts
|
|
35208
35785
|
(async () => {
|
|
35209
35786
|
const [command, ...args] = process.argv.slice(2);
|
|
35210
35787
|
if (command === "--version" || command === "-v") {
|
|
35211
|
-
console.log("0.1.
|
|
35788
|
+
console.log("0.1.3");
|
|
35212
35789
|
return;
|
|
35213
35790
|
}
|
|
35214
35791
|
await checkForUpdate();
|