@contextual-io/cli 0.4.0 → 0.5.0
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 +134 -10
- package/dist/base.d.ts +5 -1
- package/dist/base.js +19 -6
- package/dist/commands/config/add.js +1 -0
- package/dist/commands/config/current.js +1 -1
- package/dist/commands/config/get.js +2 -3
- package/dist/commands/config/list.js +5 -5
- package/dist/commands/records/delete.js +1 -1
- package/dist/commands/records/get.js +1 -1
- package/dist/commands/records/list.d.ts +1 -0
- package/dist/commands/records/list.js +1 -0
- package/dist/commands/records/patch.d.ts +25 -0
- package/dist/commands/records/patch.js +106 -0
- package/dist/commands/records/replace.js +1 -1
- package/dist/commands/types/list.d.ts +1 -0
- package/dist/commands/types/list.js +1 -0
- package/dist/models/user-config.d.ts +2 -2
- package/dist/models/user-config.js +2 -0
- package/oclif.manifest.json +108 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ $ npm install -g @contextual-io/cli
|
|
|
20
20
|
$ ctxl COMMAND
|
|
21
21
|
running command...
|
|
22
22
|
$ ctxl (--version)
|
|
23
|
-
@contextual-io/cli/0.
|
|
23
|
+
@contextual-io/cli/0.5.0 linux-x64 node-v25.2.1
|
|
24
24
|
$ ctxl --help [COMMAND]
|
|
25
25
|
USAGE
|
|
26
26
|
$ ctxl COMMAND
|
|
@@ -46,8 +46,10 @@ USAGE
|
|
|
46
46
|
* [`ctxl records get [URI]`](#ctxl-records-get-uri)
|
|
47
47
|
* [`ctxl records import [URI]`](#ctxl-records-import-uri)
|
|
48
48
|
* [`ctxl records list [URI]`](#ctxl-records-list-uri)
|
|
49
|
+
* [`ctxl records patch [URI]`](#ctxl-records-patch-uri)
|
|
49
50
|
* [`ctxl records query [URI]`](#ctxl-records-query-uri)
|
|
50
51
|
* [`ctxl records replace [URI]`](#ctxl-records-replace-uri)
|
|
52
|
+
* [`ctxl records search [URI]`](#ctxl-records-search-uri)
|
|
51
53
|
* [`ctxl types <COMMAND>`](#ctxl-types-command)
|
|
52
54
|
* [`ctxl types add`](#ctxl-types-add)
|
|
53
55
|
* [`ctxl types create`](#ctxl-types-create)
|
|
@@ -56,6 +58,7 @@ USAGE
|
|
|
56
58
|
* [`ctxl types import`](#ctxl-types-import)
|
|
57
59
|
* [`ctxl types list`](#ctxl-types-list)
|
|
58
60
|
* [`ctxl types replace [URI]`](#ctxl-types-replace-uri)
|
|
61
|
+
* [`ctxl types search`](#ctxl-types-search)
|
|
59
62
|
|
|
60
63
|
## `ctxl autocomplete [SHELL]`
|
|
61
64
|
|
|
@@ -106,14 +109,12 @@ Add a new config.
|
|
|
106
109
|
|
|
107
110
|
```
|
|
108
111
|
USAGE
|
|
109
|
-
$ ctxl config add CONFIG-ID [-
|
|
112
|
+
$ ctxl config add CONFIG-ID [-t <value>]
|
|
110
113
|
|
|
111
114
|
ARGUMENTS
|
|
112
115
|
CONFIG-ID id of config
|
|
113
116
|
|
|
114
117
|
FLAGS
|
|
115
|
-
-s, --silo=<option> [default: prod] silo
|
|
116
|
-
<options: prod|qa|dev>
|
|
117
118
|
-t, --tenant-id=<value> tenant id (if different from config id)
|
|
118
119
|
|
|
119
120
|
DESCRIPTION
|
|
@@ -333,14 +334,14 @@ Delete record(s).
|
|
|
333
334
|
|
|
334
335
|
```
|
|
335
336
|
USAGE
|
|
336
|
-
$ ctxl records delete [URI] [-C <value>] [-
|
|
337
|
+
$ ctxl records delete [URI] [-C <value>] [-I <value>...] [-T <value>]
|
|
337
338
|
|
|
338
339
|
ARGUMENTS
|
|
339
340
|
[URI] uri of record
|
|
340
341
|
|
|
341
342
|
FLAGS
|
|
343
|
+
-I, --id=<value>... id(s)
|
|
342
344
|
-T, --type=<value> type
|
|
343
|
-
-i, --id=<value>... id(s)
|
|
344
345
|
|
|
345
346
|
GLOBAL FLAGS
|
|
346
347
|
-C, --config-id=<value> Specify config id to use for call.
|
|
@@ -366,14 +367,14 @@ Get a record.
|
|
|
366
367
|
|
|
367
368
|
```
|
|
368
369
|
USAGE
|
|
369
|
-
$ ctxl records get [URI] [-C <value>] [-
|
|
370
|
+
$ ctxl records get [URI] [-C <value>] [-I <value>...] [-T <value>]
|
|
370
371
|
|
|
371
372
|
ARGUMENTS
|
|
372
373
|
[URI] uri of record
|
|
373
374
|
|
|
374
375
|
FLAGS
|
|
376
|
+
-I, --id=<value>... id(s)
|
|
375
377
|
-T, --type=<value> type
|
|
376
|
-
-i, --id=<value>... id(s)
|
|
377
378
|
|
|
378
379
|
GLOBAL FLAGS
|
|
379
380
|
-C, --config-id=<value> Specify config id to use for call.
|
|
@@ -455,6 +456,9 @@ GLOBAL FLAGS
|
|
|
455
456
|
DESCRIPTION
|
|
456
457
|
List records.
|
|
457
458
|
|
|
459
|
+
ALIASES
|
|
460
|
+
$ ctxl records search
|
|
461
|
+
|
|
458
462
|
EXAMPLES
|
|
459
463
|
$ ctxl records list native-object:my-type
|
|
460
464
|
|
|
@@ -465,6 +469,41 @@ EXAMPLES
|
|
|
465
469
|
$ ctxl records list --type my-type -s field1=value1 -s field2=value2 --include-total
|
|
466
470
|
```
|
|
467
471
|
|
|
472
|
+
## `ctxl records patch [URI]`
|
|
473
|
+
|
|
474
|
+
Patch a record.
|
|
475
|
+
|
|
476
|
+
```
|
|
477
|
+
USAGE
|
|
478
|
+
$ ctxl records patch [URI] [-C <value>] [-a <value>...] [-I <value>] [-i <value>...] [-d <value>...] [-r
|
|
479
|
+
<value>...] [-s <value>...] [-T <value>]
|
|
480
|
+
|
|
481
|
+
ARGUMENTS
|
|
482
|
+
[URI] uri of record
|
|
483
|
+
|
|
484
|
+
FLAGS
|
|
485
|
+
-I, --id=<value> id
|
|
486
|
+
-T, --type=<value> type
|
|
487
|
+
-a, --add=<value>... add field
|
|
488
|
+
-d, --remove=<value>... remove field
|
|
489
|
+
-i, --increment=<value>... increment field
|
|
490
|
+
-r, --replace=<value>... replace field
|
|
491
|
+
-s, --set=<value>... set field
|
|
492
|
+
|
|
493
|
+
GLOBAL FLAGS
|
|
494
|
+
-C, --config-id=<value> Specify config id to use for call.
|
|
495
|
+
|
|
496
|
+
DESCRIPTION
|
|
497
|
+
Patch a record.
|
|
498
|
+
|
|
499
|
+
EXAMPLES
|
|
500
|
+
$ ctxl records patch native-object:my-type/instance-1 --set field1=value1
|
|
501
|
+
|
|
502
|
+
$ ctxl records patch native-object:my-type --id instance-1 --remove field2
|
|
503
|
+
|
|
504
|
+
$ ctxl records patch --type my-type --id instance-1 --increment field3=2
|
|
505
|
+
```
|
|
506
|
+
|
|
468
507
|
## `ctxl records query [URI]`
|
|
469
508
|
|
|
470
509
|
Query records.
|
|
@@ -509,14 +548,14 @@ Replace a record.
|
|
|
509
548
|
|
|
510
549
|
```
|
|
511
550
|
USAGE
|
|
512
|
-
$ ctxl records replace [URI] [-C <value>] [-
|
|
551
|
+
$ ctxl records replace [URI] [-C <value>] [-I <value>] [-i <value>] [-T <value>]
|
|
513
552
|
|
|
514
553
|
ARGUMENTS
|
|
515
554
|
[URI] uri of record
|
|
516
555
|
|
|
517
556
|
FLAGS
|
|
557
|
+
-I, --id=<value> id
|
|
518
558
|
-T, --type=<value> type
|
|
519
|
-
-i, --id=<value> id
|
|
520
559
|
-i, --input-file=<value> [default: -] file to read. can read stdin if value is '-'
|
|
521
560
|
|
|
522
561
|
GLOBAL FLAGS
|
|
@@ -533,6 +572,50 @@ EXAMPLES
|
|
|
533
572
|
$ ctxl records replace --type my-type --id instance-1 --input-file record.json
|
|
534
573
|
```
|
|
535
574
|
|
|
575
|
+
## `ctxl records search [URI]`
|
|
576
|
+
|
|
577
|
+
List records.
|
|
578
|
+
|
|
579
|
+
```
|
|
580
|
+
USAGE
|
|
581
|
+
$ ctxl records search [URI] [-C <value>] [-S <value>...] [-e] [-f <value>...] [--include-total] [-o <value>...]
|
|
582
|
+
[--page-size <value>] [--page-token <value>] [-p] [-s <value>...] [-t <value>...] [-T <value>]
|
|
583
|
+
|
|
584
|
+
ARGUMENTS
|
|
585
|
+
[URI] uri of type
|
|
586
|
+
|
|
587
|
+
FLAGS
|
|
588
|
+
-S, --exact-search=<value>... search fields exactly
|
|
589
|
+
-T, --type=<value> type
|
|
590
|
+
-e, --export export data as JSONL
|
|
591
|
+
-f, --from=<value>... search from
|
|
592
|
+
-o, --order-by=<value>... order fields
|
|
593
|
+
-p, --progress show progress during export
|
|
594
|
+
-s, --search=<value>... search fields
|
|
595
|
+
-t, --to=<value>... search to
|
|
596
|
+
--include-total include total count
|
|
597
|
+
--page-size=<value> number of records per page
|
|
598
|
+
--page-token=<value> page token to fetch
|
|
599
|
+
|
|
600
|
+
GLOBAL FLAGS
|
|
601
|
+
-C, --config-id=<value> Specify config id to use for call.
|
|
602
|
+
|
|
603
|
+
DESCRIPTION
|
|
604
|
+
List records.
|
|
605
|
+
|
|
606
|
+
ALIASES
|
|
607
|
+
$ ctxl records search
|
|
608
|
+
|
|
609
|
+
EXAMPLES
|
|
610
|
+
$ ctxl records search native-object:my-type
|
|
611
|
+
|
|
612
|
+
$ ctxl records search --type my-type
|
|
613
|
+
|
|
614
|
+
$ ctxl records search --type my-type --order-by field1:desc
|
|
615
|
+
|
|
616
|
+
$ ctxl records search --type my-type -s field1=value1 -s field2=value2 --include-total
|
|
617
|
+
```
|
|
618
|
+
|
|
536
619
|
## `ctxl types <COMMAND>`
|
|
537
620
|
|
|
538
621
|
Manage types.
|
|
@@ -705,6 +788,9 @@ GLOBAL FLAGS
|
|
|
705
788
|
DESCRIPTION
|
|
706
789
|
List types.
|
|
707
790
|
|
|
791
|
+
ALIASES
|
|
792
|
+
$ ctxl types search
|
|
793
|
+
|
|
708
794
|
EXAMPLES
|
|
709
795
|
$ ctxl types list
|
|
710
796
|
|
|
@@ -739,4 +825,42 @@ EXAMPLES
|
|
|
739
825
|
|
|
740
826
|
$ ctxl types replace --type my-type --input-file record.json
|
|
741
827
|
```
|
|
828
|
+
|
|
829
|
+
## `ctxl types search`
|
|
830
|
+
|
|
831
|
+
List types.
|
|
832
|
+
|
|
833
|
+
```
|
|
834
|
+
USAGE
|
|
835
|
+
$ ctxl types search [-C <value>] [-S <value>...] [-e] [-f <value>...] [--include-total] [-o <value>...]
|
|
836
|
+
[--page-size <value>] [--page-token <value>] [-p] [-s <value>...] [-t <value>...]
|
|
837
|
+
|
|
838
|
+
FLAGS
|
|
839
|
+
-S, --exact-search=<value>... search fields exactly
|
|
840
|
+
-e, --export export data as JSONL
|
|
841
|
+
-f, --from=<value>... search from
|
|
842
|
+
-o, --order-by=<value>... order fields
|
|
843
|
+
-p, --progress show progress during export
|
|
844
|
+
-s, --search=<value>... search fields
|
|
845
|
+
-t, --to=<value>... search to
|
|
846
|
+
--include-total include total count
|
|
847
|
+
--page-size=<value> number of types per page
|
|
848
|
+
--page-token=<value> page token to fetch
|
|
849
|
+
|
|
850
|
+
GLOBAL FLAGS
|
|
851
|
+
-C, --config-id=<value> Specify config id to use for call.
|
|
852
|
+
|
|
853
|
+
DESCRIPTION
|
|
854
|
+
List types.
|
|
855
|
+
|
|
856
|
+
ALIASES
|
|
857
|
+
$ ctxl types search
|
|
858
|
+
|
|
859
|
+
EXAMPLES
|
|
860
|
+
$ ctxl types search
|
|
861
|
+
|
|
862
|
+
$ ctxl types search --order-by field1:desc
|
|
863
|
+
|
|
864
|
+
$ ctxl types search -s field1=value1 -s field2=value2 --include-total
|
|
865
|
+
```
|
|
742
866
|
<!-- commandsstop -->
|
package/dist/base.d.ts
CHANGED
|
@@ -7,7 +7,11 @@ export type Args<T extends typeof Command> = Interfaces.InferredArgs<T["args"]>;
|
|
|
7
7
|
declare class CommandConfig {
|
|
8
8
|
private readonly configDir;
|
|
9
9
|
constructor(configDir: string);
|
|
10
|
-
|
|
10
|
+
cleanJson(configId: UrlSafeId, { silo, tenantId }: Config): CleanConfig;
|
|
11
|
+
cleanTable(configId: UrlSafeId, config: Config): {
|
|
12
|
+
tenantId: string;
|
|
13
|
+
configId: string;
|
|
14
|
+
};
|
|
11
15
|
get(configId?: UrlSafeId): Promise<{
|
|
12
16
|
config: Config;
|
|
13
17
|
lookup: string;
|
package/dist/base.js
CHANGED
|
@@ -13,12 +13,25 @@ class CommandConfig {
|
|
|
13
13
|
constructor(configDir) {
|
|
14
14
|
this.configDir = configDir;
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
cleanJson(configId, { silo, tenantId }) {
|
|
17
|
+
const rv = {
|
|
18
18
|
configId,
|
|
19
|
-
silo,
|
|
20
19
|
tenantId,
|
|
21
20
|
};
|
|
21
|
+
if (silo === "prod") {
|
|
22
|
+
return rv;
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
...rv,
|
|
26
|
+
silo,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
cleanTable(configId, config) {
|
|
30
|
+
const { silo, ...rv } = this.cleanJson(configId, config);
|
|
31
|
+
if (silo) {
|
|
32
|
+
rv.tenantId = `[${silo}] ${rv.tenantId}`;
|
|
33
|
+
}
|
|
34
|
+
return rv;
|
|
22
35
|
}
|
|
23
36
|
async get(configId) {
|
|
24
37
|
const userConfig = this.read();
|
|
@@ -112,11 +125,11 @@ export class BaseConfigCommand extends Command {
|
|
|
112
125
|
const flattened = z.flattenError(err);
|
|
113
126
|
message = flattened.formErrors.join("\n");
|
|
114
127
|
}
|
|
128
|
+
if (!/See more help with/.test(message)) {
|
|
129
|
+
message += "\nSee more help with --help";
|
|
130
|
+
}
|
|
115
131
|
this.logToStderr(chalkStderr.red(chalkStderr.bold(" Error: ") + message));
|
|
116
132
|
this.logToStderr();
|
|
117
|
-
if (!(err instanceof HttpError)) {
|
|
118
|
-
await this.showHelp();
|
|
119
|
-
}
|
|
120
133
|
}
|
|
121
134
|
this.exit(exitCode);
|
|
122
135
|
}
|
|
@@ -16,6 +16,7 @@ export default class ConfigAdd extends BaseConfigCommand {
|
|
|
16
16
|
char: "s",
|
|
17
17
|
default: "prod",
|
|
18
18
|
description: "silo",
|
|
19
|
+
hidden: true,
|
|
19
20
|
options: [...Silo.options.values()],
|
|
20
21
|
}),
|
|
21
22
|
"tenant-id": Flags.string({ char: "t", description: "tenant id (if different from config id)" }),
|
|
@@ -10,6 +10,6 @@ export default class ConfigCurrent extends BaseConfigCommand {
|
|
|
10
10
|
async run() {
|
|
11
11
|
const { config, lookup } = await this.userConfig.get();
|
|
12
12
|
this.log(lookup);
|
|
13
|
-
return this.userConfig.
|
|
13
|
+
return this.userConfig.cleanJson(lookup, config);
|
|
14
14
|
}
|
|
15
15
|
}
|
|
@@ -16,10 +16,9 @@ export default class ConfigGet extends BaseConfigCommand {
|
|
|
16
16
|
async run() {
|
|
17
17
|
const configId = UrlSafeId.optional().parse(this.args["config-id"]);
|
|
18
18
|
const { config, lookup } = await this.userConfig.get(configId);
|
|
19
|
-
const rv = this.userConfig.clean(lookup, config);
|
|
20
19
|
this.log(makeTable({
|
|
21
|
-
data: [
|
|
20
|
+
data: [this.userConfig.cleanTable(lookup, config)],
|
|
22
21
|
}));
|
|
23
|
-
return
|
|
22
|
+
return this.userConfig.cleanJson(lookup, config);
|
|
24
23
|
}
|
|
25
24
|
}
|
|
@@ -16,17 +16,17 @@ export default class ConfigList extends BaseConfigCommand {
|
|
|
16
16
|
return config;
|
|
17
17
|
return {
|
|
18
18
|
configId: chalk.bold(chalk.yellow(config.configId)),
|
|
19
|
-
silo: chalk.bold(chalk.yellow(config.silo)),
|
|
20
19
|
tenantId: chalk.bold(chalk.yellow(config.tenantId)),
|
|
21
20
|
};
|
|
22
21
|
};
|
|
23
|
-
const configs = Object.entries(userConfig.configs)
|
|
24
|
-
.map(([configId, config]) => this.userConfig.clean(configId, config));
|
|
25
22
|
this.log(makeTable({
|
|
26
|
-
data:
|
|
23
|
+
data: Object.entries(userConfig.configs)
|
|
24
|
+
.map(([configId, config]) => this.userConfig.cleanTable(configId, config))
|
|
25
|
+
.map(c => colorize(c)),
|
|
27
26
|
}));
|
|
28
27
|
return {
|
|
29
|
-
configs
|
|
28
|
+
configs: Object.entries(userConfig.configs)
|
|
29
|
+
.map(([configId, config]) => this.userConfig.cleanJson(configId, config)),
|
|
30
30
|
current: userConfig.current,
|
|
31
31
|
};
|
|
32
32
|
}
|
|
@@ -9,6 +9,7 @@ const flagArrayToParam = (cmd, values) => values
|
|
|
9
9
|
.map(([k, v]) => ({ [`${cmd}.${k}`]: v }))
|
|
10
10
|
.reduce((a, b) => ({ ...a, ...b }), {});
|
|
11
11
|
export default class RecordsList extends BaseCommand {
|
|
12
|
+
static aliases = ["records search"];
|
|
12
13
|
static args = {
|
|
13
14
|
"uri": Args.string({ description: "uri of type" }),
|
|
14
15
|
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { BaseCommand } from "../../base.js";
|
|
2
|
+
type Patch = {
|
|
3
|
+
path: string;
|
|
4
|
+
};
|
|
5
|
+
type PatchWithValue = Patch & {
|
|
6
|
+
value: unknown;
|
|
7
|
+
};
|
|
8
|
+
export default class RecordsPatch extends BaseCommand<typeof RecordsPatch> {
|
|
9
|
+
static args: {
|
|
10
|
+
uri: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
11
|
+
};
|
|
12
|
+
static description: string;
|
|
13
|
+
static examples: string[];
|
|
14
|
+
static flags: {
|
|
15
|
+
add: import("@oclif/core/interfaces").OptionFlag<PatchWithValue[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
|
+
id: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
|
+
increment: import("@oclif/core/interfaces").OptionFlag<PatchWithValue[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
18
|
+
remove: import("@oclif/core/interfaces").OptionFlag<Patch[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
19
|
+
replace: import("@oclif/core/interfaces").OptionFlag<PatchWithValue[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
20
|
+
set: import("@oclif/core/interfaces").OptionFlag<PatchWithValue[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
21
|
+
type: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
22
|
+
};
|
|
23
|
+
run(): Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { Args, Flags } from "@oclif/core";
|
|
2
|
+
import { BaseCommand } from "../../base.js";
|
|
3
|
+
import { parseUri } from "../../models/uri.js";
|
|
4
|
+
import { getNativeObjectApiEndpoint } from "../../utils/endpoints.js";
|
|
5
|
+
const toPath = (input) => "/" + input.replaceAll(".", "/");
|
|
6
|
+
const patchFlag = Flags.custom({
|
|
7
|
+
async parse(input) {
|
|
8
|
+
return {
|
|
9
|
+
path: toPath(input),
|
|
10
|
+
};
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
const patchWithValueFlag = Flags.custom({
|
|
14
|
+
async parse(input) {
|
|
15
|
+
if (!/=/.test(input)) {
|
|
16
|
+
throw new Error("No value provided for patch");
|
|
17
|
+
}
|
|
18
|
+
const [key, value] = input.split("=");
|
|
19
|
+
return {
|
|
20
|
+
path: toPath(key),
|
|
21
|
+
value,
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
export default class RecordsPatch extends BaseCommand {
|
|
26
|
+
static args = {
|
|
27
|
+
"uri": Args.string({ description: "uri of record" }),
|
|
28
|
+
};
|
|
29
|
+
static description = "Patch a record.";
|
|
30
|
+
static examples = [
|
|
31
|
+
"<%= config.bin %> <%= command.id %> native-object:my-type/instance-1 --set field1=value1",
|
|
32
|
+
"<%= config.bin %> <%= command.id %> native-object:my-type --id instance-1 --remove field2",
|
|
33
|
+
"<%= config.bin %> <%= command.id %> --type my-type --id instance-1 --increment field3=2",
|
|
34
|
+
];
|
|
35
|
+
static flags = {
|
|
36
|
+
add: patchWithValueFlag({
|
|
37
|
+
char: "a",
|
|
38
|
+
description: "add field",
|
|
39
|
+
multiple: true,
|
|
40
|
+
}),
|
|
41
|
+
id: Flags.string({
|
|
42
|
+
char: "I",
|
|
43
|
+
description: "id",
|
|
44
|
+
}),
|
|
45
|
+
increment: patchWithValueFlag({
|
|
46
|
+
char: "i",
|
|
47
|
+
description: "increment field",
|
|
48
|
+
multiple: true,
|
|
49
|
+
}),
|
|
50
|
+
remove: patchFlag({
|
|
51
|
+
char: "d",
|
|
52
|
+
description: "remove field",
|
|
53
|
+
multiple: true,
|
|
54
|
+
}),
|
|
55
|
+
replace: patchWithValueFlag({
|
|
56
|
+
char: "r",
|
|
57
|
+
description: "replace field",
|
|
58
|
+
multiple: true,
|
|
59
|
+
}),
|
|
60
|
+
set: patchWithValueFlag({
|
|
61
|
+
char: "s",
|
|
62
|
+
description: "set field",
|
|
63
|
+
multiple: true,
|
|
64
|
+
}),
|
|
65
|
+
type: Flags.string({
|
|
66
|
+
char: "T",
|
|
67
|
+
description: "type",
|
|
68
|
+
}),
|
|
69
|
+
};
|
|
70
|
+
async run() {
|
|
71
|
+
const { uri } = this.args;
|
|
72
|
+
const { id: flagId, type: flagType } = this.flags;
|
|
73
|
+
let type = flagType;
|
|
74
|
+
let lookup = flagId;
|
|
75
|
+
if (uri) {
|
|
76
|
+
const { id, type: uriType } = parseUri(uri);
|
|
77
|
+
type = uriType;
|
|
78
|
+
if (id) {
|
|
79
|
+
lookup = id;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (!type) {
|
|
83
|
+
throw new Error("Type not provided");
|
|
84
|
+
}
|
|
85
|
+
if (!lookup) {
|
|
86
|
+
throw new Error("Id not provided");
|
|
87
|
+
}
|
|
88
|
+
const patches = [
|
|
89
|
+
...(this.flags.add ?? []).map(x => ({ op: "add", ...x })),
|
|
90
|
+
...(this.flags.set ?? []).map(x => ({ op: "set", ...x })),
|
|
91
|
+
...(this.flags.replace ?? []).map(x => ({ op: "replace", ...x })),
|
|
92
|
+
...(this.flags.remove ?? []).map(x => ({ op: "remove", ...x })),
|
|
93
|
+
...(this.flags.increment ?? []).map(({ value, ...x }) => ({ op: "increment", ...x, value: Number(`${value}`) })),
|
|
94
|
+
];
|
|
95
|
+
if (patches.length === 0) {
|
|
96
|
+
throw new Error("No patches provided");
|
|
97
|
+
}
|
|
98
|
+
this.logJson(await this.fetch(({ silo, tenantId }) => getNativeObjectApiEndpoint(tenantId, silo) + `/api/v1/${type}/${lookup}`, {
|
|
99
|
+
body: JSON.stringify(patches),
|
|
100
|
+
headers: {
|
|
101
|
+
"content-type": "application/json",
|
|
102
|
+
},
|
|
103
|
+
method: "PATCH",
|
|
104
|
+
}));
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -8,6 +8,7 @@ const flagArrayToParam = (cmd, values) => values
|
|
|
8
8
|
.map(([k, v]) => ({ [`${cmd}.${k}`]: v }))
|
|
9
9
|
.reduce((a, b) => ({ ...a, ...b }), {});
|
|
10
10
|
export default class TypesList extends BaseCommand {
|
|
11
|
+
static aliases = ["types search"];
|
|
11
12
|
static args = {};
|
|
12
13
|
static description = "List types.";
|
|
13
14
|
static examples = [
|
|
@@ -23,11 +23,11 @@ export declare const Config: z.ZodObject<{
|
|
|
23
23
|
}, z.core.$strip>;
|
|
24
24
|
export type Config = z.infer<typeof Config>;
|
|
25
25
|
export declare const CleanConfig: z.ZodObject<{
|
|
26
|
-
silo: z.ZodEnum<{
|
|
26
|
+
silo: z.ZodOptional<z.ZodEnum<{
|
|
27
27
|
prod: "prod";
|
|
28
28
|
qa: "qa";
|
|
29
29
|
dev: "dev";
|
|
30
|
-
}
|
|
30
|
+
}>>;
|
|
31
31
|
tenantId: z.ZodString;
|
|
32
32
|
configId: z.ZodString;
|
|
33
33
|
}, z.core.$strip>;
|
package/oclif.manifest.json
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"silo": {
|
|
18
18
|
"char": "s",
|
|
19
19
|
"description": "silo",
|
|
20
|
+
"hidden": true,
|
|
20
21
|
"name": "silo",
|
|
21
22
|
"default": "prod",
|
|
22
23
|
"hasDynamicHelp": false,
|
|
@@ -351,7 +352,7 @@
|
|
|
351
352
|
"type": "option"
|
|
352
353
|
},
|
|
353
354
|
"id": {
|
|
354
|
-
"char": "
|
|
355
|
+
"char": "I",
|
|
355
356
|
"description": "id(s)",
|
|
356
357
|
"name": "id",
|
|
357
358
|
"hasDynamicHelp": false,
|
|
@@ -410,7 +411,7 @@
|
|
|
410
411
|
"type": "option"
|
|
411
412
|
},
|
|
412
413
|
"id": {
|
|
413
|
-
"char": "
|
|
414
|
+
"char": "I",
|
|
414
415
|
"description": "id(s)",
|
|
415
416
|
"name": "id",
|
|
416
417
|
"hasDynamicHelp": false,
|
|
@@ -468,7 +469,9 @@
|
|
|
468
469
|
]
|
|
469
470
|
},
|
|
470
471
|
"records:list": {
|
|
471
|
-
"aliases": [
|
|
472
|
+
"aliases": [
|
|
473
|
+
"records:search"
|
|
474
|
+
],
|
|
472
475
|
"args": {
|
|
473
476
|
"uri": {
|
|
474
477
|
"description": "uri of type",
|
|
@@ -591,6 +594,103 @@
|
|
|
591
594
|
"list.js"
|
|
592
595
|
]
|
|
593
596
|
},
|
|
597
|
+
"records:patch": {
|
|
598
|
+
"aliases": [],
|
|
599
|
+
"args": {
|
|
600
|
+
"uri": {
|
|
601
|
+
"description": "uri of record",
|
|
602
|
+
"name": "uri"
|
|
603
|
+
}
|
|
604
|
+
},
|
|
605
|
+
"description": "Patch a record.",
|
|
606
|
+
"examples": [
|
|
607
|
+
"<%= config.bin %> <%= command.id %> native-object:my-type/instance-1 --set field1=value1",
|
|
608
|
+
"<%= config.bin %> <%= command.id %> native-object:my-type --id instance-1 --remove field2",
|
|
609
|
+
"<%= config.bin %> <%= command.id %> --type my-type --id instance-1 --increment field3=2"
|
|
610
|
+
],
|
|
611
|
+
"flags": {
|
|
612
|
+
"config-id": {
|
|
613
|
+
"char": "C",
|
|
614
|
+
"helpGroup": "GLOBAL",
|
|
615
|
+
"name": "config-id",
|
|
616
|
+
"summary": "Specify config id to use for call.",
|
|
617
|
+
"hasDynamicHelp": false,
|
|
618
|
+
"multiple": false,
|
|
619
|
+
"type": "option"
|
|
620
|
+
},
|
|
621
|
+
"add": {
|
|
622
|
+
"char": "a",
|
|
623
|
+
"description": "add field",
|
|
624
|
+
"name": "add",
|
|
625
|
+
"hasDynamicHelp": false,
|
|
626
|
+
"multiple": true,
|
|
627
|
+
"type": "option"
|
|
628
|
+
},
|
|
629
|
+
"id": {
|
|
630
|
+
"char": "I",
|
|
631
|
+
"description": "id",
|
|
632
|
+
"name": "id",
|
|
633
|
+
"hasDynamicHelp": false,
|
|
634
|
+
"multiple": false,
|
|
635
|
+
"type": "option"
|
|
636
|
+
},
|
|
637
|
+
"increment": {
|
|
638
|
+
"char": "i",
|
|
639
|
+
"description": "increment field",
|
|
640
|
+
"name": "increment",
|
|
641
|
+
"hasDynamicHelp": false,
|
|
642
|
+
"multiple": true,
|
|
643
|
+
"type": "option"
|
|
644
|
+
},
|
|
645
|
+
"remove": {
|
|
646
|
+
"char": "d",
|
|
647
|
+
"description": "remove field",
|
|
648
|
+
"name": "remove",
|
|
649
|
+
"hasDynamicHelp": false,
|
|
650
|
+
"multiple": true,
|
|
651
|
+
"type": "option"
|
|
652
|
+
},
|
|
653
|
+
"replace": {
|
|
654
|
+
"char": "r",
|
|
655
|
+
"description": "replace field",
|
|
656
|
+
"name": "replace",
|
|
657
|
+
"hasDynamicHelp": false,
|
|
658
|
+
"multiple": true,
|
|
659
|
+
"type": "option"
|
|
660
|
+
},
|
|
661
|
+
"set": {
|
|
662
|
+
"char": "s",
|
|
663
|
+
"description": "set field",
|
|
664
|
+
"name": "set",
|
|
665
|
+
"hasDynamicHelp": false,
|
|
666
|
+
"multiple": true,
|
|
667
|
+
"type": "option"
|
|
668
|
+
},
|
|
669
|
+
"type": {
|
|
670
|
+
"char": "T",
|
|
671
|
+
"description": "type",
|
|
672
|
+
"name": "type",
|
|
673
|
+
"hasDynamicHelp": false,
|
|
674
|
+
"multiple": false,
|
|
675
|
+
"type": "option"
|
|
676
|
+
}
|
|
677
|
+
},
|
|
678
|
+
"hasDynamicHelp": false,
|
|
679
|
+
"hiddenAliases": [],
|
|
680
|
+
"id": "records:patch",
|
|
681
|
+
"pluginAlias": "@contextual-io/cli",
|
|
682
|
+
"pluginName": "@contextual-io/cli",
|
|
683
|
+
"pluginType": "core",
|
|
684
|
+
"strict": true,
|
|
685
|
+
"enableJsonFlag": false,
|
|
686
|
+
"isESM": true,
|
|
687
|
+
"relativePath": [
|
|
688
|
+
"dist",
|
|
689
|
+
"commands",
|
|
690
|
+
"records",
|
|
691
|
+
"patch.js"
|
|
692
|
+
]
|
|
693
|
+
},
|
|
594
694
|
"records:query": {
|
|
595
695
|
"aliases": [],
|
|
596
696
|
"args": {
|
|
@@ -717,7 +817,7 @@
|
|
|
717
817
|
"type": "option"
|
|
718
818
|
},
|
|
719
819
|
"id": {
|
|
720
|
-
"char": "
|
|
820
|
+
"char": "I",
|
|
721
821
|
"description": "id",
|
|
722
822
|
"name": "id",
|
|
723
823
|
"hasDynamicHelp": false,
|
|
@@ -927,7 +1027,9 @@
|
|
|
927
1027
|
]
|
|
928
1028
|
},
|
|
929
1029
|
"types:list": {
|
|
930
|
-
"aliases": [
|
|
1030
|
+
"aliases": [
|
|
1031
|
+
"types:search"
|
|
1032
|
+
],
|
|
931
1033
|
"args": {},
|
|
932
1034
|
"description": "List types.",
|
|
933
1035
|
"examples": [
|
|
@@ -1094,5 +1196,5 @@
|
|
|
1094
1196
|
]
|
|
1095
1197
|
}
|
|
1096
1198
|
},
|
|
1097
|
-
"version": "0.
|
|
1199
|
+
"version": "0.5.0"
|
|
1098
1200
|
}
|