@engini/cli 0.20.0 → 0.22.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 +7 -2
- package/dist/cli.js +43 -11
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -100,14 +100,19 @@ engini connect outlook --json # → {need:"oauth", sign_in_url,
|
|
|
100
100
|
# show sign_in_url to the user; after they sign in:
|
|
101
101
|
engini connect outlook --oauth-state <state> # polls token → creates → checks → refreshes
|
|
102
102
|
|
|
103
|
+
# re-authenticate an EXISTING OAuth2 connection in place — same sign-in flow,
|
|
104
|
+
# but --oauth-state alone (no --field/--name/--metadata) is a valid edit and
|
|
105
|
+
# keeps the connection id instead of minting a new one
|
|
106
|
+
engini connections update 481 --oauth-state <state>
|
|
107
|
+
|
|
103
108
|
# object selection (apps that support it) — resume never re-creates
|
|
104
109
|
engini connect <app> --json # → {need:"objects", connection_id, objects, resume:"engini connect <app> --connection <id> --object <id>"}
|
|
105
110
|
engini connect <app> --connection <id> --object 5 --object 9
|
|
106
111
|
```
|
|
107
112
|
|
|
108
113
|
The same steps are available as standalone primitives: `connections sign-in-url`
|
|
109
|
-
/ `oauth-complete` (OAuth)
|
|
110
|
-
`objects` / `select-objects`.
|
|
114
|
+
/ `oauth-complete` (OAuth), `connections update` (re-authenticate in place), and
|
|
115
|
+
`connections create` / `check` / `refresh` / `objects` / `select-objects`.
|
|
111
116
|
|
|
112
117
|
## Output & exit codes
|
|
113
118
|
|
package/dist/cli.js
CHANGED
|
@@ -442,7 +442,7 @@ function saveConfig(config, path = configPath()) {
|
|
|
442
442
|
}
|
|
443
443
|
|
|
444
444
|
// src/version.ts
|
|
445
|
-
var VERSION = true ? "0.
|
|
445
|
+
var VERSION = true ? "0.22.0" : "0.0.0";
|
|
446
446
|
|
|
447
447
|
// src/http.ts
|
|
448
448
|
var USER_AGENT_PREFIX = `engini-cli/${VERSION}`;
|
|
@@ -711,13 +711,15 @@ async function connectBody(application, opts) {
|
|
|
711
711
|
return;
|
|
712
712
|
}
|
|
713
713
|
const name = await resolveName(opts.name, application);
|
|
714
|
-
const
|
|
714
|
+
const credentials = method.requiresOAuthSignIn ? await oauthFieldsFor(client, application, method, opts.oauthState, timing) : { fields: await collectFields(method, application, opts.field) };
|
|
715
715
|
progress(`Creating connection '${name}'\u2026`);
|
|
716
716
|
const created = await client.connections.create(
|
|
717
717
|
application,
|
|
718
718
|
name,
|
|
719
719
|
method.authenticationId,
|
|
720
|
-
fields
|
|
720
|
+
credentials.fields,
|
|
721
|
+
// Present only for OAuth methods; a non-OAuth create has no sign-in to point at.
|
|
722
|
+
credentials.state ? { oauthState: credentials.state } : {}
|
|
721
723
|
);
|
|
722
724
|
const connectionId = created.connectionId;
|
|
723
725
|
progress(`Checking connection ${connectionId}\u2026`);
|
|
@@ -771,9 +773,22 @@ async function chooseAuth(methods, auth, application) {
|
|
|
771
773
|
if (methods.length === 1) return methods[0];
|
|
772
774
|
if (isInteractive()) {
|
|
773
775
|
for (const m of methods) {
|
|
774
|
-
|
|
776
|
+
const marker = m.isDefault ? " [default]" : "";
|
|
777
|
+
console.error(
|
|
778
|
+
` ${m.authenticationId}: ${m.authenticationName} (${m.authenticationType})${marker}`
|
|
779
|
+
);
|
|
780
|
+
const description = clean(m.description);
|
|
781
|
+
if (description) console.error(` ${description}`);
|
|
782
|
+
const helpUrl = methodHelpUrl(m);
|
|
783
|
+
if (helpUrl) console.error(` ${helpUrl}`);
|
|
775
784
|
}
|
|
776
|
-
const
|
|
785
|
+
const preferred = methods.find((m) => m.isDefault);
|
|
786
|
+
const answer = await promptText(
|
|
787
|
+
"Choose an authentication method id",
|
|
788
|
+
preferred ? String(preferred.authenticationId) : ""
|
|
789
|
+
);
|
|
790
|
+
if (answer.trim() === "") fail(2 /* USAGE */, "Choose an authentication method id.");
|
|
791
|
+
const id = Number(answer);
|
|
777
792
|
const chosen = byId.get(id);
|
|
778
793
|
if (!chosen) fail(2 /* USAGE */, `No authentication method with id ${id}.`);
|
|
779
794
|
return chosen;
|
|
@@ -858,14 +873,14 @@ async function resolveObjects(objs, connectionId, application) {
|
|
|
858
873
|
async function oauthFieldsFor(client, application, method, oauthState, timing) {
|
|
859
874
|
if (oauthState) {
|
|
860
875
|
const token = await pollAccessToken(client, oauthState, timing);
|
|
861
|
-
return oauthFields(token);
|
|
876
|
+
return { fields: oauthFields(token), state: oauthState };
|
|
862
877
|
}
|
|
863
878
|
const resp = await client.connections.getSignInUrl(application, method.authenticationId);
|
|
864
879
|
if (isTty() && timing.wait) {
|
|
865
880
|
openBrowser(resp.signInUrl);
|
|
866
881
|
progress(`Opened ${resp.signInUrl} \u2014 complete the sign-in in your browser.`);
|
|
867
882
|
const token = await pollAccessToken(client, resp.state, timing);
|
|
868
|
-
return oauthFields(token);
|
|
883
|
+
return { fields: oauthFields(token), state: resp.state };
|
|
869
884
|
}
|
|
870
885
|
return need({
|
|
871
886
|
need: "oauth",
|
|
@@ -886,10 +901,20 @@ function methodSummary(m) {
|
|
|
886
901
|
authentication_id: m.authenticationId,
|
|
887
902
|
authentication_type: m.authenticationType,
|
|
888
903
|
authentication_name: m.authenticationName,
|
|
904
|
+
description: clean(m.description),
|
|
905
|
+
// Boolean(), not the raw value: the generated type declares isDefault non-optional and
|
|
906
|
+
// hey-api does no runtime validation, so against a server that omits it this is undefined -
|
|
907
|
+
// and JSON.stringify drops undefined keys entirely, leaving an agent parsing need:auth with
|
|
908
|
+
// description: null, help_url: null and no is_default key at all. All three normalise now.
|
|
909
|
+
is_default: Boolean(m.isDefault),
|
|
910
|
+
help_url: methodHelpUrl(m),
|
|
889
911
|
requires_oauth: m.requiresOAuthSignIn,
|
|
890
912
|
fields: m.connectionFields.map(fieldSummary)
|
|
891
913
|
};
|
|
892
914
|
}
|
|
915
|
+
function methodHelpUrl(m) {
|
|
916
|
+
return typeof m.helpUrl === "string" && m.helpUrl.trim() !== "" ? m.helpUrl : null;
|
|
917
|
+
}
|
|
893
918
|
function fieldSummary(f) {
|
|
894
919
|
return {
|
|
895
920
|
field_name: f.fieldName,
|
|
@@ -1207,7 +1232,9 @@ async function oauthCompleteBody(application, opts) {
|
|
|
1207
1232
|
interval: Number(opts.pollInterval ?? 2)
|
|
1208
1233
|
});
|
|
1209
1234
|
progress(`Creating connection '${name}'\u2026`);
|
|
1210
|
-
return client.connections.create(application, name, auth, oauthFields(token)
|
|
1235
|
+
return client.connections.create(application, name, auth, oauthFields(token), {
|
|
1236
|
+
oauthState: opts.state
|
|
1237
|
+
});
|
|
1211
1238
|
});
|
|
1212
1239
|
printOutput(summary2(conn));
|
|
1213
1240
|
}
|
|
@@ -1414,10 +1441,11 @@ async function updateBody(idRaw, opts) {
|
|
|
1414
1441
|
if (opts.description !== void 0) patch.description = opts.description;
|
|
1415
1442
|
if (opts.field !== void 0) patch.fields = parseFields(opts.field);
|
|
1416
1443
|
if (opts.metadata !== void 0) patch.metadata = parseFields(opts.metadata);
|
|
1444
|
+
if (opts.oauthState !== void 0) patch.oauthState = opts.oauthState;
|
|
1417
1445
|
if (Object.keys(patch).length === 0) {
|
|
1418
1446
|
fail(
|
|
1419
1447
|
2 /* USAGE */,
|
|
1420
|
-
"Nothing to update. Supply at least one of --name, --description, --field, --metadata."
|
|
1448
|
+
"Nothing to update. Supply at least one of --name, --description, --field, --metadata, --oauth-state."
|
|
1421
1449
|
);
|
|
1422
1450
|
}
|
|
1423
1451
|
if (dryRun()) {
|
|
@@ -1430,6 +1458,7 @@ async function updateBody(idRaw, opts) {
|
|
|
1430
1458
|
Object.entries(patch.fields).map(([k, v]) => [k, maskSecret(v)])
|
|
1431
1459
|
),
|
|
1432
1460
|
metadata: patch.metadata ?? null,
|
|
1461
|
+
oauth_state: patch.oauthState ?? null,
|
|
1433
1462
|
// Loud on purpose: this is the field-loss trap.
|
|
1434
1463
|
replaces_entire_fields_map: patch.fields !== void 0,
|
|
1435
1464
|
replaces_entire_metadata_map: patch.metadata !== void 0
|
|
@@ -1444,10 +1473,13 @@ async function updateBody(idRaw, opts) {
|
|
|
1444
1473
|
printOutput(summary4(conn));
|
|
1445
1474
|
}
|
|
1446
1475
|
function registerConnectionsUpdate(connections) {
|
|
1447
|
-
const cmd = connections.command("update").description("Update a connection's name, description, credential fields, or metadata.").argument("[connection_id]", "Connection id").option("--name <name>", "New connection name").option("--description <text>", "New description").option("--field <spec>", "Credential field: key=value (repeatable)", collect).option("--metadata <spec>", "Metadata entry: key=value (repeatable)", collect)
|
|
1476
|
+
const cmd = connections.command("update").description("Update a connection's name, description, credential fields, or metadata.").argument("[connection_id]", "Connection id").option("--name <name>", "New connection name").option("--description <text>", "New description").option("--field <spec>", "Credential field: key=value (repeatable)", collect).option("--metadata <spec>", "Metadata entry: key=value (repeatable)", collect).option(
|
|
1477
|
+
"--oauth-state <state>",
|
|
1478
|
+
"Sign-in state proving a credential change on an OAuth2 connection"
|
|
1479
|
+
);
|
|
1448
1480
|
cmd.addHelpText(
|
|
1449
1481
|
"after",
|
|
1450
|
-
"\nExamples:\n engini connections update 481 --name 'prod key'\n engini connections update 481 --field apiKey=sk-new --dry-run\n engini connections update 481 --field apiKey=sk-new\n\nWARNING: --field and --metadata REPLACE the entire map \u2014 they do not merge.\nPassing one --field clears every other field on the connection. Read the\ncurrent values with `engini connections get <id>` and pass them all, or\npreview with --dry-run first (secrets are masked in the preview)."
|
|
1482
|
+
"\nExamples:\n engini connections update 481 --name 'prod key'\n engini connections update 481 --field apiKey=sk-new --dry-run\n engini connections update 481 --field apiKey=sk-new\n engini connections update 481 --field RefreshToken=rt-new --oauth-state st-1\n engini connections update 481 --oauth-state st-1 # re-authenticate in place,\n # no --field needed\n\nWARNING: --field and --metadata REPLACE the entire map \u2014 they do not merge.\nPassing one --field clears every other field on the connection. Read the\ncurrent values with `engini connections get <id>` and pass them all, or\npreview with --dry-run first (secrets are masked in the preview).\n\nOn an OAuth2 connection, changing ApiKey, RefreshToken or ExternalOrgId needs\n--oauth-state from a fresh `engini connect` sign-in: the server derives those\nfrom its own record and will not take them from a caller. Renames and edits to\nBaseUrl or any Key{N} setting need no state."
|
|
1451
1483
|
);
|
|
1452
1484
|
addUniversalOptions(cmd, { mutating: true });
|
|
1453
1485
|
cmd.action(async (idRaw, opts, command) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@engini/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
4
4
|
"description": "Engini CLI — machine-first command line over the Engini Public API",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"test": "vitest run"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@engini/sdk": "^0.
|
|
29
|
+
"@engini/sdk": "^0.22.0",
|
|
30
30
|
"commander": "^12.1.0",
|
|
31
31
|
"smol-toml": "^1.3.0"
|
|
32
32
|
},
|