@uipath/data-fabric-tool 0.9.1 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +18263 -30990
- package/dist/tool.js +18270 -30997
- package/package.json +8 -8
- package/src/commands/entities.spec.ts +649 -8
- package/src/commands/entities.ts +272 -24
- package/src/commands/records.spec.ts +251 -10
- package/src/commands/records.ts +80 -7
package/src/commands/records.ts
CHANGED
|
@@ -15,6 +15,7 @@ import { createDataFabricClient } from "../utils/sdk-client";
|
|
|
15
15
|
interface ListOptions {
|
|
16
16
|
tenant?: string;
|
|
17
17
|
limit: string;
|
|
18
|
+
offset?: string;
|
|
18
19
|
cursor?: string;
|
|
19
20
|
}
|
|
20
21
|
|
|
@@ -43,6 +44,7 @@ interface QueryOptions {
|
|
|
43
44
|
file?: string;
|
|
44
45
|
body?: string;
|
|
45
46
|
limit: string;
|
|
47
|
+
offset?: string;
|
|
46
48
|
cursor?: string;
|
|
47
49
|
}
|
|
48
50
|
|
|
@@ -162,6 +164,10 @@ export const registerRecordsCommand = (program: Command) => {
|
|
|
162
164
|
"Number of records to return per page",
|
|
163
165
|
"50",
|
|
164
166
|
)
|
|
167
|
+
.option(
|
|
168
|
+
"-o, --offset <number>",
|
|
169
|
+
"Start from the page containing this record index (rounded down to nearest page boundary; (mutually exclusive with --cursor)",
|
|
170
|
+
)
|
|
165
171
|
.option(
|
|
166
172
|
"--cursor <cursor>",
|
|
167
173
|
"Pagination cursor from a previous response to fetch the next page",
|
|
@@ -170,7 +176,7 @@ export const registerRecordsCommand = (program: Command) => {
|
|
|
170
176
|
.trackedAction(
|
|
171
177
|
processContext,
|
|
172
178
|
async (entityId: string, options: ListOptions) => {
|
|
173
|
-
const pageSize =
|
|
179
|
+
const pageSize = Number(options.limit);
|
|
174
180
|
if (Number.isNaN(pageSize) || pageSize < 1) {
|
|
175
181
|
OutputFormatter.error({
|
|
176
182
|
Result: RESULTS.Failure,
|
|
@@ -181,6 +187,36 @@ export const registerRecordsCommand = (program: Command) => {
|
|
|
181
187
|
return;
|
|
182
188
|
}
|
|
183
189
|
|
|
190
|
+
if (
|
|
191
|
+
options.cursor !== undefined &&
|
|
192
|
+
options.offset !== undefined
|
|
193
|
+
) {
|
|
194
|
+
OutputFormatter.error({
|
|
195
|
+
Result: RESULTS.Failure,
|
|
196
|
+
Message: "--offset and --cursor are mutually exclusive",
|
|
197
|
+
Instructions:
|
|
198
|
+
"Use --offset to jump to a position by record count, or --cursor to continue from a previous response.",
|
|
199
|
+
});
|
|
200
|
+
processContext.exit(1);
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
let jumpToPage: number | undefined;
|
|
205
|
+
if (options.offset !== undefined) {
|
|
206
|
+
const offsetValue = Number(options.offset);
|
|
207
|
+
if (Number.isNaN(offsetValue) || offsetValue < 0) {
|
|
208
|
+
OutputFormatter.error({
|
|
209
|
+
Result: RESULTS.Failure,
|
|
210
|
+
Message: "Invalid --offset value",
|
|
211
|
+
Instructions:
|
|
212
|
+
"Provide a non-negative integer for --offset.",
|
|
213
|
+
});
|
|
214
|
+
processContext.exit(1);
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
jumpToPage = Math.floor(offsetValue / pageSize) + 1;
|
|
218
|
+
}
|
|
219
|
+
|
|
184
220
|
const [clientError, sdk] = await catchError(
|
|
185
221
|
createDataFabricClient(options.tenant),
|
|
186
222
|
);
|
|
@@ -201,6 +237,7 @@ export const registerRecordsCommand = (program: Command) => {
|
|
|
201
237
|
...(options.cursor !== undefined && {
|
|
202
238
|
cursor: { value: options.cursor },
|
|
203
239
|
}),
|
|
240
|
+
...(jumpToPage !== undefined && { jumpToPage }),
|
|
204
241
|
}),
|
|
205
242
|
);
|
|
206
243
|
|
|
@@ -552,25 +589,30 @@ export const registerRecordsCommand = (program: Command) => {
|
|
|
552
589
|
records
|
|
553
590
|
.command("query")
|
|
554
591
|
.description(
|
|
555
|
-
"Query records in a Data Fabric entity with filters and
|
|
592
|
+
"Query records in a Data Fabric entity with filters, sorting, and aggregates. " +
|
|
556
593
|
"Provide a JSON object via --body or --file with optional keys: " +
|
|
557
|
-
"filterGroup, sortOptions (use isDescending: true/false), selectedFields
|
|
594
|
+
"filterGroup, sortOptions (use isDescending: true/false), selectedFields, " +
|
|
595
|
+
"aggregates (function: COUNT/SUM/AVG/MIN/MAX, field, alias?), groupBy.",
|
|
558
596
|
)
|
|
559
597
|
.argument("<id>", "Entity ID")
|
|
560
598
|
.option("-t, --tenant <tenant-name>", "Tenant name")
|
|
561
599
|
.option(
|
|
562
600
|
"-f, --file <path>",
|
|
563
|
-
"Path to JSON file with query options (filterGroup, selectedFields, sortOptions)",
|
|
601
|
+
"Path to JSON file with query options (filterGroup, selectedFields, sortOptions, aggregates, groupBy)",
|
|
564
602
|
)
|
|
565
603
|
.option(
|
|
566
604
|
"--body <json>",
|
|
567
|
-
"Inline JSON query options (filterGroup, selectedFields, sortOptions)",
|
|
605
|
+
"Inline JSON query options (filterGroup, selectedFields, sortOptions, aggregates, groupBy)",
|
|
568
606
|
)
|
|
569
607
|
.option(
|
|
570
608
|
"-l, --limit <number>",
|
|
571
609
|
"Number of records to return per page",
|
|
572
610
|
"50",
|
|
573
611
|
)
|
|
612
|
+
.option(
|
|
613
|
+
"-o, --offset <number>",
|
|
614
|
+
"Start from the page containing this record index (rounded down to nearest page boundary;(mutually exclusive with --cursor)",
|
|
615
|
+
)
|
|
574
616
|
.option(
|
|
575
617
|
"--cursor <cursor>",
|
|
576
618
|
"Pagination cursor from a previous response to fetch the next page",
|
|
@@ -578,7 +620,7 @@ export const registerRecordsCommand = (program: Command) => {
|
|
|
578
620
|
.trackedAction(
|
|
579
621
|
processContext,
|
|
580
622
|
async (entityId: string, options: QueryOptions) => {
|
|
581
|
-
const pageSize =
|
|
623
|
+
const pageSize = Number(options.limit);
|
|
582
624
|
if (Number.isNaN(pageSize) || pageSize < 1) {
|
|
583
625
|
OutputFormatter.error({
|
|
584
626
|
Result: RESULTS.Failure,
|
|
@@ -589,6 +631,36 @@ export const registerRecordsCommand = (program: Command) => {
|
|
|
589
631
|
return;
|
|
590
632
|
}
|
|
591
633
|
|
|
634
|
+
if (
|
|
635
|
+
options.cursor !== undefined &&
|
|
636
|
+
options.offset !== undefined
|
|
637
|
+
) {
|
|
638
|
+
OutputFormatter.error({
|
|
639
|
+
Result: RESULTS.Failure,
|
|
640
|
+
Message: "--offset and --cursor are mutually exclusive",
|
|
641
|
+
Instructions:
|
|
642
|
+
"Use --offset to jump to a position by record count, or --cursor to continue from a previous response.",
|
|
643
|
+
});
|
|
644
|
+
processContext.exit(1);
|
|
645
|
+
return;
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
let jumpToPage: number | undefined;
|
|
649
|
+
if (options.offset !== undefined) {
|
|
650
|
+
const offsetValue = Number(options.offset);
|
|
651
|
+
if (Number.isNaN(offsetValue) || offsetValue < 0) {
|
|
652
|
+
OutputFormatter.error({
|
|
653
|
+
Result: RESULTS.Failure,
|
|
654
|
+
Message: "Invalid --offset value",
|
|
655
|
+
Instructions:
|
|
656
|
+
"Provide a non-negative integer for --offset.",
|
|
657
|
+
});
|
|
658
|
+
processContext.exit(1);
|
|
659
|
+
return;
|
|
660
|
+
}
|
|
661
|
+
jumpToPage = Math.floor(offsetValue / pageSize) + 1;
|
|
662
|
+
}
|
|
663
|
+
|
|
592
664
|
let queryBody: Record<string, unknown> | null = null;
|
|
593
665
|
if (options.file !== undefined || options.body !== undefined) {
|
|
594
666
|
const [parseError, parsed] = await catchError(
|
|
@@ -616,7 +688,7 @@ export const registerRecordsCommand = (program: Command) => {
|
|
|
616
688
|
Result: RESULTS.Failure,
|
|
617
689
|
Message: "Query options must be a JSON object",
|
|
618
690
|
Instructions:
|
|
619
|
-
"Provide a JSON object (not an array) with filterGroup, selectedFields, or
|
|
691
|
+
"Provide a JSON object (not an array) with filterGroup, selectedFields, sortOptions, aggregates, or groupBy.",
|
|
620
692
|
});
|
|
621
693
|
processContext.exit(1);
|
|
622
694
|
return;
|
|
@@ -645,6 +717,7 @@ export const registerRecordsCommand = (program: Command) => {
|
|
|
645
717
|
...(options.cursor !== undefined && {
|
|
646
718
|
cursor: { value: options.cursor },
|
|
647
719
|
}),
|
|
720
|
+
...(jumpToPage !== undefined && { jumpToPage }),
|
|
648
721
|
}),
|
|
649
722
|
);
|
|
650
723
|
|