@diafunc/cli 0.31.2 → 0.32.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/bin/diafunc.js +3 -3
- package/dist/{chunk-2BL23GQZ.js → chunk-BXPKOLZA.js} +2 -2
- package/dist/{chunk-2BL23GQZ.js.map → chunk-BXPKOLZA.js.map} +1 -1
- package/dist/{chunk-FP3ZMLXZ.js → chunk-FERQPITK.js} +1341 -428
- package/dist/chunk-FERQPITK.js.map +1 -0
- package/dist/{chunk-U554YXJR.js → chunk-TARRZIGI.js} +2 -2
- package/dist/src/index.js +2 -2
- package/dist/update-check-NBOU2XBP.js +8 -0
- package/package.json +1 -1
- package/dist/chunk-FP3ZMLXZ.js.map +0 -1
- package/dist/update-check-WNT76O6I.js +0 -8
- /package/dist/{chunk-U554YXJR.js.map → chunk-TARRZIGI.js.map} +0 -0
- /package/dist/{update-check-WNT76O6I.js.map → update-check-NBOU2XBP.js.map} +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
package_default
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-BXPKOLZA.js";
|
|
4
4
|
|
|
5
5
|
// src/index.ts
|
|
6
|
-
import
|
|
6
|
+
import chalk42 from "chalk";
|
|
7
7
|
|
|
8
8
|
// src/commands/auth/login.ts
|
|
9
9
|
import chalk4 from "chalk";
|
|
@@ -1628,8 +1628,8 @@ var ACRONYMS = /* @__PURE__ */ new Map([
|
|
|
1628
1628
|
["mcp", "MCP"]
|
|
1629
1629
|
]);
|
|
1630
1630
|
function recordLabel(key) {
|
|
1631
|
-
const
|
|
1632
|
-
const sentence =
|
|
1631
|
+
const words2 = humanizeKey(key).split(" ").filter((w) => w.length > 0).map((w) => ACRONYMS.get(w) ?? w);
|
|
1632
|
+
const sentence = words2.join(" ");
|
|
1633
1633
|
return sentence.charAt(0).toUpperCase() + sentence.slice(1);
|
|
1634
1634
|
}
|
|
1635
1635
|
function headerOf(spec) {
|
|
@@ -2095,12 +2095,12 @@ function createAnalysisService(client) {
|
|
|
2095
2095
|
path: "/last"
|
|
2096
2096
|
});
|
|
2097
2097
|
},
|
|
2098
|
-
async getRecent(
|
|
2098
|
+
async getRecent(count2 = 20) {
|
|
2099
2099
|
return client.request({
|
|
2100
2100
|
method: "GET",
|
|
2101
2101
|
service: SERVICE2,
|
|
2102
2102
|
path: "/recent",
|
|
2103
|
-
query: { count }
|
|
2103
|
+
query: { count: count2 }
|
|
2104
2104
|
});
|
|
2105
2105
|
},
|
|
2106
2106
|
async get(analysisId) {
|
|
@@ -2446,12 +2446,12 @@ function createAnalysisService(client) {
|
|
|
2446
2446
|
path: `/${encodeURIComponent(analysisId)}/runs`
|
|
2447
2447
|
});
|
|
2448
2448
|
},
|
|
2449
|
-
async getRunsForAnalysis(analysisId,
|
|
2449
|
+
async getRunsForAnalysis(analysisId, count2 = 20) {
|
|
2450
2450
|
return client.request({
|
|
2451
2451
|
method: "GET",
|
|
2452
2452
|
service: SERVICE2,
|
|
2453
2453
|
path: `/${encodeURIComponent(analysisId)}/runs`,
|
|
2454
|
-
query: { count }
|
|
2454
|
+
query: { count: count2 }
|
|
2455
2455
|
});
|
|
2456
2456
|
},
|
|
2457
2457
|
async getRun(runId) {
|
|
@@ -2539,13 +2539,85 @@ function createAnalysisService(client) {
|
|
|
2539
2539
|
};
|
|
2540
2540
|
}
|
|
2541
2541
|
|
|
2542
|
-
// src/client/services/
|
|
2543
|
-
var SERVICE3 = "
|
|
2542
|
+
// src/client/services/deployments.ts
|
|
2543
|
+
var SERVICE3 = "deployments";
|
|
2544
2544
|
function enc(s) {
|
|
2545
2545
|
return encodeURIComponent(s);
|
|
2546
2546
|
}
|
|
2547
|
+
function createDeploymentsService(client) {
|
|
2548
|
+
return {
|
|
2549
|
+
async list() {
|
|
2550
|
+
return client.request({ method: "GET", service: SERVICE3, path: "/" });
|
|
2551
|
+
},
|
|
2552
|
+
async get(deploymentId) {
|
|
2553
|
+
return client.request({ method: "GET", service: SERVICE3, path: `/${enc(deploymentId)}` });
|
|
2554
|
+
},
|
|
2555
|
+
async create(request) {
|
|
2556
|
+
return client.request({ method: "POST", service: SERVICE3, path: "/", body: request });
|
|
2557
|
+
},
|
|
2558
|
+
async delete(deploymentId) {
|
|
2559
|
+
return client.request({ method: "DELETE", service: SERVICE3, path: `/${enc(deploymentId)}` });
|
|
2560
|
+
},
|
|
2561
|
+
async update(deploymentId, request) {
|
|
2562
|
+
return client.request({
|
|
2563
|
+
method: "PATCH",
|
|
2564
|
+
service: SERVICE3,
|
|
2565
|
+
path: `/${enc(deploymentId)}`,
|
|
2566
|
+
body: request
|
|
2567
|
+
});
|
|
2568
|
+
},
|
|
2569
|
+
async predict(deploymentId, request) {
|
|
2570
|
+
return client.request({
|
|
2571
|
+
method: "POST",
|
|
2572
|
+
service: SERVICE3,
|
|
2573
|
+
path: `/${enc(deploymentId)}/predict`,
|
|
2574
|
+
body: request
|
|
2575
|
+
});
|
|
2576
|
+
},
|
|
2577
|
+
async predictBatch(deploymentId, request) {
|
|
2578
|
+
return client.request({
|
|
2579
|
+
method: "POST",
|
|
2580
|
+
service: SERVICE3,
|
|
2581
|
+
path: `/${enc(deploymentId)}/predict/batch`,
|
|
2582
|
+
body: request
|
|
2583
|
+
});
|
|
2584
|
+
},
|
|
2585
|
+
async recordOutcomes(deploymentId, request) {
|
|
2586
|
+
return client.request({
|
|
2587
|
+
method: "POST",
|
|
2588
|
+
service: SERVICE3,
|
|
2589
|
+
path: `/${enc(deploymentId)}/outcomes`,
|
|
2590
|
+
body: request
|
|
2591
|
+
});
|
|
2592
|
+
},
|
|
2593
|
+
async deletePrediction(deploymentId, predictionId) {
|
|
2594
|
+
return client.request({
|
|
2595
|
+
method: "DELETE",
|
|
2596
|
+
service: SERVICE3,
|
|
2597
|
+
path: `/${enc(deploymentId)}/predictions/${enc(predictionId)}`
|
|
2598
|
+
});
|
|
2599
|
+
},
|
|
2600
|
+
async monitoring(deploymentId, window) {
|
|
2601
|
+
return client.request({
|
|
2602
|
+
method: "GET",
|
|
2603
|
+
service: SERVICE3,
|
|
2604
|
+
path: `/${enc(deploymentId)}/monitoring`,
|
|
2605
|
+
query: { window }
|
|
2606
|
+
});
|
|
2607
|
+
},
|
|
2608
|
+
async serveNewestModel(deploymentId) {
|
|
2609
|
+
return client.request({ method: "POST", service: SERVICE3, path: `/${enc(deploymentId)}/model` });
|
|
2610
|
+
}
|
|
2611
|
+
};
|
|
2612
|
+
}
|
|
2613
|
+
|
|
2614
|
+
// src/client/services/storage.ts
|
|
2615
|
+
var SERVICE4 = "storage";
|
|
2616
|
+
function enc2(s) {
|
|
2617
|
+
return encodeURIComponent(s);
|
|
2618
|
+
}
|
|
2547
2619
|
function entityPath(ref) {
|
|
2548
|
-
return `/${
|
|
2620
|
+
return `/${enc2(ref.projectId)}/${enc2(ref.projectBranch)}/${enc2(ref.entityId)}/${enc2(ref.entityBranch)}`;
|
|
2549
2621
|
}
|
|
2550
2622
|
function exportTableQuery(options) {
|
|
2551
2623
|
const query = {};
|
|
@@ -2567,14 +2639,14 @@ function createStorageService(client) {
|
|
|
2567
2639
|
async entityExists(ref) {
|
|
2568
2640
|
return client.request({
|
|
2569
2641
|
method: "GET",
|
|
2570
|
-
service:
|
|
2642
|
+
service: SERVICE4,
|
|
2571
2643
|
path: `/entities/exists${entityPath(ref)}`
|
|
2572
2644
|
});
|
|
2573
2645
|
},
|
|
2574
2646
|
async getEntity(ref, content = false) {
|
|
2575
2647
|
return client.request({
|
|
2576
2648
|
method: "GET",
|
|
2577
|
-
service:
|
|
2649
|
+
service: SERVICE4,
|
|
2578
2650
|
path: `/entities/actual${entityPath(ref)}`,
|
|
2579
2651
|
query: content ? { content: true } : void 0
|
|
2580
2652
|
});
|
|
@@ -2582,14 +2654,14 @@ function createStorageService(client) {
|
|
|
2582
2654
|
async getEntityContent(ref) {
|
|
2583
2655
|
return client.requestRaw({
|
|
2584
2656
|
method: "GET",
|
|
2585
|
-
service:
|
|
2657
|
+
service: SERVICE4,
|
|
2586
2658
|
path: `/entities/contents/actual${entityPath(ref)}`
|
|
2587
2659
|
});
|
|
2588
2660
|
},
|
|
2589
2661
|
async saveEntities(entities) {
|
|
2590
2662
|
return client.request({
|
|
2591
2663
|
method: "PUT",
|
|
2592
|
-
service:
|
|
2664
|
+
service: SERVICE4,
|
|
2593
2665
|
path: "/entities/actual",
|
|
2594
2666
|
body: entities
|
|
2595
2667
|
});
|
|
@@ -2597,14 +2669,14 @@ function createStorageService(client) {
|
|
|
2597
2669
|
async deleteEntity(ref) {
|
|
2598
2670
|
return client.request({
|
|
2599
2671
|
method: "DELETE",
|
|
2600
|
-
service:
|
|
2672
|
+
service: SERVICE4,
|
|
2601
2673
|
path: `/entities/actual${entityPath(ref)}`
|
|
2602
2674
|
});
|
|
2603
2675
|
},
|
|
2604
2676
|
async saveEntityContentBase64(ref, base64Content) {
|
|
2605
2677
|
return client.request({
|
|
2606
2678
|
method: "PUT",
|
|
2607
|
-
service:
|
|
2679
|
+
service: SERVICE4,
|
|
2608
2680
|
path: `/entities/contents/actual${entityPath(ref)}`,
|
|
2609
2681
|
rawBody: base64Content,
|
|
2610
2682
|
contentType: "text/plain"
|
|
@@ -2613,7 +2685,7 @@ function createStorageService(client) {
|
|
|
2613
2685
|
async uploadEntityContent(ref, formData) {
|
|
2614
2686
|
return client.request({
|
|
2615
2687
|
method: "PUT",
|
|
2616
|
-
service:
|
|
2688
|
+
service: SERVICE4,
|
|
2617
2689
|
path: `/entities/contents/actual${entityPath(ref)}`,
|
|
2618
2690
|
rawBody: formData
|
|
2619
2691
|
});
|
|
@@ -2621,35 +2693,35 @@ function createStorageService(client) {
|
|
|
2621
2693
|
async deleteEntityContent(ref) {
|
|
2622
2694
|
return client.request({
|
|
2623
2695
|
method: "DELETE",
|
|
2624
|
-
service:
|
|
2696
|
+
service: SERVICE4,
|
|
2625
2697
|
path: `/entities/contents/actual${entityPath(ref)}`
|
|
2626
2698
|
});
|
|
2627
2699
|
},
|
|
2628
2700
|
async getEntityHistory(ref, version) {
|
|
2629
2701
|
return client.request({
|
|
2630
2702
|
method: "GET",
|
|
2631
|
-
service:
|
|
2703
|
+
service: SERVICE4,
|
|
2632
2704
|
path: `/entities/history${entityPath(ref)}/${version}`
|
|
2633
2705
|
});
|
|
2634
2706
|
},
|
|
2635
2707
|
async getEntityHistoryRange(ref, fromVersion, toVersion) {
|
|
2636
2708
|
return client.request({
|
|
2637
2709
|
method: "GET",
|
|
2638
|
-
service:
|
|
2710
|
+
service: SERVICE4,
|
|
2639
2711
|
path: `/entities/history${entityPath(ref)}/${fromVersion}/${toVersion}`
|
|
2640
2712
|
});
|
|
2641
2713
|
},
|
|
2642
2714
|
async renameEntity(ref, newEntityId) {
|
|
2643
2715
|
return client.request({
|
|
2644
2716
|
method: "PUT",
|
|
2645
|
-
service:
|
|
2646
|
-
path: `/entities/ids${entityPath(ref)}/${
|
|
2717
|
+
service: SERVICE4,
|
|
2718
|
+
path: `/entities/ids${entityPath(ref)}/${enc2(newEntityId)}`
|
|
2647
2719
|
});
|
|
2648
2720
|
},
|
|
2649
2721
|
async revertEntity(ref, version) {
|
|
2650
2722
|
return client.request({
|
|
2651
2723
|
method: "PUT",
|
|
2652
|
-
service:
|
|
2724
|
+
service: SERVICE4,
|
|
2653
2725
|
path: `/entities/revert${entityPath(ref)}/${version}`
|
|
2654
2726
|
});
|
|
2655
2727
|
},
|
|
@@ -2675,7 +2747,7 @@ function createStorageService(client) {
|
|
|
2675
2747
|
};
|
|
2676
2748
|
return client.request({
|
|
2677
2749
|
method: "POST",
|
|
2678
|
-
service:
|
|
2750
|
+
service: SERVICE4,
|
|
2679
2751
|
path: "/transactions/",
|
|
2680
2752
|
body: transaction
|
|
2681
2753
|
});
|
|
@@ -2684,25 +2756,25 @@ function createStorageService(client) {
|
|
|
2684
2756
|
async searchEntityIds(projectId, projectBranch, body) {
|
|
2685
2757
|
return client.request({
|
|
2686
2758
|
method: "POST",
|
|
2687
|
-
service:
|
|
2759
|
+
service: SERVICE4,
|
|
2688
2760
|
path: "/entity-ids/search",
|
|
2689
2761
|
body
|
|
2690
2762
|
});
|
|
2691
2763
|
},
|
|
2692
2764
|
// --- Linked Entities ---
|
|
2693
2765
|
async getLinkedEntities(direction, ref, linkId) {
|
|
2694
|
-
const byLink = linkId ? `/${
|
|
2766
|
+
const byLink = linkId ? `/${enc2(linkId)}` : "";
|
|
2695
2767
|
return client.request({
|
|
2696
2768
|
method: "GET",
|
|
2697
|
-
service:
|
|
2698
|
-
path: `/linked-entities/${
|
|
2769
|
+
service: SERVICE4,
|
|
2770
|
+
path: `/linked-entities/${enc2(direction)}${entityPath(ref)}${byLink}`
|
|
2699
2771
|
});
|
|
2700
2772
|
},
|
|
2701
2773
|
async saveLinkedEntities(ref, linkId, entities) {
|
|
2702
2774
|
return client.request({
|
|
2703
2775
|
method: "PUT",
|
|
2704
|
-
service:
|
|
2705
|
-
path: `/linked-entities/${
|
|
2776
|
+
service: SERVICE4,
|
|
2777
|
+
path: `/linked-entities/${enc2(ref.projectId)}/${enc2(ref.projectBranch)}/${enc2(ref.entityId)}/${enc2(ref.entityBranch)}/${enc2(linkId)}`,
|
|
2706
2778
|
body: entities
|
|
2707
2779
|
});
|
|
2708
2780
|
},
|
|
@@ -2710,33 +2782,33 @@ function createStorageService(client) {
|
|
|
2710
2782
|
async getLinks(direction, ref) {
|
|
2711
2783
|
return client.request({
|
|
2712
2784
|
method: "GET",
|
|
2713
|
-
service:
|
|
2714
|
-
path: `/links/actual/${
|
|
2785
|
+
service: SERVICE4,
|
|
2786
|
+
path: `/links/actual/${enc2(direction)}${entityPath(ref)}`
|
|
2715
2787
|
});
|
|
2716
2788
|
},
|
|
2717
2789
|
async getLinkIds(direction, ref) {
|
|
2718
2790
|
return client.request({
|
|
2719
2791
|
method: "GET",
|
|
2720
|
-
service:
|
|
2721
|
-
path: `/links/ids/actual/${
|
|
2792
|
+
service: SERVICE4,
|
|
2793
|
+
path: `/links/ids/actual/${enc2(direction)}${entityPath(ref)}`
|
|
2722
2794
|
});
|
|
2723
2795
|
},
|
|
2724
2796
|
async createLink(projectId, projectBranch, sourceEntityId, sourceEntityBranch, linkId, targetEntityId, targetEntityBranch, link) {
|
|
2725
2797
|
return client.request({
|
|
2726
2798
|
method: "POST",
|
|
2727
|
-
service:
|
|
2728
|
-
path: `/links/actual/${
|
|
2799
|
+
service: SERVICE4,
|
|
2800
|
+
path: `/links/actual/${enc2(projectId)}/${enc2(projectBranch)}/${enc2(sourceEntityId)}/${enc2(sourceEntityBranch)}/${enc2(linkId)}/${enc2(targetEntityId)}/${enc2(targetEntityBranch)}`,
|
|
2729
2801
|
body: link
|
|
2730
2802
|
});
|
|
2731
2803
|
},
|
|
2732
2804
|
async deleteLink(projectId, projectBranch, sourceEntityId, sourceEntityBranch, linkId, targetEntityId, targetEntityBranch) {
|
|
2733
|
-
let path13 = `/links/actual/${
|
|
2805
|
+
let path13 = `/links/actual/${enc2(projectId)}/${enc2(projectBranch)}/${enc2(sourceEntityId)}/${enc2(sourceEntityBranch)}/${enc2(linkId)}`;
|
|
2734
2806
|
if (targetEntityId && targetEntityBranch) {
|
|
2735
|
-
path13 += `/${
|
|
2807
|
+
path13 += `/${enc2(targetEntityId)}/${enc2(targetEntityBranch)}`;
|
|
2736
2808
|
}
|
|
2737
2809
|
return client.request({
|
|
2738
2810
|
method: "DELETE",
|
|
2739
|
-
service:
|
|
2811
|
+
service: SERVICE4,
|
|
2740
2812
|
path: path13
|
|
2741
2813
|
});
|
|
2742
2814
|
},
|
|
@@ -2744,21 +2816,21 @@ function createStorageService(client) {
|
|
|
2744
2816
|
async getEvents(ref) {
|
|
2745
2817
|
return client.request({
|
|
2746
2818
|
method: "GET",
|
|
2747
|
-
service:
|
|
2819
|
+
service: SERVICE4,
|
|
2748
2820
|
path: `/events/actual${entityPath(ref)}`
|
|
2749
2821
|
});
|
|
2750
2822
|
},
|
|
2751
2823
|
async getEvent(ref, eventId, occurrenceId) {
|
|
2752
2824
|
return client.request({
|
|
2753
2825
|
method: "GET",
|
|
2754
|
-
service:
|
|
2755
|
-
path: `/events/actual${entityPath(ref)}/${
|
|
2826
|
+
service: SERVICE4,
|
|
2827
|
+
path: `/events/actual${entityPath(ref)}/${enc2(eventId)}/${enc2(occurrenceId)}`
|
|
2756
2828
|
});
|
|
2757
2829
|
},
|
|
2758
2830
|
async createEvents(events) {
|
|
2759
2831
|
return client.request({
|
|
2760
2832
|
method: "POST",
|
|
2761
|
-
service:
|
|
2833
|
+
service: SERVICE4,
|
|
2762
2834
|
path: "/events/",
|
|
2763
2835
|
body: events
|
|
2764
2836
|
});
|
|
@@ -2766,7 +2838,7 @@ function createStorageService(client) {
|
|
|
2766
2838
|
async consumeEvents(body) {
|
|
2767
2839
|
return client.request({
|
|
2768
2840
|
method: "POST",
|
|
2769
|
-
service:
|
|
2841
|
+
service: SERVICE4,
|
|
2770
2842
|
path: "/events/consume",
|
|
2771
2843
|
body
|
|
2772
2844
|
});
|
|
@@ -2774,15 +2846,15 @@ function createStorageService(client) {
|
|
|
2774
2846
|
async deleteEvent(ref, eventId, occurrenceId) {
|
|
2775
2847
|
return client.request({
|
|
2776
2848
|
method: "DELETE",
|
|
2777
|
-
service:
|
|
2778
|
-
path: `/events/actual${entityPath(ref)}/${
|
|
2849
|
+
service: SERVICE4,
|
|
2850
|
+
path: `/events/actual${entityPath(ref)}/${enc2(eventId)}/${enc2(occurrenceId)}`
|
|
2779
2851
|
});
|
|
2780
2852
|
},
|
|
2781
2853
|
// --- Tables ---
|
|
2782
2854
|
async getTableSnapshot(ref, request) {
|
|
2783
2855
|
return client.request({
|
|
2784
2856
|
method: "POST",
|
|
2785
|
-
service:
|
|
2857
|
+
service: SERVICE4,
|
|
2786
2858
|
path: `/tables${entityPath(ref)}/snapshots`,
|
|
2787
2859
|
body: request ?? {}
|
|
2788
2860
|
});
|
|
@@ -2790,78 +2862,78 @@ function createStorageService(client) {
|
|
|
2790
2862
|
async appendRow(ref) {
|
|
2791
2863
|
return client.request({
|
|
2792
2864
|
method: "POST",
|
|
2793
|
-
service:
|
|
2865
|
+
service: SERVICE4,
|
|
2794
2866
|
path: `/tables${entityPath(ref)}/rows`
|
|
2795
2867
|
});
|
|
2796
2868
|
},
|
|
2797
2869
|
async insertRow(ref, rowIndex) {
|
|
2798
2870
|
return client.request({
|
|
2799
2871
|
method: "POST",
|
|
2800
|
-
service:
|
|
2872
|
+
service: SERVICE4,
|
|
2801
2873
|
path: `/tables${entityPath(ref)}/rows/${rowIndex}/insert`
|
|
2802
2874
|
});
|
|
2803
2875
|
},
|
|
2804
2876
|
async removeRow(ref, rowIndex) {
|
|
2805
2877
|
return client.request({
|
|
2806
2878
|
method: "DELETE",
|
|
2807
|
-
service:
|
|
2879
|
+
service: SERVICE4,
|
|
2808
2880
|
path: `/tables${entityPath(ref)}/rows/${rowIndex}`
|
|
2809
2881
|
});
|
|
2810
2882
|
},
|
|
2811
2883
|
async deleteRow(ref, rowIndex) {
|
|
2812
2884
|
return client.request({
|
|
2813
2885
|
method: "POST",
|
|
2814
|
-
service:
|
|
2886
|
+
service: SERVICE4,
|
|
2815
2887
|
path: `/tables${entityPath(ref)}/rows/${rowIndex}/delete`
|
|
2816
2888
|
});
|
|
2817
2889
|
},
|
|
2818
2890
|
async appendColumn(ref) {
|
|
2819
2891
|
return client.request({
|
|
2820
2892
|
method: "POST",
|
|
2821
|
-
service:
|
|
2893
|
+
service: SERVICE4,
|
|
2822
2894
|
path: `/tables${entityPath(ref)}/columns`
|
|
2823
2895
|
});
|
|
2824
2896
|
},
|
|
2825
|
-
async insertColumn(ref,
|
|
2897
|
+
async insertColumn(ref, columnIndex2) {
|
|
2826
2898
|
return client.request({
|
|
2827
2899
|
method: "POST",
|
|
2828
|
-
service:
|
|
2829
|
-
path: `/tables${entityPath(ref)}/columns/${
|
|
2900
|
+
service: SERVICE4,
|
|
2901
|
+
path: `/tables${entityPath(ref)}/columns/${columnIndex2}/insert`
|
|
2830
2902
|
});
|
|
2831
2903
|
},
|
|
2832
|
-
async removeColumn(ref,
|
|
2904
|
+
async removeColumn(ref, columnIndex2) {
|
|
2833
2905
|
return client.request({
|
|
2834
2906
|
method: "DELETE",
|
|
2835
|
-
service:
|
|
2836
|
-
path: `/tables${entityPath(ref)}/columns/${
|
|
2907
|
+
service: SERVICE4,
|
|
2908
|
+
path: `/tables${entityPath(ref)}/columns/${columnIndex2}`
|
|
2837
2909
|
});
|
|
2838
2910
|
},
|
|
2839
|
-
async deleteColumn(ref,
|
|
2911
|
+
async deleteColumn(ref, columnIndex2) {
|
|
2840
2912
|
return client.request({
|
|
2841
2913
|
method: "POST",
|
|
2842
|
-
service:
|
|
2843
|
-
path: `/tables${entityPath(ref)}/columns/${
|
|
2914
|
+
service: SERVICE4,
|
|
2915
|
+
path: `/tables${entityPath(ref)}/columns/${columnIndex2}/delete`
|
|
2844
2916
|
});
|
|
2845
2917
|
},
|
|
2846
2918
|
async mergeCells(ref, cells) {
|
|
2847
2919
|
return client.request({
|
|
2848
2920
|
method: "PUT",
|
|
2849
|
-
service:
|
|
2921
|
+
service: SERVICE4,
|
|
2850
2922
|
path: `/tables${entityPath(ref)}/cells`,
|
|
2851
2923
|
body: cells
|
|
2852
2924
|
});
|
|
2853
2925
|
},
|
|
2854
|
-
async removeCell(ref, rowIndex,
|
|
2926
|
+
async removeCell(ref, rowIndex, columnIndex2) {
|
|
2855
2927
|
return client.request({
|
|
2856
2928
|
method: "DELETE",
|
|
2857
|
-
service:
|
|
2858
|
-
path: `/tables${entityPath(ref)}/cells/${rowIndex}/${
|
|
2929
|
+
service: SERVICE4,
|
|
2930
|
+
path: `/tables${entityPath(ref)}/cells/${rowIndex}/${columnIndex2}`
|
|
2859
2931
|
});
|
|
2860
2932
|
},
|
|
2861
2933
|
async clearTable(ref) {
|
|
2862
2934
|
return client.request({
|
|
2863
2935
|
method: "POST",
|
|
2864
|
-
service:
|
|
2936
|
+
service: SERVICE4,
|
|
2865
2937
|
path: `/tables${entityPath(ref)}/clear`
|
|
2866
2938
|
});
|
|
2867
2939
|
},
|
|
@@ -2871,7 +2943,7 @@ function createStorageService(client) {
|
|
|
2871
2943
|
if (selection) query.selection = selection;
|
|
2872
2944
|
return client.request({
|
|
2873
2945
|
method: "PUT",
|
|
2874
|
-
service:
|
|
2946
|
+
service: SERVICE4,
|
|
2875
2947
|
path: `/table-imports${entityPath(ref)}`,
|
|
2876
2948
|
query: Object.keys(query).length > 0 ? query : void 0,
|
|
2877
2949
|
rawBody: formData
|
|
@@ -2880,15 +2952,15 @@ function createStorageService(client) {
|
|
|
2880
2952
|
async getSupportedImportFormats() {
|
|
2881
2953
|
return client.request({
|
|
2882
2954
|
method: "GET",
|
|
2883
|
-
service:
|
|
2955
|
+
service: SERVICE4,
|
|
2884
2956
|
path: `/table-imports/supported-formats`
|
|
2885
2957
|
});
|
|
2886
2958
|
},
|
|
2887
2959
|
async getImport(ref, importId) {
|
|
2888
2960
|
return client.request({
|
|
2889
2961
|
method: "GET",
|
|
2890
|
-
service:
|
|
2891
|
-
path: `/imports${entityPath(ref)}/${
|
|
2962
|
+
service: SERVICE4,
|
|
2963
|
+
path: `/imports${entityPath(ref)}/${enc2(importId)}`
|
|
2892
2964
|
});
|
|
2893
2965
|
},
|
|
2894
2966
|
/**
|
|
@@ -2900,8 +2972,8 @@ function createStorageService(client) {
|
|
|
2900
2972
|
const query = exportTableQuery(options);
|
|
2901
2973
|
return client.request({
|
|
2902
2974
|
method: "POST",
|
|
2903
|
-
service:
|
|
2904
|
-
path: `/table-exports${entityPath(ref)}/${
|
|
2975
|
+
service: SERVICE4,
|
|
2976
|
+
path: `/table-exports${entityPath(ref)}/${enc2(format2)}`,
|
|
2905
2977
|
query: Object.keys(query).length > 0 ? query : void 0
|
|
2906
2978
|
});
|
|
2907
2979
|
},
|
|
@@ -2916,8 +2988,8 @@ function createStorageService(client) {
|
|
|
2916
2988
|
const query = exportTableQuery(options);
|
|
2917
2989
|
return client.requestRaw({
|
|
2918
2990
|
method: "POST",
|
|
2919
|
-
service:
|
|
2920
|
-
path: `/table-exports${entityPath(ref)}/${
|
|
2991
|
+
service: SERVICE4,
|
|
2992
|
+
path: `/table-exports${entityPath(ref)}/${enc2(format2)}/stream`,
|
|
2921
2993
|
query: Object.keys(query).length > 0 ? query : void 0
|
|
2922
2994
|
});
|
|
2923
2995
|
},
|
|
@@ -2930,7 +3002,7 @@ function createStorageService(client) {
|
|
|
2930
3002
|
async getSupportedExportFormats() {
|
|
2931
3003
|
return client.request({
|
|
2932
3004
|
method: "GET",
|
|
2933
|
-
service:
|
|
3005
|
+
service: SERVICE4,
|
|
2934
3006
|
path: `/table-exports/supported-formats`
|
|
2935
3007
|
});
|
|
2936
3008
|
},
|
|
@@ -2938,7 +3010,7 @@ function createStorageService(client) {
|
|
|
2938
3010
|
async listExports(ref) {
|
|
2939
3011
|
return client.request({
|
|
2940
3012
|
method: "GET",
|
|
2941
|
-
service:
|
|
3013
|
+
service: SERVICE4,
|
|
2942
3014
|
path: `/exports${entityPath(ref)}`
|
|
2943
3015
|
});
|
|
2944
3016
|
},
|
|
@@ -2951,22 +3023,22 @@ function createStorageService(client) {
|
|
|
2951
3023
|
async downloadExport(ref, exportId, filename) {
|
|
2952
3024
|
return client.requestRaw({
|
|
2953
3025
|
method: "GET",
|
|
2954
|
-
service:
|
|
2955
|
-
path: `/exports${entityPath(ref)}/${
|
|
3026
|
+
service: SERVICE4,
|
|
3027
|
+
path: `/exports${entityPath(ref)}/${enc2(exportId)}/${enc2(filename)}`
|
|
2956
3028
|
});
|
|
2957
3029
|
},
|
|
2958
3030
|
// --- Branches ---
|
|
2959
3031
|
async getProjectBranches(projectId) {
|
|
2960
3032
|
return client.request({
|
|
2961
3033
|
method: "GET",
|
|
2962
|
-
service:
|
|
2963
|
-
path: `/project-branches/${
|
|
3034
|
+
service: SERVICE4,
|
|
3035
|
+
path: `/project-branches/${enc2(projectId)}`
|
|
2964
3036
|
});
|
|
2965
3037
|
},
|
|
2966
3038
|
async createProjectBranch(request) {
|
|
2967
3039
|
return client.request({
|
|
2968
3040
|
method: "POST",
|
|
2969
|
-
service:
|
|
3041
|
+
service: SERVICE4,
|
|
2970
3042
|
path: "/project-branches/",
|
|
2971
3043
|
body: request
|
|
2972
3044
|
});
|
|
@@ -2974,21 +3046,21 @@ function createStorageService(client) {
|
|
|
2974
3046
|
async deleteProjectBranch(projectId, projectBranch) {
|
|
2975
3047
|
return client.request({
|
|
2976
3048
|
method: "DELETE",
|
|
2977
|
-
service:
|
|
2978
|
-
path: `/project-branches/${
|
|
3049
|
+
service: SERVICE4,
|
|
3050
|
+
path: `/project-branches/${enc2(projectId)}/${enc2(projectBranch)}`
|
|
2979
3051
|
});
|
|
2980
3052
|
},
|
|
2981
3053
|
async getEntityBranches(projectId, projectBranch, entityId) {
|
|
2982
3054
|
return client.request({
|
|
2983
3055
|
method: "GET",
|
|
2984
|
-
service:
|
|
2985
|
-
path: `/entity-branches/${
|
|
3056
|
+
service: SERVICE4,
|
|
3057
|
+
path: `/entity-branches/${enc2(projectId)}/${enc2(projectBranch)}/${enc2(entityId)}`
|
|
2986
3058
|
});
|
|
2987
3059
|
},
|
|
2988
3060
|
async createEntityBranch(request) {
|
|
2989
3061
|
return client.request({
|
|
2990
3062
|
method: "POST",
|
|
2991
|
-
service:
|
|
3063
|
+
service: SERVICE4,
|
|
2992
3064
|
path: "/entity-branches/",
|
|
2993
3065
|
body: request
|
|
2994
3066
|
});
|
|
@@ -2997,7 +3069,7 @@ function createStorageService(client) {
|
|
|
2997
3069
|
async merge(request) {
|
|
2998
3070
|
return client.request({
|
|
2999
3071
|
method: "POST",
|
|
3000
|
-
service:
|
|
3072
|
+
service: SERVICE4,
|
|
3001
3073
|
path: "/merge/",
|
|
3002
3074
|
body: request
|
|
3003
3075
|
});
|
|
@@ -3005,7 +3077,7 @@ function createStorageService(client) {
|
|
|
3005
3077
|
async fork(request) {
|
|
3006
3078
|
return client.request({
|
|
3007
3079
|
method: "POST",
|
|
3008
|
-
service:
|
|
3080
|
+
service: SERVICE4,
|
|
3009
3081
|
path: "/fork/",
|
|
3010
3082
|
body: request
|
|
3011
3083
|
});
|
|
@@ -3014,8 +3086,8 @@ function createStorageService(client) {
|
|
|
3014
3086
|
async searchProject(projectId, projectBranch, body) {
|
|
3015
3087
|
return client.request({
|
|
3016
3088
|
method: "POST",
|
|
3017
|
-
service:
|
|
3018
|
-
path: `/project-searches/${
|
|
3089
|
+
service: SERVICE4,
|
|
3090
|
+
path: `/project-searches/${enc2(projectId)}/${enc2(projectBranch)}`,
|
|
3019
3091
|
body
|
|
3020
3092
|
});
|
|
3021
3093
|
},
|
|
@@ -3023,21 +3095,21 @@ function createStorageService(client) {
|
|
|
3023
3095
|
async createShortTermProjectBackup() {
|
|
3024
3096
|
return client.request({
|
|
3025
3097
|
method: "POST",
|
|
3026
|
-
service:
|
|
3098
|
+
service: SERVICE4,
|
|
3027
3099
|
path: "/backups/project/short-term/create"
|
|
3028
3100
|
});
|
|
3029
3101
|
},
|
|
3030
3102
|
async createLongTermProjectBackup() {
|
|
3031
3103
|
return client.request({
|
|
3032
3104
|
method: "POST",
|
|
3033
|
-
service:
|
|
3105
|
+
service: SERVICE4,
|
|
3034
3106
|
path: "/backups/project/long-term/create"
|
|
3035
3107
|
});
|
|
3036
3108
|
},
|
|
3037
3109
|
async restoreProjectBackup(request) {
|
|
3038
3110
|
return client.request({
|
|
3039
3111
|
method: "POST",
|
|
3040
|
-
service:
|
|
3112
|
+
service: SERVICE4,
|
|
3041
3113
|
path: "/backups/project/restore",
|
|
3042
3114
|
body: request
|
|
3043
3115
|
});
|
|
@@ -3045,21 +3117,21 @@ function createStorageService(client) {
|
|
|
3045
3117
|
async createShortTermFullBackup() {
|
|
3046
3118
|
return client.request({
|
|
3047
3119
|
method: "POST",
|
|
3048
|
-
service:
|
|
3120
|
+
service: SERVICE4,
|
|
3049
3121
|
path: "/backups/full/short-term/create"
|
|
3050
3122
|
});
|
|
3051
3123
|
},
|
|
3052
3124
|
async createLongTermFullBackup() {
|
|
3053
3125
|
return client.request({
|
|
3054
3126
|
method: "POST",
|
|
3055
|
-
service:
|
|
3127
|
+
service: SERVICE4,
|
|
3056
3128
|
path: "/backups/full/long-term/create"
|
|
3057
3129
|
});
|
|
3058
3130
|
},
|
|
3059
3131
|
async restoreFullBackup(request) {
|
|
3060
3132
|
return client.request({
|
|
3061
3133
|
method: "POST",
|
|
3062
|
-
service:
|
|
3134
|
+
service: SERVICE4,
|
|
3063
3135
|
path: "/backups/full/restore",
|
|
3064
3136
|
body: request
|
|
3065
3137
|
});
|
|
@@ -3070,14 +3142,14 @@ function createStorageService(client) {
|
|
|
3070
3142
|
async listUserDefinedExporters() {
|
|
3071
3143
|
return client.request({
|
|
3072
3144
|
method: "GET",
|
|
3073
|
-
service:
|
|
3145
|
+
service: SERVICE4,
|
|
3074
3146
|
path: `/table-exporters`
|
|
3075
3147
|
});
|
|
3076
3148
|
},
|
|
3077
3149
|
async registerUserDefinedExporter(request) {
|
|
3078
3150
|
return client.request({
|
|
3079
3151
|
method: "POST",
|
|
3080
|
-
service:
|
|
3152
|
+
service: SERVICE4,
|
|
3081
3153
|
path: `/table-exporters`,
|
|
3082
3154
|
body: request
|
|
3083
3155
|
});
|
|
@@ -3085,15 +3157,15 @@ function createStorageService(client) {
|
|
|
3085
3157
|
async deleteUserDefinedExporter(id) {
|
|
3086
3158
|
await client.request({
|
|
3087
3159
|
method: "DELETE",
|
|
3088
|
-
service:
|
|
3089
|
-
path: `/table-exporters/${
|
|
3160
|
+
service: SERVICE4,
|
|
3161
|
+
path: `/table-exporters/${enc2(id)}`
|
|
3090
3162
|
});
|
|
3091
3163
|
},
|
|
3092
3164
|
// --- Data sources ---
|
|
3093
3165
|
async createDataSource(request) {
|
|
3094
3166
|
return client.request({
|
|
3095
3167
|
method: "POST",
|
|
3096
|
-
service:
|
|
3168
|
+
service: SERVICE4,
|
|
3097
3169
|
path: `/data-sources`,
|
|
3098
3170
|
body: request
|
|
3099
3171
|
});
|
|
@@ -3101,7 +3173,7 @@ function createStorageService(client) {
|
|
|
3101
3173
|
async listDataSources(projectId) {
|
|
3102
3174
|
return client.request({
|
|
3103
3175
|
method: "GET",
|
|
3104
|
-
service:
|
|
3176
|
+
service: SERVICE4,
|
|
3105
3177
|
path: `/data-sources`,
|
|
3106
3178
|
query: projectId ? { projectId } : void 0
|
|
3107
3179
|
});
|
|
@@ -3109,7 +3181,7 @@ function createStorageService(client) {
|
|
|
3109
3181
|
async getDataSourceDashboard(projectId) {
|
|
3110
3182
|
return client.request({
|
|
3111
3183
|
method: "GET",
|
|
3112
|
-
service:
|
|
3184
|
+
service: SERVICE4,
|
|
3113
3185
|
path: `/data-sources/dashboard`,
|
|
3114
3186
|
query: { projectId }
|
|
3115
3187
|
});
|
|
@@ -3117,51 +3189,51 @@ function createStorageService(client) {
|
|
|
3117
3189
|
async getDataSource(id) {
|
|
3118
3190
|
return client.request({
|
|
3119
3191
|
method: "GET",
|
|
3120
|
-
service:
|
|
3121
|
-
path: `/data-sources/${
|
|
3192
|
+
service: SERVICE4,
|
|
3193
|
+
path: `/data-sources/${enc2(id)}`
|
|
3122
3194
|
});
|
|
3123
3195
|
},
|
|
3124
3196
|
async updateDataSource(id, request) {
|
|
3125
3197
|
return client.request({
|
|
3126
3198
|
method: "PUT",
|
|
3127
|
-
service:
|
|
3128
|
-
path: `/data-sources/${
|
|
3199
|
+
service: SERVICE4,
|
|
3200
|
+
path: `/data-sources/${enc2(id)}`,
|
|
3129
3201
|
body: request
|
|
3130
3202
|
});
|
|
3131
3203
|
},
|
|
3132
3204
|
async deleteDataSource(id) {
|
|
3133
3205
|
await client.request({
|
|
3134
3206
|
method: "DELETE",
|
|
3135
|
-
service:
|
|
3136
|
-
path: `/data-sources/${
|
|
3207
|
+
service: SERVICE4,
|
|
3208
|
+
path: `/data-sources/${enc2(id)}`
|
|
3137
3209
|
});
|
|
3138
3210
|
},
|
|
3139
3211
|
async refreshDataSource(id) {
|
|
3140
3212
|
return client.request({
|
|
3141
3213
|
method: "POST",
|
|
3142
|
-
service:
|
|
3143
|
-
path: `/data-sources/${
|
|
3214
|
+
service: SERVICE4,
|
|
3215
|
+
path: `/data-sources/${enc2(id)}/refresh`
|
|
3144
3216
|
});
|
|
3145
3217
|
},
|
|
3146
3218
|
async listDataSourceRuns(id, limit) {
|
|
3147
3219
|
return client.request({
|
|
3148
3220
|
method: "GET",
|
|
3149
|
-
service:
|
|
3150
|
-
path: `/data-sources/${
|
|
3221
|
+
service: SERVICE4,
|
|
3222
|
+
path: `/data-sources/${enc2(id)}/runs`,
|
|
3151
3223
|
query: limit !== void 0 ? { limit } : void 0
|
|
3152
3224
|
});
|
|
3153
3225
|
},
|
|
3154
3226
|
async getDataSourceRun(id, runId) {
|
|
3155
3227
|
return client.request({
|
|
3156
3228
|
method: "GET",
|
|
3157
|
-
service:
|
|
3158
|
-
path: `/data-sources/${
|
|
3229
|
+
service: SERVICE4,
|
|
3230
|
+
path: `/data-sources/${enc2(id)}/runs/${enc2(runId)}`
|
|
3159
3231
|
});
|
|
3160
3232
|
},
|
|
3161
3233
|
async listDataSourceConnectorTypes() {
|
|
3162
3234
|
return client.request({
|
|
3163
3235
|
method: "GET",
|
|
3164
|
-
service:
|
|
3236
|
+
service: SERVICE4,
|
|
3165
3237
|
path: `/data-sources/types`
|
|
3166
3238
|
});
|
|
3167
3239
|
},
|
|
@@ -3169,7 +3241,7 @@ function createStorageService(client) {
|
|
|
3169
3241
|
async createSkeleton(request) {
|
|
3170
3242
|
return client.request({
|
|
3171
3243
|
method: "POST",
|
|
3172
|
-
service:
|
|
3244
|
+
service: SERVICE4,
|
|
3173
3245
|
path: `/skeletons`,
|
|
3174
3246
|
body: request
|
|
3175
3247
|
});
|
|
@@ -3177,7 +3249,7 @@ function createStorageService(client) {
|
|
|
3177
3249
|
async listSkeletons(projectId) {
|
|
3178
3250
|
return client.request({
|
|
3179
3251
|
method: "GET",
|
|
3180
|
-
service:
|
|
3252
|
+
service: SERVICE4,
|
|
3181
3253
|
path: `/skeletons`,
|
|
3182
3254
|
query: { projectId }
|
|
3183
3255
|
});
|
|
@@ -3185,23 +3257,23 @@ function createStorageService(client) {
|
|
|
3185
3257
|
async getSkeleton(id) {
|
|
3186
3258
|
return client.request({
|
|
3187
3259
|
method: "GET",
|
|
3188
|
-
service:
|
|
3189
|
-
path: `/skeletons/${
|
|
3260
|
+
service: SERVICE4,
|
|
3261
|
+
path: `/skeletons/${enc2(id)}`
|
|
3190
3262
|
});
|
|
3191
3263
|
},
|
|
3192
3264
|
async updateSkeleton(id, request) {
|
|
3193
3265
|
return client.request({
|
|
3194
3266
|
method: "PUT",
|
|
3195
|
-
service:
|
|
3196
|
-
path: `/skeletons/${
|
|
3267
|
+
service: SERVICE4,
|
|
3268
|
+
path: `/skeletons/${enc2(id)}`,
|
|
3197
3269
|
body: request
|
|
3198
3270
|
});
|
|
3199
3271
|
},
|
|
3200
3272
|
async deleteSkeleton(id) {
|
|
3201
3273
|
await client.request({
|
|
3202
3274
|
method: "DELETE",
|
|
3203
|
-
service:
|
|
3204
|
-
path: `/skeletons/${
|
|
3275
|
+
service: SERVICE4,
|
|
3276
|
+
path: `/skeletons/${enc2(id)}`
|
|
3205
3277
|
});
|
|
3206
3278
|
},
|
|
3207
3279
|
// --- Notebook bundles ---
|
|
@@ -3209,8 +3281,8 @@ function createStorageService(client) {
|
|
|
3209
3281
|
async exportBundle(projectId, projectBranch, request) {
|
|
3210
3282
|
return client.request({
|
|
3211
3283
|
method: "POST",
|
|
3212
|
-
service:
|
|
3213
|
-
path: `/notebook-bundles/${
|
|
3284
|
+
service: SERVICE4,
|
|
3285
|
+
path: `/notebook-bundles/${enc2(projectId)}/${enc2(projectBranch)}/export`,
|
|
3214
3286
|
body: request
|
|
3215
3287
|
});
|
|
3216
3288
|
},
|
|
@@ -3218,8 +3290,8 @@ function createStorageService(client) {
|
|
|
3218
3290
|
async streamBundle(projectId, projectBranch, request) {
|
|
3219
3291
|
return client.requestRaw({
|
|
3220
3292
|
method: "POST",
|
|
3221
|
-
service:
|
|
3222
|
-
path: `/notebook-bundles/${
|
|
3293
|
+
service: SERVICE4,
|
|
3294
|
+
path: `/notebook-bundles/${enc2(projectId)}/${enc2(projectBranch)}/export/stream`,
|
|
3223
3295
|
body: request
|
|
3224
3296
|
});
|
|
3225
3297
|
},
|
|
@@ -3227,16 +3299,16 @@ function createStorageService(client) {
|
|
|
3227
3299
|
async exportProjectBundle(projectId, projectBranch) {
|
|
3228
3300
|
return client.request({
|
|
3229
3301
|
method: "POST",
|
|
3230
|
-
service:
|
|
3231
|
-
path: `/project-bundles/${
|
|
3302
|
+
service: SERVICE4,
|
|
3303
|
+
path: `/project-bundles/${enc2(projectId)}/${enc2(projectBranch)}/export`
|
|
3232
3304
|
});
|
|
3233
3305
|
},
|
|
3234
3306
|
/** Queue an async entity-subset (.dfset) export; returns the bundleId for polling. */
|
|
3235
3307
|
async exportEntitySubset(projectId, projectBranch, request) {
|
|
3236
3308
|
return client.request({
|
|
3237
3309
|
method: "POST",
|
|
3238
|
-
service:
|
|
3239
|
-
path: `/entity-subset-bundles/${
|
|
3310
|
+
service: SERVICE4,
|
|
3311
|
+
path: `/entity-subset-bundles/${enc2(projectId)}/${enc2(projectBranch)}/export`,
|
|
3240
3312
|
body: request
|
|
3241
3313
|
});
|
|
3242
3314
|
},
|
|
@@ -3244,39 +3316,39 @@ function createStorageService(client) {
|
|
|
3244
3316
|
async streamEntitySubset(projectId, projectBranch, request) {
|
|
3245
3317
|
return client.requestRaw({
|
|
3246
3318
|
method: "POST",
|
|
3247
|
-
service:
|
|
3248
|
-
path: `/entity-subset-bundles/${
|
|
3319
|
+
service: SERVICE4,
|
|
3320
|
+
path: `/entity-subset-bundles/${enc2(projectId)}/${enc2(projectBranch)}/export/stream`,
|
|
3249
3321
|
body: request
|
|
3250
3322
|
});
|
|
3251
3323
|
},
|
|
3252
3324
|
async getBundles(projectId, projectBranch) {
|
|
3253
3325
|
return client.request({
|
|
3254
3326
|
method: "GET",
|
|
3255
|
-
service:
|
|
3256
|
-
path: `/bundles/${
|
|
3327
|
+
service: SERVICE4,
|
|
3328
|
+
path: `/bundles/${enc2(projectId)}/${enc2(projectBranch)}`
|
|
3257
3329
|
});
|
|
3258
3330
|
},
|
|
3259
3331
|
/** Download a finished bundle's bytes. */
|
|
3260
3332
|
async getBundleContent(projectId, projectBranch, bundleId, filename) {
|
|
3261
3333
|
return client.requestRaw({
|
|
3262
3334
|
method: "GET",
|
|
3263
|
-
service:
|
|
3264
|
-
path: `/bundles/${
|
|
3335
|
+
service: SERVICE4,
|
|
3336
|
+
path: `/bundles/${enc2(projectId)}/${enc2(projectBranch)}/${enc2(bundleId)}/${enc2(filename)}`
|
|
3265
3337
|
});
|
|
3266
3338
|
},
|
|
3267
3339
|
async stopBundle(projectId, projectBranch, bundleId, filename) {
|
|
3268
3340
|
await client.request({
|
|
3269
3341
|
method: "DELETE",
|
|
3270
|
-
service:
|
|
3271
|
-
path: `/bundles/${
|
|
3342
|
+
service: SERVICE4,
|
|
3343
|
+
path: `/bundles/${enc2(projectId)}/${enc2(projectBranch)}/${enc2(bundleId)}/${enc2(filename)}`
|
|
3272
3344
|
});
|
|
3273
3345
|
},
|
|
3274
3346
|
/** Non-committing inventory of an uploaded bundle. */
|
|
3275
3347
|
async previewBundleImport(projectId, projectBranch, formData) {
|
|
3276
3348
|
return client.request({
|
|
3277
3349
|
method: "POST",
|
|
3278
|
-
service:
|
|
3279
|
-
path: `/notebook-bundle-imports/${
|
|
3350
|
+
service: SERVICE4,
|
|
3351
|
+
path: `/notebook-bundle-imports/${enc2(projectId)}/${enc2(projectBranch)}/preview`,
|
|
3280
3352
|
rawBody: formData
|
|
3281
3353
|
});
|
|
3282
3354
|
},
|
|
@@ -3284,8 +3356,8 @@ function createStorageService(client) {
|
|
|
3284
3356
|
async importBundle(projectId, projectBranch, formData, onConflict = "copy") {
|
|
3285
3357
|
return client.request({
|
|
3286
3358
|
method: "POST",
|
|
3287
|
-
service:
|
|
3288
|
-
path: `/notebook-bundle-imports/${
|
|
3359
|
+
service: SERVICE4,
|
|
3360
|
+
path: `/notebook-bundle-imports/${enc2(projectId)}/${enc2(projectBranch)}/import`,
|
|
3289
3361
|
query: { onConflict },
|
|
3290
3362
|
rawBody: formData
|
|
3291
3363
|
});
|
|
@@ -3294,8 +3366,8 @@ function createStorageService(client) {
|
|
|
3294
3366
|
}
|
|
3295
3367
|
|
|
3296
3368
|
// src/client/services/evaluation.ts
|
|
3297
|
-
var
|
|
3298
|
-
function
|
|
3369
|
+
var SERVICE5 = "evaluation";
|
|
3370
|
+
function enc3(s) {
|
|
3299
3371
|
return encodeURIComponent(s);
|
|
3300
3372
|
}
|
|
3301
3373
|
function createEvaluationService(client) {
|
|
@@ -3304,25 +3376,25 @@ function createEvaluationService(client) {
|
|
|
3304
3376
|
async call(request, async = false) {
|
|
3305
3377
|
return client.request({
|
|
3306
3378
|
method: "POST",
|
|
3307
|
-
service:
|
|
3379
|
+
service: SERVICE5,
|
|
3308
3380
|
path: "/calls/",
|
|
3309
3381
|
body: request,
|
|
3310
3382
|
query: async ? { async: true } : void 0
|
|
3311
3383
|
});
|
|
3312
3384
|
},
|
|
3313
3385
|
// Evaluations
|
|
3314
|
-
async getEvaluations(projectId, projectBranch, functionId, functionBranch, year, month,
|
|
3386
|
+
async getEvaluations(projectId, projectBranch, functionId, functionBranch, year, month, day2, hour) {
|
|
3315
3387
|
return client.request({
|
|
3316
3388
|
method: "GET",
|
|
3317
|
-
service:
|
|
3318
|
-
path: `/evaluations/${
|
|
3389
|
+
service: SERVICE5,
|
|
3390
|
+
path: `/evaluations/${enc3(projectId)}/${enc3(projectBranch)}/${enc3(functionId)}/${enc3(functionBranch)}/${year}/${month}/${day2}/${hour}`
|
|
3319
3391
|
});
|
|
3320
3392
|
},
|
|
3321
|
-
async getEvaluation(projectId, projectBranch, functionId, functionBranch, year, month,
|
|
3393
|
+
async getEvaluation(projectId, projectBranch, functionId, functionBranch, year, month, day2, hour, evaluationId, result = false) {
|
|
3322
3394
|
return client.request({
|
|
3323
3395
|
method: "GET",
|
|
3324
|
-
service:
|
|
3325
|
-
path: `/evaluations/${
|
|
3396
|
+
service: SERVICE5,
|
|
3397
|
+
path: `/evaluations/${enc3(projectId)}/${enc3(projectBranch)}/${enc3(functionId)}/${enc3(functionBranch)}/${year}/${month}/${day2}/${hour}/${enc3(evaluationId)}`,
|
|
3326
3398
|
query: result ? { result: true } : void 0
|
|
3327
3399
|
});
|
|
3328
3400
|
},
|
|
@@ -3330,61 +3402,61 @@ function createEvaluationService(client) {
|
|
|
3330
3402
|
async getLastEvaluation(projectId, projectBranch, functionId, functionBranch) {
|
|
3331
3403
|
return client.request({
|
|
3332
3404
|
method: "GET",
|
|
3333
|
-
service:
|
|
3334
|
-
path: `/last-evaluation/${
|
|
3405
|
+
service: SERVICE5,
|
|
3406
|
+
path: `/last-evaluation/${enc3(projectId)}/${enc3(projectBranch)}/${enc3(functionId)}/${enc3(functionBranch)}`
|
|
3335
3407
|
});
|
|
3336
3408
|
},
|
|
3337
3409
|
// Outputs
|
|
3338
3410
|
async getOutputs(projectId, evaluationId) {
|
|
3339
3411
|
return client.request({
|
|
3340
3412
|
method: "GET",
|
|
3341
|
-
service:
|
|
3342
|
-
path: `/output/${
|
|
3413
|
+
service: SERVICE5,
|
|
3414
|
+
path: `/output/${enc3(projectId)}/${enc3(evaluationId)}`
|
|
3343
3415
|
});
|
|
3344
3416
|
},
|
|
3345
3417
|
// Logs
|
|
3346
|
-
async getLogs(projectId, projectBranch, functionId, functionBranch, year, month,
|
|
3418
|
+
async getLogs(projectId, projectBranch, functionId, functionBranch, year, month, day2, hour) {
|
|
3347
3419
|
return client.request({
|
|
3348
3420
|
method: "GET",
|
|
3349
|
-
service:
|
|
3350
|
-
path: `/log/${
|
|
3421
|
+
service: SERVICE5,
|
|
3422
|
+
path: `/log/${enc3(projectId)}/${enc3(projectBranch)}/${enc3(functionId)}/${enc3(functionBranch)}/${year}/${month}/${day2}/${hour}`
|
|
3351
3423
|
});
|
|
3352
3424
|
},
|
|
3353
3425
|
// Source Code
|
|
3354
3426
|
async getSourceCode(projectId, projectBranch, functionId, functionBranch, sourceCodeHash, sourceCodeId) {
|
|
3355
3427
|
return client.request({
|
|
3356
3428
|
method: "GET",
|
|
3357
|
-
service:
|
|
3358
|
-
path: `/sourcecodes/${
|
|
3429
|
+
service: SERVICE5,
|
|
3430
|
+
path: `/sourcecodes/${enc3(projectId)}/${enc3(projectBranch)}/${enc3(functionId)}/${enc3(functionBranch)}/${enc3(sourceCodeHash)}/${enc3(sourceCodeId)}`
|
|
3359
3431
|
});
|
|
3360
3432
|
},
|
|
3361
3433
|
// Stop
|
|
3362
|
-
async stopEvaluation(projectId, projectBranch, functionId, functionBranch, year, month,
|
|
3434
|
+
async stopEvaluation(projectId, projectBranch, functionId, functionBranch, year, month, day2, hour, evaluationId) {
|
|
3363
3435
|
return client.request({
|
|
3364
3436
|
method: "POST",
|
|
3365
|
-
service:
|
|
3366
|
-
path: `/stop/${
|
|
3437
|
+
service: SERVICE5,
|
|
3438
|
+
path: `/stop/${enc3(projectId)}/${enc3(projectBranch)}/${enc3(functionId)}/${enc3(functionBranch)}/${year}/${month}/${day2}/${hour}/${enc3(evaluationId)}`
|
|
3367
3439
|
});
|
|
3368
3440
|
},
|
|
3369
3441
|
// Triggers
|
|
3370
3442
|
async getTriggers(projectId, projectBranch, functionId, functionBranch) {
|
|
3371
3443
|
return client.request({
|
|
3372
3444
|
method: "GET",
|
|
3373
|
-
service:
|
|
3374
|
-
path: `/triggers/actual/${
|
|
3445
|
+
service: SERVICE5,
|
|
3446
|
+
path: `/triggers/actual/${enc3(projectId)}/${enc3(projectBranch)}/${enc3(functionId)}/${enc3(functionBranch)}`
|
|
3375
3447
|
});
|
|
3376
3448
|
},
|
|
3377
3449
|
async getTrigger(projectId, projectBranch, functionId, functionBranch, triggerId) {
|
|
3378
3450
|
return client.request({
|
|
3379
3451
|
method: "GET",
|
|
3380
|
-
service:
|
|
3381
|
-
path: `/triggers/actual/${
|
|
3452
|
+
service: SERVICE5,
|
|
3453
|
+
path: `/triggers/actual/${enc3(projectId)}/${enc3(projectBranch)}/${enc3(functionId)}/${enc3(functionBranch)}/${enc3(triggerId)}`
|
|
3382
3454
|
});
|
|
3383
3455
|
},
|
|
3384
3456
|
async saveTrigger(trigger) {
|
|
3385
3457
|
return client.request({
|
|
3386
3458
|
method: "PUT",
|
|
3387
|
-
service:
|
|
3459
|
+
service: SERVICE5,
|
|
3388
3460
|
path: "/triggers/",
|
|
3389
3461
|
body: trigger
|
|
3390
3462
|
});
|
|
@@ -3392,16 +3464,16 @@ function createEvaluationService(client) {
|
|
|
3392
3464
|
async deleteTrigger(projectId, projectBranch, functionId, functionBranch, triggerId) {
|
|
3393
3465
|
return client.request({
|
|
3394
3466
|
method: "DELETE",
|
|
3395
|
-
service:
|
|
3396
|
-
path: `/triggers/${
|
|
3467
|
+
service: SERVICE5,
|
|
3468
|
+
path: `/triggers/${enc3(projectId)}/${enc3(projectBranch)}/${enc3(functionId)}/${enc3(functionBranch)}/${enc3(triggerId)}`
|
|
3397
3469
|
});
|
|
3398
3470
|
}
|
|
3399
3471
|
};
|
|
3400
3472
|
}
|
|
3401
3473
|
|
|
3402
3474
|
// src/client/services/scheduler.ts
|
|
3403
|
-
var
|
|
3404
|
-
function
|
|
3475
|
+
var SERVICE6 = "scheduler";
|
|
3476
|
+
function enc4(s) {
|
|
3405
3477
|
return encodeURIComponent(s);
|
|
3406
3478
|
}
|
|
3407
3479
|
function createSchedulerService(client) {
|
|
@@ -3409,24 +3481,24 @@ function createSchedulerService(client) {
|
|
|
3409
3481
|
async scheduleCall(request) {
|
|
3410
3482
|
return client.request({
|
|
3411
3483
|
method: "POST",
|
|
3412
|
-
service:
|
|
3484
|
+
service: SERVICE6,
|
|
3413
3485
|
path: "/calls/",
|
|
3414
3486
|
body: request
|
|
3415
3487
|
});
|
|
3416
3488
|
},
|
|
3417
|
-
async stopScheduled(projectId, projectBranch, functionId, functionBranch, year, month,
|
|
3489
|
+
async stopScheduled(projectId, projectBranch, functionId, functionBranch, year, month, day2, hour, evaluationId) {
|
|
3418
3490
|
return client.request({
|
|
3419
3491
|
method: "POST",
|
|
3420
|
-
service:
|
|
3421
|
-
path: `/stop/${
|
|
3492
|
+
service: SERVICE6,
|
|
3493
|
+
path: `/stop/${enc4(projectId)}/${enc4(projectBranch)}/${enc4(functionId)}/${enc4(functionBranch)}/${year}/${month}/${day2}/${hour}/${enc4(evaluationId)}`
|
|
3422
3494
|
});
|
|
3423
3495
|
}
|
|
3424
3496
|
};
|
|
3425
3497
|
}
|
|
3426
3498
|
|
|
3427
3499
|
// src/client/services/language.ts
|
|
3428
|
-
var
|
|
3429
|
-
function
|
|
3500
|
+
var SERVICE7 = "language";
|
|
3501
|
+
function enc5(s) {
|
|
3430
3502
|
return encodeURIComponent(s);
|
|
3431
3503
|
}
|
|
3432
3504
|
function createLanguageService(client) {
|
|
@@ -3435,7 +3507,7 @@ function createLanguageService(client) {
|
|
|
3435
3507
|
async chat(request) {
|
|
3436
3508
|
return client.request({
|
|
3437
3509
|
method: "POST",
|
|
3438
|
-
service:
|
|
3510
|
+
service: SERVICE7,
|
|
3439
3511
|
path: "/chat/",
|
|
3440
3512
|
body: request
|
|
3441
3513
|
});
|
|
@@ -3444,7 +3516,7 @@ function createLanguageService(client) {
|
|
|
3444
3516
|
async chatStream(request) {
|
|
3445
3517
|
return client.requestRaw({
|
|
3446
3518
|
method: "POST",
|
|
3447
|
-
service:
|
|
3519
|
+
service: SERVICE7,
|
|
3448
3520
|
path: "/chat/stream",
|
|
3449
3521
|
body: request
|
|
3450
3522
|
});
|
|
@@ -3453,7 +3525,7 @@ function createLanguageService(client) {
|
|
|
3453
3525
|
async upload(formData) {
|
|
3454
3526
|
return client.request({
|
|
3455
3527
|
method: "POST",
|
|
3456
|
-
service:
|
|
3528
|
+
service: SERVICE7,
|
|
3457
3529
|
path: "/upload/",
|
|
3458
3530
|
rawBody: formData
|
|
3459
3531
|
});
|
|
@@ -3462,7 +3534,7 @@ function createLanguageService(client) {
|
|
|
3462
3534
|
async getUsage() {
|
|
3463
3535
|
return client.request({
|
|
3464
3536
|
method: "GET",
|
|
3465
|
-
service:
|
|
3537
|
+
service: SERVICE7,
|
|
3466
3538
|
path: "/usage/"
|
|
3467
3539
|
});
|
|
3468
3540
|
},
|
|
@@ -3470,36 +3542,36 @@ function createLanguageService(client) {
|
|
|
3470
3542
|
async getSessions() {
|
|
3471
3543
|
return client.request({
|
|
3472
3544
|
method: "GET",
|
|
3473
|
-
service:
|
|
3545
|
+
service: SERVICE7,
|
|
3474
3546
|
path: "/sessions/"
|
|
3475
3547
|
});
|
|
3476
3548
|
},
|
|
3477
3549
|
async getSession(sessionId) {
|
|
3478
3550
|
return client.request({
|
|
3479
3551
|
method: "GET",
|
|
3480
|
-
service:
|
|
3481
|
-
path: `/sessions/${
|
|
3552
|
+
service: SERVICE7,
|
|
3553
|
+
path: `/sessions/${enc5(sessionId)}`
|
|
3482
3554
|
});
|
|
3483
3555
|
},
|
|
3484
3556
|
async deleteSession(sessionId) {
|
|
3485
3557
|
return client.request({
|
|
3486
3558
|
method: "DELETE",
|
|
3487
|
-
service:
|
|
3488
|
-
path: `/sessions/${
|
|
3559
|
+
service: SERVICE7,
|
|
3560
|
+
path: `/sessions/${enc5(sessionId)}`
|
|
3489
3561
|
});
|
|
3490
3562
|
},
|
|
3491
3563
|
async getSessionMessages(sessionId) {
|
|
3492
3564
|
return client.request({
|
|
3493
3565
|
method: "GET",
|
|
3494
|
-
service:
|
|
3495
|
-
path: `/sessions/${
|
|
3566
|
+
service: SERVICE7,
|
|
3567
|
+
path: `/sessions/${enc5(sessionId)}/messages`
|
|
3496
3568
|
});
|
|
3497
3569
|
},
|
|
3498
3570
|
async renameSession(sessionId, title) {
|
|
3499
3571
|
return client.request({
|
|
3500
3572
|
method: "PUT",
|
|
3501
|
-
service:
|
|
3502
|
-
path: `/sessions/${
|
|
3573
|
+
service: SERVICE7,
|
|
3574
|
+
path: `/sessions/${enc5(sessionId)}/title`,
|
|
3503
3575
|
rawBody: title,
|
|
3504
3576
|
contentType: "text/plain"
|
|
3505
3577
|
});
|
|
@@ -3508,8 +3580,8 @@ function createLanguageService(client) {
|
|
|
3508
3580
|
}
|
|
3509
3581
|
|
|
3510
3582
|
// src/client/services/index-search.ts
|
|
3511
|
-
var
|
|
3512
|
-
function
|
|
3583
|
+
var SERVICE8 = "index";
|
|
3584
|
+
function enc6(s) {
|
|
3513
3585
|
return encodeURIComponent(s);
|
|
3514
3586
|
}
|
|
3515
3587
|
function createIndexService(client) {
|
|
@@ -3521,7 +3593,7 @@ function createIndexService(client) {
|
|
|
3521
3593
|
async searchPage(query) {
|
|
3522
3594
|
return client.request({
|
|
3523
3595
|
method: "GET",
|
|
3524
|
-
service:
|
|
3596
|
+
service: SERVICE8,
|
|
3525
3597
|
path: "/search/page",
|
|
3526
3598
|
query: {
|
|
3527
3599
|
query: query.query,
|
|
@@ -3541,7 +3613,7 @@ function createIndexService(client) {
|
|
|
3541
3613
|
async getCuratedTags(counts = false) {
|
|
3542
3614
|
return client.request({
|
|
3543
3615
|
method: "GET",
|
|
3544
|
-
service:
|
|
3616
|
+
service: SERVICE8,
|
|
3545
3617
|
path: "/tags/curated",
|
|
3546
3618
|
query: counts ? { counts: true } : void 0
|
|
3547
3619
|
});
|
|
@@ -3550,7 +3622,7 @@ function createIndexService(client) {
|
|
|
3550
3622
|
async createCuratedTag(request) {
|
|
3551
3623
|
return client.request({
|
|
3552
3624
|
method: "POST",
|
|
3553
|
-
service:
|
|
3625
|
+
service: SERVICE8,
|
|
3554
3626
|
path: "/admin/curated-tags",
|
|
3555
3627
|
body: request
|
|
3556
3628
|
});
|
|
@@ -3559,8 +3631,8 @@ function createIndexService(client) {
|
|
|
3559
3631
|
async updateCuratedTag(tag, request) {
|
|
3560
3632
|
return client.request({
|
|
3561
3633
|
method: "PUT",
|
|
3562
|
-
service:
|
|
3563
|
-
path: `/admin/curated-tags/${
|
|
3634
|
+
service: SERVICE8,
|
|
3635
|
+
path: `/admin/curated-tags/${enc6(tag)}`,
|
|
3564
3636
|
body: request
|
|
3565
3637
|
});
|
|
3566
3638
|
},
|
|
@@ -3568,22 +3640,22 @@ function createIndexService(client) {
|
|
|
3568
3640
|
async deleteCuratedTag(tag) {
|
|
3569
3641
|
return client.request({
|
|
3570
3642
|
method: "DELETE",
|
|
3571
|
-
service:
|
|
3572
|
-
path: `/admin/curated-tags/${
|
|
3643
|
+
service: SERVICE8,
|
|
3644
|
+
path: `/admin/curated-tags/${enc6(tag)}`
|
|
3573
3645
|
});
|
|
3574
3646
|
},
|
|
3575
3647
|
async rebuildAll() {
|
|
3576
3648
|
return client.request({
|
|
3577
3649
|
method: "POST",
|
|
3578
|
-
service:
|
|
3650
|
+
service: SERVICE8,
|
|
3579
3651
|
path: "/indexes/rebuild"
|
|
3580
3652
|
});
|
|
3581
3653
|
},
|
|
3582
3654
|
async rebuildProject(projectId) {
|
|
3583
3655
|
return client.request({
|
|
3584
3656
|
method: "POST",
|
|
3585
|
-
service:
|
|
3586
|
-
path: `/indexes/rebuild/${
|
|
3657
|
+
service: SERVICE8,
|
|
3658
|
+
path: `/indexes/rebuild/${enc6(projectId)}`
|
|
3587
3659
|
});
|
|
3588
3660
|
}
|
|
3589
3661
|
};
|
|
@@ -3596,6 +3668,7 @@ function createApiClient(options = {}) {
|
|
|
3596
3668
|
http,
|
|
3597
3669
|
admin: createAdminService(http),
|
|
3598
3670
|
analysis: createAnalysisService(http),
|
|
3671
|
+
deployments: createDeploymentsService(http),
|
|
3599
3672
|
storage: createStorageService(http),
|
|
3600
3673
|
evaluation: createEvaluationService(http),
|
|
3601
3674
|
scheduler: createSchedulerService(http),
|
|
@@ -4144,8 +4217,8 @@ function printImportPreview(preview) {
|
|
|
4144
4217
|
for (const e of preview.entities ?? []) {
|
|
4145
4218
|
counts.set(e.type, (counts.get(e.type) ?? 0) + 1);
|
|
4146
4219
|
}
|
|
4147
|
-
for (const [type,
|
|
4148
|
-
console.log(` ${type}: ${
|
|
4220
|
+
for (const [type, count2] of [...counts.entries()].sort((a, b) => a[0].localeCompare(b[0]))) {
|
|
4221
|
+
console.log(` ${type}: ${count2}`);
|
|
4149
4222
|
}
|
|
4150
4223
|
if (preview.hasAnalysis) {
|
|
4151
4224
|
console.log(" analysis recipe: included");
|
|
@@ -5071,11 +5144,11 @@ function parseInterval(value) {
|
|
|
5071
5144
|
return interval;
|
|
5072
5145
|
}
|
|
5073
5146
|
function parseCount(value, label) {
|
|
5074
|
-
const
|
|
5075
|
-
if (!Number.isInteger(
|
|
5147
|
+
const count2 = Number(value);
|
|
5148
|
+
if (!Number.isInteger(count2) || count2 < 0) {
|
|
5076
5149
|
throw new Error(`Invalid ${label} "${value}". Expected a non-negative whole number.`);
|
|
5077
5150
|
}
|
|
5078
|
-
return
|
|
5151
|
+
return count2;
|
|
5079
5152
|
}
|
|
5080
5153
|
function formatMoney(cents, currency) {
|
|
5081
5154
|
const sign = cents < 0 ? "-" : "";
|
|
@@ -5330,20 +5403,20 @@ function registerInvitationCommands(team) {
|
|
|
5330
5403
|
}
|
|
5331
5404
|
function registerSeatCommands(team) {
|
|
5332
5405
|
const seats = team.command("seats").description("Change a team's seat count");
|
|
5333
|
-
seats.command("preview").description("Preview the invoice for a seat-count change without applying it").argument("<teamId>", "Team ID").argument("<count>", "New seat count").action(async (teamId,
|
|
5406
|
+
seats.command("preview").description("Preview the invoice for a seat-count change without applying it").argument("<teamId>", "Team ID").argument("<count>", "New seat count").action(async (teamId, count2, _options, cmd) => {
|
|
5334
5407
|
try {
|
|
5335
5408
|
const api = createApiClient();
|
|
5336
5409
|
printInvoicePreview(
|
|
5337
|
-
await api.admin.previewTeamSeatCount(teamId, parseCount(
|
|
5410
|
+
await api.admin.previewTeamSeatCount(teamId, parseCount(count2, "seat count")),
|
|
5338
5411
|
getOutputFormat4(cmd)
|
|
5339
5412
|
);
|
|
5340
5413
|
} catch (error) {
|
|
5341
5414
|
handleError(error);
|
|
5342
5415
|
}
|
|
5343
5416
|
});
|
|
5344
|
-
seats.command("set").description("Change the seat count and bill the difference").argument("<teamId>", "Team ID").argument("<count>", "New seat count").option("-y, --yes", "Skip the confirmation prompt").action(async (teamId,
|
|
5417
|
+
seats.command("set").description("Change the seat count and bill the difference").argument("<teamId>", "Team ID").argument("<count>", "New seat count").option("-y, --yes", "Skip the confirmation prompt").action(async (teamId, count2, options, cmd) => {
|
|
5345
5418
|
try {
|
|
5346
|
-
const seatCount = parseCount(
|
|
5419
|
+
const seatCount = parseCount(count2, "seat count");
|
|
5347
5420
|
await confirmDestructive(
|
|
5348
5421
|
`This will change the seat count of team "${teamId}" to ${seatCount} and adjust billing.`,
|
|
5349
5422
|
{ yes: options.yes, resourceId: teamId }
|
|
@@ -5360,20 +5433,20 @@ function registerSeatCommands(team) {
|
|
|
5360
5433
|
}
|
|
5361
5434
|
function registerPackCommands(team) {
|
|
5362
5435
|
const packs = team.command("packs").description("Change a team's credit extension packs");
|
|
5363
|
-
packs.command("preview").description("Preview the invoice for a pack-count change without applying it").argument("<teamId>", "Team ID").argument("<count>", "New pack count").action(async (teamId,
|
|
5436
|
+
packs.command("preview").description("Preview the invoice for a pack-count change without applying it").argument("<teamId>", "Team ID").argument("<count>", "New pack count").action(async (teamId, count2, _options, cmd) => {
|
|
5364
5437
|
try {
|
|
5365
5438
|
const api = createApiClient();
|
|
5366
5439
|
printInvoicePreview(
|
|
5367
|
-
await api.admin.previewTeamPackCount(teamId, parseCount(
|
|
5440
|
+
await api.admin.previewTeamPackCount(teamId, parseCount(count2, "pack count")),
|
|
5368
5441
|
getOutputFormat4(cmd)
|
|
5369
5442
|
);
|
|
5370
5443
|
} catch (error) {
|
|
5371
5444
|
handleError(error);
|
|
5372
5445
|
}
|
|
5373
5446
|
});
|
|
5374
|
-
packs.command("set").description("Change the pack count and bill the difference").argument("<teamId>", "Team ID").argument("<count>", "New pack count").option("-y, --yes", "Skip the confirmation prompt").action(async (teamId,
|
|
5447
|
+
packs.command("set").description("Change the pack count and bill the difference").argument("<teamId>", "Team ID").argument("<count>", "New pack count").option("-y, --yes", "Skip the confirmation prompt").action(async (teamId, count2, options, cmd) => {
|
|
5375
5448
|
try {
|
|
5376
|
-
const packCount = parseCount(
|
|
5449
|
+
const packCount = parseCount(count2, "pack count");
|
|
5377
5450
|
await confirmDestructive(
|
|
5378
5451
|
`This will change the extension packs of team "${teamId}" to ${packCount} and adjust billing.`,
|
|
5379
5452
|
{ yes: options.yes, resourceId: teamId }
|
|
@@ -5812,8 +5885,8 @@ function registerEventCommands(program) {
|
|
|
5812
5885
|
});
|
|
5813
5886
|
event.command("create").description("Create one or more events (body from JSON file or stdin)").argument("[file]", "JSON file containing a BareEvent array; defaults to stdin").action(async (file) => {
|
|
5814
5887
|
try {
|
|
5815
|
-
const
|
|
5816
|
-
const body = file ?
|
|
5888
|
+
const fs20 = await import("fs");
|
|
5889
|
+
const body = file ? fs20.readFileSync(file, "utf-8") : await new Promise((resolve2, reject) => {
|
|
5817
5890
|
let data = "";
|
|
5818
5891
|
process.stdin.setEncoding("utf-8");
|
|
5819
5892
|
process.stdin.on("data", (chunk) => {
|
|
@@ -6692,8 +6765,8 @@ Examples:
|
|
|
6692
6765
|
for (const e of preview.entities ?? []) {
|
|
6693
6766
|
counts.set(e.type, (counts.get(e.type) ?? 0) + 1);
|
|
6694
6767
|
}
|
|
6695
|
-
for (const [type,
|
|
6696
|
-
console.log(` ${type}: ${
|
|
6768
|
+
for (const [type, count2] of [...counts.entries()].sort((a, b) => a[0].localeCompare(b[0]))) {
|
|
6769
|
+
console.log(` ${type}: ${count2}`);
|
|
6697
6770
|
}
|
|
6698
6771
|
if (preview.lossinessNotes && preview.lossinessNotes.length > 0) {
|
|
6699
6772
|
console.log(chalk17.yellow("Lossiness:"));
|
|
@@ -6975,7 +7048,7 @@ Examples:
|
|
|
6975
7048
|
const resolved = parseEntityReference(ref, overrides);
|
|
6976
7049
|
const api = createApiClient();
|
|
6977
7050
|
const parts = options.date.split("-").map(Number);
|
|
6978
|
-
const [year, month,
|
|
7051
|
+
const [year, month, day2, hour] = parts;
|
|
6979
7052
|
const evaluations = await api.evaluation.getEvaluations(
|
|
6980
7053
|
resolved.projectId,
|
|
6981
7054
|
resolved.projectBranch,
|
|
@@ -6983,7 +7056,7 @@ Examples:
|
|
|
6983
7056
|
resolved.entityBranch,
|
|
6984
7057
|
year,
|
|
6985
7058
|
month,
|
|
6986
|
-
|
|
7059
|
+
day2,
|
|
6987
7060
|
hour
|
|
6988
7061
|
);
|
|
6989
7062
|
const summary = evaluations.map((e) => ({
|
|
@@ -7036,7 +7109,7 @@ Examples:
|
|
|
7036
7109
|
const resolved = parseEntityReference(ref, overrides);
|
|
7037
7110
|
const api = createApiClient();
|
|
7038
7111
|
const parts = options.date.split("-").map(Number);
|
|
7039
|
-
const [year, month,
|
|
7112
|
+
const [year, month, day2, hour] = parts;
|
|
7040
7113
|
const logs = await api.evaluation.getLogs(
|
|
7041
7114
|
resolved.projectId,
|
|
7042
7115
|
resolved.projectBranch,
|
|
@@ -7044,7 +7117,7 @@ Examples:
|
|
|
7044
7117
|
resolved.entityBranch,
|
|
7045
7118
|
year,
|
|
7046
7119
|
month,
|
|
7047
|
-
|
|
7120
|
+
day2,
|
|
7048
7121
|
hour
|
|
7049
7122
|
);
|
|
7050
7123
|
format(logs, { format: outputFormat });
|
|
@@ -7058,7 +7131,7 @@ Examples:
|
|
|
7058
7131
|
const resolved = parseEntityReference(ref, overrides);
|
|
7059
7132
|
const api = createApiClient();
|
|
7060
7133
|
const parts = options.date.split("-").map(Number);
|
|
7061
|
-
const [year, month,
|
|
7134
|
+
const [year, month, day2, hour] = parts;
|
|
7062
7135
|
await api.evaluation.stopEvaluation(
|
|
7063
7136
|
resolved.projectId,
|
|
7064
7137
|
resolved.projectBranch,
|
|
@@ -7066,7 +7139,7 @@ Examples:
|
|
|
7066
7139
|
resolved.entityBranch,
|
|
7067
7140
|
year,
|
|
7068
7141
|
month,
|
|
7069
|
-
|
|
7142
|
+
day2,
|
|
7070
7143
|
hour,
|
|
7071
7144
|
evaluationId
|
|
7072
7145
|
);
|
|
@@ -7904,6 +7977,8 @@ var BY_COMMAND = {
|
|
|
7904
7977
|
"project members invite": { "<userId>": TEXT, "<role>": { kind: "choice", choices: PROJECT_ROLES } },
|
|
7905
7978
|
"project members join": { "<userId>": TEXT },
|
|
7906
7979
|
"license create": { "<licenseId>": TEXT, "--name": TEXT, "--flags": TEXT },
|
|
7980
|
+
"deployment create": { "--analysis": { kind: "analysis" }, "--target": TEXT },
|
|
7981
|
+
"deployment delete-prediction": { "<predictionId>": TEXT },
|
|
7907
7982
|
"trigger create": { "--type": { kind: "choice", choices: TRIGGER_TYPES } },
|
|
7908
7983
|
"analyze triggers create": { "--kind": { kind: "choice", choices: ANALYSIS_TRIGGER_KINDS } },
|
|
7909
7984
|
"function outputs": { "<evaluationId>": TEXT },
|
|
@@ -7920,6 +7995,7 @@ var BY_NAME = {
|
|
|
7920
7995
|
invitationId: { kind: "teamInvitation" },
|
|
7921
7996
|
analysisId: { kind: "analysis" },
|
|
7922
7997
|
licenseId: { kind: "license" },
|
|
7998
|
+
deploymentId: { kind: "deployment" },
|
|
7923
7999
|
sessionId: { kind: "chatSession" },
|
|
7924
8000
|
tokenId: { kind: "apiToken" },
|
|
7925
8001
|
resource: { kind: "tokenResource" },
|
|
@@ -8133,8 +8209,8 @@ Examples:
|
|
|
8133
8209
|
if (!TRIGGER_TYPES.includes(type)) {
|
|
8134
8210
|
throw new Error(`Unknown trigger type "${options.type}": use one of ${TRIGGER_TYPES.join(", ")}.`);
|
|
8135
8211
|
}
|
|
8136
|
-
const
|
|
8137
|
-
if (!Number.isInteger(
|
|
8212
|
+
const count2 = Number(options.count);
|
|
8213
|
+
if (!Number.isInteger(count2) || count2 < 1) {
|
|
8138
8214
|
throw new Error(`--count must be a whole number of at least 1, not "${options.count}".`);
|
|
8139
8215
|
}
|
|
8140
8216
|
const api = createApiClient();
|
|
@@ -8163,7 +8239,7 @@ Examples:
|
|
|
8163
8239
|
originEntityId,
|
|
8164
8240
|
originEntityBranch,
|
|
8165
8241
|
active: !options.inactive,
|
|
8166
|
-
quantity:
|
|
8242
|
+
quantity: count2,
|
|
8167
8243
|
fired: 0,
|
|
8168
8244
|
maximum: options.max ? parseInt(options.max, 10) || null : null,
|
|
8169
8245
|
evaluationIds: null,
|
|
@@ -8247,7 +8323,7 @@ function registerScheduleCommands(program) {
|
|
|
8247
8323
|
const overrides = getOverrides10(cmd);
|
|
8248
8324
|
const resolved = parseEntityReference(ref, overrides);
|
|
8249
8325
|
const api = createApiClient();
|
|
8250
|
-
const [year, month,
|
|
8326
|
+
const [year, month, day2, hour] = options.date.split("-").map(Number);
|
|
8251
8327
|
await api.scheduler.stopScheduled(
|
|
8252
8328
|
resolved.projectId,
|
|
8253
8329
|
resolved.projectBranch,
|
|
@@ -8255,7 +8331,7 @@ function registerScheduleCommands(program) {
|
|
|
8255
8331
|
resolved.entityBranch,
|
|
8256
8332
|
year,
|
|
8257
8333
|
month,
|
|
8258
|
-
|
|
8334
|
+
day2,
|
|
8259
8335
|
hour,
|
|
8260
8336
|
evaluationId
|
|
8261
8337
|
);
|
|
@@ -8479,7 +8555,7 @@ var HELP = [
|
|
|
8479
8555
|
];
|
|
8480
8556
|
async function runChatRepl(options) {
|
|
8481
8557
|
const { input: promptInput } = await import("@inquirer/prompts");
|
|
8482
|
-
const { getUpdateNotice } = await import("./update-check-
|
|
8558
|
+
const { getUpdateNotice } = await import("./update-check-NBOU2XBP.js");
|
|
8483
8559
|
let sessionId = options.session;
|
|
8484
8560
|
let lastReportedSession;
|
|
8485
8561
|
console.log(chalk21.bold("Diafunc chat") + chalk21.dim(" \xB7 /help for commands, /quit to exit"));
|
|
@@ -10306,8 +10382,8 @@ function licenseText(analysis) {
|
|
|
10306
10382
|
return analysis.visibility === "PUBLIC" ? "none chosen" : null;
|
|
10307
10383
|
}
|
|
10308
10384
|
function sentenceCase(token) {
|
|
10309
|
-
const
|
|
10310
|
-
return
|
|
10385
|
+
const words2 = token.toLowerCase().replace(/_/g, " ");
|
|
10386
|
+
return words2.charAt(0).toUpperCase() + words2.slice(1);
|
|
10311
10387
|
}
|
|
10312
10388
|
function hoursText(hours) {
|
|
10313
10389
|
if (hours == null || hours === "") return null;
|
|
@@ -11823,10 +11899,10 @@ async function listColumns(analysisId, cmd) {
|
|
|
11823
11899
|
}
|
|
11824
11900
|
format(columns, { format: outputFormat, columns: ["name", "valueType"] });
|
|
11825
11901
|
}
|
|
11826
|
-
async function listRuns(analysisId,
|
|
11902
|
+
async function listRuns(analysisId, count2, cmd) {
|
|
11827
11903
|
const outputFormat = getOutputFormat19(cmd);
|
|
11828
11904
|
const api = createApiClient();
|
|
11829
|
-
const runs = await api.analysis.getRunsForAnalysis(analysisId,
|
|
11905
|
+
const runs = await api.analysis.getRunsForAnalysis(analysisId, count2);
|
|
11830
11906
|
format(runs.map((r) => ({
|
|
11831
11907
|
runId: r.runId,
|
|
11832
11908
|
state: r.state,
|
|
@@ -12391,10 +12467,898 @@ Examples:
|
|
|
12391
12467
|
});
|
|
12392
12468
|
}
|
|
12393
12469
|
|
|
12470
|
+
// src/commands/deployment/index.ts
|
|
12471
|
+
import * as fs13 from "fs";
|
|
12472
|
+
import chalk30 from "chalk";
|
|
12473
|
+
|
|
12474
|
+
// src/util/csv.ts
|
|
12475
|
+
function detectDelimiter(firstLine) {
|
|
12476
|
+
if (firstLine.includes(",")) return ",";
|
|
12477
|
+
if (firstLine.includes(" ")) return " ";
|
|
12478
|
+
if (firstLine.includes(";")) return ";";
|
|
12479
|
+
return ",";
|
|
12480
|
+
}
|
|
12481
|
+
function records(text2, delimiter) {
|
|
12482
|
+
const out = [];
|
|
12483
|
+
let fields = [];
|
|
12484
|
+
let field = "";
|
|
12485
|
+
let quoted = false;
|
|
12486
|
+
let line = 1;
|
|
12487
|
+
let startLine = 1;
|
|
12488
|
+
let i = 0;
|
|
12489
|
+
const finishRecord = () => {
|
|
12490
|
+
fields.push(field);
|
|
12491
|
+
if (!(fields.length === 1 && fields[0].trim() === "")) out.push({ fields, line: startLine });
|
|
12492
|
+
fields = [];
|
|
12493
|
+
field = "";
|
|
12494
|
+
};
|
|
12495
|
+
while (i < text2.length) {
|
|
12496
|
+
const c = text2[i];
|
|
12497
|
+
if (quoted) {
|
|
12498
|
+
if (c === '"') {
|
|
12499
|
+
if (text2[i + 1] === '"') {
|
|
12500
|
+
field += '"';
|
|
12501
|
+
i += 2;
|
|
12502
|
+
continue;
|
|
12503
|
+
}
|
|
12504
|
+
quoted = false;
|
|
12505
|
+
} else {
|
|
12506
|
+
if (c === "\n") line++;
|
|
12507
|
+
field += c;
|
|
12508
|
+
}
|
|
12509
|
+
i++;
|
|
12510
|
+
continue;
|
|
12511
|
+
}
|
|
12512
|
+
if (c === '"' && field === "") {
|
|
12513
|
+
quoted = true;
|
|
12514
|
+
} else if (c === delimiter) {
|
|
12515
|
+
fields.push(field);
|
|
12516
|
+
field = "";
|
|
12517
|
+
} else if (c === "\r" && text2[i + 1] === "\n") {
|
|
12518
|
+
} else if (c === "\n") {
|
|
12519
|
+
finishRecord();
|
|
12520
|
+
line++;
|
|
12521
|
+
startLine = line;
|
|
12522
|
+
} else {
|
|
12523
|
+
field += c;
|
|
12524
|
+
}
|
|
12525
|
+
i++;
|
|
12526
|
+
}
|
|
12527
|
+
if (field !== "" || fields.length > 0) finishRecord();
|
|
12528
|
+
return out;
|
|
12529
|
+
}
|
|
12530
|
+
function parseCsv(text2) {
|
|
12531
|
+
const body = text2.charCodeAt(0) === 65279 ? text2.slice(1) : text2;
|
|
12532
|
+
const firstLine = body.split(/\r?\n/, 1)[0] ?? "";
|
|
12533
|
+
const all = records(body, detectDelimiter(firstLine));
|
|
12534
|
+
if (all.length === 0) return { header: [], rows: [], lines: [] };
|
|
12535
|
+
const header = all[0].fields.map((h) => h.trim());
|
|
12536
|
+
const rows = all.slice(1).map((r) => header.map((_, index) => r.fields[index] ?? ""));
|
|
12537
|
+
return { header, rows, lines: all.slice(1).map((r) => r.line) };
|
|
12538
|
+
}
|
|
12539
|
+
function csvLine(fields) {
|
|
12540
|
+
return fields.map((value) => {
|
|
12541
|
+
const text2 = value === null || value === void 0 ? "" : String(value);
|
|
12542
|
+
return /[",\r\n]/.test(text2) ? `"${text2.replace(/"/g, '""')}"` : text2;
|
|
12543
|
+
}).join(",");
|
|
12544
|
+
}
|
|
12545
|
+
function chunks(items, size) {
|
|
12546
|
+
if (size < 1) throw new Error("chunk size must be at least 1");
|
|
12547
|
+
const out = [];
|
|
12548
|
+
for (let i = 0; i < items.length; i += size) out.push(items.slice(i, i + size));
|
|
12549
|
+
return out;
|
|
12550
|
+
}
|
|
12551
|
+
|
|
12552
|
+
// src/prompting/command.ts
|
|
12553
|
+
import { Command as Command2 } from "commander";
|
|
12554
|
+
var commanderOriginal = Command2.prototype;
|
|
12555
|
+
var DiafuncCommand = class _DiafuncCommand extends Command2 {
|
|
12556
|
+
/** Gaps recorded during the current parse, in the order commander found them. */
|
|
12557
|
+
pendingInputs = [];
|
|
12558
|
+
/** Set on the program only; every command reads it from there. */
|
|
12559
|
+
promptEnvironment = {};
|
|
12560
|
+
createCommand(name) {
|
|
12561
|
+
return new _DiafuncCommand(name);
|
|
12562
|
+
}
|
|
12563
|
+
missingArgument(name) {
|
|
12564
|
+
if (!this.mayPrompt()) {
|
|
12565
|
+
commanderOriginal.missingArgument.call(this, name);
|
|
12566
|
+
return;
|
|
12567
|
+
}
|
|
12568
|
+
const index = this.registeredArguments.findIndex((a) => a.name() === name);
|
|
12569
|
+
const argument = this.registeredArguments[index];
|
|
12570
|
+
this.pendingInputs.push({
|
|
12571
|
+
kind: "argument",
|
|
12572
|
+
name,
|
|
12573
|
+
index,
|
|
12574
|
+
description: argument?.description ?? "",
|
|
12575
|
+
variadic: Boolean(argument?.variadic)
|
|
12576
|
+
});
|
|
12577
|
+
}
|
|
12578
|
+
missingMandatoryOptionValue(option) {
|
|
12579
|
+
if (!this.mayPrompt()) {
|
|
12580
|
+
commanderOriginal.missingMandatoryOptionValue.call(this, option);
|
|
12581
|
+
return;
|
|
12582
|
+
}
|
|
12583
|
+
this.pendingInputs.push({
|
|
12584
|
+
kind: "option",
|
|
12585
|
+
name: option.attributeName(),
|
|
12586
|
+
flag: option.long ?? option.flags,
|
|
12587
|
+
description: option.description ?? "",
|
|
12588
|
+
variadic: Boolean(option.variadic)
|
|
12589
|
+
});
|
|
12590
|
+
}
|
|
12591
|
+
/** The environment set on the program. */
|
|
12592
|
+
environment() {
|
|
12593
|
+
let root = this;
|
|
12594
|
+
while (root.parent) root = root.parent;
|
|
12595
|
+
return root instanceof _DiafuncCommand ? root.promptEnvironment : {};
|
|
12596
|
+
}
|
|
12597
|
+
mayPrompt() {
|
|
12598
|
+
const forced = this.environment().interactive;
|
|
12599
|
+
if (forced !== void 0) return forced;
|
|
12600
|
+
const globals = this.optsWithGlobals();
|
|
12601
|
+
const output = globals.output ?? loadConfig().defaults.output ?? "human";
|
|
12602
|
+
return canPrompt(output, globals.interactive === false);
|
|
12603
|
+
}
|
|
12604
|
+
};
|
|
12605
|
+
|
|
12606
|
+
// src/commands/deployment/index.ts
|
|
12607
|
+
var MAX_ROWS_PER_CALL = 1e3;
|
|
12608
|
+
var RETENTION_DAYS = [30, 90, 180];
|
|
12609
|
+
var WINDOWS = ["7d", "30d"];
|
|
12610
|
+
var NOT_ENOUGH_CREDITS = "Not enough credits. Each prediction costs credits.";
|
|
12611
|
+
var CREDITS_HINT = `See your credits with 'diafunc utilization'.`;
|
|
12612
|
+
function getOutputFormat20(cmd) {
|
|
12613
|
+
const config = loadConfig();
|
|
12614
|
+
const globalOpts = cmd.optsWithGlobals();
|
|
12615
|
+
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
12616
|
+
}
|
|
12617
|
+
function prompterFor(cmd) {
|
|
12618
|
+
const env = cmd instanceof DiafuncCommand ? cmd.environment() : {};
|
|
12619
|
+
const globals = cmd.optsWithGlobals();
|
|
12620
|
+
const interactive = env.interactive ?? canPrompt(getOutputFormat20(cmd), globals.interactive === false);
|
|
12621
|
+
return interactive ? env.prompter ?? createInquirerPrompter() : null;
|
|
12622
|
+
}
|
|
12623
|
+
async function confirmStep(cmd, question2, yes, refusal) {
|
|
12624
|
+
if (yes || isDryRun()) return true;
|
|
12625
|
+
const prompter = prompterFor(cmd);
|
|
12626
|
+
if (!prompter) throw new CliError(refusal, { exitCode: EXIT_USAGE, hint: "Add --yes to go ahead without being asked." });
|
|
12627
|
+
return prompter.confirm({ message: question2, default: false });
|
|
12628
|
+
}
|
|
12629
|
+
function words(code) {
|
|
12630
|
+
return code ? code.replace(/_/g, " ") : null;
|
|
12631
|
+
}
|
|
12632
|
+
function num(value) {
|
|
12633
|
+
if (value === null || value === void 0 || !Number.isFinite(value)) return ABSENT;
|
|
12634
|
+
if (Number.isInteger(value)) return value.toLocaleString("en-US");
|
|
12635
|
+
const abs = Math.abs(value);
|
|
12636
|
+
if (abs >= 1e3) return Math.round(value).toLocaleString("en-US");
|
|
12637
|
+
if (abs >= 1e-3) return String(Number(value.toPrecision(4)));
|
|
12638
|
+
return value.toPrecision(3);
|
|
12639
|
+
}
|
|
12640
|
+
function percent2(share) {
|
|
12641
|
+
if (share === null || share === void 0 || !Number.isFinite(share)) return ABSENT;
|
|
12642
|
+
const p = share * 100;
|
|
12643
|
+
return `${p >= 10 || Number.isInteger(p) ? Math.round(p) : p.toFixed(1)}%`;
|
|
12644
|
+
}
|
|
12645
|
+
function day(value) {
|
|
12646
|
+
if (value === null || value === void 0 || value === "") return null;
|
|
12647
|
+
const date = new Date(typeof value === "number" && value < 1e11 ? value * 1e3 : value);
|
|
12648
|
+
return Number.isNaN(date.getTime()) ? null : date.toISOString().slice(0, 10);
|
|
12649
|
+
}
|
|
12650
|
+
function shortRun(id) {
|
|
12651
|
+
return id.length > 8 ? `${id.slice(0, 8)}\u2026` : id;
|
|
12652
|
+
}
|
|
12653
|
+
function modelWords(version, at) {
|
|
12654
|
+
const when2 = day(at);
|
|
12655
|
+
if (when2 && version) return `the model of the run of ${when2} (run ${shortRun(version)})`;
|
|
12656
|
+
if (when2) return `the model of the run of ${when2}`;
|
|
12657
|
+
if (version) return `the model of run ${shortRun(version)}`;
|
|
12658
|
+
return null;
|
|
12659
|
+
}
|
|
12660
|
+
function count(n) {
|
|
12661
|
+
return n.toLocaleString("en-US");
|
|
12662
|
+
}
|
|
12663
|
+
function onOff(value) {
|
|
12664
|
+
return value ? "on" : "off";
|
|
12665
|
+
}
|
|
12666
|
+
function parseOnOff(flag, value) {
|
|
12667
|
+
if (value === void 0) return void 0;
|
|
12668
|
+
const v = value.trim().toLowerCase();
|
|
12669
|
+
if (v === "on" || v === "true") return true;
|
|
12670
|
+
if (v === "off" || v === "false") return false;
|
|
12671
|
+
throw new CliError(`${flag} takes on or off, not "${value}".`, { exitCode: EXIT_USAGE });
|
|
12672
|
+
}
|
|
12673
|
+
function parseRetention(value) {
|
|
12674
|
+
if (value === void 0) return void 0;
|
|
12675
|
+
const days = Number(value.trim());
|
|
12676
|
+
if (!RETENTION_DAYS.includes(days)) {
|
|
12677
|
+
throw new CliError(`--retention takes ${RETENTION_DAYS.join(", ")} (days), not "${value}".`, { exitCode: EXIT_USAGE });
|
|
12678
|
+
}
|
|
12679
|
+
return days;
|
|
12680
|
+
}
|
|
12681
|
+
function parseWindow(value) {
|
|
12682
|
+
const w = (value ?? "7d").trim().toLowerCase();
|
|
12683
|
+
if (!WINDOWS.includes(w)) {
|
|
12684
|
+
throw new CliError(`--window takes 7d or 30d, not "${value}".`, { exitCode: EXIT_USAGE });
|
|
12685
|
+
}
|
|
12686
|
+
return w;
|
|
12687
|
+
}
|
|
12688
|
+
function settingsFrom(options) {
|
|
12689
|
+
const request = {};
|
|
12690
|
+
if (options.name !== void 0) {
|
|
12691
|
+
if (options.name.trim() === "") throw new CliError("--name cannot be empty.", { exitCode: EXIT_USAGE });
|
|
12692
|
+
request.name = options.name;
|
|
12693
|
+
}
|
|
12694
|
+
const logInputs = parseOnOff("--log-inputs", options.logInputs);
|
|
12695
|
+
if (logInputs !== void 0) request.logInputs = logInputs;
|
|
12696
|
+
const retention = parseRetention(options.retention);
|
|
12697
|
+
if (retention !== void 0) request.retentionDays = retention;
|
|
12698
|
+
const mailAlerts = parseOnOff("--mail-alerts", options.mailAlerts);
|
|
12699
|
+
if (mailAlerts !== void 0) request.mailAlerts = mailAlerts;
|
|
12700
|
+
if (Object.keys(request).length === 0) {
|
|
12701
|
+
throw new CliError("Nothing to change.", {
|
|
12702
|
+
exitCode: EXIT_USAGE,
|
|
12703
|
+
hint: "Give at least one of --name, --log-inputs on|off, --retention 30|90|180, --mail-alerts on|off."
|
|
12704
|
+
});
|
|
12705
|
+
}
|
|
12706
|
+
return request;
|
|
12707
|
+
}
|
|
12708
|
+
function parseInputs(pairs) {
|
|
12709
|
+
const inputs = {};
|
|
12710
|
+
for (const pair of pairs) {
|
|
12711
|
+
const at = pair.indexOf("=");
|
|
12712
|
+
const key = at < 0 ? "" : pair.slice(0, at).trim();
|
|
12713
|
+
if (at < 0 || key === "") {
|
|
12714
|
+
throw new CliError(`--input takes name=value, not "${pair}".`, { exitCode: EXIT_USAGE });
|
|
12715
|
+
}
|
|
12716
|
+
if (Object.prototype.hasOwnProperty.call(inputs, key)) {
|
|
12717
|
+
throw new CliError(`Input ${key} is given twice.`, { exitCode: EXIT_USAGE });
|
|
12718
|
+
}
|
|
12719
|
+
inputs[key] = pair.slice(at + 1).trim();
|
|
12720
|
+
}
|
|
12721
|
+
return inputs;
|
|
12722
|
+
}
|
|
12723
|
+
function predictRequestsFrom(table, inputKeys, options = {}) {
|
|
12724
|
+
if (table.rows.length === 0) throw new CliError("The file has no rows to predict.");
|
|
12725
|
+
const referenceIndex = options.referenceColumn === void 0 ? -1 : table.header.indexOf(options.referenceColumn);
|
|
12726
|
+
if (options.referenceColumn !== void 0 && referenceIndex < 0) {
|
|
12727
|
+
throw new CliError(`The file has no column ${options.referenceColumn} for --reference.`, {
|
|
12728
|
+
hint: `Its columns are: ${table.header.join(", ")}.`
|
|
12729
|
+
});
|
|
12730
|
+
}
|
|
12731
|
+
const keys = inputKeys && inputKeys.length > 0 ? inputKeys : table.header.filter((_, i) => i !== referenceIndex);
|
|
12732
|
+
const missing = keys.filter((k) => !table.header.includes(k));
|
|
12733
|
+
if (missing.length > 0) {
|
|
12734
|
+
throw new CliError(`The file has no column for the input${missing.length > 1 ? "s" : ""} ${missing.join(", ")}.`, {
|
|
12735
|
+
hint: `The deployment reads ${keys.join(", ")}.`
|
|
12736
|
+
});
|
|
12737
|
+
}
|
|
12738
|
+
const indexOf = new Map(keys.map((k) => [k, table.header.indexOf(k)]));
|
|
12739
|
+
return table.rows.map((row) => {
|
|
12740
|
+
const inputs = {};
|
|
12741
|
+
for (const [key, index] of indexOf) {
|
|
12742
|
+
const value = row[index].trim();
|
|
12743
|
+
if (value !== "") inputs[key] = value;
|
|
12744
|
+
}
|
|
12745
|
+
const request = { inputs };
|
|
12746
|
+
if (referenceIndex >= 0 && row[referenceIndex].trim() !== "") request.reference = row[referenceIndex].trim();
|
|
12747
|
+
if (options.store === false) request.store = false;
|
|
12748
|
+
return request;
|
|
12749
|
+
});
|
|
12750
|
+
}
|
|
12751
|
+
var RESULT_HEADER = ["row", "reference", "prediction", "lower", "upper", "outOfRange", "predictionId", "error"];
|
|
12752
|
+
function resultFields(row, answer) {
|
|
12753
|
+
const outOfRange = (answer?.checks?.inputs ?? []).map((c) => c.input).join(";");
|
|
12754
|
+
return [
|
|
12755
|
+
row,
|
|
12756
|
+
answer?.reference ?? null,
|
|
12757
|
+
answer?.prediction ?? answer?.classLabel ?? null,
|
|
12758
|
+
answer?.confidence?.lower ?? null,
|
|
12759
|
+
answer?.confidence?.upper ?? null,
|
|
12760
|
+
outOfRange,
|
|
12761
|
+
answer?.predictionId ?? null,
|
|
12762
|
+
answer === void 0 ? "no answer for this row" : answer.error ?? null
|
|
12763
|
+
];
|
|
12764
|
+
}
|
|
12765
|
+
function columnIndex(header, name) {
|
|
12766
|
+
const norm = (s) => s.toLowerCase().replace(/[_\s-]/g, "");
|
|
12767
|
+
return header.findIndex((h) => norm(h) === norm(name));
|
|
12768
|
+
}
|
|
12769
|
+
function parseOutcomeValue(value, where) {
|
|
12770
|
+
const text2 = value.trim();
|
|
12771
|
+
if (text2 === "") throw new CliError(`${where}: the outcome is empty.`, { exitCode: EXIT_USAGE });
|
|
12772
|
+
const number = Number(text2);
|
|
12773
|
+
return Number.isFinite(number) ? number : text2;
|
|
12774
|
+
}
|
|
12775
|
+
function outcomesFrom(table) {
|
|
12776
|
+
const actualIndex = columnIndex(table.header, "actual");
|
|
12777
|
+
const idIndex = columnIndex(table.header, "predictionId");
|
|
12778
|
+
const referenceIndex = columnIndex(table.header, "reference");
|
|
12779
|
+
if (actualIndex < 0 || idIndex < 0 && referenceIndex < 0) {
|
|
12780
|
+
throw new CliError("The file needs an actual column and a predictionId or reference column.", {
|
|
12781
|
+
hint: `Its columns are: ${table.header.join(", ") || "none"}.`
|
|
12782
|
+
});
|
|
12783
|
+
}
|
|
12784
|
+
const outcomes = [];
|
|
12785
|
+
let skipped = 0;
|
|
12786
|
+
table.rows.forEach((row, i) => {
|
|
12787
|
+
const line = `Line ${table.lines[i] ?? i + 2}`;
|
|
12788
|
+
if (row[actualIndex].trim() === "") {
|
|
12789
|
+
skipped++;
|
|
12790
|
+
return;
|
|
12791
|
+
}
|
|
12792
|
+
const actual = parseOutcomeValue(row[actualIndex], line);
|
|
12793
|
+
const predictionId = idIndex >= 0 ? row[idIndex].trim() : "";
|
|
12794
|
+
const reference = referenceIndex >= 0 ? row[referenceIndex].trim() : "";
|
|
12795
|
+
if (predictionId !== "") outcomes.push({ predictionId, actual });
|
|
12796
|
+
else if (reference !== "") outcomes.push({ reference, actual });
|
|
12797
|
+
else throw new CliError(`${line}: no prediction id and no reference.`, { exitCode: EXIT_USAGE });
|
|
12798
|
+
});
|
|
12799
|
+
if (outcomes.length === 0) throw new CliError("The file has no rows with an outcome in its actual column.");
|
|
12800
|
+
return { outcomes, skipped };
|
|
12801
|
+
}
|
|
12802
|
+
function readTable(file) {
|
|
12803
|
+
let text2;
|
|
12804
|
+
try {
|
|
12805
|
+
text2 = fs13.readFileSync(file, "utf8");
|
|
12806
|
+
} catch (error) {
|
|
12807
|
+
throw new CliError(`Could not read ${file}: ${error.message}`);
|
|
12808
|
+
}
|
|
12809
|
+
return parseCsv(text2);
|
|
12810
|
+
}
|
|
12811
|
+
function deploymentNotFound(error, deploymentId, predictionId) {
|
|
12812
|
+
if (!(error instanceof ApiError) || error.status !== 404) return error;
|
|
12813
|
+
if (predictionId !== void 0) {
|
|
12814
|
+
return new CliError(`No prediction ${predictionId} in deployment ${deploymentId}, or no such deployment.`, {
|
|
12815
|
+
hint: `List your deployments with 'diafunc deployment list'.`
|
|
12816
|
+
});
|
|
12817
|
+
}
|
|
12818
|
+
return new CliError(`No deployment ${deploymentId} in your account.`, {
|
|
12819
|
+
hint: `List your deployments with 'diafunc deployment list'.`
|
|
12820
|
+
});
|
|
12821
|
+
}
|
|
12822
|
+
function isNotEnoughCredits(error) {
|
|
12823
|
+
return error instanceof ApiError && error.status === 402;
|
|
12824
|
+
}
|
|
12825
|
+
function checkWords(check) {
|
|
12826
|
+
const range = check.observedMin !== null && check.observedMin !== void 0 && check.observedMax !== null && check.observedMax !== void 0 ? ` (observed ${num(check.observedMin)} to ${num(check.observedMax)})` : "";
|
|
12827
|
+
const value = check.value === null || check.value === void 0 ? "" : ` = ${String(check.value)}`;
|
|
12828
|
+
switch (check.kind) {
|
|
12829
|
+
case "below_range":
|
|
12830
|
+
return `${check.input}${value}, below the observed range${range}`;
|
|
12831
|
+
case "above_range":
|
|
12832
|
+
return `${check.input}${value}, above the observed range${range}`;
|
|
12833
|
+
case "unseen_level":
|
|
12834
|
+
return `${check.input}${value}, a level the model was not found on`;
|
|
12835
|
+
case "missing":
|
|
12836
|
+
return `${check.input}, not sent or not readable`;
|
|
12837
|
+
default:
|
|
12838
|
+
return `${check.input}${value}, ${words(check.kind)}`;
|
|
12839
|
+
}
|
|
12840
|
+
}
|
|
12841
|
+
function predictionLines(deploymentId, answer) {
|
|
12842
|
+
const lines = [];
|
|
12843
|
+
const value = answer.prediction ?? answer.classLabel;
|
|
12844
|
+
const target = answer.target ? `${answer.target}: ` : "";
|
|
12845
|
+
lines.push(`${target}${value === null || value === void 0 ? ABSENT : typeof value === "number" ? num(value) : value}`);
|
|
12846
|
+
const c = answer.confidence;
|
|
12847
|
+
if (c && c.lower !== null && c.lower !== void 0 && c.upper !== null && c.upper !== void 0) {
|
|
12848
|
+
const level = c.level ? `${percent2(c.level)} ` : "";
|
|
12849
|
+
const expected = c.expectedCoverage ? `, expected to hold ${percent2(c.expectedCoverage)} of new rows` : "";
|
|
12850
|
+
lines.push(`${level}interval ${num(c.lower)} to ${num(c.upper)}${expected}`);
|
|
12851
|
+
}
|
|
12852
|
+
const checks = answer.checks;
|
|
12853
|
+
if (checks && checks.withinRange === null) {
|
|
12854
|
+
lines.push("Inputs not checked: the analysis recorded no input ranges for this model.");
|
|
12855
|
+
} else if (checks && checks.withinRange === false) {
|
|
12856
|
+
for (const check of checks.inputs ?? []) lines.push(`Outside what the model was found on: ${checkWords(check)}`);
|
|
12857
|
+
}
|
|
12858
|
+
if (checks?.distance !== null && checks?.distance !== void 0 && checks.distanceLine !== null && checks.distanceLine !== void 0 && checks.distance > checks.distanceLine) {
|
|
12859
|
+
lines.push("The row lies farther from the training rows than 99 of 100 training rows do.");
|
|
12860
|
+
}
|
|
12861
|
+
if (answer.predictionId) {
|
|
12862
|
+
lines.push(`Prediction id ${answer.predictionId}`);
|
|
12863
|
+
lines.push(`Record its outcome with 'diafunc deployment outcomes ${deploymentId} --prediction ${answer.predictionId} --actual <value>'.`);
|
|
12864
|
+
}
|
|
12865
|
+
return lines;
|
|
12866
|
+
}
|
|
12867
|
+
function inputRow(i) {
|
|
12868
|
+
return {
|
|
12869
|
+
input: i.input === "@prediction" ? "(predictions)" : i.input,
|
|
12870
|
+
state: words(i.state),
|
|
12871
|
+
psi: i.psi === null || i.psi === void 0 ? null : num(i.psi),
|
|
12872
|
+
outOfRange: i.outOfRange > 0 ? `${count(i.outOfRange)} (${percent2(i.outOfRangeShare)})` : "0",
|
|
12873
|
+
missing: i.missing,
|
|
12874
|
+
counted: i.counted
|
|
12875
|
+
};
|
|
12876
|
+
}
|
|
12877
|
+
function monitoringSummary(deploymentId, report) {
|
|
12878
|
+
const verdict = report.health ? [report.health.title, ...report.health.reasons ?? []] : ["No verdict yet: the first daily check has not run."];
|
|
12879
|
+
const outside = report.outOfRangeShare === null || report.outOfRangeShare === void 0 ? "" : `, ${percent2(report.outOfRangeShare)} with an input outside the observed range`;
|
|
12880
|
+
const traffic = `${count(report.predictions)} predictions, ${count(report.failed)} failed${outside}.`;
|
|
12881
|
+
const quality = [];
|
|
12882
|
+
const q = report.quality;
|
|
12883
|
+
if (!q || q.scored === 0) {
|
|
12884
|
+
quality.push(`No outcomes recorded in this window. Record them with 'diafunc deployment outcomes ${deploymentId}'.`);
|
|
12885
|
+
} else {
|
|
12886
|
+
const reportRange = q.reportQualityLow !== null && q.reportQualityLow !== void 0 && q.reportQualityHigh !== null && q.reportQualityHigh !== void 0 ? `, from ${num(q.reportQualityLow)} to ${num(q.reportQualityHigh)}` : "";
|
|
12887
|
+
if (q.classification && q.accuracy !== null && q.accuracy !== void 0) {
|
|
12888
|
+
quality.push(`Accuracy ${percent2(q.accuracy)} on ${count(q.scored)} predictions with an outcome: the share whose recorded label matches the predicted one.`);
|
|
12889
|
+
}
|
|
12890
|
+
if (!q.classification || q.quality !== null && q.quality !== void 0) {
|
|
12891
|
+
quality.push(`Quality ${num(q.quality)} on ${count(q.scored)} predictions with an outcome; the report has ${num(q.reportQuality)}${reportRange}.`);
|
|
12892
|
+
}
|
|
12893
|
+
if (q.error !== null && q.error !== void 0) {
|
|
12894
|
+
quality.push(`Error ${num(q.error)} (report ${num(q.reportError)}), mean absolute error ${num(q.mae)}.`);
|
|
12895
|
+
}
|
|
12896
|
+
if (!q.graded) quality.push("Not graded yet: grading starts at 30 predictions with an outcome.");
|
|
12897
|
+
if (q.withInterval > 0) {
|
|
12898
|
+
quality.push(`${count(q.inInterval)} of ${count(q.withInterval)} outcomes lay inside their prediction's interval (${percent2(q.coverage)}); the report expects ${percent2(q.expectedCoverage)}.`);
|
|
12899
|
+
}
|
|
12900
|
+
}
|
|
12901
|
+
const model = [];
|
|
12902
|
+
const m = report.model;
|
|
12903
|
+
if (m) {
|
|
12904
|
+
const served = modelWords(m.servedVersion, m.servedAt) ?? "the model it was made with";
|
|
12905
|
+
model.push(`Serves ${served}${m.servedQuality !== null && m.servedQuality !== void 0 ? `, quality ${num(m.servedQuality)} in its report` : ""}.`);
|
|
12906
|
+
if (m.newerAvailable) {
|
|
12907
|
+
const newer = modelWords(m.newerVersion, m.newerAt) ?? "the model of a newer run";
|
|
12908
|
+
model.push(`The analysis has a newer model: ${newer}${m.newerQuality !== null && m.newerQuality !== void 0 ? `, quality ${num(m.newerQuality)} in its report` : ""}.`);
|
|
12909
|
+
model.push(`Serve it with 'diafunc deployment serve-newest ${deploymentId}'.`);
|
|
12910
|
+
}
|
|
12911
|
+
}
|
|
12912
|
+
const u = report.usage;
|
|
12913
|
+
const usage = u ? `${count(u.predictions)} predictions this month, ${num(u.credits)} credits (${num(u.creditsPerPrediction)} per prediction).` : null;
|
|
12914
|
+
const s = report.settings;
|
|
12915
|
+
const settings = s ? `Input storage ${onOff(s.logInputs)}${s.logInputs && s.retentionDays ? ` (kept ${s.retentionDays} days)` : ""}, mail alerts ${onOff(s.mailAlerts)}.` : null;
|
|
12916
|
+
return { verdict, traffic, quality, model, usage, settings };
|
|
12917
|
+
}
|
|
12918
|
+
async function listDeployments(cmd) {
|
|
12919
|
+
const outputFormat = getOutputFormat20(cmd);
|
|
12920
|
+
const deployments = await createApiClient().deployments.list();
|
|
12921
|
+
if (outputFormat === "json") {
|
|
12922
|
+
format(deployments, { format: outputFormat });
|
|
12923
|
+
return;
|
|
12924
|
+
}
|
|
12925
|
+
if (deployments.length === 0 && outputFormat === "human") {
|
|
12926
|
+
empty("deployments");
|
|
12927
|
+
hint(`Deploy a finished analysis with 'diafunc deployment create --analysis <id> --target <column>'.`);
|
|
12928
|
+
return;
|
|
12929
|
+
}
|
|
12930
|
+
format(deployments.map((d) => ({
|
|
12931
|
+
deploymentId: d.deploymentId,
|
|
12932
|
+
name: d.name,
|
|
12933
|
+
target: d.target,
|
|
12934
|
+
health: words(d.health),
|
|
12935
|
+
status: d.status ? d.status.toLowerCase() : null,
|
|
12936
|
+
createdAt: d.createdAt
|
|
12937
|
+
})), {
|
|
12938
|
+
format: outputFormat,
|
|
12939
|
+
columns: [
|
|
12940
|
+
{ key: "deploymentId", header: "id", kind: "id" },
|
|
12941
|
+
{ key: "name" },
|
|
12942
|
+
{ key: "target" },
|
|
12943
|
+
{ key: "health" },
|
|
12944
|
+
{ key: "status", kind: "state" },
|
|
12945
|
+
{ key: "createdAt", header: "created", kind: "date" }
|
|
12946
|
+
]
|
|
12947
|
+
});
|
|
12948
|
+
}
|
|
12949
|
+
function printDeployment(deployment, outputFormat) {
|
|
12950
|
+
if (outputFormat === "json") {
|
|
12951
|
+
format(deployment, { format: outputFormat });
|
|
12952
|
+
return;
|
|
12953
|
+
}
|
|
12954
|
+
format({
|
|
12955
|
+
deploymentId: deployment.deploymentId,
|
|
12956
|
+
name: deployment.name,
|
|
12957
|
+
target: deployment.target,
|
|
12958
|
+
analysisId: deployment.analysisId,
|
|
12959
|
+
formula: deployment.formula,
|
|
12960
|
+
inputs: (deployment.inputKeys ?? []).join(", "),
|
|
12961
|
+
status: deployment.status ? deployment.status.toLowerCase() : null,
|
|
12962
|
+
health: words(deployment.health),
|
|
12963
|
+
model: modelWords(deployment.modelVersion, deployment.modelVersionAt),
|
|
12964
|
+
logInputs: onOff(deployment.logInputs) + (deployment.logInputs && deployment.retentionDays ? `, kept ${deployment.retentionDays} days` : ""),
|
|
12965
|
+
mailAlerts: onOff(deployment.mailAlerts),
|
|
12966
|
+
createdAt: deployment.createdAt
|
|
12967
|
+
}, {
|
|
12968
|
+
format: outputFormat,
|
|
12969
|
+
columns: [
|
|
12970
|
+
{ key: "deploymentId", header: "ID", kind: "id" },
|
|
12971
|
+
{ key: "name", header: "Name" },
|
|
12972
|
+
{ key: "target", header: "Target" },
|
|
12973
|
+
{ key: "analysisId", header: "Analysis", kind: "id" },
|
|
12974
|
+
{ key: "formula", header: "Formula" },
|
|
12975
|
+
{ key: "inputs", header: "Inputs" },
|
|
12976
|
+
{ key: "status", header: "Status", kind: "state" },
|
|
12977
|
+
{ key: "health", header: "Health" },
|
|
12978
|
+
{ key: "model", header: "Model" },
|
|
12979
|
+
{ key: "logInputs", header: "Input storage" },
|
|
12980
|
+
{ key: "mailAlerts", header: "Mail alerts" },
|
|
12981
|
+
{ key: "createdAt", header: "Created", kind: "date" }
|
|
12982
|
+
]
|
|
12983
|
+
});
|
|
12984
|
+
if (outputFormat === "human" && (deployment.inputRanges ?? []).length > 0) {
|
|
12985
|
+
heading("Inputs on the rows the model was found on");
|
|
12986
|
+
for (const r of deployment.inputRanges ?? []) {
|
|
12987
|
+
detail(r.kind === "categorical" ? `${r.input}: ${(r.levels ?? []).join(", ") || ABSENT}` : `${r.input}: ${num(r.min)} to ${num(r.max)}, median ${num(r.median)}`);
|
|
12988
|
+
}
|
|
12989
|
+
}
|
|
12990
|
+
}
|
|
12991
|
+
async function predictOne(deploymentId, options, cmd) {
|
|
12992
|
+
const outputFormat = getOutputFormat20(cmd);
|
|
12993
|
+
const request = { inputs: parseInputs(options.input ?? []) };
|
|
12994
|
+
if (options.reference !== void 0) request.reference = options.reference;
|
|
12995
|
+
if (options.store === false) request.store = false;
|
|
12996
|
+
let answer;
|
|
12997
|
+
try {
|
|
12998
|
+
answer = await createApiClient().deployments.predict(deploymentId, request);
|
|
12999
|
+
} catch (error) {
|
|
13000
|
+
if (isNotEnoughCredits(error)) throw new CliError(NOT_ENOUGH_CREDITS, { hint: CREDITS_HINT });
|
|
13001
|
+
throw error;
|
|
13002
|
+
}
|
|
13003
|
+
if (isDryRun()) return;
|
|
13004
|
+
if (outputFormat !== "human") {
|
|
13005
|
+
format(answer, { format: outputFormat });
|
|
13006
|
+
return;
|
|
13007
|
+
}
|
|
13008
|
+
const [first, ...rest] = predictionLines(deploymentId, answer);
|
|
13009
|
+
console.log(first);
|
|
13010
|
+
for (const line of rest) {
|
|
13011
|
+
if (line.startsWith("Outside") || line.startsWith("The row lies") || line.startsWith("Inputs not checked")) warn(line);
|
|
13012
|
+
else detail(line);
|
|
13013
|
+
}
|
|
13014
|
+
}
|
|
13015
|
+
function resultSink(out) {
|
|
13016
|
+
if (out) {
|
|
13017
|
+
fs13.writeFileSync(out, "");
|
|
13018
|
+
return (line) => fs13.appendFileSync(out, `${line}
|
|
13019
|
+
`);
|
|
13020
|
+
}
|
|
13021
|
+
return (line) => {
|
|
13022
|
+
process.stdout.write(`${line}
|
|
13023
|
+
`);
|
|
13024
|
+
};
|
|
13025
|
+
}
|
|
13026
|
+
async function predictFile(deploymentId, options, cmd) {
|
|
13027
|
+
const outputFormat = getOutputFormat20(cmd);
|
|
13028
|
+
const api = createApiClient();
|
|
13029
|
+
const deployment = await api.deployments.get(deploymentId);
|
|
13030
|
+
const table = readTable(options.file);
|
|
13031
|
+
const requests = predictRequestsFrom(table, deployment.inputKeys, {
|
|
13032
|
+
referenceColumn: options.reference,
|
|
13033
|
+
store: options.store
|
|
13034
|
+
});
|
|
13035
|
+
const rows = requests.length;
|
|
13036
|
+
const note = (line) => console.error(chalk30.dim(line));
|
|
13037
|
+
note(`${options.file}: ${count(rows)} row${rows === 1 ? "" : "s"} for ${deployment.name}. Each prediction costs credits; rows that cannot be predicted are not charged.`);
|
|
13038
|
+
if (!options.yes && !isDryRun() && prompterFor(cmd)) {
|
|
13039
|
+
try {
|
|
13040
|
+
const usage = (await api.deployments.monitoring(deploymentId, "7d")).usage;
|
|
13041
|
+
if (usage) note(`One prediction costs ${num(usage.creditsPerPrediction)} credits; ${count(rows)} cost ${num(usage.creditsPerPrediction * rows)}.`);
|
|
13042
|
+
} catch (error) {
|
|
13043
|
+
if (!(error instanceof ApiError)) throw error;
|
|
13044
|
+
}
|
|
13045
|
+
}
|
|
13046
|
+
const go = await confirmStep(
|
|
13047
|
+
cmd,
|
|
13048
|
+
`Predict ${count(rows)} rows?`,
|
|
13049
|
+
options.yes,
|
|
13050
|
+
`${count(rows)} predictions cost credits, so this run needs a confirmation.`
|
|
13051
|
+
);
|
|
13052
|
+
if (!go) {
|
|
13053
|
+
warn("Nothing was sent.");
|
|
13054
|
+
return;
|
|
13055
|
+
}
|
|
13056
|
+
const json = outputFormat === "json";
|
|
13057
|
+
const collected = [];
|
|
13058
|
+
const write2 = json ? null : resultSink(options.out);
|
|
13059
|
+
write2?.(csvLine([...RESULT_HEADER]));
|
|
13060
|
+
let sent = 0;
|
|
13061
|
+
let predicted = 0;
|
|
13062
|
+
let failed = 0;
|
|
13063
|
+
const pieces = chunks(requests, MAX_ROWS_PER_CALL);
|
|
13064
|
+
for (const piece of pieces) {
|
|
13065
|
+
let response;
|
|
13066
|
+
try {
|
|
13067
|
+
response = await api.deployments.predictBatch(deploymentId, { rows: piece });
|
|
13068
|
+
} catch (error) {
|
|
13069
|
+
if (json) formatJson(collected);
|
|
13070
|
+
if (sent > 0) {
|
|
13071
|
+
warn(`${count(sent)} of ${count(rows)} rows were sent before this; their results are written. The other ${count(rows - sent)} were not sent.`);
|
|
13072
|
+
}
|
|
13073
|
+
if (isNotEnoughCredits(error)) throw new CliError(NOT_ENOUGH_CREDITS, { hint: CREDITS_HINT });
|
|
13074
|
+
throw error;
|
|
13075
|
+
}
|
|
13076
|
+
if (isDryRun()) {
|
|
13077
|
+
sent += piece.length;
|
|
13078
|
+
continue;
|
|
13079
|
+
}
|
|
13080
|
+
const answers = response.predictions ?? [];
|
|
13081
|
+
piece.forEach((_, i) => {
|
|
13082
|
+
const row = sent + i + 1;
|
|
13083
|
+
const answer = answers[i];
|
|
13084
|
+
if (json) collected.push({ row, ...answer ?? { error: "no answer for this row" } });
|
|
13085
|
+
else write2(csvLine(resultFields(row, answer)));
|
|
13086
|
+
});
|
|
13087
|
+
predicted += response.predicted ?? answers.filter((a) => !a.error).length;
|
|
13088
|
+
failed += response.failed ?? answers.filter((a) => a.error).length;
|
|
13089
|
+
sent += piece.length;
|
|
13090
|
+
if (pieces.length > 1) note(`Sent ${count(sent)} of ${count(rows)} rows.`);
|
|
13091
|
+
}
|
|
13092
|
+
if (isDryRun()) return;
|
|
13093
|
+
if (json) formatJson(collected);
|
|
13094
|
+
const where = options.out ? ` Results are in ${options.out}.` : "";
|
|
13095
|
+
const failures = failed > 0 ? ` ${count(failed)} ${failed === 1 ? "row" : "rows"} could not be predicted and ${failed === 1 ? "was" : "were"} not charged; the error column says why.` : "";
|
|
13096
|
+
console.error(`${chalk30.green("\u2713")} Predicted ${count(predicted)} of ${count(rows)} rows.${failures}${where}`);
|
|
13097
|
+
}
|
|
13098
|
+
async function recordOutcomes(deploymentId, options, cmd) {
|
|
13099
|
+
const outputFormat = getOutputFormat20(cmd);
|
|
13100
|
+
let outcomes;
|
|
13101
|
+
let skipped = 0;
|
|
13102
|
+
if (options.file !== void 0) {
|
|
13103
|
+
if (options.prediction !== void 0 || options.reference !== void 0 || options.actual !== void 0) {
|
|
13104
|
+
throw new CliError("--file goes alone; --prediction, --reference and --actual are for one outcome.", { exitCode: EXIT_USAGE });
|
|
13105
|
+
}
|
|
13106
|
+
({ outcomes, skipped } = outcomesFrom(readTable(options.file)));
|
|
13107
|
+
} else {
|
|
13108
|
+
if (options.actual === void 0 || options.prediction === void 0 === (options.reference === void 0)) {
|
|
13109
|
+
throw new CliError("Name one prediction and its outcome.", {
|
|
13110
|
+
exitCode: EXIT_USAGE,
|
|
13111
|
+
hint: "Use --prediction <predictionId> (or --reference <reference>) with --actual <value>, or --file outcomes.csv."
|
|
13112
|
+
});
|
|
13113
|
+
}
|
|
13114
|
+
const actual = parseOutcomeValue(options.actual, "--actual");
|
|
13115
|
+
outcomes = [options.prediction !== void 0 ? { predictionId: options.prediction, actual } : { reference: options.reference, actual }];
|
|
13116
|
+
}
|
|
13117
|
+
const api = createApiClient();
|
|
13118
|
+
let recorded = 0;
|
|
13119
|
+
const notFound = [];
|
|
13120
|
+
for (const piece of chunks(outcomes, MAX_ROWS_PER_CALL)) {
|
|
13121
|
+
const response = await api.deployments.recordOutcomes(deploymentId, { outcomes: piece });
|
|
13122
|
+
if (isDryRun()) continue;
|
|
13123
|
+
recorded += response.recorded ?? 0;
|
|
13124
|
+
notFound.push(...response.notFound ?? []);
|
|
13125
|
+
}
|
|
13126
|
+
if (isDryRun()) return;
|
|
13127
|
+
if (outputFormat !== "human") {
|
|
13128
|
+
format({ recorded, notFound, skipped }, { format: outputFormat });
|
|
13129
|
+
return;
|
|
13130
|
+
}
|
|
13131
|
+
success(`Recorded ${count(recorded)} outcome${recorded === 1 ? "" : "s"}.`);
|
|
13132
|
+
if (skipped > 0) detail(`${count(skipped)} row${skipped === 1 ? " with an empty actual column was" : "s with an empty actual column were"} skipped.`);
|
|
13133
|
+
if (notFound.length > 0) {
|
|
13134
|
+
warn(`${count(notFound.length)} named no prediction of this deployment:`);
|
|
13135
|
+
for (const name of notFound.slice(0, 20)) detail(name);
|
|
13136
|
+
if (notFound.length > 20) detail(`and ${count(notFound.length - 20)} more (see them all with --output json).`);
|
|
13137
|
+
}
|
|
13138
|
+
}
|
|
13139
|
+
async function monitor(deploymentId, options, cmd) {
|
|
13140
|
+
const outputFormat = getOutputFormat20(cmd);
|
|
13141
|
+
const window = parseWindow(options.window);
|
|
13142
|
+
const report = await createApiClient().deployments.monitoring(deploymentId, window);
|
|
13143
|
+
if (outputFormat === "json") {
|
|
13144
|
+
format(report, { format: outputFormat });
|
|
13145
|
+
return;
|
|
13146
|
+
}
|
|
13147
|
+
const inputs = [...report.inputs ?? [], ...report.prediction ? [report.prediction] : []];
|
|
13148
|
+
const columns = [
|
|
13149
|
+
{ key: "input" },
|
|
13150
|
+
{ key: "state" },
|
|
13151
|
+
{ key: "psi", header: "PSI" },
|
|
13152
|
+
{ key: "outOfRange", header: "outside range" },
|
|
13153
|
+
{ key: "missing", kind: "number" },
|
|
13154
|
+
{ key: "counted", kind: "number" }
|
|
13155
|
+
];
|
|
13156
|
+
if (outputFormat === "table") {
|
|
13157
|
+
format(inputs.map(inputRow), { format: outputFormat, columns });
|
|
13158
|
+
return;
|
|
13159
|
+
}
|
|
13160
|
+
const summary = monitoringSummary(deploymentId, report);
|
|
13161
|
+
console.log(chalk30.bold(`${report.name}`) + chalk30.dim(` (target ${report.target}), last ${report.windowDays} days`));
|
|
13162
|
+
heading("Verdict");
|
|
13163
|
+
const [title, ...reasons] = summary.verdict;
|
|
13164
|
+
console.log(` ${title}`);
|
|
13165
|
+
for (const reason2 of reasons) detail(reason2);
|
|
13166
|
+
heading("Traffic");
|
|
13167
|
+
console.log(` ${summary.traffic}`);
|
|
13168
|
+
if (inputs.length > 0) {
|
|
13169
|
+
heading("Inputs against the training rows");
|
|
13170
|
+
format(inputs.map(inputRow), { format: "human", columns });
|
|
13171
|
+
}
|
|
13172
|
+
heading("Quality on outcomes");
|
|
13173
|
+
for (const line of summary.quality) console.log(` ${line}`);
|
|
13174
|
+
if (summary.model.length > 0) {
|
|
13175
|
+
heading("Model");
|
|
13176
|
+
for (const line of summary.model) console.log(` ${line}`);
|
|
13177
|
+
}
|
|
13178
|
+
if (summary.usage) {
|
|
13179
|
+
heading("Usage");
|
|
13180
|
+
console.log(` ${summary.usage}`);
|
|
13181
|
+
}
|
|
13182
|
+
if (summary.settings) {
|
|
13183
|
+
heading("Settings");
|
|
13184
|
+
console.log(` ${summary.settings}`);
|
|
13185
|
+
}
|
|
13186
|
+
}
|
|
13187
|
+
async function serveNewest(deploymentId, options, cmd) {
|
|
13188
|
+
const outputFormat = getOutputFormat20(cmd);
|
|
13189
|
+
const api = createApiClient();
|
|
13190
|
+
const model = (await api.deployments.monitoring(deploymentId, "7d")).model;
|
|
13191
|
+
if (model && !model.newerAvailable) {
|
|
13192
|
+
const served = modelWords(model.servedVersion, model.servedAt);
|
|
13193
|
+
success(
|
|
13194
|
+
`The deployment already serves the newest model${served ? `, ${served}` : ""}.`,
|
|
13195
|
+
{ format: outputFormat === "json" ? "json" : void 0 }
|
|
13196
|
+
);
|
|
13197
|
+
return;
|
|
13198
|
+
}
|
|
13199
|
+
if (model && outputFormat === "human") {
|
|
13200
|
+
detail(`Serves ${modelWords(model.servedVersion, model.servedAt) ?? "the model it was made with"}, quality ${num(model.servedQuality)} in its report.`);
|
|
13201
|
+
detail(`Newest: ${modelWords(model.newerVersion, model.newerAt) ?? "the model of a newer run"}, quality ${num(model.newerQuality)} in its report.`);
|
|
13202
|
+
}
|
|
13203
|
+
const go = await confirmStep(
|
|
13204
|
+
cmd,
|
|
13205
|
+
"Serve the newest model? Every prediction from now on uses it.",
|
|
13206
|
+
options.yes,
|
|
13207
|
+
"Serving the newest model changes what every prediction uses, so it needs a confirmation."
|
|
13208
|
+
);
|
|
13209
|
+
if (!go) {
|
|
13210
|
+
warn("Nothing changed; the deployment serves the same model.");
|
|
13211
|
+
return;
|
|
13212
|
+
}
|
|
13213
|
+
const updated = await api.deployments.serveNewestModel(deploymentId);
|
|
13214
|
+
if (isDryRun()) return;
|
|
13215
|
+
if (outputFormat !== "human") {
|
|
13216
|
+
format(updated, { format: outputFormat });
|
|
13217
|
+
return;
|
|
13218
|
+
}
|
|
13219
|
+
success(`Now serving ${modelWords(updated.modelVersion, updated.modelVersionAt) ?? "the newest model"}.`);
|
|
13220
|
+
}
|
|
13221
|
+
function registerDeploymentCommands(program) {
|
|
13222
|
+
const deployment = program.command("deployment").description("Serve a finished analysis's model as a predict endpoint, predict with it, record outcomes and follow its monitoring").addHelpText("after", `
|
|
13223
|
+
Every prediction costs 0.001 credits, monitoring included. Recording outcomes costs nothing.
|
|
13224
|
+
|
|
13225
|
+
Examples:
|
|
13226
|
+
$ diafunc deployment create --analysis <analysisId> --target price
|
|
13227
|
+
$ diafunc deployment predict <deploymentId> --input size=120 --input rooms=4
|
|
13228
|
+
$ diafunc deployment predict <deploymentId> --file rows.csv --reference id --out results.csv
|
|
13229
|
+
$ diafunc deployment outcomes <deploymentId> --file results-with-outcomes.csv
|
|
13230
|
+
$ diafunc deployment monitor <deploymentId> --window 30d
|
|
13231
|
+
$ diafunc deployment set <deploymentId> --log-inputs on --retention 90
|
|
13232
|
+
`);
|
|
13233
|
+
deployment.command("list").description("List your deployments, newest first, with the verdict of each one's latest daily check").action(async (_options, cmd) => {
|
|
13234
|
+
try {
|
|
13235
|
+
await listDeployments(cmd);
|
|
13236
|
+
} catch (error) {
|
|
13237
|
+
handleError(error);
|
|
13238
|
+
}
|
|
13239
|
+
});
|
|
13240
|
+
deployment.command("get").description("Show a deployment: its formula, the inputs it reads and their ranges on the training rows, and its settings").argument("<deploymentId>", "Deployment ID").action(async (deploymentId, _options, cmd) => {
|
|
13241
|
+
try {
|
|
13242
|
+
printDeployment(await createApiClient().deployments.get(deploymentId), getOutputFormat20(cmd));
|
|
13243
|
+
} catch (error) {
|
|
13244
|
+
handleError(deploymentNotFound(error, deploymentId));
|
|
13245
|
+
}
|
|
13246
|
+
});
|
|
13247
|
+
deployment.command("create").description("Deploy the model a finished analysis found for one target").requiredOption("--analysis <analysisId>", "The analysis").requiredOption("--target <column>", "The target column whose model is served").option("--name <name>", "Name of the deployment (default: the analysis name and the target)").action(async (options, cmd) => {
|
|
13248
|
+
try {
|
|
13249
|
+
const created = await createApiClient().deployments.create({
|
|
13250
|
+
analysisId: options.analysis,
|
|
13251
|
+
target: options.target,
|
|
13252
|
+
...options.name !== void 0 ? { name: options.name } : {}
|
|
13253
|
+
});
|
|
13254
|
+
if (isDryRun()) return;
|
|
13255
|
+
const outputFormat = getOutputFormat20(cmd);
|
|
13256
|
+
if (outputFormat !== "human") {
|
|
13257
|
+
format(created, { format: outputFormat });
|
|
13258
|
+
return;
|
|
13259
|
+
}
|
|
13260
|
+
success(`Deployment ${created.name} created (${created.deploymentId}).`);
|
|
13261
|
+
if ((created.inputKeys ?? []).length > 0) detail(`It reads ${created.inputKeys.join(", ")}.`);
|
|
13262
|
+
hint(`Predict with 'diafunc deployment predict ${created.deploymentId} --input <name>=<value> ...'; each prediction costs credits.`);
|
|
13263
|
+
} catch (error) {
|
|
13264
|
+
handleError(error);
|
|
13265
|
+
}
|
|
13266
|
+
});
|
|
13267
|
+
deployment.command("delete").description("Delete a deployment; its endpoint stops answering").argument("<deploymentId>", "Deployment ID").option("-y, --yes", "Skip confirmation prompt (for CI / scripted use)").action(async (deploymentId, options, cmd) => {
|
|
13268
|
+
try {
|
|
13269
|
+
await confirmDestructive(
|
|
13270
|
+
`This will permanently delete deployment "${deploymentId}"; its endpoint stops answering.`,
|
|
13271
|
+
{ yes: options.yes, resourceId: deploymentId }
|
|
13272
|
+
);
|
|
13273
|
+
await createApiClient().deployments.delete(deploymentId);
|
|
13274
|
+
success(`Deployment ${deploymentId} deleted.`, { format: getOutputFormat20(cmd) === "json" ? "json" : void 0 });
|
|
13275
|
+
} catch (error) {
|
|
13276
|
+
handleError(deploymentNotFound(error, deploymentId));
|
|
13277
|
+
}
|
|
13278
|
+
});
|
|
13279
|
+
deployment.command("predict").description("Predict with a deployment, one row from --input or every row of a CSV file. Each prediction costs 0.001 credits").argument("<deploymentId>", "Deployment ID").option(
|
|
13280
|
+
"--input <name=value>",
|
|
13281
|
+
"An input value; repeat for every input (see them with 'deployment get')",
|
|
13282
|
+
(value, previous = []) => previous.concat([value])
|
|
13283
|
+
).option("--file <path>", "A CSV file with a header row and one row per prediction, sent in calls of 1,000 rows").option("--reference <text>", "Your own reference, to record the outcome by it later. With --file: the column that holds each row's reference").option("--no-store", "Keep the input values of these predictions out of storage, even when the deployment stores inputs").option("--out <file>", "With --file: write the results here instead of to standard output").option("-y, --yes", "With --file: predict without asking first (for CI / scripted use)").addHelpText("after", `
|
|
13284
|
+
Each prediction costs 0.001 credits, monitoring included. A --file run prints the number of rows and asks before
|
|
13285
|
+
sending them; rows the platform cannot predict are not charged. The result is CSV, one line
|
|
13286
|
+
per input row: ${RESULT_HEADER.join(", ")}.
|
|
13287
|
+
Add an actual column with the values that came true and send it back with
|
|
13288
|
+
'diafunc deployment outcomes <id> --file'.
|
|
13289
|
+
`).action(async (deploymentId, options, cmd) => {
|
|
13290
|
+
try {
|
|
13291
|
+
const hasInputs = (options.input ?? []).length > 0;
|
|
13292
|
+
if (hasInputs === (options.file !== void 0)) {
|
|
13293
|
+
throw new CliError("Give the inputs with --input name=value, or a CSV file with --file, not both.", {
|
|
13294
|
+
exitCode: EXIT_USAGE,
|
|
13295
|
+
hint: `See the inputs the deployment reads with 'diafunc deployment get ${deploymentId}'.`
|
|
13296
|
+
});
|
|
13297
|
+
}
|
|
13298
|
+
if (options.out !== void 0 && options.file === void 0) {
|
|
13299
|
+
throw new CliError("--out goes with --file.", { exitCode: EXIT_USAGE });
|
|
13300
|
+
}
|
|
13301
|
+
if (options.file !== void 0) await predictFile(deploymentId, options, cmd);
|
|
13302
|
+
else await predictOne(deploymentId, options, cmd);
|
|
13303
|
+
} catch (error) {
|
|
13304
|
+
handleError(deploymentNotFound(error, deploymentId));
|
|
13305
|
+
}
|
|
13306
|
+
});
|
|
13307
|
+
deployment.command("outcomes").description("Record outcomes, the values that came true, for earlier predictions, by prediction id or by your reference. Recording costs nothing").argument("<deploymentId>", "Deployment ID").option("--prediction <predictionId>", "The prediction the outcome belongs to").option("--reference <reference>", "Instead of --prediction: the reference you sent with the prediction").option("--actual <value>", "The value that came true: a number, or a class label for a classification deployment").option("--file <path>", "A CSV file with an actual column and a predictionId or reference column, sent in calls of 1,000 rows").action(async (deploymentId, options, cmd) => {
|
|
13308
|
+
try {
|
|
13309
|
+
await recordOutcomes(deploymentId, options, cmd);
|
|
13310
|
+
} catch (error) {
|
|
13311
|
+
handleError(deploymentNotFound(error, deploymentId));
|
|
13312
|
+
}
|
|
13313
|
+
});
|
|
13314
|
+
deployment.command("monitor").description("How a deployment is doing: verdict and reasons, traffic, drift and range per input, quality on outcomes, interval coverage, newer model, usage").argument("<deploymentId>", "Deployment ID").option("--window <window>", "The period the figures cover: 7d or 30d", "7d").action(async (deploymentId, options, cmd) => {
|
|
13315
|
+
try {
|
|
13316
|
+
await monitor(deploymentId, options, cmd);
|
|
13317
|
+
} catch (error) {
|
|
13318
|
+
handleError(deploymentNotFound(error, deploymentId));
|
|
13319
|
+
}
|
|
13320
|
+
});
|
|
13321
|
+
deployment.command("set").description("Change a deployment's name, input storage or mail alerts; what is not given stays as it is").argument("<deploymentId>", "Deployment ID").option("--name <name>", "New name").option("--log-inputs <on|off>", "Store the input values of each prediction").option("--retention <days>", "How long stored input values are kept: 30, 90 or 180 days").option("--mail-alerts <on|off>", "Also send a change of health by mail (the notice in the app is always sent)").action(async (deploymentId, options, cmd) => {
|
|
13322
|
+
try {
|
|
13323
|
+
const request = settingsFrom(options);
|
|
13324
|
+
const updated = await createApiClient().deployments.update(deploymentId, request);
|
|
13325
|
+
if (isDryRun()) return;
|
|
13326
|
+
const outputFormat = getOutputFormat20(cmd);
|
|
13327
|
+
if (outputFormat !== "human") {
|
|
13328
|
+
format(updated, { format: outputFormat });
|
|
13329
|
+
return;
|
|
13330
|
+
}
|
|
13331
|
+
success(`Deployment ${updated.name} updated.`);
|
|
13332
|
+
detail(`Input storage ${onOff(updated.logInputs)}${updated.logInputs && updated.retentionDays ? ` (kept ${updated.retentionDays} days)` : ""}, mail alerts ${onOff(updated.mailAlerts)}.`);
|
|
13333
|
+
} catch (error) {
|
|
13334
|
+
handleError(deploymentNotFound(error, deploymentId));
|
|
13335
|
+
}
|
|
13336
|
+
});
|
|
13337
|
+
deployment.command("serve-newest").description("Serve the newest model the analysis has for the target. Until then a deployment keeps the model it was made with").argument("<deploymentId>", "Deployment ID").option("-y, --yes", "Switch without asking first (for CI / scripted use)").action(async (deploymentId, options, cmd) => {
|
|
13338
|
+
try {
|
|
13339
|
+
await serveNewest(deploymentId, options, cmd);
|
|
13340
|
+
} catch (error) {
|
|
13341
|
+
handleError(deploymentNotFound(error, deploymentId));
|
|
13342
|
+
}
|
|
13343
|
+
});
|
|
13344
|
+
deployment.command("delete-prediction").description("Delete one prediction with its stored input values and its outcome").argument("<deploymentId>", "Deployment ID").argument("<predictionId>", "Prediction ID").option("-y, --yes", "Skip confirmation prompt (for CI / scripted use)").action(async (deploymentId, predictionId, options, cmd) => {
|
|
13345
|
+
try {
|
|
13346
|
+
await confirmDestructive(
|
|
13347
|
+
`This will permanently delete prediction "${predictionId}" with its stored inputs and outcome.`,
|
|
13348
|
+
{ yes: options.yes, resourceId: predictionId }
|
|
13349
|
+
);
|
|
13350
|
+
await createApiClient().deployments.deletePrediction(deploymentId, predictionId);
|
|
13351
|
+
success(`Prediction ${predictionId} deleted.`, { format: getOutputFormat20(cmd) === "json" ? "json" : void 0 });
|
|
13352
|
+
} catch (error) {
|
|
13353
|
+
handleError(deploymentNotFound(error, deploymentId, predictionId));
|
|
13354
|
+
}
|
|
13355
|
+
});
|
|
13356
|
+
}
|
|
13357
|
+
|
|
12394
13358
|
// src/commands/public/index.ts
|
|
12395
13359
|
var MIN_LIMIT = 1;
|
|
12396
13360
|
var MAX_LIMIT = 500;
|
|
12397
|
-
function
|
|
13361
|
+
function getOutputFormat21(cmd) {
|
|
12398
13362
|
const config = loadConfig();
|
|
12399
13363
|
const globalOpts = cmd.optsWithGlobals();
|
|
12400
13364
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -12446,7 +13410,7 @@ async function readPublicAnalyses(analysis, options) {
|
|
|
12446
13410
|
}
|
|
12447
13411
|
}
|
|
12448
13412
|
async function listPublicAnalyses(options, cmd) {
|
|
12449
|
-
const outputFormat =
|
|
13413
|
+
const outputFormat = getOutputFormat21(cmd);
|
|
12450
13414
|
const limit = parseLimit(options.limit);
|
|
12451
13415
|
const changedSince = options.changedSince === void 0 ? void 0 : parseChangedSince(options.changedSince);
|
|
12452
13416
|
const api = createApiClient();
|
|
@@ -12489,7 +13453,7 @@ function newestRunRecord(run) {
|
|
|
12489
13453
|
};
|
|
12490
13454
|
}
|
|
12491
13455
|
async function showPublicAnalysis(analysisId, cmd) {
|
|
12492
|
-
const outputFormat =
|
|
13456
|
+
const outputFormat = getOutputFormat21(cmd);
|
|
12493
13457
|
const api = createApiClient();
|
|
12494
13458
|
const result = await api.analysis.get(analysisId);
|
|
12495
13459
|
if (!result?.analysis) {
|
|
@@ -12558,8 +13522,8 @@ Examples:
|
|
|
12558
13522
|
}
|
|
12559
13523
|
|
|
12560
13524
|
// src/commands/license/index.ts
|
|
12561
|
-
import
|
|
12562
|
-
function
|
|
13525
|
+
import chalk31 from "chalk";
|
|
13526
|
+
function getOutputFormat22(cmd) {
|
|
12563
13527
|
const config = loadConfig();
|
|
12564
13528
|
const globalOpts = cmd.optsWithGlobals();
|
|
12565
13529
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -12620,7 +13584,7 @@ async function catalogEntry(licenseId) {
|
|
|
12620
13584
|
return entry;
|
|
12621
13585
|
}
|
|
12622
13586
|
function printLicense(license, cmd, verb) {
|
|
12623
|
-
const outputFormat =
|
|
13587
|
+
const outputFormat = getOutputFormat22(cmd);
|
|
12624
13588
|
if (outputFormat !== "human") {
|
|
12625
13589
|
format(license, { format: outputFormat });
|
|
12626
13590
|
return;
|
|
@@ -12628,7 +13592,7 @@ function printLicense(license, cmd, verb) {
|
|
|
12628
13592
|
success(`License "${license.licenceId}" ${verb} (${stateWord(license.state)}, flags ${licenseMarks(license) ?? "none"}).`);
|
|
12629
13593
|
}
|
|
12630
13594
|
async function listCatalog(cmd) {
|
|
12631
|
-
const outputFormat =
|
|
13595
|
+
const outputFormat = getOutputFormat22(cmd);
|
|
12632
13596
|
const entries = await createApiClient().admin.listLicenseCatalog();
|
|
12633
13597
|
if (outputFormat === "json") {
|
|
12634
13598
|
format(entries, { format: outputFormat });
|
|
@@ -12660,7 +13624,7 @@ async function listCatalog(cmd) {
|
|
|
12660
13624
|
});
|
|
12661
13625
|
}
|
|
12662
13626
|
async function listLicenses(cmd) {
|
|
12663
|
-
const outputFormat =
|
|
13627
|
+
const outputFormat = getOutputFormat22(cmd);
|
|
12664
13628
|
const api = createApiClient();
|
|
12665
13629
|
const licenses = await api.admin.listLicenses();
|
|
12666
13630
|
if (outputFormat === "json") {
|
|
@@ -12688,14 +13652,14 @@ async function listLicenses(cmd) {
|
|
|
12688
13652
|
]
|
|
12689
13653
|
});
|
|
12690
13654
|
if (outputFormat === "human") {
|
|
12691
|
-
console.error(
|
|
13655
|
+
console.error(chalk31.dim(
|
|
12692
13656
|
`
|
|
12693
13657
|
Flags: ${LICENSE_MARKS.map(({ mark, meaning }) => `${mark} ${meaning}`).join(", ")}. A deprecated license stays on the projects that carry it and cannot be chosen.`
|
|
12694
13658
|
));
|
|
12695
13659
|
}
|
|
12696
13660
|
}
|
|
12697
13661
|
async function showLicense(licenseId, cmd) {
|
|
12698
|
-
const outputFormat =
|
|
13662
|
+
const outputFormat = getOutputFormat22(cmd);
|
|
12699
13663
|
const api = createApiClient();
|
|
12700
13664
|
let license;
|
|
12701
13665
|
try {
|
|
@@ -12855,8 +13819,8 @@ Examples:
|
|
|
12855
13819
|
}
|
|
12856
13820
|
|
|
12857
13821
|
// src/commands/data-sources/index.ts
|
|
12858
|
-
import
|
|
12859
|
-
function
|
|
13822
|
+
import chalk32 from "chalk";
|
|
13823
|
+
function getOutputFormat23(cmd) {
|
|
12860
13824
|
const config = loadConfig();
|
|
12861
13825
|
const globalOpts = cmd.optsWithGlobals();
|
|
12862
13826
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -12956,7 +13920,7 @@ function resolveProjectId(cmd) {
|
|
|
12956
13920
|
return resolved;
|
|
12957
13921
|
}
|
|
12958
13922
|
async function listDataSources(projectId, cmd) {
|
|
12959
|
-
const outputFormat =
|
|
13923
|
+
const outputFormat = getOutputFormat23(cmd);
|
|
12960
13924
|
const api = createApiClient();
|
|
12961
13925
|
const sources = await api.storage.listDataSources(projectId);
|
|
12962
13926
|
if (outputFormat === "human" && sources.length === 0) {
|
|
@@ -12977,13 +13941,13 @@ async function listDataSources(projectId, cmd) {
|
|
|
12977
13941
|
});
|
|
12978
13942
|
}
|
|
12979
13943
|
async function getDataSource(id, cmd) {
|
|
12980
|
-
const outputFormat =
|
|
13944
|
+
const outputFormat = getOutputFormat23(cmd);
|
|
12981
13945
|
const api = createApiClient();
|
|
12982
13946
|
const ds = await api.storage.getDataSource(id);
|
|
12983
13947
|
format(ds, { format: outputFormat });
|
|
12984
13948
|
}
|
|
12985
13949
|
async function showDashboard(projectId, cmd) {
|
|
12986
|
-
const outputFormat =
|
|
13950
|
+
const outputFormat = getOutputFormat23(cmd);
|
|
12987
13951
|
const api = createApiClient();
|
|
12988
13952
|
const dashboard = await api.storage.getDataSourceDashboard(projectId);
|
|
12989
13953
|
if (outputFormat !== "human") {
|
|
@@ -12991,7 +13955,7 @@ async function showDashboard(projectId, cmd) {
|
|
|
12991
13955
|
return;
|
|
12992
13956
|
}
|
|
12993
13957
|
const r = dashboard.rollup;
|
|
12994
|
-
let line =
|
|
13958
|
+
let line = chalk32.bold(`DataSources in ${projectId}: `) + `${r.totalSources} total, ${r.scheduledSources} scheduled, ${r.sourcesWithRecentFailure} failing recently`;
|
|
12995
13959
|
if (r.lastActivityAt) line += `, last activity ${r.lastActivityAt}`;
|
|
12996
13960
|
console.log(line);
|
|
12997
13961
|
if (dashboard.sources.length === 0) {
|
|
@@ -13052,14 +14016,14 @@ async function createForAnalysis(api, options, human) {
|
|
|
13052
14016
|
if (human) {
|
|
13053
14017
|
success(`Added ${source.fileName} to analysis ${analysisId} from data source ${source.dataSourceId ?? ""}`.trimEnd());
|
|
13054
14018
|
for (const line of planLines(build.plan)) {
|
|
13055
|
-
console.log(line.caution ?
|
|
14019
|
+
console.log(line.caution ? chalk32.yellow(` ${line.text}`) : chalk32.dim(` ${line.text}`));
|
|
13056
14020
|
}
|
|
13057
|
-
console.log(
|
|
14021
|
+
console.log(chalk32.dim(options.scheduleCron ? ` Refreshes ${humanizeCron(options.scheduleCron)}; each refresh replaces the file and builds the data again.` : " No schedule of its own: refresh it with `data-sources refresh`, or let a trigger fetch it before a run (`analyze triggers create --refresh-first`)."));
|
|
13058
14022
|
}
|
|
13059
14023
|
return { source, build };
|
|
13060
14024
|
}
|
|
13061
14025
|
async function createDataSource(options, cmd) {
|
|
13062
|
-
const outputFormat =
|
|
14026
|
+
const outputFormat = getOutputFormat23(cmd);
|
|
13063
14027
|
const target = createTarget(options);
|
|
13064
14028
|
const api = createApiClient();
|
|
13065
14029
|
if (target === "analysis") {
|
|
@@ -13082,14 +14046,14 @@ async function createDataSource(options, cmd) {
|
|
|
13082
14046
|
const ds = await api.storage.createDataSource(request);
|
|
13083
14047
|
if (outputFormat === "human") {
|
|
13084
14048
|
success(`Created data source ${ds.id}`);
|
|
13085
|
-
console.log(
|
|
13086
|
-
if (ds.lastRunError) console.log(
|
|
14049
|
+
console.log(chalk32.dim(` Last run: ${ds.lastRunStatus ?? "\u2014"}`));
|
|
14050
|
+
if (ds.lastRunError) console.log(chalk32.dim(` Error: ${ds.lastRunError}`));
|
|
13087
14051
|
} else {
|
|
13088
14052
|
format(ds, { format: outputFormat });
|
|
13089
14053
|
}
|
|
13090
14054
|
}
|
|
13091
14055
|
async function updateDataSource(id, options, cmd) {
|
|
13092
|
-
const outputFormat =
|
|
14056
|
+
const outputFormat = getOutputFormat23(cmd);
|
|
13093
14057
|
if (options.name === void 0 && options.type === void 0 && (!options.config || options.config.length === 0) && options.scheduleCron === void 0 && !options.clearSchedule) {
|
|
13094
14058
|
throw new Error("Provide at least one of --name, --type, --config, --schedule-cron, or --clear-schedule.");
|
|
13095
14059
|
}
|
|
@@ -13124,18 +14088,18 @@ async function deleteDataSource(id) {
|
|
|
13124
14088
|
success(`Deleted data source ${id}`);
|
|
13125
14089
|
}
|
|
13126
14090
|
async function refreshDataSource(id, cmd) {
|
|
13127
|
-
const outputFormat =
|
|
14091
|
+
const outputFormat = getOutputFormat23(cmd);
|
|
13128
14092
|
const api = createApiClient();
|
|
13129
14093
|
const run = await api.storage.refreshDataSource(id);
|
|
13130
14094
|
if (outputFormat === "human") {
|
|
13131
14095
|
success(`Refresh queued: run ${run.runId}, status ${run.status}.`);
|
|
13132
|
-
if (run.errorMessage) console.log(
|
|
14096
|
+
if (run.errorMessage) console.log(chalk32.red(` Error: ${run.errorMessage}`));
|
|
13133
14097
|
} else {
|
|
13134
14098
|
format(run, { format: outputFormat });
|
|
13135
14099
|
}
|
|
13136
14100
|
}
|
|
13137
14101
|
async function listRuns2(id, limit, cmd) {
|
|
13138
|
-
const outputFormat =
|
|
14102
|
+
const outputFormat = getOutputFormat23(cmd);
|
|
13139
14103
|
const api = createApiClient();
|
|
13140
14104
|
const runs = await api.storage.listDataSourceRuns(id, limit);
|
|
13141
14105
|
if (outputFormat === "human" && runs.length === 0) {
|
|
@@ -13157,13 +14121,13 @@ async function listRuns2(id, limit, cmd) {
|
|
|
13157
14121
|
});
|
|
13158
14122
|
}
|
|
13159
14123
|
async function getRun(id, runId, cmd) {
|
|
13160
|
-
const outputFormat =
|
|
14124
|
+
const outputFormat = getOutputFormat23(cmd);
|
|
13161
14125
|
const api = createApiClient();
|
|
13162
14126
|
const run = await api.storage.getDataSourceRun(id, runId);
|
|
13163
14127
|
format(run, { format: outputFormat });
|
|
13164
14128
|
}
|
|
13165
14129
|
async function listConnectorTypes(cmd) {
|
|
13166
|
-
const outputFormat =
|
|
14130
|
+
const outputFormat = getOutputFormat23(cmd);
|
|
13167
14131
|
const api = createApiClient();
|
|
13168
14132
|
const types = await api.storage.listDataSourceConnectorTypes();
|
|
13169
14133
|
if (outputFormat === "human") {
|
|
@@ -13256,8 +14220,8 @@ Examples:
|
|
|
13256
14220
|
}
|
|
13257
14221
|
|
|
13258
14222
|
// src/commands/table-exporters/index.ts
|
|
13259
|
-
import
|
|
13260
|
-
function
|
|
14223
|
+
import chalk33 from "chalk";
|
|
14224
|
+
function getOutputFormat24(cmd) {
|
|
13261
14225
|
const config = loadConfig();
|
|
13262
14226
|
const globalOpts = cmd.optsWithGlobals();
|
|
13263
14227
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -13266,7 +14230,7 @@ function registerTableExportersCommands(program) {
|
|
|
13266
14230
|
const exporters = program.command("table-exporters").description("Manage user-defined exporters (UDE); admin only");
|
|
13267
14231
|
exporters.command("list").description("List all registered user-defined exporters").action(async (_options, cmd) => {
|
|
13268
14232
|
try {
|
|
13269
|
-
const outputFormat =
|
|
14233
|
+
const outputFormat = getOutputFormat24(cmd);
|
|
13270
14234
|
const api = createApiClient();
|
|
13271
14235
|
const list = await api.storage.listUserDefinedExporters();
|
|
13272
14236
|
if (outputFormat === "json") {
|
|
@@ -13287,14 +14251,14 @@ function registerTableExportersCommands(program) {
|
|
|
13287
14251
|
format: outputFormat,
|
|
13288
14252
|
columns: ["id", "name", "format", "extension", "mimeType", "priority", "function", "createdBy"]
|
|
13289
14253
|
});
|
|
13290
|
-
console.log(
|
|
14254
|
+
console.log(chalk33.dim(`${list.length} exporter(s)`));
|
|
13291
14255
|
} catch (error) {
|
|
13292
14256
|
handleError(error);
|
|
13293
14257
|
}
|
|
13294
14258
|
});
|
|
13295
14259
|
exporters.command("get").description("Show a single user-defined exporter by id").argument("<id>", "Exporter id").action(async (id, _options, cmd) => {
|
|
13296
14260
|
try {
|
|
13297
|
-
const outputFormat =
|
|
14261
|
+
const outputFormat = getOutputFormat24(cmd);
|
|
13298
14262
|
const api = createApiClient();
|
|
13299
14263
|
const list = await api.storage.listUserDefinedExporters();
|
|
13300
14264
|
const exporter = list.find((e) => e.id === id);
|
|
@@ -13309,7 +14273,7 @@ function registerTableExportersCommands(program) {
|
|
|
13309
14273
|
});
|
|
13310
14274
|
exporters.command("create").description("Register a new user-defined exporter").requiredOption("--name <name>", 'Display name (e.g. "Acme machine instrument export")').requiredOption("--format <token>", 'Format token used in the dispatch URL (e.g. "acme")').requiredOption("--function-project <id>", "Function entity's project id").requiredOption("--function-entity <id>", "Function entity id").option("--description <text>", "Free-form description").option("--extension <ext>", 'Filename extension (must start with ".")').option("--mime-type <mime>", "MIME type the function produces").option("--function-project-branch <branch>", "Function project branch", "main").option("--function-entity-branch <branch>", "Function entity branch", "main").option("--priority <n>", "Dispatch priority (default 50; > 200 overrides built-ins)", "50").action(async (options, cmd) => {
|
|
13311
14275
|
try {
|
|
13312
|
-
const outputFormat =
|
|
14276
|
+
const outputFormat = getOutputFormat24(cmd);
|
|
13313
14277
|
const api = createApiClient();
|
|
13314
14278
|
const payload = {
|
|
13315
14279
|
name: options.name,
|
|
@@ -13345,9 +14309,9 @@ function registerTableExportersCommands(program) {
|
|
|
13345
14309
|
}
|
|
13346
14310
|
|
|
13347
14311
|
// src/commands/skeleton/index.ts
|
|
13348
|
-
import
|
|
13349
|
-
import * as
|
|
13350
|
-
function
|
|
14312
|
+
import chalk34 from "chalk";
|
|
14313
|
+
import * as fs14 from "fs";
|
|
14314
|
+
function getOutputFormat25(cmd) {
|
|
13351
14315
|
const config = loadConfig();
|
|
13352
14316
|
const globalOpts = cmd.optsWithGlobals();
|
|
13353
14317
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -13370,10 +14334,10 @@ function resolveTemplate(raw) {
|
|
|
13370
14334
|
if (!file) {
|
|
13371
14335
|
throw new Error("--template @ requires a filename after the @, e.g. --template @template.txt");
|
|
13372
14336
|
}
|
|
13373
|
-
if (!
|
|
14337
|
+
if (!fs14.existsSync(file)) {
|
|
13374
14338
|
throw new Error(`Template file not found: ${file}`);
|
|
13375
14339
|
}
|
|
13376
|
-
return
|
|
14340
|
+
return fs14.readFileSync(file, "utf-8").trim();
|
|
13377
14341
|
}
|
|
13378
14342
|
return raw;
|
|
13379
14343
|
}
|
|
@@ -13396,7 +14360,7 @@ function skeletonTableRow(s) {
|
|
|
13396
14360
|
};
|
|
13397
14361
|
}
|
|
13398
14362
|
async function createSkeleton(options, cmd) {
|
|
13399
|
-
const outputFormat =
|
|
14363
|
+
const outputFormat = getOutputFormat25(cmd);
|
|
13400
14364
|
const projectId = resolveProjectId2(cmd);
|
|
13401
14365
|
const template = resolveTemplate(options.template);
|
|
13402
14366
|
const weight = parseWeight(options.weight);
|
|
@@ -13412,16 +14376,16 @@ async function createSkeleton(options, cmd) {
|
|
|
13412
14376
|
const skeleton = await api.storage.createSkeleton(request);
|
|
13413
14377
|
if (outputFormat === "human") {
|
|
13414
14378
|
success(`Created skeleton ${skeleton.id}`);
|
|
13415
|
-
console.log(
|
|
13416
|
-
console.log(
|
|
13417
|
-
console.log(
|
|
13418
|
-
console.log(
|
|
14379
|
+
console.log(chalk34.dim(` name: ${skeleton.name}`));
|
|
14380
|
+
console.log(chalk34.dim(` template: ${skeleton.template}`));
|
|
14381
|
+
console.log(chalk34.dim(` paramCount: ${skeleton.paramCount}`));
|
|
14382
|
+
console.log(chalk34.dim(` weight: ${skeleton.weight}`));
|
|
13419
14383
|
} else {
|
|
13420
14384
|
format(skeleton, { format: outputFormat });
|
|
13421
14385
|
}
|
|
13422
14386
|
}
|
|
13423
14387
|
async function listSkeletons(cmd) {
|
|
13424
|
-
const outputFormat =
|
|
14388
|
+
const outputFormat = getOutputFormat25(cmd);
|
|
13425
14389
|
const projectId = resolveProjectId2(cmd);
|
|
13426
14390
|
const api = createApiClient();
|
|
13427
14391
|
const skeletons = await api.storage.listSkeletons(projectId);
|
|
@@ -13435,13 +14399,13 @@ async function listSkeletons(cmd) {
|
|
|
13435
14399
|
});
|
|
13436
14400
|
}
|
|
13437
14401
|
async function getSkeleton(id, cmd) {
|
|
13438
|
-
const outputFormat =
|
|
14402
|
+
const outputFormat = getOutputFormat25(cmd);
|
|
13439
14403
|
const api = createApiClient();
|
|
13440
14404
|
const skeleton = await api.storage.getSkeleton(id);
|
|
13441
14405
|
format(skeleton, { format: outputFormat });
|
|
13442
14406
|
}
|
|
13443
14407
|
async function updateSkeleton(id, options, cmd) {
|
|
13444
|
-
const outputFormat =
|
|
14408
|
+
const outputFormat = getOutputFormat25(cmd);
|
|
13445
14409
|
if (options.name === void 0 && options.template === void 0 && options.weight === void 0) {
|
|
13446
14410
|
throw new Error("Provide at least one of --name, --template, --weight.");
|
|
13447
14411
|
}
|
|
@@ -13454,10 +14418,10 @@ async function updateSkeleton(id, options, cmd) {
|
|
|
13454
14418
|
const skeleton = await api.storage.updateSkeleton(id, request);
|
|
13455
14419
|
if (outputFormat === "human") {
|
|
13456
14420
|
success(`Updated skeleton ${skeleton.id}`);
|
|
13457
|
-
console.log(
|
|
13458
|
-
console.log(
|
|
13459
|
-
console.log(
|
|
13460
|
-
console.log(
|
|
14421
|
+
console.log(chalk34.dim(` name: ${skeleton.name}`));
|
|
14422
|
+
console.log(chalk34.dim(` template: ${skeleton.template}`));
|
|
14423
|
+
console.log(chalk34.dim(` paramCount: ${skeleton.paramCount}`));
|
|
14424
|
+
console.log(chalk34.dim(` weight: ${skeleton.weight}`));
|
|
13461
14425
|
} else {
|
|
13462
14426
|
format(skeleton, { format: outputFormat });
|
|
13463
14427
|
}
|
|
@@ -13782,7 +14746,7 @@ function registerCompletionCommand(program) {
|
|
|
13782
14746
|
}
|
|
13783
14747
|
|
|
13784
14748
|
// src/commands/whoami/index.ts
|
|
13785
|
-
import
|
|
14749
|
+
import chalk35 from "chalk";
|
|
13786
14750
|
function registerWhoamiCommand(program) {
|
|
13787
14751
|
program.command("whoami").description("Show the currently authenticated user").action(async (_options, cmd) => {
|
|
13788
14752
|
try {
|
|
@@ -13792,8 +14756,8 @@ function registerWhoamiCommand(program) {
|
|
|
13792
14756
|
const api = createApiClient();
|
|
13793
14757
|
const user = await api.admin.getMyUser();
|
|
13794
14758
|
if (outputFormat === "human") {
|
|
13795
|
-
console.log(
|
|
13796
|
-
console.log(
|
|
14759
|
+
console.log(chalk35.bold(user.name) + chalk35.dim(` <${user.email}>`));
|
|
14760
|
+
console.log(chalk35.dim(` Role: ${user.role} \xB7 Remaining credits: ${user.remainingCredits} \xB7 Profile: ${getActiveProfileName(config)}`));
|
|
13797
14761
|
} else {
|
|
13798
14762
|
format(user, { format: outputFormat });
|
|
13799
14763
|
}
|
|
@@ -13804,8 +14768,8 @@ function registerWhoamiCommand(program) {
|
|
|
13804
14768
|
}
|
|
13805
14769
|
|
|
13806
14770
|
// src/commands/utilization/index.ts
|
|
13807
|
-
import
|
|
13808
|
-
function
|
|
14771
|
+
import chalk36 from "chalk";
|
|
14772
|
+
function getOutputFormat26(cmd) {
|
|
13809
14773
|
const config = loadConfig();
|
|
13810
14774
|
const globalOpts = cmd.optsWithGlobals();
|
|
13811
14775
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -13821,19 +14785,19 @@ function windowLabel(u) {
|
|
|
13821
14785
|
}
|
|
13822
14786
|
function printUtilizationHuman(u, label) {
|
|
13823
14787
|
const when2 = windowLabel(u);
|
|
13824
|
-
console.log(label ?
|
|
14788
|
+
console.log(label ? chalk36.bold(label) + " " + chalk36.dim(when2) : chalk36.bold(when2));
|
|
13825
14789
|
if (u.types.length === 0) {
|
|
13826
|
-
console.log(
|
|
14790
|
+
console.log(chalk36.dim(" (no usage)"));
|
|
13827
14791
|
return;
|
|
13828
14792
|
}
|
|
13829
14793
|
const types = [...u.types].sort((a, b) => b.credits - a.credits);
|
|
13830
14794
|
const width = Math.max(...types.map((t) => t.type.length));
|
|
13831
14795
|
for (const t of types) {
|
|
13832
|
-
const line = ` ${t.type.padEnd(width)} ${formatNumber(t.quantity).padStart(12)} ${
|
|
13833
|
-
console.log(t.credits === 0 ?
|
|
14796
|
+
const line = ` ${t.type.padEnd(width)} ${formatNumber(t.quantity).padStart(12)} ${chalk36.dim("credits")} ${t.credits.toFixed(2).padStart(10)}`;
|
|
14797
|
+
console.log(t.credits === 0 ? chalk36.dim(line) : line);
|
|
13834
14798
|
}
|
|
13835
14799
|
const total = u.totalCredits ?? u.types.reduce((s, t) => s + t.credits, 0);
|
|
13836
|
-
console.log(
|
|
14800
|
+
console.log(chalk36.bold(` ${"Total".padEnd(width)} ${" ".repeat(12)} ${chalk36.dim("credits")} ${total.toFixed(2).padStart(10)}`));
|
|
13837
14801
|
}
|
|
13838
14802
|
function formatDailyHistory(history) {
|
|
13839
14803
|
const spentOn = (u) => u.dailyCredits ?? u.types.reduce((sum, t) => sum + (t.dailyCredits ?? 0), 0);
|
|
@@ -13850,14 +14814,14 @@ function formatDailyHistory(history) {
|
|
|
13850
14814
|
for (const u of history) {
|
|
13851
14815
|
const spent = spentOn(u);
|
|
13852
14816
|
total += spent;
|
|
13853
|
-
const line = `${windowLabel(u).padEnd(width)} ${amount(spent)} ${
|
|
13854
|
-
lines.push(spent > 0 ?
|
|
14817
|
+
const line = `${windowLabel(u).padEnd(width)} ${amount(spent)} ${chalk36.dim("credits")}`;
|
|
14818
|
+
lines.push(spent > 0 ? chalk36.bold(line) : chalk36.dim(line));
|
|
13855
14819
|
for (const t of costly(u)) {
|
|
13856
14820
|
lines.push(` ${t.type.padEnd(width - 2)} ${amount(t.dailyCredits ?? 0)}`);
|
|
13857
14821
|
}
|
|
13858
14822
|
}
|
|
13859
14823
|
lines.push("");
|
|
13860
|
-
lines.push(
|
|
14824
|
+
lines.push(chalk36.bold(`${totalLabel.padEnd(width)} ${amount(total)} ${chalk36.dim("credits")}`));
|
|
13861
14825
|
return lines;
|
|
13862
14826
|
}
|
|
13863
14827
|
function registerUtilizationCommand(program) {
|
|
@@ -13870,7 +14834,7 @@ Examples:
|
|
|
13870
14834
|
`);
|
|
13871
14835
|
util.command("actual", { isDefault: true }).description("Show current utilization (default subcommand)").action(async (_options, cmd) => {
|
|
13872
14836
|
try {
|
|
13873
|
-
const outputFormat =
|
|
14837
|
+
const outputFormat = getOutputFormat26(cmd);
|
|
13874
14838
|
const api = createApiClient();
|
|
13875
14839
|
const utilization = await api.admin.getActualUtilization();
|
|
13876
14840
|
if (outputFormat === "human") {
|
|
@@ -13884,7 +14848,7 @@ Examples:
|
|
|
13884
14848
|
});
|
|
13885
14849
|
util.command("history").description("Show what each day of the billing cycle cost").action(async (_options, cmd) => {
|
|
13886
14850
|
try {
|
|
13887
|
-
const outputFormat =
|
|
14851
|
+
const outputFormat = getOutputFormat26(cmd);
|
|
13888
14852
|
const api = createApiClient();
|
|
13889
14853
|
const history = await api.admin.getUtilizationHistory();
|
|
13890
14854
|
if (outputFormat === "human") {
|
|
@@ -13905,7 +14869,7 @@ Examples:
|
|
|
13905
14869
|
}
|
|
13906
14870
|
|
|
13907
14871
|
// src/commands/entity-branch/index.ts
|
|
13908
|
-
function
|
|
14872
|
+
function getOutputFormat27(cmd) {
|
|
13909
14873
|
const config = loadConfig();
|
|
13910
14874
|
const globalOpts = cmd.optsWithGlobals();
|
|
13911
14875
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -13918,7 +14882,7 @@ function registerEntityBranchCommands(program) {
|
|
|
13918
14882
|
const eb = program.command("entity-branch").description("Manage entity branches (parallel versions of a single entity)");
|
|
13919
14883
|
eb.command("list").description("List branches of an entity").argument("<ref>", "Entity reference (projectId/branch/entityId)").action(async (ref, _options, cmd) => {
|
|
13920
14884
|
try {
|
|
13921
|
-
const outputFormat =
|
|
14885
|
+
const outputFormat = getOutputFormat27(cmd);
|
|
13922
14886
|
const overrides = getOverrides11(cmd);
|
|
13923
14887
|
const resolved = parseEntityReference(ref, overrides);
|
|
13924
14888
|
const api = createApiClient();
|
|
@@ -13970,7 +14934,7 @@ function forReader(subscription) {
|
|
|
13970
14934
|
Object.entries(subscription).filter(([key]) => !BILLING_INTERNALS.has(key))
|
|
13971
14935
|
);
|
|
13972
14936
|
}
|
|
13973
|
-
function
|
|
14937
|
+
function getOutputFormat28(cmd) {
|
|
13974
14938
|
const config = loadConfig();
|
|
13975
14939
|
const globalOpts = cmd.optsWithGlobals();
|
|
13976
14940
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -13984,7 +14948,7 @@ Examples:
|
|
|
13984
14948
|
sub.command("current", { isDefault: true }).description("Show the current subscription").action(async (_options, cmd) => {
|
|
13985
14949
|
try {
|
|
13986
14950
|
const api = createApiClient();
|
|
13987
|
-
const outputFormat =
|
|
14951
|
+
const outputFormat = getOutputFormat28(cmd);
|
|
13988
14952
|
const s = await api.admin.getCurrentSubscription();
|
|
13989
14953
|
format(outputFormat === "human" ? forReader(s) : s, { format: outputFormat });
|
|
13990
14954
|
} catch (error) {
|
|
@@ -13994,7 +14958,7 @@ Examples:
|
|
|
13994
14958
|
sub.command("next").description("Show the next (upcoming) subscription").action(async (_options, cmd) => {
|
|
13995
14959
|
try {
|
|
13996
14960
|
const api = createApiClient();
|
|
13997
|
-
const outputFormat =
|
|
14961
|
+
const outputFormat = getOutputFormat28(cmd);
|
|
13998
14962
|
const s = await api.admin.getNextSubscription();
|
|
13999
14963
|
format(outputFormat === "human" ? forReader(s) : s, { format: outputFormat });
|
|
14000
14964
|
} catch (error) {
|
|
@@ -14005,7 +14969,7 @@ Examples:
|
|
|
14005
14969
|
try {
|
|
14006
14970
|
const api = createApiClient();
|
|
14007
14971
|
const plans = await api.admin.getSubscriptionPlans(subscriptionToken);
|
|
14008
|
-
format(plans, { format:
|
|
14972
|
+
format(plans, { format: getOutputFormat28(cmd) });
|
|
14009
14973
|
} catch (error) {
|
|
14010
14974
|
handleError(error);
|
|
14011
14975
|
}
|
|
@@ -14013,8 +14977,8 @@ Examples:
|
|
|
14013
14977
|
}
|
|
14014
14978
|
|
|
14015
14979
|
// src/commands/invoice/index.ts
|
|
14016
|
-
import * as
|
|
14017
|
-
function
|
|
14980
|
+
import * as fs15 from "fs";
|
|
14981
|
+
function getOutputFormat29(cmd) {
|
|
14018
14982
|
const config = loadConfig();
|
|
14019
14983
|
const globalOpts = cmd.optsWithGlobals();
|
|
14020
14984
|
return globalOpts.output ?? config.defaults.output ?? "human";
|
|
@@ -14031,7 +14995,7 @@ Examples:
|
|
|
14031
14995
|
const api = createApiClient();
|
|
14032
14996
|
const invoices = await api.admin.getInvoices();
|
|
14033
14997
|
format(invoices, {
|
|
14034
|
-
format:
|
|
14998
|
+
format: getOutputFormat29(cmd),
|
|
14035
14999
|
columns: [
|
|
14036
15000
|
{ key: "invoiceNumber", header: "number" },
|
|
14037
15001
|
{ key: "issued", kind: "date" },
|
|
@@ -14051,7 +15015,7 @@ Examples:
|
|
|
14051
15015
|
const response = await api.admin.downloadInvoice(invoiceNumber, fileName);
|
|
14052
15016
|
const buffer = Buffer.from(await response.arrayBuffer());
|
|
14053
15017
|
const outPath = options.out ?? fileName;
|
|
14054
|
-
|
|
15018
|
+
fs15.writeFileSync(outPath, buffer);
|
|
14055
15019
|
success(`Invoice saved to ${outPath}`);
|
|
14056
15020
|
} catch (error) {
|
|
14057
15021
|
handleError(error);
|
|
@@ -14060,8 +15024,8 @@ Examples:
|
|
|
14060
15024
|
}
|
|
14061
15025
|
|
|
14062
15026
|
// src/commands/shell/index.ts
|
|
14063
|
-
import
|
|
14064
|
-
import * as
|
|
15027
|
+
import chalk37 from "chalk";
|
|
15028
|
+
import * as fs16 from "fs";
|
|
14065
15029
|
import * as os4 from "os";
|
|
14066
15030
|
import * as path10 from "path";
|
|
14067
15031
|
import { spawn as spawn3 } from "child_process";
|
|
@@ -14077,15 +15041,15 @@ function extensionFor2(language) {
|
|
|
14077
15041
|
}
|
|
14078
15042
|
async function openInEditor(initial, ext) {
|
|
14079
15043
|
const tmpFile = path10.join(os4.tmpdir(), `diafunc-shell-${randomUUID4()}.${ext}`);
|
|
14080
|
-
|
|
15044
|
+
fs16.writeFileSync(tmpFile, initial);
|
|
14081
15045
|
const editor = process.env.VISUAL ?? process.env.EDITOR ?? "vi";
|
|
14082
15046
|
await new Promise((resolve2, reject) => {
|
|
14083
15047
|
const child = spawn3(editor, [tmpFile], { stdio: "inherit" });
|
|
14084
15048
|
child.on("exit", (code) => code === 0 ? resolve2() : reject(new Error(`Editor exited with ${code}`)));
|
|
14085
15049
|
child.on("error", reject);
|
|
14086
15050
|
});
|
|
14087
|
-
const content =
|
|
14088
|
-
|
|
15051
|
+
const content = fs16.readFileSync(tmpFile, "utf-8");
|
|
15052
|
+
fs16.unlinkSync(tmpFile);
|
|
14089
15053
|
return content;
|
|
14090
15054
|
}
|
|
14091
15055
|
function utcNowParts() {
|
|
@@ -14126,21 +15090,21 @@ async function evaluate(api, fnRef, language, sourceCode) {
|
|
|
14126
15090
|
}, false);
|
|
14127
15091
|
if (result.outputs?.length) {
|
|
14128
15092
|
for (const out of result.outputs) {
|
|
14129
|
-
console.log(
|
|
15093
|
+
console.log(chalk37.dim(` [${out.type}]`) + " " + out.output);
|
|
14130
15094
|
}
|
|
14131
15095
|
}
|
|
14132
15096
|
if (result.successful) {
|
|
14133
15097
|
if (result.result) {
|
|
14134
|
-
console.log(
|
|
15098
|
+
console.log(chalk37.green("=>") + " " + resultText(result.result, result.resultEncoding));
|
|
14135
15099
|
} else {
|
|
14136
|
-
console.log(
|
|
15100
|
+
console.log(chalk37.dim("=> (no value)"));
|
|
14137
15101
|
}
|
|
14138
15102
|
const duration = result.completed - result.started;
|
|
14139
|
-
console.log(
|
|
15103
|
+
console.log(chalk37.dim(` [${duration}ms \xB7 ${evaluationId}]`));
|
|
14140
15104
|
} else {
|
|
14141
|
-
console.log(
|
|
15105
|
+
console.log(chalk37.red("error: ") + result.error);
|
|
14142
15106
|
if (result.lineNumber > 0) {
|
|
14143
|
-
console.log(
|
|
15107
|
+
console.log(chalk37.dim(` at line ${result.lineNumber}, col ${result.columnNumber}`));
|
|
14144
15108
|
}
|
|
14145
15109
|
}
|
|
14146
15110
|
}
|
|
@@ -14161,19 +15125,19 @@ function registerShellCommand(program) {
|
|
|
14161
15125
|
});
|
|
14162
15126
|
const api = createApiClient();
|
|
14163
15127
|
const { input: promptInput } = await import("@inquirer/prompts");
|
|
14164
|
-
const { getUpdateNotice } = await import("./update-check-
|
|
15128
|
+
const { getUpdateNotice } = await import("./update-check-NBOU2XBP.js");
|
|
14165
15129
|
const resolvedLanguage = await resolveLanguage(api, fnRef.projectId, options.language);
|
|
14166
|
-
console.log(
|
|
14167
|
-
console.log(
|
|
14168
|
-
console.log(
|
|
15130
|
+
console.log(chalk37.bold("Diafunc shell") + chalk37.dim(` \xB7 function ${fnRef.entityId} \xB7 ${resolvedLanguage}`));
|
|
15131
|
+
console.log(chalk37.dim(`Endpoint: ${config.profiles[getActiveProfileName(config)]?.endpoint}`));
|
|
15132
|
+
console.log(chalk37.dim("Commands: /edit (multi-line in $EDITOR), /lang <name>, /file <path>, /help, /quit"));
|
|
14169
15133
|
const notice = await getUpdateNotice();
|
|
14170
|
-
if (notice) console.log(
|
|
15134
|
+
if (notice) console.log(chalk37.dim(notice));
|
|
14171
15135
|
console.log();
|
|
14172
15136
|
let language = resolvedLanguage;
|
|
14173
15137
|
for (; ; ) {
|
|
14174
15138
|
let line;
|
|
14175
15139
|
try {
|
|
14176
|
-
line = await promptInput({ message:
|
|
15140
|
+
line = await promptInput({ message: chalk37.cyan.bold(`${language} >`) });
|
|
14177
15141
|
} catch {
|
|
14178
15142
|
console.log();
|
|
14179
15143
|
return;
|
|
@@ -14191,54 +15155,54 @@ function registerShellCommand(program) {
|
|
|
14191
15155
|
case "help":
|
|
14192
15156
|
case "h":
|
|
14193
15157
|
case "?":
|
|
14194
|
-
console.log(
|
|
14195
|
-
console.log(
|
|
14196
|
-
console.log(
|
|
14197
|
-
console.log(
|
|
15158
|
+
console.log(chalk37.dim(" /edit open $EDITOR for multi-line code"));
|
|
15159
|
+
console.log(chalk37.dim(" /file <path> evaluate the contents of a file"));
|
|
15160
|
+
console.log(chalk37.dim(" /lang <name> switch language (Java, JavaScript, Kotlin, Python, Scala)"));
|
|
15161
|
+
console.log(chalk37.dim(" /quit exit the shell"));
|
|
14198
15162
|
continue;
|
|
14199
15163
|
case "lang":
|
|
14200
15164
|
if (arg) language = arg;
|
|
14201
|
-
console.log(
|
|
15165
|
+
console.log(chalk37.dim(`Language: ${language}`));
|
|
14202
15166
|
continue;
|
|
14203
15167
|
case "edit": {
|
|
14204
15168
|
const sourceCode = await openInEditor("", extensionFor2(language));
|
|
14205
15169
|
if (!sourceCode.trim()) {
|
|
14206
|
-
console.log(
|
|
15170
|
+
console.log(chalk37.dim("(empty; not evaluated)"));
|
|
14207
15171
|
continue;
|
|
14208
15172
|
}
|
|
14209
15173
|
try {
|
|
14210
15174
|
await evaluate(api, fnRef, language, sourceCode);
|
|
14211
15175
|
} catch (e) {
|
|
14212
|
-
console.error(
|
|
15176
|
+
console.error(chalk37.red(e.message));
|
|
14213
15177
|
}
|
|
14214
15178
|
continue;
|
|
14215
15179
|
}
|
|
14216
15180
|
case "file": {
|
|
14217
15181
|
if (!arg) {
|
|
14218
|
-
console.log(
|
|
15182
|
+
console.log(chalk37.dim("usage: /file <path>"));
|
|
14219
15183
|
continue;
|
|
14220
15184
|
}
|
|
14221
|
-
if (!
|
|
14222
|
-
console.log(
|
|
15185
|
+
if (!fs16.existsSync(arg)) {
|
|
15186
|
+
console.log(chalk37.red(`file not found: ${arg}`));
|
|
14223
15187
|
continue;
|
|
14224
15188
|
}
|
|
14225
|
-
const sourceCode =
|
|
15189
|
+
const sourceCode = fs16.readFileSync(arg, "utf-8");
|
|
14226
15190
|
try {
|
|
14227
15191
|
await evaluate(api, fnRef, language, sourceCode);
|
|
14228
15192
|
} catch (e) {
|
|
14229
|
-
console.error(
|
|
15193
|
+
console.error(chalk37.red(e.message));
|
|
14230
15194
|
}
|
|
14231
15195
|
continue;
|
|
14232
15196
|
}
|
|
14233
15197
|
default:
|
|
14234
|
-
console.log(
|
|
15198
|
+
console.log(chalk37.dim(`Unknown command: /${cmd2}. Try /help.`));
|
|
14235
15199
|
continue;
|
|
14236
15200
|
}
|
|
14237
15201
|
}
|
|
14238
15202
|
try {
|
|
14239
15203
|
await evaluate(api, fnRef, language, trimmed);
|
|
14240
15204
|
} catch (e) {
|
|
14241
|
-
console.error(
|
|
15205
|
+
console.error(chalk37.red(e.message));
|
|
14242
15206
|
}
|
|
14243
15207
|
}
|
|
14244
15208
|
} catch (error) {
|
|
@@ -14248,19 +15212,19 @@ function registerShellCommand(program) {
|
|
|
14248
15212
|
}
|
|
14249
15213
|
|
|
14250
15214
|
// src/commands/update/index.ts
|
|
14251
|
-
import
|
|
15215
|
+
import chalk38 from "chalk";
|
|
14252
15216
|
import * as path11 from "path";
|
|
14253
15217
|
import { spawn as spawn4 } from "child_process";
|
|
14254
15218
|
|
|
14255
15219
|
// src/util/install-method.ts
|
|
14256
|
-
import * as
|
|
15220
|
+
import * as fs17 from "fs";
|
|
14257
15221
|
function detectInstall() {
|
|
14258
15222
|
const exec = process.execPath;
|
|
14259
15223
|
const exe = exec.replace(/\\/g, "/").toLowerCase();
|
|
14260
15224
|
const isNode = exe.endsWith("/node") || exe.endsWith("/node.exe");
|
|
14261
15225
|
return {
|
|
14262
15226
|
method: isNode ? "npm" : "binary",
|
|
14263
|
-
binaryPath: isNode ? exec :
|
|
15227
|
+
binaryPath: isNode ? exec : fs17.realpathSync(exec)
|
|
14264
15228
|
};
|
|
14265
15229
|
}
|
|
14266
15230
|
|
|
@@ -14294,14 +15258,14 @@ function registerUpdateCommand(program) {
|
|
|
14294
15258
|
const install = detectInstall();
|
|
14295
15259
|
const latest = await fetchLatestVersion();
|
|
14296
15260
|
if (latest === package_default.version) {
|
|
14297
|
-
console.log(
|
|
15261
|
+
console.log(chalk38.dim(`diafunc is already at the latest version (${package_default.version}).`));
|
|
14298
15262
|
return;
|
|
14299
15263
|
}
|
|
14300
|
-
console.log(
|
|
15264
|
+
console.log(chalk38.dim(`Current: ${package_default.version} \u2192 Available: ${latest}`));
|
|
14301
15265
|
if (install.method === "npm") {
|
|
14302
15266
|
console.log();
|
|
14303
15267
|
console.log("Installed via npm. Upgrade with:");
|
|
14304
|
-
console.log(
|
|
15268
|
+
console.log(chalk38.bold(` npm install -g @diafunc/cli@${latest}`));
|
|
14305
15269
|
return;
|
|
14306
15270
|
}
|
|
14307
15271
|
const installDir = path11.dirname(install.binaryPath);
|
|
@@ -14315,9 +15279,9 @@ function registerUpdateCommand(program) {
|
|
|
14315
15279
|
}
|
|
14316
15280
|
|
|
14317
15281
|
// src/commands/uninstall/index.ts
|
|
14318
|
-
import
|
|
15282
|
+
import chalk39 from "chalk";
|
|
14319
15283
|
import { spawn as spawn5 } from "child_process";
|
|
14320
|
-
import * as
|
|
15284
|
+
import * as fs18 from "fs";
|
|
14321
15285
|
import * as os5 from "os";
|
|
14322
15286
|
import * as path12 from "path";
|
|
14323
15287
|
function registerUninstallCommand(program) {
|
|
@@ -14327,11 +15291,11 @@ function registerUninstallCommand(program) {
|
|
|
14327
15291
|
const configDir = path12.join(os5.homedir(), ".diafunc");
|
|
14328
15292
|
if (install.method === "npm") {
|
|
14329
15293
|
console.log("Installed via npm. Remove with:");
|
|
14330
|
-
console.log(
|
|
14331
|
-
if (
|
|
15294
|
+
console.log(chalk39.bold(" npm uninstall -g @diafunc/cli"));
|
|
15295
|
+
if (fs18.existsSync(configDir)) {
|
|
14332
15296
|
console.log();
|
|
14333
15297
|
console.log(`Config and credentials live at ${configDir}. Remove them manually with:`);
|
|
14334
|
-
console.log(
|
|
15298
|
+
console.log(chalk39.bold(` rm -rf ${configDir}`));
|
|
14335
15299
|
}
|
|
14336
15300
|
return;
|
|
14337
15301
|
}
|
|
@@ -14341,19 +15305,19 @@ function registerUninstallCommand(program) {
|
|
|
14341
15305
|
default: false
|
|
14342
15306
|
});
|
|
14343
15307
|
if (!removeBinary) {
|
|
14344
|
-
console.log(
|
|
15308
|
+
console.log(chalk39.dim("Aborted."));
|
|
14345
15309
|
return;
|
|
14346
15310
|
}
|
|
14347
15311
|
let removeConfig = options.purge ?? false;
|
|
14348
|
-
if (!options.purge && !options.yes &&
|
|
15312
|
+
if (!options.purge && !options.yes && fs18.existsSync(configDir)) {
|
|
14349
15313
|
removeConfig = await confirm({
|
|
14350
15314
|
message: `Also remove ${configDir} (config + credentials)?`,
|
|
14351
15315
|
default: false
|
|
14352
15316
|
});
|
|
14353
15317
|
}
|
|
14354
|
-
if (removeConfig &&
|
|
14355
|
-
|
|
14356
|
-
console.log(
|
|
15318
|
+
if (removeConfig && fs18.existsSync(configDir)) {
|
|
15319
|
+
fs18.rmSync(configDir, { recursive: true, force: true });
|
|
15320
|
+
console.log(chalk39.dim(`Removed ${configDir}`));
|
|
14357
15321
|
}
|
|
14358
15322
|
if (process.platform === "win32") {
|
|
14359
15323
|
const cmd = `timeout /t 2 /nobreak >nul & del /f /q "${install.binaryPath}"`;
|
|
@@ -14363,13 +15327,13 @@ function registerUninstallCommand(program) {
|
|
|
14363
15327
|
windowsHide: true
|
|
14364
15328
|
});
|
|
14365
15329
|
child.unref();
|
|
14366
|
-
console.log(
|
|
15330
|
+
console.log(chalk39.dim(`Removing ${install.binaryPath} on exit...`));
|
|
14367
15331
|
console.log();
|
|
14368
15332
|
console.log("diafunc uninstalled.");
|
|
14369
15333
|
return;
|
|
14370
15334
|
}
|
|
14371
|
-
|
|
14372
|
-
console.log(
|
|
15335
|
+
fs18.rmSync(install.binaryPath, { force: true });
|
|
15336
|
+
console.log(chalk39.dim(`Removed ${install.binaryPath}`));
|
|
14373
15337
|
console.log();
|
|
14374
15338
|
console.log("diafunc uninstalled.");
|
|
14375
15339
|
} catch (error) {
|
|
@@ -14378,66 +15342,12 @@ function registerUninstallCommand(program) {
|
|
|
14378
15342
|
});
|
|
14379
15343
|
}
|
|
14380
15344
|
|
|
14381
|
-
// src/prompting/command.ts
|
|
14382
|
-
import { Command as Command2 } from "commander";
|
|
14383
|
-
var commanderOriginal = Command2.prototype;
|
|
14384
|
-
var DiafuncCommand = class _DiafuncCommand extends Command2 {
|
|
14385
|
-
/** Gaps recorded during the current parse, in the order commander found them. */
|
|
14386
|
-
pendingInputs = [];
|
|
14387
|
-
/** Set on the program only; every command reads it from there. */
|
|
14388
|
-
promptEnvironment = {};
|
|
14389
|
-
createCommand(name) {
|
|
14390
|
-
return new _DiafuncCommand(name);
|
|
14391
|
-
}
|
|
14392
|
-
missingArgument(name) {
|
|
14393
|
-
if (!this.mayPrompt()) {
|
|
14394
|
-
commanderOriginal.missingArgument.call(this, name);
|
|
14395
|
-
return;
|
|
14396
|
-
}
|
|
14397
|
-
const index = this.registeredArguments.findIndex((a) => a.name() === name);
|
|
14398
|
-
const argument = this.registeredArguments[index];
|
|
14399
|
-
this.pendingInputs.push({
|
|
14400
|
-
kind: "argument",
|
|
14401
|
-
name,
|
|
14402
|
-
index,
|
|
14403
|
-
description: argument?.description ?? "",
|
|
14404
|
-
variadic: Boolean(argument?.variadic)
|
|
14405
|
-
});
|
|
14406
|
-
}
|
|
14407
|
-
missingMandatoryOptionValue(option) {
|
|
14408
|
-
if (!this.mayPrompt()) {
|
|
14409
|
-
commanderOriginal.missingMandatoryOptionValue.call(this, option);
|
|
14410
|
-
return;
|
|
14411
|
-
}
|
|
14412
|
-
this.pendingInputs.push({
|
|
14413
|
-
kind: "option",
|
|
14414
|
-
name: option.attributeName(),
|
|
14415
|
-
flag: option.long ?? option.flags,
|
|
14416
|
-
description: option.description ?? "",
|
|
14417
|
-
variadic: Boolean(option.variadic)
|
|
14418
|
-
});
|
|
14419
|
-
}
|
|
14420
|
-
/** The environment set on the program. */
|
|
14421
|
-
environment() {
|
|
14422
|
-
let root = this;
|
|
14423
|
-
while (root.parent) root = root.parent;
|
|
14424
|
-
return root instanceof _DiafuncCommand ? root.promptEnvironment : {};
|
|
14425
|
-
}
|
|
14426
|
-
mayPrompt() {
|
|
14427
|
-
const forced = this.environment().interactive;
|
|
14428
|
-
if (forced !== void 0) return forced;
|
|
14429
|
-
const globals = this.optsWithGlobals();
|
|
14430
|
-
const output = globals.output ?? loadConfig().defaults.output ?? "human";
|
|
14431
|
-
return canPrompt(output, globals.interactive === false);
|
|
14432
|
-
}
|
|
14433
|
-
};
|
|
14434
|
-
|
|
14435
15345
|
// src/prompting/fill.ts
|
|
14436
|
-
import
|
|
15346
|
+
import chalk41 from "chalk";
|
|
14437
15347
|
|
|
14438
15348
|
// src/prompting/pickers.ts
|
|
14439
|
-
import * as
|
|
14440
|
-
import
|
|
15349
|
+
import * as fs19 from "fs";
|
|
15350
|
+
import chalk40 from "chalk";
|
|
14441
15351
|
var SEARCH_THRESHOLD = 10;
|
|
14442
15352
|
var TYPE_IT = "\0type-it";
|
|
14443
15353
|
async function askFor(spec, input, ctx) {
|
|
@@ -14559,6 +15469,8 @@ async function askFor(spec, input, ctx) {
|
|
|
14559
15469
|
return listed(ctx, "profiles", messageFor(input, "Profile"), async () => Object.keys(loadConfig().profiles).map((p) => ({ label: p, value: p })));
|
|
14560
15470
|
case "statusComponent":
|
|
14561
15471
|
return listed(ctx, "components", messageFor(input, "Component"), async () => (await createStatusService().getComponents()).map((c) => ({ label: c.id, value: c.id, hint: `${c.state} \xB7 ${c.domainId}` })));
|
|
15472
|
+
case "deployment":
|
|
15473
|
+
return listed(ctx, "deployments", messageFor(input, "Deployment"), async () => (await ctx.api().deployments.list()).map((d) => ({ label: d.name, value: d.deploymentId, hint: `${d.target} \xB7 ${d.deploymentId}` })));
|
|
14562
15474
|
case "license":
|
|
14563
15475
|
return listed(ctx, "licenses", messageFor(input, "License"), async () => (await ctx.api().admin.listLicenses()).map((l) => ({ label: l.name, value: l.licenceId, hint: `${l.state.toLowerCase()} \xB7 ${l.licenceId}` })));
|
|
14564
15476
|
case "choice":
|
|
@@ -14573,7 +15485,7 @@ async function askFor(spec, input, ctx) {
|
|
|
14573
15485
|
}
|
|
14574
15486
|
case "file":
|
|
14575
15487
|
return typed(ctx, question(input), {
|
|
14576
|
-
validate: (value) =>
|
|
15488
|
+
validate: (value) => fs19.existsSync(value.trim()) || `No file at ${value.trim()}.`
|
|
14577
15489
|
});
|
|
14578
15490
|
case "number":
|
|
14579
15491
|
return typed(ctx, question(input), { validate: numberRule(spec) });
|
|
@@ -14787,7 +15699,7 @@ function typedValue(ctx, message) {
|
|
|
14787
15699
|
return typed(ctx, message);
|
|
14788
15700
|
}
|
|
14789
15701
|
function typeItChoice() {
|
|
14790
|
-
return { name:
|
|
15702
|
+
return { name: chalk40.dim("Type it instead"), value: TYPE_IT };
|
|
14791
15703
|
}
|
|
14792
15704
|
function text(ctx, name) {
|
|
14793
15705
|
const value = ctx.known.get(name);
|
|
@@ -14817,7 +15729,7 @@ function capitalize(value) {
|
|
|
14817
15729
|
return value.charAt(0).toUpperCase() + value.slice(1);
|
|
14818
15730
|
}
|
|
14819
15731
|
function labelled(label, hint2) {
|
|
14820
|
-
return hint2 && hint2 !== label ? `${label} ${
|
|
15732
|
+
return hint2 && hint2 !== label ? `${label} ${chalk40.dim(hint2)}` : label;
|
|
14821
15733
|
}
|
|
14822
15734
|
function numberRule(spec) {
|
|
14823
15735
|
return (raw) => {
|
|
@@ -14863,7 +15775,7 @@ async function fillPendingInputs(actionCommand) {
|
|
|
14863
15775
|
known: knownValues(actionCommand),
|
|
14864
15776
|
globals: actionCommand.optsWithGlobals(),
|
|
14865
15777
|
prefill: /* @__PURE__ */ new Map(),
|
|
14866
|
-
note: (line) => process.stderr.write(
|
|
15778
|
+
note: (line) => process.stderr.write(chalk41.dim(` ${line}
|
|
14867
15779
|
`))
|
|
14868
15780
|
};
|
|
14869
15781
|
for (const item of orderByDependencies(pending)) {
|
|
@@ -14872,7 +15784,7 @@ async function fillPendingInputs(actionCommand) {
|
|
|
14872
15784
|
ctx.known.set(item.input.name, value);
|
|
14873
15785
|
}
|
|
14874
15786
|
const log = env.log ?? ((line) => console.log(line));
|
|
14875
|
-
log(
|
|
15787
|
+
log(chalk41.dim(` Equivalent: ${equivalentCommand(actionCommand)}`));
|
|
14876
15788
|
}
|
|
14877
15789
|
function commandChain(cmd) {
|
|
14878
15790
|
const chain = [];
|
|
@@ -14978,7 +15890,7 @@ function createProgram(environment = {}) {
|
|
|
14978
15890
|
selectProfile(opts.profile);
|
|
14979
15891
|
if (opts.dryRun) setDryRun(true);
|
|
14980
15892
|
if (opts.verbose) setVerbose(true);
|
|
14981
|
-
if (opts.color === false)
|
|
15893
|
+
if (opts.color === false) chalk42.level = 0;
|
|
14982
15894
|
}).hook("preAction", (_thisCommand, actionCommand) => fillPendingInputs(actionCommand));
|
|
14983
15895
|
program.addHelpText("after", HELP_EPILOGUE);
|
|
14984
15896
|
registerAuthCommands(program);
|
|
@@ -14999,6 +15911,7 @@ function createProgram(environment = {}) {
|
|
|
14999
15911
|
registerAdminCommands(program);
|
|
15000
15912
|
registerStatusCommands(program);
|
|
15001
15913
|
registerAnalyzeCommand(program);
|
|
15914
|
+
registerDeploymentCommands(program);
|
|
15002
15915
|
registerPublicCommands(program);
|
|
15003
15916
|
registerLicenseCommands(program);
|
|
15004
15917
|
registerDataSourcesCommands(program);
|
|
@@ -15023,4 +15936,4 @@ export {
|
|
|
15023
15936
|
PromptCanceled,
|
|
15024
15937
|
createProgram
|
|
15025
15938
|
};
|
|
15026
|
-
//# sourceMappingURL=chunk-
|
|
15939
|
+
//# sourceMappingURL=chunk-FERQPITK.js.map
|