arketix 0.1.1 → 0.2.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 +4 -4
- package/dist/arketix.js +9 -6
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# arketix
|
|
2
2
|
|
|
3
|
-
The command line of
|
|
3
|
+
The command line of Arketix ERP (https://erp.arketix.cl), for founders and agents. Its commands come from Arketix ERP's operations, so a new operation is a new command with no new release.
|
|
4
4
|
|
|
5
5
|
```sh
|
|
6
6
|
npm i -g arketix
|
|
@@ -16,7 +16,7 @@ arketix help crm opportunities
|
|
|
16
16
|
|
|
17
17
|
- **Flags come from each operation's input.** `ownerId` is `--owner-id`, enums are choices, objects and arrays take JSON, `--input '<json>'` passes the whole input. An operation with exactly one required id also takes it as one trailing word.
|
|
18
18
|
- **Output.** People get a table for a list and `key: value` lines otherwise. `--json` prints one line: the output, or `{"error":{"code","message","retryable"}}`.
|
|
19
|
-
- **Sign-in.** `login` keeps the token in the OS keychain. `ARKETIX_TOKEN` overrides it. `--env prod` (default) or `local` (http://localhost:3417); `ARKETIX_URL` points anywhere else.
|
|
20
|
-
- **Catalogue.** Every command, and help for one, asks
|
|
19
|
+
- **Sign-in.** `login` keeps the token in the OS keychain. `ARKETIX_TOKEN` overrides it. `--env prod` (default, https://erp.arketix.cl) or `local` (http://localhost:3417); `ARKETIX_URL` points anywhere else. A token kept by 0.1.x for https://crm.admin.acredix.cl still signs in to prod; `logout` forgets both.
|
|
20
|
+
- **Catalogue.** Every command, and help for one, asks Arketix ERP for its list of operations. The list is cached per server version and CLI release in `~/.cache/arketix`, which only saves the `tools/list` call while the server's version is unchanged. Nothing falls back to it: when the server can't be reached or gives no usable answer, the command exits 9, and a refused token exits with its code. `arketix`, `arketix help` and the built-ins' help need no token and no connection, so they list only the built-ins; `arketix help crm` lists the CRM module's commands.
|
|
21
21
|
|
|
22
|
-
Exit codes: 0 ok, 1 other
|
|
22
|
+
Exit codes: 0 ok, 1 other error, 2 usage, 3 unauthenticated, 4 read-only token, 6 confirmation required, 7 not in catalogue, 8 rate limited, 9 connection lost (a write may have run), 10 forbidden, 12 input invalid.
|
package/dist/arketix.js
CHANGED
|
@@ -36499,7 +36499,7 @@ var fail9 = (code, message, retryable = false) => {
|
|
|
36499
36499
|
var exitCodes = EXIT_CODES;
|
|
36500
36500
|
var exitCodeFor = (code) => exitCodes[code] ?? 1;
|
|
36501
36501
|
// package.json
|
|
36502
|
-
var version2 = "0.
|
|
36502
|
+
var version2 = "0.2.0";
|
|
36503
36503
|
|
|
36504
36504
|
// src/version.ts
|
|
36505
36505
|
var VERSION = version2;
|
|
@@ -36622,8 +36622,9 @@ function human(output, columns = Infinity) {
|
|
|
36622
36622
|
}
|
|
36623
36623
|
|
|
36624
36624
|
// src/cli.ts
|
|
36625
|
-
var URLS = { prod: "https://
|
|
36625
|
+
var URLS = { prod: "https://erp.arketix.cl", local: "http://localhost:3417" };
|
|
36626
36626
|
var isEnv = (value) => (value in URLS);
|
|
36627
|
+
var OLD_PROD = "https://crm.admin.acredix.cl";
|
|
36627
36628
|
function preParse(argv) {
|
|
36628
36629
|
let env;
|
|
36629
36630
|
const words = [];
|
|
@@ -36642,7 +36643,7 @@ function targetOf(env, io) {
|
|
|
36642
36643
|
if (!isEnv(env))
|
|
36643
36644
|
return fail9("USAGE", "--env is prod or local; ARKETIX_URL points anywhere else.");
|
|
36644
36645
|
const url = new URL(io.env.ARKETIX_URL ?? URLS[env]).origin;
|
|
36645
|
-
return { url, token: io.env.ARKETIX_TOKEN?.trim() || io.secrets.get(url) };
|
|
36646
|
+
return { url, token: io.env.ARKETIX_TOKEN?.trim() || io.secrets.get(url) || (url === URLS.prod ? io.secrets.get(OLD_PROD) : undefined) };
|
|
36646
36647
|
}
|
|
36647
36648
|
var opIdOf = (tool) => tool.name.replaceAll("_", ".");
|
|
36648
36649
|
var kebab = (name) => name.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`);
|
|
@@ -36733,7 +36734,7 @@ var JsonFlag = Setting("json")({
|
|
|
36733
36734
|
flag: Boolean6("json").pipe(withDescription3("One line of JSON on stdout, errors included"), withDefault4(false))
|
|
36734
36735
|
});
|
|
36735
36736
|
var EnvFlag = Setting("env")({
|
|
36736
|
-
flag: Literals3("env", ["prod", "local"]).pipe(withDescription3("Which
|
|
36737
|
+
flag: Literals3("env", ["prod", "local"]).pipe(withDescription3("Which server: prod is erp.arketix.cl, local is localhost:3417. ARKETIX_URL points anywhere else"), withDefault4("prod"))
|
|
36737
36738
|
});
|
|
36738
36739
|
var Me = object({
|
|
36739
36740
|
member: object({ name: string4(), email: string4(), role: string4() }),
|
|
@@ -36756,8 +36757,10 @@ function builtIns(run) {
|
|
|
36756
36757
|
await crm.close();
|
|
36757
36758
|
}
|
|
36758
36759
|
})));
|
|
36759
|
-
const logout = make12("logout").pipe(withDescription4("Forget the token for this
|
|
36760
|
+
const logout = make12("logout").pipe(withDescription4("Forget the token for this server."), withHandler(handle(async () => {
|
|
36760
36761
|
run.io.secrets.delete(run.url);
|
|
36762
|
+
if (run.url === URLS.prod)
|
|
36763
|
+
run.io.secrets.delete(OLD_PROD);
|
|
36761
36764
|
print(run, { signedOut: run.url }, `Signed out of ${run.url}.`);
|
|
36762
36765
|
})));
|
|
36763
36766
|
const whoami = make12("whoami").pipe(withDescription4("Who the token belongs to, and whether it may write."), withHandler(handle(async () => {
|
|
@@ -36799,7 +36802,7 @@ async function runCli(args, io) {
|
|
|
36799
36802
|
catalogue = (await crm.catalogue()).tools;
|
|
36800
36803
|
}
|
|
36801
36804
|
const run = { io, json, url, crm, catalogue };
|
|
36802
|
-
const cli = make12("arketix").pipe(withDescription4(`
|
|
36805
|
+
const cli = make12("arketix").pipe(withDescription4(`Arketix ERP (${url}) for people and agents. Commands come from its operations: ` + "`arketix help crm`, `arketix help metrics`, `arketix help settings`, `arketix help account`. " + "Exit codes: 0 ok, 1 other error, 2 usage, 3 unauthenticated, 4 read-only token, 6 confirmation required, " + "7 not in catalogue, 8 rate limited, 9 connection lost, 10 forbidden, 12 input invalid."), withSubcommands([...builtIns(run), ...operationCommands(run)]), withGlobalFlags([JsonFlag, EnvFlag]));
|
|
36803
36806
|
const exit = await runPromiseExit2(runWith2(cli, { version: VERSION, renderErrors: false })(argv).pipe(provide3(services(io, json))));
|
|
36804
36807
|
if (isSuccess3(exit))
|
|
36805
36808
|
return 0;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "arketix",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Command line for
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Command line for Arketix ERP: every operation, for founders and agents.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": {
|