@engini/cli 0.23.0 → 0.26.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 +29 -0
- package/dist/cli.js +671 -90
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -30,6 +30,13 @@ var PromptStreamEnded = class extends Error {
|
|
|
30
30
|
this.name = "PromptStreamEnded";
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
|
+
async function readStdin(stream = process.stdin) {
|
|
34
|
+
const chunks = [];
|
|
35
|
+
for await (const chunk of stream) {
|
|
36
|
+
chunks.push(typeof chunk === "string" ? Buffer.from(chunk) : chunk);
|
|
37
|
+
}
|
|
38
|
+
return Buffer.concat(chunks).toString("utf8").replace(/\r?\n$/, "");
|
|
39
|
+
}
|
|
33
40
|
function ask(rl, question) {
|
|
34
41
|
return new Promise((resolve, reject) => {
|
|
35
42
|
let answered = false;
|
|
@@ -383,6 +390,7 @@ import {
|
|
|
383
390
|
ENV_COMPANY_TOKEN_VAR,
|
|
384
391
|
ENV_TOKEN_VAR,
|
|
385
392
|
EnginiAuthError,
|
|
393
|
+
EnginiConflictError,
|
|
386
394
|
EnginiError,
|
|
387
395
|
EnginiMcpServerNotFoundError,
|
|
388
396
|
EnginiNotFoundError,
|
|
@@ -442,7 +450,7 @@ function saveConfig(config, path = configPath()) {
|
|
|
442
450
|
}
|
|
443
451
|
|
|
444
452
|
// src/version.ts
|
|
445
|
-
var VERSION = true ? "0.
|
|
453
|
+
var VERSION = true ? "0.26.0" : "0.0.0";
|
|
446
454
|
|
|
447
455
|
// src/http.ts
|
|
448
456
|
var USER_AGENT_PREFIX = `engini-cli/${VERSION}`;
|
|
@@ -464,10 +472,19 @@ function buildClient(overrides = {}) {
|
|
|
464
472
|
userAgentPrefix: USER_AGENT_PREFIX
|
|
465
473
|
});
|
|
466
474
|
}
|
|
475
|
+
var AUTH_PROVIDER_CONFLICT_CODES = /* @__PURE__ */ new Set([
|
|
476
|
+
"AUTH_PROVIDER_IN_USE",
|
|
477
|
+
"AUTH_PROVIDER_NOT_SUPPORTED",
|
|
478
|
+
"AUTH_PROVIDER_NAME_TAKEN",
|
|
479
|
+
"CONNECTOR_REMOVED"
|
|
480
|
+
]);
|
|
467
481
|
function exitForError(err) {
|
|
468
482
|
if (err instanceof EnginiAuthError) return 3 /* AUTH */;
|
|
469
483
|
if (err instanceof EnginiOpaApplicationAmbiguousError) return 5 /* VALIDATION */;
|
|
470
484
|
if (err instanceof EnginiOpaAgentTimeoutError) return 124 /* TIMEOUT */;
|
|
485
|
+
if (err instanceof EnginiConflictError && err.errorCode !== void 0 && AUTH_PROVIDER_CONFLICT_CODES.has(err.errorCode)) {
|
|
486
|
+
return 5 /* VALIDATION */;
|
|
487
|
+
}
|
|
471
488
|
if (err instanceof EnginiToolsetNotFoundError) return 4 /* NOT_FOUND */;
|
|
472
489
|
if (err instanceof EnginiMcpServerNotFoundError) return 4 /* NOT_FOUND */;
|
|
473
490
|
if (err instanceof EnginiTriggerGapError) return 4 /* NOT_FOUND */;
|
|
@@ -568,6 +585,42 @@ function registerApplications(program) {
|
|
|
568
585
|
registerApplicationsGet(applications);
|
|
569
586
|
}
|
|
570
587
|
|
|
588
|
+
// src/connections/auth-providers/resolve.ts
|
|
589
|
+
var PROVIDER_OPTION_HELP = "Auth provider: a name, a numeric id, or 'none' for the connector's own OAuth client";
|
|
590
|
+
async function resolveProvider(client, spec) {
|
|
591
|
+
if (spec === void 0) return void 0;
|
|
592
|
+
const value = spec.trim();
|
|
593
|
+
if (value === "") fail(2 /* USAGE */, "--provider needs a name, an id, or 'none'.");
|
|
594
|
+
if (value.toLowerCase() === "none" || value === "0") return { id: 0 };
|
|
595
|
+
const usable = await client.authProviders.usable();
|
|
596
|
+
const matches = /^\d+$/.test(value) ? usable.filter((p) => p.id === Number(value)) : usable.filter((p) => p.providerName === value);
|
|
597
|
+
if (matches.length === 0) {
|
|
598
|
+
fail(
|
|
599
|
+
4 /* NOT_FOUND */,
|
|
600
|
+
`No usable auth provider '${value}'. It may not exist, be disabled, or be unavailable to you.`,
|
|
601
|
+
"Run `engini connections auth-providers usable` to list the providers you can use."
|
|
602
|
+
);
|
|
603
|
+
}
|
|
604
|
+
if (matches.length > 1) {
|
|
605
|
+
fail(
|
|
606
|
+
2 /* USAGE */,
|
|
607
|
+
`Several auth providers are named '${value}': ids ${matches.map((p) => p.id).join(", ")}.`,
|
|
608
|
+
"Pass the numeric id to --provider."
|
|
609
|
+
);
|
|
610
|
+
}
|
|
611
|
+
return { id: matches[0].id, sourceAuthenticationId: matches[0].sourceAuthenticationId };
|
|
612
|
+
}
|
|
613
|
+
function assertProviderFitsMethod(provider, authenticationId) {
|
|
614
|
+
if (provider?.sourceAuthenticationId === void 0) return;
|
|
615
|
+
if (provider.sourceAuthenticationId !== authenticationId) {
|
|
616
|
+
fail(
|
|
617
|
+
2 /* USAGE */,
|
|
618
|
+
`Auth provider ${provider.id} is for authentication method ${provider.sourceAuthenticationId}, not ${authenticationId}.`,
|
|
619
|
+
"Drop --auth to use the provider's own method, or pick a provider for this method."
|
|
620
|
+
);
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
|
|
571
624
|
// src/connections/shared.ts
|
|
572
625
|
import { EnginiNetworkError, EnginiServerError, refreshFailed } from "@engini/sdk";
|
|
573
626
|
var GATEWAY_TIMEOUT_MARKERS = ["502", "503", "504", "gateway", "timeout"];
|
|
@@ -708,27 +761,52 @@ async function connectBody(application, opts) {
|
|
|
708
761
|
}
|
|
709
762
|
if (!application) fail(2 /* USAGE */, "Missing required argument 'application'.");
|
|
710
763
|
const detail4 = await client.applications.get(application);
|
|
711
|
-
const
|
|
764
|
+
const provider = await resolveProvider(client, opts.provider);
|
|
765
|
+
if (provider?.sourceAuthenticationId !== void 0) {
|
|
766
|
+
const methods = detail4.authenticationMethods ?? [];
|
|
767
|
+
if (!methods.some((m) => m.authenticationId === provider.sourceAuthenticationId)) {
|
|
768
|
+
fail(
|
|
769
|
+
2 /* USAGE */,
|
|
770
|
+
`Auth provider ${provider.id} is not for '${application}'.`,
|
|
771
|
+
"Run `engini connections auth-providers usable` to see which application each provider is for."
|
|
772
|
+
);
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
const method = await chooseAuth(
|
|
776
|
+
detail4.authenticationMethods ?? [],
|
|
777
|
+
opts.auth ?? (provider?.sourceAuthenticationId !== void 0 ? String(provider.sourceAuthenticationId) : void 0),
|
|
778
|
+
application,
|
|
779
|
+
provider
|
|
780
|
+
);
|
|
781
|
+
assertProviderFitsMethod(provider, method.authenticationId);
|
|
712
782
|
if (dryRun()) {
|
|
713
783
|
printOutput({
|
|
714
784
|
would_connect: {
|
|
715
785
|
application,
|
|
716
786
|
authentication_id: method.authenticationId,
|
|
717
|
-
oauth: Boolean(method.requiresOAuthSignIn)
|
|
787
|
+
oauth: Boolean(method.requiresOAuthSignIn),
|
|
788
|
+
...provider ? { auth_provider_id: provider.id } : {}
|
|
718
789
|
}
|
|
719
790
|
});
|
|
720
791
|
return;
|
|
721
792
|
}
|
|
722
793
|
const name = await resolveName(opts.name, application);
|
|
723
|
-
const credentials = method.requiresOAuthSignIn ? await oauthFieldsFor(client, application, method, opts.oauthState, opts.field, timing) : {
|
|
794
|
+
const credentials = method.requiresOAuthSignIn ? await oauthFieldsFor(client, application, method, opts.oauthState, opts.field, timing, provider) : {
|
|
795
|
+
fields: await collectFields(method, application, parseFields(opts.field), void 0, void 0, provider)
|
|
796
|
+
};
|
|
724
797
|
progress(`Creating connection '${name}'\u2026`);
|
|
725
798
|
const created = await client.connections.create(
|
|
726
799
|
application,
|
|
727
800
|
name,
|
|
728
801
|
method.authenticationId,
|
|
729
802
|
credentials.fields,
|
|
730
|
-
|
|
731
|
-
|
|
803
|
+
{
|
|
804
|
+
// Present only for OAuth methods; a non-OAuth create has no sign-in to point at.
|
|
805
|
+
...credentials.state ? { oauthState: credentials.state } : {},
|
|
806
|
+
// On create the provider is a query parameter the server honours only for a method
|
|
807
|
+
// with no sign-in; an OAuth sign-in already pinned it in get-sign-in-url.
|
|
808
|
+
...provider && !method.requiresOAuthSignIn ? { authProviderId: provider.id } : {}
|
|
809
|
+
}
|
|
732
810
|
);
|
|
733
811
|
const connectionId = created.connectionId;
|
|
734
812
|
progress(`Checking connection ${connectionId}\u2026`);
|
|
@@ -762,7 +840,7 @@ function parseObjectIds(specs) {
|
|
|
762
840
|
return n;
|
|
763
841
|
});
|
|
764
842
|
}
|
|
765
|
-
async function chooseAuth(methods, auth, application) {
|
|
843
|
+
async function chooseAuth(methods, auth, application, provider) {
|
|
766
844
|
if (methods.length === 0) {
|
|
767
845
|
fail(1 /* GENERIC */, `Application '${application}' exposes no authentication methods.`);
|
|
768
846
|
}
|
|
@@ -806,10 +884,10 @@ async function chooseAuth(methods, auth, application) {
|
|
|
806
884
|
need: "auth",
|
|
807
885
|
application,
|
|
808
886
|
methods: methods.map(methodSummary),
|
|
809
|
-
resume: `engini connect ${application} --auth <id
|
|
887
|
+
resume: `engini connect ${application} --auth <id>${providerResumeFlag(provider)}`
|
|
810
888
|
});
|
|
811
889
|
}
|
|
812
|
-
async function collectFields(method, application, provided, oauthState) {
|
|
890
|
+
async function collectFields(method, application, provided, oauthState, fieldOptions, provider) {
|
|
813
891
|
async function readSecretField(label) {
|
|
814
892
|
const { value, truncated } = await promptHidden(label);
|
|
815
893
|
if (truncated) {
|
|
@@ -821,10 +899,29 @@ async function collectFields(method, application, provided, oauthState) {
|
|
|
821
899
|
}
|
|
822
900
|
return value;
|
|
823
901
|
}
|
|
824
|
-
const
|
|
902
|
+
const providerPinned = provider !== void 0 && provider.id > 0;
|
|
903
|
+
const schema = method.connectionFields.filter(
|
|
904
|
+
(f) => !f.isHidden && !(providerPinned && f.setOnProvider)
|
|
905
|
+
);
|
|
906
|
+
const resumeHint = oauthState ? `Resume with: engini connect ${application} --auth ${method.authenticationId} --oauth-state ${oauthState}${providerResumeFlag(provider)}` : void 0;
|
|
825
907
|
for (const [k, v] of Object.entries(provided)) {
|
|
826
908
|
if (v === PLACEHOLDER) delete provided[k];
|
|
827
909
|
}
|
|
910
|
+
for (const f of schema) {
|
|
911
|
+
const opts = fieldOptions?.[f.fieldName];
|
|
912
|
+
const val = provided[f.fieldName];
|
|
913
|
+
if (!opts || Object.keys(opts).length === 0 || val === void 0) continue;
|
|
914
|
+
if (!Object.hasOwn(opts, val)) {
|
|
915
|
+
fail(
|
|
916
|
+
2 /* USAGE */,
|
|
917
|
+
`'${val}' is not a legal ${f.fieldName} for this org. Legal values: ${Object.keys(opts).join(", ")}`,
|
|
918
|
+
// A TTY caller who just completed the inline browser sign-in and then supplied this bad
|
|
919
|
+
// value must recover the same way a mistyped picker digit does (below) - not with a
|
|
920
|
+
// hard fail that has no resume hint and forces a full re-auth.
|
|
921
|
+
resumeHint
|
|
922
|
+
);
|
|
923
|
+
}
|
|
924
|
+
}
|
|
828
925
|
const required = schema.filter((f) => f.isRequired);
|
|
829
926
|
const missing = required.filter((f) => !(f.fieldName in provided));
|
|
830
927
|
if (missing.length === 0) return provided;
|
|
@@ -832,7 +929,8 @@ async function collectFields(method, application, provided, oauthState) {
|
|
|
832
929
|
for (const f of schema) {
|
|
833
930
|
if (f.fieldName in provided) continue;
|
|
834
931
|
const label = fieldLabel(f);
|
|
835
|
-
const
|
|
932
|
+
const options = fieldOptions?.[f.fieldName];
|
|
933
|
+
const value = options && Object.keys(options).length > 0 ? await promptFieldOption(label, options, f.isRequired, resumeHint) : f.isPassword ? await readSecretField(label) : await promptText(label, clean(f.defaultValue) ?? "");
|
|
836
934
|
if (value) provided[f.fieldName] = value;
|
|
837
935
|
}
|
|
838
936
|
return provided;
|
|
@@ -842,16 +940,34 @@ async function collectFields(method, application, provided, oauthState) {
|
|
|
842
940
|
`engini connect ${application}`,
|
|
843
941
|
`--auth ${method.authenticationId}`,
|
|
844
942
|
...oauthState ? [`--oauth-state ${oauthState}`] : [],
|
|
943
|
+
...provider ? [`--provider ${provider.id}`] : [],
|
|
845
944
|
fieldsFlags
|
|
846
945
|
].filter(Boolean);
|
|
847
946
|
return need({
|
|
848
947
|
need: "fields",
|
|
849
948
|
application,
|
|
850
949
|
authentication_id: method.authenticationId,
|
|
851
|
-
fields: schema.map(fieldSummary),
|
|
950
|
+
fields: schema.map((f) => fieldSummary(f, fieldOptions?.[f.fieldName])),
|
|
852
951
|
resume: resumeParts.join(" ")
|
|
853
952
|
});
|
|
854
953
|
}
|
|
954
|
+
async function promptFieldOption(label, options, isRequired, resumeHint) {
|
|
955
|
+
const entries = Object.entries(options);
|
|
956
|
+
entries.forEach(([value, optionLabel], i) => {
|
|
957
|
+
console.error(` ${i + 1}: ${optionLabel} (${value})`);
|
|
958
|
+
});
|
|
959
|
+
const range = `1-${entries.length}`;
|
|
960
|
+
const answer = await promptText(
|
|
961
|
+
isRequired ? `Choose ${label} (${range})` : `Choose ${label} (${range}, blank to skip)`
|
|
962
|
+
);
|
|
963
|
+
if (answer.trim() === "" && !isRequired) return "";
|
|
964
|
+
const index = Number(answer);
|
|
965
|
+
const chosen = entries[index - 1];
|
|
966
|
+
if (!chosen) {
|
|
967
|
+
fail(2 /* USAGE */, `Choose a number between 1 and ${entries.length} for ${label}.`, resumeHint);
|
|
968
|
+
}
|
|
969
|
+
return chosen[0];
|
|
970
|
+
}
|
|
855
971
|
async function resolveName(name, application) {
|
|
856
972
|
if (name) return name;
|
|
857
973
|
const fallback = `${application} connection`;
|
|
@@ -887,22 +1003,29 @@ async function resolveObjects(objs, connectionId, application) {
|
|
|
887
1003
|
resume: `engini connect ${app} --connection ${connectionId} --object <id>`
|
|
888
1004
|
});
|
|
889
1005
|
}
|
|
890
|
-
async function oauthFieldsFor(client, application, method, oauthState, field, timing) {
|
|
1006
|
+
async function oauthFieldsFor(client, application, method, oauthState, field, timing, provider) {
|
|
891
1007
|
const cliFields = parseFields(field);
|
|
892
1008
|
if (oauthState) {
|
|
893
1009
|
const token = await pollAccessToken(client, oauthState, timing);
|
|
894
1010
|
const merged = { ...cliFields, ...oauthFields(token) };
|
|
895
|
-
return {
|
|
1011
|
+
return {
|
|
1012
|
+
fields: await collectFields(method, application, merged, oauthState, token.fieldOptions, provider),
|
|
1013
|
+
state: oauthState
|
|
1014
|
+
};
|
|
896
1015
|
}
|
|
897
1016
|
const resp = await client.connections.getSignInUrl(application, method.authenticationId, {
|
|
898
|
-
fields: field && field.length > 0 ? cliFields : void 0
|
|
1017
|
+
fields: field && field.length > 0 ? cliFields : void 0,
|
|
1018
|
+
authProviderId: provider?.id
|
|
899
1019
|
});
|
|
900
1020
|
if (isTty() && timing.wait) {
|
|
901
1021
|
openBrowser(resp.signInUrl);
|
|
902
1022
|
progress(`Opened ${resp.signInUrl} \u2014 complete the sign-in in your browser.`);
|
|
903
1023
|
const token = await pollAccessToken(client, resp.state, timing);
|
|
904
1024
|
const merged = { ...cliFields, ...oauthFields(token) };
|
|
905
|
-
return {
|
|
1025
|
+
return {
|
|
1026
|
+
fields: await collectFields(method, application, merged, resp.state, token.fieldOptions, provider),
|
|
1027
|
+
state: resp.state
|
|
1028
|
+
};
|
|
906
1029
|
}
|
|
907
1030
|
const secretFields = new Set(
|
|
908
1031
|
method.connectionFields.filter(isSecretField).map((f) => f.fieldName)
|
|
@@ -927,10 +1050,16 @@ async function oauthFieldsFor(client, application, method, oauthState, field, ti
|
|
|
927
1050
|
`engini connect ${application}`,
|
|
928
1051
|
`--auth ${method.authenticationId}`,
|
|
929
1052
|
`--oauth-state ${resp.state}`,
|
|
1053
|
+
// The state pins the provider server-side, but the replay still needs it client-side to
|
|
1054
|
+
// know which "Set on provider" fields not to ask for again.
|
|
1055
|
+
...provider ? [`--provider ${provider.id}`] : [],
|
|
930
1056
|
...(field ?? []).map((spec) => resumeFieldFlag(spec, secretFields))
|
|
931
1057
|
].join(" ")
|
|
932
1058
|
});
|
|
933
1059
|
}
|
|
1060
|
+
function providerResumeFlag(provider) {
|
|
1061
|
+
return provider ? ` --provider ${provider.id}` : "";
|
|
1062
|
+
}
|
|
934
1063
|
var SAFE_BAREWORD = /^[A-Za-z0-9_@%+:,./=-]+$/;
|
|
935
1064
|
function shellQuoteFieldSpec(spec) {
|
|
936
1065
|
if (SAFE_BAREWORD.test(spec)) return spec;
|
|
@@ -963,20 +1092,28 @@ function methodSummary(m) {
|
|
|
963
1092
|
is_default: Boolean(m.isDefault),
|
|
964
1093
|
help_url: methodHelpUrl(m),
|
|
965
1094
|
requires_oauth: m.requiresOAuthSignIn,
|
|
966
|
-
|
|
1095
|
+
// No fieldOptions here - this listing runs before any sign-in, so there is no org yet
|
|
1096
|
+
// to have discovered them from. Each field's `options` therefore comes back `null` in
|
|
1097
|
+
// this `need: "auth"` payload specifically because it's not knowable yet, not because
|
|
1098
|
+
// the field has none - that's a distinct case (`{}`, once a sign-in has run - see
|
|
1099
|
+
// `fieldSummary` and the `AccessTokenResponse.fieldOptions` doc in @engini/sdk). Worth
|
|
1100
|
+
// calling out explicitly wherever step 5 documents this payload, since the two look the
|
|
1101
|
+
// same on the wire (both fall out here as `options: null`) but mean different things.
|
|
1102
|
+
fields: m.connectionFields.map((f) => fieldSummary(f))
|
|
967
1103
|
};
|
|
968
1104
|
}
|
|
969
1105
|
function methodHelpUrl(m) {
|
|
970
1106
|
return typeof m.helpUrl === "string" && m.helpUrl.trim() !== "" ? m.helpUrl : null;
|
|
971
1107
|
}
|
|
972
|
-
function fieldSummary(f) {
|
|
1108
|
+
function fieldSummary(f, options) {
|
|
973
1109
|
return {
|
|
974
1110
|
field_name: f.fieldName,
|
|
975
1111
|
is_required: f.isRequired,
|
|
976
1112
|
is_password: f.isPassword,
|
|
977
1113
|
description: clean(f.fieldDescription),
|
|
978
1114
|
default: clean(f.defaultValue),
|
|
979
|
-
list_values: clean(f.listValues)
|
|
1115
|
+
list_values: clean(f.listValues),
|
|
1116
|
+
options: options && Object.keys(options).length > 0 ? options : null
|
|
980
1117
|
};
|
|
981
1118
|
}
|
|
982
1119
|
function objectSummary(o) {
|
|
@@ -988,7 +1125,7 @@ function objectSummary(o) {
|
|
|
988
1125
|
};
|
|
989
1126
|
}
|
|
990
1127
|
function registerConnect(program) {
|
|
991
|
-
const cmd = program.command("connect").description("Create a connection (interactive/agent-resumable), or open the connections page.").argument("[application]", "Application slug to connect").option("--auth <id>", "Authentication method id").option("--name <name>", "Connection name").option("--field <spec>", "Credential field: key=value (repeatable)", collect).option("--object <id>", "Object id to select (repeatable)", collect).option("--no-objects", "Skip object selection").option("--oauth-state <state>", "Resume an OAuth2 sign-in by its state token").option("--connection <id>", "Resume object selection for an existing connection id").option("--no-wait", "Return early instead of waiting for async jobs").option("--timeout <seconds>", "Seconds to wait before timing out").option("--poll-interval <seconds>", "Seconds between polls");
|
|
1128
|
+
const cmd = program.command("connect").description("Create a connection (interactive/agent-resumable), or open the connections page.").argument("[application]", "Application slug to connect").option("--auth <id>", "Authentication method id").option("--name <name>", "Connection name").option("--field <spec>", "Credential field: key=value (repeatable)", collect).option("--object <id>", "Object id to select (repeatable)", collect).option("--no-objects", "Skip object selection").option("--provider <name|id|none>", PROVIDER_OPTION_HELP).option("--oauth-state <state>", "Resume an OAuth2 sign-in by its state token").option("--connection <id>", "Resume object selection for an existing connection id").option("--no-wait", "Return early instead of waiting for async jobs").option("--timeout <seconds>", "Seconds to wait before timing out").option("--poll-interval <seconds>", "Seconds between polls");
|
|
992
1129
|
cmd.addHelpText(
|
|
993
1130
|
"after",
|
|
994
1131
|
[
|
|
@@ -998,6 +1135,8 @@ function registerConnect(program) {
|
|
|
998
1135
|
" engini connect monday # interactive walkthrough (TTY)",
|
|
999
1136
|
" engini connect monday --field ApiKey=\u2026 --name 'My Monday'",
|
|
1000
1137
|
" engini connect monday --json # agent: prints the next step + exit 5",
|
|
1138
|
+
" engini connect salesforce --provider 'Acme prod' # sign in through your own OAuth app",
|
|
1139
|
+
" engini connect salesforce --provider none # the connector's own OAuth client",
|
|
1001
1140
|
" engini connect outlook --oauth-state <state> # resume an OAuth sign-in",
|
|
1002
1141
|
" engini connect monday --connection 42 --object 5 # resume object selection"
|
|
1003
1142
|
].join("\n")
|
|
@@ -1013,6 +1152,411 @@ function registerConnect(program) {
|
|
|
1013
1152
|
});
|
|
1014
1153
|
}
|
|
1015
1154
|
|
|
1155
|
+
// src/connections/auth-providers/shared.ts
|
|
1156
|
+
var SLOTS = [
|
|
1157
|
+
...Array.from({ length: 10 }, (_, i) => `Key${i + 1}`),
|
|
1158
|
+
"ApiUser",
|
|
1159
|
+
"ApiPassword",
|
|
1160
|
+
"BaseUrl"
|
|
1161
|
+
];
|
|
1162
|
+
var SLOT_HINT = `Valid slots: ${SLOTS.join(", ")}.`;
|
|
1163
|
+
function parseProviderId(value) {
|
|
1164
|
+
if (!value) fail(2 /* USAGE */, "Missing required argument 'id'.");
|
|
1165
|
+
if (!/^[1-9]\d*$/.test(value)) fail(2 /* USAGE */, "id must be a positive integer.");
|
|
1166
|
+
return Number(value);
|
|
1167
|
+
}
|
|
1168
|
+
function renderField(f) {
|
|
1169
|
+
return {
|
|
1170
|
+
slot: f.slot,
|
|
1171
|
+
label: clean(f.label),
|
|
1172
|
+
is_password: f.isPassword,
|
|
1173
|
+
is_required: f.isRequired,
|
|
1174
|
+
// A secret is write-only: never render a value for it, whatever the server sent.
|
|
1175
|
+
value: f.isPassword ? null : clean(f.value) ?? null,
|
|
1176
|
+
has_value: Boolean(f.hasValue)
|
|
1177
|
+
};
|
|
1178
|
+
}
|
|
1179
|
+
function renderProvider(p) {
|
|
1180
|
+
return {
|
|
1181
|
+
id: p.id,
|
|
1182
|
+
provider_name: p.providerName,
|
|
1183
|
+
application_id: p.applicationId,
|
|
1184
|
+
application_name: clean(p.applicationName),
|
|
1185
|
+
source_authentication_id: p.sourceAuthenticationId,
|
|
1186
|
+
source_authentication_name: clean(p.sourceAuthenticationName),
|
|
1187
|
+
is_default: p.isDefault,
|
|
1188
|
+
is_sandbox: p.isSandbox,
|
|
1189
|
+
status: p.status === 1 ? "active" : "disabled",
|
|
1190
|
+
scopes_override: clean(p.scopesOverride),
|
|
1191
|
+
extra_options: clean(p.extraOptions),
|
|
1192
|
+
connection_count: p.connectionCount,
|
|
1193
|
+
connector_removed: p.connectorRemoved,
|
|
1194
|
+
no_longer_supported: p.noLongerSupported,
|
|
1195
|
+
fields_need_review: p.fieldsNeedReview,
|
|
1196
|
+
fields: p.fields.map(renderField)
|
|
1197
|
+
};
|
|
1198
|
+
}
|
|
1199
|
+
function requireSlot(slot) {
|
|
1200
|
+
if (!SLOTS.includes(slot)) {
|
|
1201
|
+
fail(2 /* USAGE */, `Not a valid provider field slot. ${SLOT_HINT}`);
|
|
1202
|
+
}
|
|
1203
|
+
return slot;
|
|
1204
|
+
}
|
|
1205
|
+
async function collectFieldValues(specs, stdinSlots, opts) {
|
|
1206
|
+
const requests = [];
|
|
1207
|
+
for (const spec of specs ?? []) {
|
|
1208
|
+
const eq = spec.indexOf("=");
|
|
1209
|
+
if (eq === 0) fail(2 /* USAGE */, `--field needs a slot name before '='. ${SLOT_HINT}`);
|
|
1210
|
+
if (eq > 0) {
|
|
1211
|
+
requests.push({ slot: requireSlot(spec.slice(0, eq)), value: spec.slice(eq + 1), source: "inline" });
|
|
1212
|
+
} else {
|
|
1213
|
+
requests.push({ slot: requireSlot(spec), source: "prompt" });
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
if ((stdinSlots?.length ?? 0) > 1) fail(2 /* USAGE */, "--field-stdin can be given only once.");
|
|
1217
|
+
for (const slot of stdinSlots ?? []) requests.push({ slot: requireSlot(slot), source: "stdin" });
|
|
1218
|
+
if (requests.length === 0) return void 0;
|
|
1219
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1220
|
+
for (const r of requests) {
|
|
1221
|
+
if (seen.has(r.slot)) fail(2 /* USAGE */, `Field slot ${r.slot} was given more than once.`);
|
|
1222
|
+
seen.add(r.slot);
|
|
1223
|
+
}
|
|
1224
|
+
const out = {};
|
|
1225
|
+
for (const r of requests) {
|
|
1226
|
+
if (opts.dryRun) {
|
|
1227
|
+
out[r.slot] = "";
|
|
1228
|
+
continue;
|
|
1229
|
+
}
|
|
1230
|
+
if (r.source === "inline") {
|
|
1231
|
+
out[r.slot] = r.value;
|
|
1232
|
+
} else if (r.source === "prompt") {
|
|
1233
|
+
if (!isInteractive()) {
|
|
1234
|
+
fail(
|
|
1235
|
+
2 /* USAGE */,
|
|
1236
|
+
`--field ${r.slot} has no value and there is no terminal to prompt on.`,
|
|
1237
|
+
`Pass --field ${r.slot}=<value>, or pipe the secret in: --field-stdin ${r.slot}`
|
|
1238
|
+
);
|
|
1239
|
+
}
|
|
1240
|
+
const { value, truncated } = await promptHidden(r.slot);
|
|
1241
|
+
if (truncated) {
|
|
1242
|
+
fail(2 /* USAGE */, `${r.slot} contained a line break - only the first line was captured.`);
|
|
1243
|
+
}
|
|
1244
|
+
out[r.slot] = nonBlank(value, r.slot);
|
|
1245
|
+
} else {
|
|
1246
|
+
if (process.stdin.isTTY) {
|
|
1247
|
+
fail(2 /* USAGE */, `--field-stdin ${r.slot} reads a piped value, but stdin is a terminal.`);
|
|
1248
|
+
}
|
|
1249
|
+
out[r.slot] = nonBlank(await readStdin(), r.slot);
|
|
1250
|
+
}
|
|
1251
|
+
}
|
|
1252
|
+
return out;
|
|
1253
|
+
}
|
|
1254
|
+
function nonBlank(value, slot) {
|
|
1255
|
+
if (value === "") {
|
|
1256
|
+
fail(
|
|
1257
|
+
2 /* USAGE */,
|
|
1258
|
+
`No value for ${slot}; aborting.`,
|
|
1259
|
+
`To clear a slot on update, pass --field ${slot}= explicitly.`
|
|
1260
|
+
);
|
|
1261
|
+
}
|
|
1262
|
+
return value;
|
|
1263
|
+
}
|
|
1264
|
+
async function resolveApplicationId(client, app) {
|
|
1265
|
+
if (/^\d+$/.test(app)) return Number(app);
|
|
1266
|
+
const detail4 = await client.applications.get(app);
|
|
1267
|
+
const name = clean(detail4.applicationName) ?? detail4.slug;
|
|
1268
|
+
const matches = (await client.authProviders.sources()).filter(
|
|
1269
|
+
(s) => (s.applicationName ?? "").toLowerCase() === name.toLowerCase()
|
|
1270
|
+
);
|
|
1271
|
+
if (matches.length === 1) return matches[0].applicationId;
|
|
1272
|
+
if (matches.length === 0) {
|
|
1273
|
+
fail(
|
|
1274
|
+
4 /* NOT_FOUND */,
|
|
1275
|
+
`Application '${app}' has no authentication method that allows auth providers.`,
|
|
1276
|
+
"Run `engini connections auth-providers sources` to list eligible applications."
|
|
1277
|
+
);
|
|
1278
|
+
}
|
|
1279
|
+
return fail(
|
|
1280
|
+
2 /* USAGE */,
|
|
1281
|
+
`'${app}' matches several applications named '${name}': ids ${matches.map((m) => m.applicationId).join(", ")}.`,
|
|
1282
|
+
"Pass the numeric id to --app."
|
|
1283
|
+
);
|
|
1284
|
+
}
|
|
1285
|
+
function parseIntOption(name, value) {
|
|
1286
|
+
if (!/^\d+$/.test(value)) fail(2 /* USAGE */, `${name} must be a non-negative integer.`);
|
|
1287
|
+
return Number(value);
|
|
1288
|
+
}
|
|
1289
|
+
async function defaultAuthenticationId(client, applicationId) {
|
|
1290
|
+
const source = (await client.authProviders.sources()).find((s) => s.applicationId === applicationId);
|
|
1291
|
+
if (!source) {
|
|
1292
|
+
fail(
|
|
1293
|
+
4 /* NOT_FOUND */,
|
|
1294
|
+
`Application ${applicationId} has no authentication method that allows auth providers.`,
|
|
1295
|
+
"Run `engini connections auth-providers sources` to list eligible applications."
|
|
1296
|
+
);
|
|
1297
|
+
}
|
|
1298
|
+
if (source.methods.length === 1) return source.methods[0].authenticationId;
|
|
1299
|
+
return fail(
|
|
1300
|
+
2 /* USAGE */,
|
|
1301
|
+
`Application ${applicationId} has several eligible methods; pass --auth <id>: ${source.methods.map((m) => `${m.authenticationId} (${m.displayName ?? m.authenticationType})`).join(", ")}.`
|
|
1302
|
+
);
|
|
1303
|
+
}
|
|
1304
|
+
|
|
1305
|
+
// src/connections/auth-providers/create.ts
|
|
1306
|
+
async function createBody(opts) {
|
|
1307
|
+
if (!opts.app) fail(2 /* USAGE */, "Missing required option '--app'.");
|
|
1308
|
+
if (!opts.name) fail(2 /* USAGE */, "Missing required option '--name'.");
|
|
1309
|
+
const app = opts.app;
|
|
1310
|
+
const name = opts.name;
|
|
1311
|
+
const auth = opts.auth !== void 0 ? parseIntOption("--auth", opts.auth) : void 0;
|
|
1312
|
+
const fieldValues = await collectFieldValues(opts.field, opts.fieldStdin, { dryRun: dryRun() });
|
|
1313
|
+
if (dryRun()) {
|
|
1314
|
+
printOutput({
|
|
1315
|
+
would_create: {
|
|
1316
|
+
application: app,
|
|
1317
|
+
authentication_id: auth ?? null,
|
|
1318
|
+
provider_name: name,
|
|
1319
|
+
is_default: Boolean(opts.default),
|
|
1320
|
+
is_sandbox: Boolean(opts.sandbox),
|
|
1321
|
+
scopes_override: opts.scopes ?? null,
|
|
1322
|
+
extra_options: opts.extraOptions ?? null,
|
|
1323
|
+
// Slot names only - a dry run must never print a value.
|
|
1324
|
+
field_slots: Object.keys(fieldValues ?? {})
|
|
1325
|
+
}
|
|
1326
|
+
});
|
|
1327
|
+
return;
|
|
1328
|
+
}
|
|
1329
|
+
const created = await apiErrors(async () => {
|
|
1330
|
+
const client = buildClient();
|
|
1331
|
+
const applicationId = await resolveApplicationId(client, app);
|
|
1332
|
+
const sourceAuthenticationId = auth ?? await defaultAuthenticationId(client, applicationId);
|
|
1333
|
+
return client.authProviders.create({
|
|
1334
|
+
providerName: name,
|
|
1335
|
+
applicationId,
|
|
1336
|
+
sourceAuthenticationId,
|
|
1337
|
+
isDefault: Boolean(opts.default),
|
|
1338
|
+
isSandbox: Boolean(opts.sandbox),
|
|
1339
|
+
...opts.scopes !== void 0 ? { scopesOverride: opts.scopes } : {},
|
|
1340
|
+
...opts.extraOptions !== void 0 ? { extraOptions: opts.extraOptions } : {},
|
|
1341
|
+
...fieldValues !== void 0 ? { fieldValues } : {}
|
|
1342
|
+
});
|
|
1343
|
+
});
|
|
1344
|
+
printOutput(renderProvider(created));
|
|
1345
|
+
}
|
|
1346
|
+
function registerAuthProvidersCreate(group) {
|
|
1347
|
+
const cmd = group.command("create").description("Create an auth provider for one authentication method of an application.").option("--app <slug|id>", "Application slug, or numeric application id").option("--auth <id>", "Authentication method id (optional when the app has one eligible method)").option("--name <name>", "Provider name (unique within the account)").option("--default", "Make this the application's default provider").option("--sandbox", "The provider is for the vendor's sandbox environment").option("--scopes <scopes>", "Scopes that replace the method's own scope option").option("--extra-options <json>", "Extra OAuth options as a JSON object of strings").option("--field <slot[=value]>", "Provider field: Slot=value, or a bare Slot to prompt (repeatable)", collect).option("--field-stdin <slot>", "Read one provider field value from stdin (e.g. a secret)", collect);
|
|
1348
|
+
cmd.addHelpText(
|
|
1349
|
+
"after",
|
|
1350
|
+
[
|
|
1351
|
+
"",
|
|
1352
|
+
"Examples:",
|
|
1353
|
+
" engini connections auth-providers sources # find the app, method and slots",
|
|
1354
|
+
" engini connections auth-providers redirect-uri --app salesforce",
|
|
1355
|
+
" engini connections auth-providers create --app salesforce --name 'Acme prod' \\",
|
|
1356
|
+
" --field Key1=<client-id> --field Key2 # Key2 prompts, hidden",
|
|
1357
|
+
' printf %s "$SECRET" | engini connections auth-providers create --app salesforce \\',
|
|
1358
|
+
" --name 'Acme prod' --field Key1=<client-id> --field-stdin Key2"
|
|
1359
|
+
].join("\n")
|
|
1360
|
+
);
|
|
1361
|
+
addUniversalOptions(cmd, { mutating: true });
|
|
1362
|
+
cmd.action(async (opts, command) => {
|
|
1363
|
+
await runCommand(command, opts, true, () => createBody(opts));
|
|
1364
|
+
});
|
|
1365
|
+
}
|
|
1366
|
+
|
|
1367
|
+
// src/connections/auth-providers/delete.ts
|
|
1368
|
+
async function deleteBody(idArg, opts) {
|
|
1369
|
+
const id = parseProviderId(idArg);
|
|
1370
|
+
if (dryRun()) {
|
|
1371
|
+
printOutput({ would_delete: id });
|
|
1372
|
+
return;
|
|
1373
|
+
}
|
|
1374
|
+
await confirmOrFail(`Delete auth provider ${id}?`, { force: Boolean(opts.force) });
|
|
1375
|
+
await apiErrors(async () => buildClient().authProviders.delete(id));
|
|
1376
|
+
printOutput({ deleted: id });
|
|
1377
|
+
}
|
|
1378
|
+
function registerAuthProvidersDelete(group) {
|
|
1379
|
+
const cmd = group.command("delete").description("Remove an auth provider (refused while a connection uses it).").argument("[id]", "Auth provider id").option("--force", "Delete without confirming");
|
|
1380
|
+
cmd.addHelpText("after", "\nExamples:\n engini connections auth-providers delete 7 --force");
|
|
1381
|
+
addUniversalOptions(cmd, { mutating: true });
|
|
1382
|
+
cmd.action(async (id, opts, command) => {
|
|
1383
|
+
await runCommand(command, opts, true, () => deleteBody(id, opts));
|
|
1384
|
+
});
|
|
1385
|
+
}
|
|
1386
|
+
|
|
1387
|
+
// src/connections/auth-providers/get.ts
|
|
1388
|
+
async function getBody2(idArg) {
|
|
1389
|
+
const id = parseProviderId(idArg);
|
|
1390
|
+
const provider = await apiErrors(async () => buildClient().authProviders.get(id));
|
|
1391
|
+
printOutput(renderProvider(provider));
|
|
1392
|
+
}
|
|
1393
|
+
function registerAuthProvidersGet(group) {
|
|
1394
|
+
const cmd = group.command("get").description("Show one auth provider.").argument("[id]", "Auth provider id");
|
|
1395
|
+
addUniversalOptions(cmd);
|
|
1396
|
+
cmd.action(async (id, opts, command) => {
|
|
1397
|
+
await runCommand(command, opts, false, () => getBody2(id));
|
|
1398
|
+
});
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
// src/connections/auth-providers/list.ts
|
|
1402
|
+
async function listBody2() {
|
|
1403
|
+
const providers = await apiErrors(async () => buildClient().authProviders.list());
|
|
1404
|
+
printOutput(providers.map(renderProvider));
|
|
1405
|
+
}
|
|
1406
|
+
function registerAuthProvidersList(group) {
|
|
1407
|
+
const cmd = group.command("list").description("List the account's auth providers (needs permission to manage them).");
|
|
1408
|
+
cmd.addHelpText(
|
|
1409
|
+
"after",
|
|
1410
|
+
"\nA secret slot reads back as has_value: true with a null value.\nPlain members can resolve a provider by name with `auth-providers usable`."
|
|
1411
|
+
);
|
|
1412
|
+
addUniversalOptions(cmd);
|
|
1413
|
+
cmd.action(async (opts, command) => {
|
|
1414
|
+
await runCommand(command, opts, false, listBody2);
|
|
1415
|
+
});
|
|
1416
|
+
}
|
|
1417
|
+
|
|
1418
|
+
// src/connections/auth-providers/redirect-uri.ts
|
|
1419
|
+
async function redirectUriBody(opts) {
|
|
1420
|
+
if (!opts.app) fail(2 /* USAGE */, "Missing required option '--app'.");
|
|
1421
|
+
const authenticationId = opts.auth !== void 0 ? parseIntOption("--auth", opts.auth) : void 0;
|
|
1422
|
+
const result = await apiErrors(async () => {
|
|
1423
|
+
const client = buildClient();
|
|
1424
|
+
const applicationId = await resolveApplicationId(client, opts.app);
|
|
1425
|
+
return client.authProviders.redirectUri(applicationId, {
|
|
1426
|
+
authenticationId,
|
|
1427
|
+
sandbox: Boolean(opts.sandbox)
|
|
1428
|
+
});
|
|
1429
|
+
});
|
|
1430
|
+
printOutput({ redirect_uri: result.redirectUri });
|
|
1431
|
+
}
|
|
1432
|
+
function registerAuthProvidersRedirectUri(group) {
|
|
1433
|
+
const cmd = group.command("redirect-uri").description("Show the callback URL to register in your own OAuth app.").option("--app <slug|id>", "Application slug, or numeric application id").option("--auth <id>", "Authentication method id (optional when the app has one eligible method)").option("--sandbox", "Use the vendor's sandbox environment");
|
|
1434
|
+
cmd.addHelpText(
|
|
1435
|
+
"after",
|
|
1436
|
+
"\nExamples:\n engini connections auth-providers redirect-uri --app salesforce --sandbox"
|
|
1437
|
+
);
|
|
1438
|
+
addUniversalOptions(cmd);
|
|
1439
|
+
cmd.action(async (opts, command) => {
|
|
1440
|
+
await runCommand(command, opts, false, () => redirectUriBody(opts));
|
|
1441
|
+
});
|
|
1442
|
+
}
|
|
1443
|
+
|
|
1444
|
+
// src/connections/auth-providers/sources.ts
|
|
1445
|
+
async function sourcesBody() {
|
|
1446
|
+
const sources = await apiErrors(async () => buildClient().authProviders.sources());
|
|
1447
|
+
printOutput(
|
|
1448
|
+
sources.map((s) => ({
|
|
1449
|
+
application_id: s.applicationId,
|
|
1450
|
+
application_name: clean(s.applicationName),
|
|
1451
|
+
methods: s.methods.map((m) => ({
|
|
1452
|
+
authentication_id: m.authenticationId,
|
|
1453
|
+
display_name: clean(m.displayName),
|
|
1454
|
+
authentication_type: m.authenticationType,
|
|
1455
|
+
fields: m.fields.map((f) => ({
|
|
1456
|
+
slot: f.slot,
|
|
1457
|
+
label: clean(f.label),
|
|
1458
|
+
is_password: f.isPassword,
|
|
1459
|
+
is_required: f.isRequired
|
|
1460
|
+
}))
|
|
1461
|
+
}))
|
|
1462
|
+
}))
|
|
1463
|
+
);
|
|
1464
|
+
}
|
|
1465
|
+
function registerAuthProvidersSources(group) {
|
|
1466
|
+
const cmd = group.command("sources").description("List applications and methods a provider can be based on, with their field slots.");
|
|
1467
|
+
cmd.addHelpText(
|
|
1468
|
+
"after",
|
|
1469
|
+
"\nUse the application_id / authentication_id / slots with `auth-providers create`."
|
|
1470
|
+
);
|
|
1471
|
+
addUniversalOptions(cmd);
|
|
1472
|
+
cmd.action(async (opts, command) => {
|
|
1473
|
+
await runCommand(command, opts, false, sourcesBody);
|
|
1474
|
+
});
|
|
1475
|
+
}
|
|
1476
|
+
|
|
1477
|
+
// src/connections/auth-providers/update.ts
|
|
1478
|
+
function parseStatus(value) {
|
|
1479
|
+
const v = value.toLowerCase();
|
|
1480
|
+
if (v === "active" || v === "1") return 1;
|
|
1481
|
+
if (v === "disabled" || v === "0") return 0;
|
|
1482
|
+
return fail(2 /* USAGE */, "--status must be 'active' or 'disabled'.");
|
|
1483
|
+
}
|
|
1484
|
+
async function updateBody(idArg, opts) {
|
|
1485
|
+
const id = parseProviderId(idArg);
|
|
1486
|
+
const fieldValues = await collectFieldValues(opts.field, opts.fieldStdin, { dryRun: dryRun() });
|
|
1487
|
+
const body = {
|
|
1488
|
+
...opts.name !== void 0 ? { providerName: opts.name } : {},
|
|
1489
|
+
...opts.default !== void 0 ? { isDefault: opts.default } : {},
|
|
1490
|
+
...opts.sandbox !== void 0 ? { isSandbox: opts.sandbox } : {},
|
|
1491
|
+
...opts.status !== void 0 ? { status: parseStatus(opts.status) } : {},
|
|
1492
|
+
...opts.scopes !== void 0 ? { scopesOverride: opts.scopes } : {},
|
|
1493
|
+
...opts.extraOptions !== void 0 ? { extraOptions: opts.extraOptions } : {},
|
|
1494
|
+
...fieldValues !== void 0 ? { fieldValues } : {}
|
|
1495
|
+
};
|
|
1496
|
+
if (Object.keys(body).length === 0) fail(2 /* USAGE */, "Nothing to update: pass at least one option.");
|
|
1497
|
+
if (dryRun()) {
|
|
1498
|
+
const { fieldValues: fv, ...rest } = body;
|
|
1499
|
+
printOutput({ would_update: { id, ...rest, ...fv ? { field_slots: Object.keys(fv) } : {} } });
|
|
1500
|
+
return;
|
|
1501
|
+
}
|
|
1502
|
+
const updated = await apiErrors(async () => buildClient().authProviders.update(id, body));
|
|
1503
|
+
printOutput(renderProvider(updated));
|
|
1504
|
+
}
|
|
1505
|
+
function registerAuthProvidersUpdate(group) {
|
|
1506
|
+
const cmd = group.command("update").description("Update an auth provider; omitted options and field slots are left unchanged.").argument("[id]", "Auth provider id").option("--name <name>", "New provider name").option("--default", "Make this the application's default provider").option("--no-default", "Stop this being the default provider").option("--sandbox", "Mark as the vendor's sandbox environment").option("--no-sandbox", "Mark as the vendor's production environment").option("--status <active|disabled>", "Enable or disable the provider").option("--scopes <scopes>", "New scopes override ('' clears it)").option("--extra-options <json>", "New extra OAuth options ('' clears them)").option("--field <slot[=value]>", "Field to change: Slot=value, bare Slot to prompt, Slot= to clear (repeatable)", collect).option("--field-stdin <slot>", "Read one field value from stdin (e.g. a secret)", collect);
|
|
1507
|
+
cmd.addHelpText(
|
|
1508
|
+
"after",
|
|
1509
|
+
[
|
|
1510
|
+
"",
|
|
1511
|
+
"Examples:",
|
|
1512
|
+
" engini connections auth-providers update 7 --status disabled",
|
|
1513
|
+
" engini connections auth-providers update 7 --field Key1=<new-client-id>",
|
|
1514
|
+
" engini connections auth-providers update 7 --field Key3= # clears Key3"
|
|
1515
|
+
].join("\n")
|
|
1516
|
+
);
|
|
1517
|
+
addUniversalOptions(cmd, { mutating: true });
|
|
1518
|
+
cmd.action(async (id, opts, command) => {
|
|
1519
|
+
await runCommand(command, opts, true, () => updateBody(id, opts));
|
|
1520
|
+
});
|
|
1521
|
+
}
|
|
1522
|
+
|
|
1523
|
+
// src/connections/auth-providers/usable.ts
|
|
1524
|
+
async function usableBody() {
|
|
1525
|
+
const usable = await apiErrors(async () => buildClient().authProviders.usable());
|
|
1526
|
+
printOutput(
|
|
1527
|
+
usable.map((p) => ({
|
|
1528
|
+
id: p.id,
|
|
1529
|
+
provider_name: p.providerName,
|
|
1530
|
+
application_id: p.applicationId,
|
|
1531
|
+
application_name: clean(p.applicationName),
|
|
1532
|
+
source_authentication_id: p.sourceAuthenticationId,
|
|
1533
|
+
source_authentication_name: clean(p.sourceAuthenticationName),
|
|
1534
|
+
is_default: p.isDefault
|
|
1535
|
+
}))
|
|
1536
|
+
);
|
|
1537
|
+
}
|
|
1538
|
+
function registerAuthProvidersUsable(group) {
|
|
1539
|
+
const cmd = group.command("usable").description("List active providers you can use for a connection (ids and names only).");
|
|
1540
|
+
cmd.addHelpText("after", "\nThe id is what `connect --provider <id>` takes; no field values are shown.");
|
|
1541
|
+
addUniversalOptions(cmd);
|
|
1542
|
+
cmd.action(async (opts, command) => {
|
|
1543
|
+
await runCommand(command, opts, false, usableBody);
|
|
1544
|
+
});
|
|
1545
|
+
}
|
|
1546
|
+
|
|
1547
|
+
// src/connections/auth-providers/index.ts
|
|
1548
|
+
function registerAuthProviders(connections) {
|
|
1549
|
+
const group = connections.command("auth-providers").description("Manage your own OAuth/credential providers for connections.");
|
|
1550
|
+
registerAuthProvidersList(group);
|
|
1551
|
+
registerAuthProvidersGet(group);
|
|
1552
|
+
registerAuthProvidersCreate(group);
|
|
1553
|
+
registerAuthProvidersUpdate(group);
|
|
1554
|
+
registerAuthProvidersDelete(group);
|
|
1555
|
+
registerAuthProvidersRedirectUri(group);
|
|
1556
|
+
registerAuthProvidersSources(group);
|
|
1557
|
+
registerAuthProvidersUsable(group);
|
|
1558
|
+
}
|
|
1559
|
+
|
|
1016
1560
|
// src/connections/check.ts
|
|
1017
1561
|
async function checkBody(connectionId) {
|
|
1018
1562
|
const id = parseId(connectionId);
|
|
@@ -1045,7 +1589,7 @@ function summary(c) {
|
|
|
1045
1589
|
use_select_db_objects: clean(c.useSelectDBObjects)
|
|
1046
1590
|
};
|
|
1047
1591
|
}
|
|
1048
|
-
async function
|
|
1592
|
+
async function createBody2(application, opts) {
|
|
1049
1593
|
if (!application) fail(2 /* USAGE */, "Missing required argument 'application'.");
|
|
1050
1594
|
if (!opts.auth) fail(2 /* USAGE */, "Missing required option '--auth'.");
|
|
1051
1595
|
if (!opts.name) fail(2 /* USAGE */, "Missing required option '--name'.");
|
|
@@ -1059,21 +1603,25 @@ async function createBody(application, opts) {
|
|
|
1059
1603
|
connection_name: opts.name,
|
|
1060
1604
|
authentication_id: auth,
|
|
1061
1605
|
fields: Object.fromEntries(Object.entries(fields).map(([k, v]) => [k, maskSecret(v)])),
|
|
1062
|
-
description: opts.description ?? null
|
|
1606
|
+
description: opts.description ?? null,
|
|
1607
|
+
...opts.provider !== void 0 ? { provider: opts.provider } : {}
|
|
1063
1608
|
}
|
|
1064
1609
|
});
|
|
1065
1610
|
return;
|
|
1066
1611
|
}
|
|
1067
1612
|
const conn = await apiErrors(async () => {
|
|
1068
1613
|
const client = buildClient();
|
|
1614
|
+
const provider = await resolveProvider(client, opts.provider);
|
|
1615
|
+
assertProviderFitsMethod(provider, auth);
|
|
1069
1616
|
return client.connections.create(application, opts.name, auth, fields, {
|
|
1070
|
-
description: opts.description
|
|
1617
|
+
description: opts.description,
|
|
1618
|
+
authProviderId: provider?.id
|
|
1071
1619
|
});
|
|
1072
1620
|
});
|
|
1073
1621
|
printOutput(summary(conn));
|
|
1074
1622
|
}
|
|
1075
1623
|
function registerConnectionsCreate(connections) {
|
|
1076
|
-
const cmd = connections.command("create").description("Create a direct-credential connection.").argument("[application]", "Application slug").option("--auth <id>", "Authentication method id").option("--name <name>", "Connection name").option("--field <spec>", "Credential field: key=value (repeatable)", collect).option("--description <text>", "Connection description");
|
|
1624
|
+
const cmd = connections.command("create").description("Create a direct-credential connection.").argument("[application]", "Application slug").option("--auth <id>", "Authentication method id").option("--name <name>", "Connection name").option("--field <spec>", "Credential field: key=value (repeatable)", collect).option("--description <text>", "Connection description").option("--provider <name|id|none>", PROVIDER_OPTION_HELP);
|
|
1077
1625
|
cmd.addHelpText(
|
|
1078
1626
|
"after",
|
|
1079
1627
|
"\nExamples:\n engini connections create slack --auth 2 --name Sales --field token=xoxb-1"
|
|
@@ -1084,7 +1632,7 @@ function registerConnectionsCreate(connections) {
|
|
|
1084
1632
|
command,
|
|
1085
1633
|
opts,
|
|
1086
1634
|
true,
|
|
1087
|
-
() =>
|
|
1635
|
+
() => createBody2(application, opts)
|
|
1088
1636
|
);
|
|
1089
1637
|
});
|
|
1090
1638
|
}
|
|
@@ -1097,7 +1645,7 @@ function summarize2(d) {
|
|
|
1097
1645
|
connection_name: clean(d.connectionName)
|
|
1098
1646
|
};
|
|
1099
1647
|
}
|
|
1100
|
-
async function
|
|
1648
|
+
async function listBody3() {
|
|
1101
1649
|
const rows = await apiErrors(async () => {
|
|
1102
1650
|
const client = buildClient();
|
|
1103
1651
|
return client.connections.defaults();
|
|
@@ -1136,7 +1684,7 @@ function registerConnectionsDefaults(connections) {
|
|
|
1136
1684
|
);
|
|
1137
1685
|
addUniversalOptions(list);
|
|
1138
1686
|
list.action(async (opts, command) => {
|
|
1139
|
-
await runCommand(command, opts, false, () =>
|
|
1687
|
+
await runCommand(command, opts, false, () => listBody3());
|
|
1140
1688
|
});
|
|
1141
1689
|
const set = connections.command("set-default").description("Make a connection the default for its application.").argument("[connection_id]", "Connection id");
|
|
1142
1690
|
set.addHelpText("after", "\nExamples:\n engini connections set-default 481");
|
|
@@ -1155,7 +1703,7 @@ function registerConnectionsDefaults(connections) {
|
|
|
1155
1703
|
}
|
|
1156
1704
|
|
|
1157
1705
|
// src/connections/delete.ts
|
|
1158
|
-
async function
|
|
1706
|
+
async function deleteBody2(connectionId, opts) {
|
|
1159
1707
|
const id = parseId(connectionId);
|
|
1160
1708
|
if (dryRun()) {
|
|
1161
1709
|
printOutput({ would_delete: id });
|
|
@@ -1173,7 +1721,7 @@ function registerConnectionsDelete(connections) {
|
|
|
1173
1721
|
cmd.addHelpText("after", "\nExamples:\n engini connections delete 42 --force");
|
|
1174
1722
|
addUniversalOptions(cmd, { mutating: true });
|
|
1175
1723
|
cmd.action(async (id, opts, command) => {
|
|
1176
|
-
await runCommand(command, opts, true, () =>
|
|
1724
|
+
await runCommand(command, opts, true, () => deleteBody2(id, opts));
|
|
1177
1725
|
});
|
|
1178
1726
|
}
|
|
1179
1727
|
|
|
@@ -1204,7 +1752,7 @@ function parseId2(value) {
|
|
|
1204
1752
|
}
|
|
1205
1753
|
return id;
|
|
1206
1754
|
}
|
|
1207
|
-
async function
|
|
1755
|
+
async function getBody3(connectionId) {
|
|
1208
1756
|
const id = parseId2(connectionId);
|
|
1209
1757
|
const connection = await apiErrors(async () => {
|
|
1210
1758
|
const client = buildClient();
|
|
@@ -1217,7 +1765,7 @@ function registerConnectionsGet(connections) {
|
|
|
1217
1765
|
cmd.addHelpText("after", "\nExamples:\n engini connections get 42 --json");
|
|
1218
1766
|
addUniversalOptions(cmd);
|
|
1219
1767
|
cmd.action(async (id, opts, command) => {
|
|
1220
|
-
await runCommand(command, opts, false, () =>
|
|
1768
|
+
await runCommand(command, opts, false, () => getBody3(id));
|
|
1221
1769
|
});
|
|
1222
1770
|
}
|
|
1223
1771
|
|
|
@@ -1234,7 +1782,7 @@ function summarize3(c) {
|
|
|
1234
1782
|
created_date: c.createdDate
|
|
1235
1783
|
};
|
|
1236
1784
|
}
|
|
1237
|
-
async function
|
|
1785
|
+
async function listBody4(opts) {
|
|
1238
1786
|
const conns = await apiErrors(async () => {
|
|
1239
1787
|
const client = buildClient();
|
|
1240
1788
|
return client.connections.list(opts.application, opts.kind);
|
|
@@ -1254,7 +1802,7 @@ Examples:
|
|
|
1254
1802
|
);
|
|
1255
1803
|
addUniversalOptions(cmd);
|
|
1256
1804
|
cmd.action(async (opts, command) => {
|
|
1257
|
-
await runCommand(command, opts, false, () =>
|
|
1805
|
+
await runCommand(command, opts, false, () => listBody4(opts));
|
|
1258
1806
|
});
|
|
1259
1807
|
}
|
|
1260
1808
|
|
|
@@ -1455,7 +2003,12 @@ async function signInUrlBody(application, opts) {
|
|
|
1455
2003
|
const fields = opts.field ? parseFields(opts.field) : void 0;
|
|
1456
2004
|
const resp = await apiErrors(async () => {
|
|
1457
2005
|
const client = buildClient();
|
|
1458
|
-
|
|
2006
|
+
const provider = await resolveProvider(client, opts.provider);
|
|
2007
|
+
assertProviderFitsMethod(provider, auth);
|
|
2008
|
+
return client.connections.getSignInUrl(application, auth, {
|
|
2009
|
+
fields,
|
|
2010
|
+
authProviderId: provider?.id
|
|
2011
|
+
});
|
|
1459
2012
|
});
|
|
1460
2013
|
printOutput({
|
|
1461
2014
|
sign_in_url: resp.signInUrl,
|
|
@@ -1464,7 +2017,7 @@ async function signInUrlBody(application, opts) {
|
|
|
1464
2017
|
});
|
|
1465
2018
|
}
|
|
1466
2019
|
function registerConnectionsSignInUrl(connections) {
|
|
1467
|
-
const cmd = connections.command("sign-in-url").description("Start an OAuth2 sign-in (returns the URL + state).").argument("[application]", "Application slug").option("--auth <id>", "Authentication method id").option("--field <spec>", "Pre-sign-in field: key=value (repeatable)", collect);
|
|
2020
|
+
const cmd = connections.command("sign-in-url").description("Start an OAuth2 sign-in (returns the URL + state).").argument("[application]", "Application slug").option("--auth <id>", "Authentication method id").option("--field <spec>", "Pre-sign-in field: key=value (repeatable)", collect).option("--provider <name|id|none>", PROVIDER_OPTION_HELP);
|
|
1468
2021
|
cmd.addHelpText("after", "\nExamples:\n engini connections sign-in-url outlook --auth 0");
|
|
1469
2022
|
addUniversalOptions(cmd);
|
|
1470
2023
|
cmd.action(async (application, opts, command) => {
|
|
@@ -1488,7 +2041,7 @@ function summary4(c) {
|
|
|
1488
2041
|
is_alive: clean(c.isAlive)
|
|
1489
2042
|
};
|
|
1490
2043
|
}
|
|
1491
|
-
async function
|
|
2044
|
+
async function updateBody2(idRaw, opts) {
|
|
1492
2045
|
const connectionId = parseId(idRaw);
|
|
1493
2046
|
const patch = {};
|
|
1494
2047
|
if (opts.name !== void 0) patch.name = opts.name;
|
|
@@ -1541,7 +2094,7 @@ function registerConnectionsUpdate(connections) {
|
|
|
1541
2094
|
command,
|
|
1542
2095
|
opts,
|
|
1543
2096
|
true,
|
|
1544
|
-
() =>
|
|
2097
|
+
() => updateBody2(idRaw, opts)
|
|
1545
2098
|
);
|
|
1546
2099
|
});
|
|
1547
2100
|
}
|
|
@@ -1562,6 +2115,7 @@ function registerConnections(program) {
|
|
|
1562
2115
|
registerConnectionsSelectObjects(connections);
|
|
1563
2116
|
registerConnectionsSignInUrl(connections);
|
|
1564
2117
|
registerConnectionsOauthComplete(connections);
|
|
2118
|
+
registerAuthProviders(connections);
|
|
1565
2119
|
}
|
|
1566
2120
|
|
|
1567
2121
|
// src/help.ts
|
|
@@ -1620,17 +2174,20 @@ ACCOUNT
|
|
|
1620
2174
|
whoami Show the authenticated user/company.
|
|
1621
2175
|
|
|
1622
2176
|
CONNECTIONS
|
|
1623
|
-
connect [<app>]
|
|
2177
|
+
connect [<app>] [--provider <name|id|none>]
|
|
2178
|
+
Create a connection \u2014 interactive on a TTY, or
|
|
1624
2179
|
agent-resumable when piped (prints {need, resume}).
|
|
1625
2180
|
Resume with --oauth-state <state> (OAuth) or
|
|
1626
2181
|
--connection <id> (object selection). No app \u2192 web page.
|
|
2182
|
+
--provider signs in through your own auth provider
|
|
2183
|
+
(see AUTH PROVIDERS); 'none' = the connector's own client.
|
|
1627
2184
|
connections list [--application <slug>] [--kind <kind>]
|
|
1628
2185
|
List your connections. --kind filters on
|
|
1629
2186
|
Regular | Key | MCPClient. The web UI's
|
|
1630
2187
|
"Keys" tab is --kind Key. On-premise agents are
|
|
1631
2188
|
not connections - see ON-PREMISE AGENTS.
|
|
1632
2189
|
connections get <id> Inspect a connection.
|
|
1633
|
-
connections create <app> --auth <id> --name <n> --field k=v
|
|
2190
|
+
connections create <app> --auth <id> --name <n> --field k=v [--provider <name|id|none>]
|
|
1634
2191
|
Create a direct-credential connection.
|
|
1635
2192
|
connections update <id> [--name <n>] [--description <t>] [--field k=v] [--metadata k=v]
|
|
1636
2193
|
Update a connection. --field/--metadata REPLACE
|
|
@@ -1640,7 +2197,8 @@ CONNECTIONS
|
|
|
1640
2197
|
connections defaults List your per-application default connections.
|
|
1641
2198
|
connections set-default <id> Make a connection its application's default.
|
|
1642
2199
|
connections clear-default <app> Clear an application's default (takes a slug).
|
|
1643
|
-
connections sign-in-url <app> --auth <id>
|
|
2200
|
+
connections sign-in-url <app> --auth <id> [--provider <name|id|none>]
|
|
2201
|
+
Start an OAuth2 sign-in (returns URL + state).
|
|
1644
2202
|
connections oauth-complete <app> --auth <id> --state <state>
|
|
1645
2203
|
Finish an OAuth2 sign-in and create the connection.
|
|
1646
2204
|
connections check <id> Test a connection's liveness.
|
|
@@ -1649,6 +2207,29 @@ CONNECTIONS
|
|
|
1649
2207
|
connections select-objects <id> --object <id> Choose which objects to sync (async).
|
|
1650
2208
|
connections delete <id> [--force] Remove a connection.
|
|
1651
2209
|
|
|
2210
|
+
AUTH PROVIDERS
|
|
2211
|
+
Your own OAuth app / credentials for one authentication method of an app, filled once and
|
|
2212
|
+
used by every connection signed in through it. A provider is a name plus values for the
|
|
2213
|
+
connector's "Set on provider" fields, addressed by slot (Key1..Key10, ApiUser, ApiPassword,
|
|
2214
|
+
BaseUrl) - there is no client-id/client-secret flag; every value is a --field.
|
|
2215
|
+
connections auth-providers sources Which apps/methods can have a provider, and the slots to fill.
|
|
2216
|
+
connections auth-providers redirect-uri --app <slug|id> [--auth <id>] [--sandbox]
|
|
2217
|
+
The callback URL to register in your OAuth app FIRST.
|
|
2218
|
+
connections auth-providers create --app <slug|id> --name <n> [--auth <id>] [--default] [--sandbox]
|
|
2219
|
+
[--scopes <s>] [--extra-options <json>] [--field Slot=value ...] [--field-stdin Slot]
|
|
2220
|
+
Create a provider. A bare "--field Slot" prompts hidden on a
|
|
2221
|
+
terminal; "--field-stdin Slot" reads a secret from a pipe, so it
|
|
2222
|
+
never reaches shell history or ps.
|
|
2223
|
+
connections auth-providers update <id> [--name <n>] [--status active|disabled] [--default|--no-default]
|
|
2224
|
+
[--sandbox|--no-sandbox] [--scopes <s>] [--extra-options <json>] [--field ...]
|
|
2225
|
+
Change a provider. Omitted fields/slots are kept; "--field Slot="
|
|
2226
|
+
(empty) clears that slot. A secret reads back as has_value only.
|
|
2227
|
+
connections auth-providers list List providers with their field values (manager-only).
|
|
2228
|
+
connections auth-providers get <id> Show one provider.
|
|
2229
|
+
connections auth-providers usable Providers you may connect through (ids + names only).
|
|
2230
|
+
connections auth-providers delete <id> [--force]
|
|
2231
|
+
Remove a provider (refused while a connection uses it).
|
|
2232
|
+
|
|
1652
2233
|
TOOLSETS
|
|
1653
2234
|
toolsets list List your toolsets.
|
|
1654
2235
|
toolsets get <id> Show full detail for one toolset.
|
|
@@ -2248,7 +2829,7 @@ function registerMcpConnections(mcp) {
|
|
|
2248
2829
|
}
|
|
2249
2830
|
|
|
2250
2831
|
// src/mcp/get.ts
|
|
2251
|
-
async function
|
|
2832
|
+
async function getBody4(token) {
|
|
2252
2833
|
const mcpServerToken = parseMcpServerToken(token);
|
|
2253
2834
|
const server = await apiErrors(async () => {
|
|
2254
2835
|
const client = buildClient();
|
|
@@ -2267,12 +2848,12 @@ function registerMcpGet(mcp) {
|
|
|
2267
2848
|
cmd.addHelpText("after", "\nExamples:\n engini mcp get <mcp_server_token> --json");
|
|
2268
2849
|
addUniversalOptions(cmd);
|
|
2269
2850
|
cmd.action(async (token, opts, command) => {
|
|
2270
|
-
await runCommand(command, opts, false, () =>
|
|
2851
|
+
await runCommand(command, opts, false, () => getBody4(token));
|
|
2271
2852
|
});
|
|
2272
2853
|
}
|
|
2273
2854
|
|
|
2274
2855
|
// src/mcp/list.ts
|
|
2275
|
-
async function
|
|
2856
|
+
async function listBody5() {
|
|
2276
2857
|
const servers = await apiErrors(async () => {
|
|
2277
2858
|
const client = buildClient();
|
|
2278
2859
|
return client.mcp.list();
|
|
@@ -2287,7 +2868,7 @@ function registerMcpList(mcp) {
|
|
|
2287
2868
|
);
|
|
2288
2869
|
addUniversalOptions(cmd);
|
|
2289
2870
|
cmd.action(async (opts, command) => {
|
|
2290
|
-
await runCommand(command, opts, false, () =>
|
|
2871
|
+
await runCommand(command, opts, false, () => listBody5());
|
|
2291
2872
|
});
|
|
2292
2873
|
}
|
|
2293
2874
|
|
|
@@ -2325,7 +2906,7 @@ function registerMcpStatus(mcp) {
|
|
|
2325
2906
|
}
|
|
2326
2907
|
|
|
2327
2908
|
// src/mcp/tools.ts
|
|
2328
|
-
async function
|
|
2909
|
+
async function listBody6(token, connectionIdRaw) {
|
|
2329
2910
|
const mcpServerToken = parseMcpServerToken(token);
|
|
2330
2911
|
if (!connectionIdRaw) fail(2 /* USAGE */, "Missing required option '--connection-id'.");
|
|
2331
2912
|
const [connectionId] = parseConnectionIds([connectionIdRaw]);
|
|
@@ -2389,7 +2970,7 @@ function registerMcpTools(mcp) {
|
|
|
2389
2970
|
command,
|
|
2390
2971
|
opts,
|
|
2391
2972
|
false,
|
|
2392
|
-
() =>
|
|
2973
|
+
() => listBody6(token, opts.connectionId)
|
|
2393
2974
|
);
|
|
2394
2975
|
}
|
|
2395
2976
|
);
|
|
@@ -2560,7 +3141,7 @@ function addSettingsOptions(cmd) {
|
|
|
2560
3141
|
}
|
|
2561
3142
|
|
|
2562
3143
|
// src/opa/create.ts
|
|
2563
|
-
async function
|
|
3144
|
+
async function createBody3(opts) {
|
|
2564
3145
|
if (opts.name === void 0 || opts.name.trim() === "") fail(2 /* USAGE */, "--name is required.");
|
|
2565
3146
|
const settings = parseSettingsFlags(opts);
|
|
2566
3147
|
const preview = settingsPreview(settings);
|
|
@@ -2603,12 +3184,12 @@ function registerOpaCreate(opa) {
|
|
|
2603
3184
|
);
|
|
2604
3185
|
addUniversalOptions(cmd, { mutating: true });
|
|
2605
3186
|
cmd.action(async (opts, command) => {
|
|
2606
|
-
await runCommand(command, opts, true, () =>
|
|
3187
|
+
await runCommand(command, opts, true, () => createBody3(opts));
|
|
2607
3188
|
});
|
|
2608
3189
|
}
|
|
2609
3190
|
|
|
2610
3191
|
// src/opa/delete.ts
|
|
2611
|
-
async function
|
|
3192
|
+
async function deleteBody3(raw, opts) {
|
|
2612
3193
|
const agentId = parseAgentId(raw);
|
|
2613
3194
|
if (dryRun()) {
|
|
2614
3195
|
printOutput({ would_delete: agentId });
|
|
@@ -2630,7 +3211,7 @@ function registerOpaDelete(opa) {
|
|
|
2630
3211
|
command,
|
|
2631
3212
|
opts,
|
|
2632
3213
|
true,
|
|
2633
|
-
() =>
|
|
3214
|
+
() => deleteBody3(raw, opts)
|
|
2634
3215
|
);
|
|
2635
3216
|
});
|
|
2636
3217
|
}
|
|
@@ -2716,7 +3297,7 @@ function registerOpaDownload(opa) {
|
|
|
2716
3297
|
}
|
|
2717
3298
|
|
|
2718
3299
|
// src/opa/get.ts
|
|
2719
|
-
async function
|
|
3300
|
+
async function getBody5(raw) {
|
|
2720
3301
|
const agentId = parseAgentId(raw);
|
|
2721
3302
|
const agent = await apiErrors(async () => buildClient().opa.get(agentId));
|
|
2722
3303
|
printOutput({
|
|
@@ -2732,12 +3313,12 @@ function registerOpaGet(opa) {
|
|
|
2732
3313
|
cmd.addHelpText("after", "\nExamples:\n engini opa get 41 --json");
|
|
2733
3314
|
addUniversalOptions(cmd);
|
|
2734
3315
|
cmd.action(async (raw, opts, command) => {
|
|
2735
|
-
await runCommand(command, opts, false, () =>
|
|
3316
|
+
await runCommand(command, opts, false, () => getBody5(raw));
|
|
2736
3317
|
});
|
|
2737
3318
|
}
|
|
2738
3319
|
|
|
2739
3320
|
// src/opa/list.ts
|
|
2740
|
-
async function
|
|
3321
|
+
async function listBody7(opts) {
|
|
2741
3322
|
const agents = await apiErrors(
|
|
2742
3323
|
async () => buildClient().opa.list({ status: opts.status, name: opts.name })
|
|
2743
3324
|
);
|
|
@@ -2754,7 +3335,7 @@ function registerOpaList(opa) {
|
|
|
2754
3335
|
);
|
|
2755
3336
|
addUniversalOptions(cmd);
|
|
2756
3337
|
cmd.action(async (opts, command) => {
|
|
2757
|
-
await runCommand(command, opts, false, () =>
|
|
3338
|
+
await runCommand(command, opts, false, () => listBody7(opts));
|
|
2758
3339
|
});
|
|
2759
3340
|
}
|
|
2760
3341
|
|
|
@@ -2829,7 +3410,7 @@ function registerOpaDisable(opa) {
|
|
|
2829
3410
|
}
|
|
2830
3411
|
|
|
2831
3412
|
// src/opa/token.ts
|
|
2832
|
-
async function
|
|
3413
|
+
async function getBody6(raw) {
|
|
2833
3414
|
const agentId = parseAgentId(raw);
|
|
2834
3415
|
const token = await apiErrors(async () => buildClient().opa.getToken(agentId));
|
|
2835
3416
|
printOutput({ agent_id: token.agentId, token: token.token });
|
|
@@ -2857,7 +3438,7 @@ function registerOpaToken(opa) {
|
|
|
2857
3438
|
get.addHelpText("after", "\nExamples:\n engini opa token get 41 --json");
|
|
2858
3439
|
addUniversalOptions(get);
|
|
2859
3440
|
get.action(async (raw, opts, command) => {
|
|
2860
|
-
await runCommand(command, opts, false, () =>
|
|
3441
|
+
await runCommand(command, opts, false, () => getBody6(raw));
|
|
2861
3442
|
});
|
|
2862
3443
|
const rotate = token.command("rotate").description(
|
|
2863
3444
|
"Issue a new token, invalidating the current one. Stops the running agent until it is reconfigured."
|
|
@@ -2877,7 +3458,7 @@ function registerOpaToken(opa) {
|
|
|
2877
3458
|
}
|
|
2878
3459
|
|
|
2879
3460
|
// src/opa/update.ts
|
|
2880
|
-
async function
|
|
3461
|
+
async function updateBody3(raw, opts) {
|
|
2881
3462
|
const agentId = parseAgentId(raw);
|
|
2882
3463
|
const settings = parseSettingsFlags(opts);
|
|
2883
3464
|
const preview = settingsPreview(settings);
|
|
@@ -2925,7 +3506,7 @@ function registerOpaUpdate(opa) {
|
|
|
2925
3506
|
command,
|
|
2926
3507
|
opts,
|
|
2927
3508
|
true,
|
|
2928
|
-
() =>
|
|
3509
|
+
() => updateBody3(raw, opts)
|
|
2929
3510
|
);
|
|
2930
3511
|
});
|
|
2931
3512
|
}
|
|
@@ -3367,7 +3948,7 @@ function detail3(schema) {
|
|
|
3367
3948
|
max_sorts: clean(schema.maxSorts)
|
|
3368
3949
|
};
|
|
3369
3950
|
}
|
|
3370
|
-
async function
|
|
3951
|
+
async function getBody7(toolId) {
|
|
3371
3952
|
if (!toolId) {
|
|
3372
3953
|
fail(2 /* USAGE */, "Missing required argument 'tool_id'.");
|
|
3373
3954
|
}
|
|
@@ -3381,7 +3962,7 @@ function registerToolsGet(tools) {
|
|
|
3381
3962
|
const cmd = tools.command("get").description("Show full canonical detail for one tool.").argument("[tool_id]", "Tool slug");
|
|
3382
3963
|
addUniversalOptions(cmd);
|
|
3383
3964
|
cmd.action(async (toolId, opts, command) => {
|
|
3384
|
-
await runCommand(command, opts, false, () =>
|
|
3965
|
+
await runCommand(command, opts, false, () => getBody7(toolId));
|
|
3385
3966
|
});
|
|
3386
3967
|
}
|
|
3387
3968
|
|
|
@@ -3404,7 +3985,7 @@ function parseLimit2(value) {
|
|
|
3404
3985
|
}
|
|
3405
3986
|
return limit;
|
|
3406
3987
|
}
|
|
3407
|
-
async function
|
|
3988
|
+
async function listBody8(opts) {
|
|
3408
3989
|
if (opts.application && opts.toolset) {
|
|
3409
3990
|
fail(2 /* USAGE */, "Pass only one of --application / --toolset.");
|
|
3410
3991
|
}
|
|
@@ -3427,7 +4008,7 @@ function registerToolsList(tools) {
|
|
|
3427
4008
|
const cmd = tools.command("list").description("List available tools, optionally filtered.").option("--application <slug>", "Filter by application slug (e.g. monday)").option("--toolset <id>", "List the tools of a server toolset (by id)").option("--limit <n>", "Cap the number of tools returned");
|
|
3428
4009
|
addUniversalOptions(cmd);
|
|
3429
4010
|
cmd.action(async (opts, command) => {
|
|
3430
|
-
await runCommand(command, opts, false, () =>
|
|
4011
|
+
await runCommand(command, opts, false, () => listBody8(opts));
|
|
3431
4012
|
});
|
|
3432
4013
|
}
|
|
3433
4014
|
|
|
@@ -3618,7 +4199,7 @@ function buildRequestBody(opts) {
|
|
|
3618
4199
|
workflows: workflowsFromFlagsOrUndefined(opts.workflow)
|
|
3619
4200
|
};
|
|
3620
4201
|
}
|
|
3621
|
-
async function
|
|
4202
|
+
async function createBody4(opts) {
|
|
3622
4203
|
const body = buildRequestBody(opts);
|
|
3623
4204
|
if (dryRun()) {
|
|
3624
4205
|
printOutput({
|
|
@@ -3652,12 +4233,12 @@ function registerToolsetsCreate(toolsets) {
|
|
|
3652
4233
|
);
|
|
3653
4234
|
addUniversalOptions(cmd, { mutating: true });
|
|
3654
4235
|
cmd.action(async (opts, command) => {
|
|
3655
|
-
await runCommand(command, opts, true, () =>
|
|
4236
|
+
await runCommand(command, opts, true, () => createBody4(opts));
|
|
3656
4237
|
});
|
|
3657
4238
|
}
|
|
3658
4239
|
|
|
3659
4240
|
// src/toolsets/delete.ts
|
|
3660
|
-
async function
|
|
4241
|
+
async function deleteBody4(toolsetId, opts) {
|
|
3661
4242
|
const id = parseToolsetId(toolsetId);
|
|
3662
4243
|
if (dryRun()) {
|
|
3663
4244
|
printOutput({ would_delete: id });
|
|
@@ -3675,12 +4256,12 @@ function registerToolsetsDelete(toolsets) {
|
|
|
3675
4256
|
cmd.addHelpText("after", "\nExamples:\n engini toolsets delete <toolset_id> --force");
|
|
3676
4257
|
addUniversalOptions(cmd, { mutating: true });
|
|
3677
4258
|
cmd.action(async (id, opts, command) => {
|
|
3678
|
-
await runCommand(command, opts, true, () =>
|
|
4259
|
+
await runCommand(command, opts, true, () => deleteBody4(id, opts));
|
|
3679
4260
|
});
|
|
3680
4261
|
}
|
|
3681
4262
|
|
|
3682
4263
|
// src/toolsets/get.ts
|
|
3683
|
-
async function
|
|
4264
|
+
async function getBody8(toolsetId) {
|
|
3684
4265
|
const id = parseToolsetId(toolsetId);
|
|
3685
4266
|
const toolset = await apiErrors(async () => {
|
|
3686
4267
|
const client = buildClient();
|
|
@@ -3698,12 +4279,12 @@ function registerToolsetsGet(toolsets) {
|
|
|
3698
4279
|
cmd.addHelpText("after", "\nExamples:\n engini toolsets get <toolset_id> --json");
|
|
3699
4280
|
addUniversalOptions(cmd);
|
|
3700
4281
|
cmd.action(async (id, opts, command) => {
|
|
3701
|
-
await runCommand(command, opts, false, () =>
|
|
4282
|
+
await runCommand(command, opts, false, () => getBody8(id));
|
|
3702
4283
|
});
|
|
3703
4284
|
}
|
|
3704
4285
|
|
|
3705
4286
|
// src/toolsets/list.ts
|
|
3706
|
-
async function
|
|
4287
|
+
async function listBody9() {
|
|
3707
4288
|
const toolsets = await apiErrors(async () => {
|
|
3708
4289
|
const client = buildClient();
|
|
3709
4290
|
return client.toolsets.list();
|
|
@@ -3718,7 +4299,7 @@ function registerToolsetsList(toolsets) {
|
|
|
3718
4299
|
);
|
|
3719
4300
|
addUniversalOptions(cmd);
|
|
3720
4301
|
cmd.action(async (opts, command) => {
|
|
3721
|
-
await runCommand(command, opts, false, () =>
|
|
4302
|
+
await runCommand(command, opts, false, () => listBody9());
|
|
3722
4303
|
});
|
|
3723
4304
|
}
|
|
3724
4305
|
|
|
@@ -3753,7 +4334,7 @@ async function previewDryRun(toolsetId, body) {
|
|
|
3753
4334
|
}
|
|
3754
4335
|
});
|
|
3755
4336
|
}
|
|
3756
|
-
async function
|
|
4337
|
+
async function updateBody4(toolsetId, opts) {
|
|
3757
4338
|
const id = parseToolsetId(toolsetId);
|
|
3758
4339
|
const body = buildRequestBody2(opts);
|
|
3759
4340
|
if (body.name === void 0 && body.connections === void 0 && body.workflows === void 0) {
|
|
@@ -3790,7 +4371,7 @@ function registerToolsetsUpdate(toolsets) {
|
|
|
3790
4371
|
);
|
|
3791
4372
|
addUniversalOptions(cmd, { mutating: true });
|
|
3792
4373
|
cmd.action(async (id, opts, command) => {
|
|
3793
|
-
await runCommand(command, opts, true, () =>
|
|
4374
|
+
await runCommand(command, opts, true, () => updateBody4(id, opts));
|
|
3794
4375
|
});
|
|
3795
4376
|
}
|
|
3796
4377
|
|
|
@@ -3966,7 +4547,7 @@ async function hasAccountDefaultDestination() {
|
|
|
3966
4547
|
throw err;
|
|
3967
4548
|
}
|
|
3968
4549
|
}
|
|
3969
|
-
async function
|
|
4550
|
+
async function createBody5(triggerSlug, opts) {
|
|
3970
4551
|
if (triggerSlug === void 0 || triggerSlug === "") fail(2 /* USAGE */, "A trigger_slug is required.");
|
|
3971
4552
|
if (opts.connection === "") {
|
|
3972
4553
|
fail(
|
|
@@ -4036,12 +4617,12 @@ function registerTriggerCreate(triggers) {
|
|
|
4036
4617
|
);
|
|
4037
4618
|
addUniversalOptions(create, { mutating: true });
|
|
4038
4619
|
create.action(async (triggerSlug, opts, command) => {
|
|
4039
|
-
await runCommand(command, opts, true, () =>
|
|
4620
|
+
await runCommand(command, opts, true, () => createBody5(triggerSlug, opts));
|
|
4040
4621
|
});
|
|
4041
4622
|
}
|
|
4042
4623
|
|
|
4043
4624
|
// src/triggers/delete.ts
|
|
4044
|
-
async function
|
|
4625
|
+
async function deleteBody5(raw, opts) {
|
|
4045
4626
|
const triggerId = parseTriggerId(raw);
|
|
4046
4627
|
if (dryRun()) {
|
|
4047
4628
|
printOutput({ would_delete: triggerId });
|
|
@@ -4060,7 +4641,7 @@ function registerTriggerDelete(triggers) {
|
|
|
4060
4641
|
addUniversalOptions(cmd, { mutating: true });
|
|
4061
4642
|
cmd.action(
|
|
4062
4643
|
async (raw, opts, command) => {
|
|
4063
|
-
await runCommand(command, opts, true, () =>
|
|
4644
|
+
await runCommand(command, opts, true, () => deleteBody5(raw, opts));
|
|
4064
4645
|
}
|
|
4065
4646
|
);
|
|
4066
4647
|
}
|
|
@@ -4105,7 +4686,7 @@ async function addBody(name, url, opts) {
|
|
|
4105
4686
|
);
|
|
4106
4687
|
printOutput(withSecret(created));
|
|
4107
4688
|
}
|
|
4108
|
-
async function
|
|
4689
|
+
async function listBody10() {
|
|
4109
4690
|
const destinations = await apiErrors(async () => buildClient().triggers.destinations.list());
|
|
4110
4691
|
printOutput(destinations.map(summarizeDestination));
|
|
4111
4692
|
}
|
|
@@ -4171,7 +4752,7 @@ function registerTriggerDestinations(triggers) {
|
|
|
4171
4752
|
list.addHelpText("after", "\nExamples:\n engini triggers destinations list --json");
|
|
4172
4753
|
addUniversalOptions(list);
|
|
4173
4754
|
list.action(async (opts, command) => {
|
|
4174
|
-
await runCommand(command, opts, false,
|
|
4755
|
+
await runCommand(command, opts, false, listBody10);
|
|
4175
4756
|
});
|
|
4176
4757
|
const show = destinations.command("show").description("One destination's failure counters and status.").argument("[name]", "Destination name");
|
|
4177
4758
|
show.addHelpText("after", "\nExamples:\n engini triggers destinations show billing");
|
|
@@ -4207,13 +4788,13 @@ function registerTriggerDestinations(triggers) {
|
|
|
4207
4788
|
}
|
|
4208
4789
|
|
|
4209
4790
|
// src/triggers/events.ts
|
|
4210
|
-
async function
|
|
4791
|
+
async function listBody11(triggerId, opts) {
|
|
4211
4792
|
if (triggerId === void 0 || triggerId === "") fail(2 /* USAGE */, "A trigger_id is required.");
|
|
4212
4793
|
const top = opts.limit !== void 0 ? Number(opts.limit) : void 0;
|
|
4213
4794
|
const events = await apiErrors(async () => buildClient().triggers.events.list(triggerId, { top }));
|
|
4214
4795
|
printOutput(events.map(summarizeEvent));
|
|
4215
4796
|
}
|
|
4216
|
-
async function
|
|
4797
|
+
async function getBody9(eventId) {
|
|
4217
4798
|
if (eventId === void 0 || eventId === "") fail(2 /* USAGE */, "An event_id is required.");
|
|
4218
4799
|
const detail4 = await apiErrors(async () => buildClient().triggers.events.get(eventId));
|
|
4219
4800
|
printOutput({ event: summarizeEvent(detail4.event), attempts: detail4.attempts });
|
|
@@ -4236,14 +4817,14 @@ function registerTriggerEvents(triggers) {
|
|
|
4236
4817
|
addUniversalOptions(events);
|
|
4237
4818
|
events.action(
|
|
4238
4819
|
async (triggerId, opts, command) => {
|
|
4239
|
-
await runCommand(command, opts, false, () =>
|
|
4820
|
+
await runCommand(command, opts, false, () => listBody11(triggerId, opts));
|
|
4240
4821
|
}
|
|
4241
4822
|
);
|
|
4242
4823
|
const get = events.command("get").description("One event plus its delivery attempts \u2014 the only place a real delivery state is read.").argument("[event_id]", "Event id (te_\u2026)");
|
|
4243
4824
|
get.addHelpText("after", "\nExamples:\n engini triggers events get te_abc123 --json");
|
|
4244
4825
|
addUniversalOptions(get);
|
|
4245
4826
|
get.action(async (eventId, opts, command) => {
|
|
4246
|
-
await runCommand(command, opts, false, () =>
|
|
4827
|
+
await runCommand(command, opts, false, () => getBody9(eventId));
|
|
4247
4828
|
});
|
|
4248
4829
|
const replay = events.command("replay").description("Re-deliver a captured event to its destination.").argument("[event_id]", "Event id (te_\u2026)");
|
|
4249
4830
|
replay.addHelpText(
|
|
@@ -4257,7 +4838,7 @@ function registerTriggerEvents(triggers) {
|
|
|
4257
4838
|
}
|
|
4258
4839
|
|
|
4259
4840
|
// src/triggers/get.ts
|
|
4260
|
-
async function
|
|
4841
|
+
async function getBody10(raw) {
|
|
4261
4842
|
const triggerId = parseTriggerId(raw);
|
|
4262
4843
|
const trigger = await apiErrors(async () => buildClient().triggers.get(triggerId));
|
|
4263
4844
|
printOutput(summarizeTrigger(trigger));
|
|
@@ -4267,7 +4848,7 @@ function registerTriggersGet(triggers) {
|
|
|
4267
4848
|
get.addHelpText("after", "\nExamples:\n engini triggers get ti_abc123 --json");
|
|
4268
4849
|
addUniversalOptions(get);
|
|
4269
4850
|
get.action(async (raw, opts, command) => {
|
|
4270
|
-
await runCommand(command, opts, false, () =>
|
|
4851
|
+
await runCommand(command, opts, false, () => getBody10(raw));
|
|
4271
4852
|
});
|
|
4272
4853
|
}
|
|
4273
4854
|
|
|
@@ -4383,7 +4964,7 @@ function registerTriggerListen(triggers) {
|
|
|
4383
4964
|
}
|
|
4384
4965
|
|
|
4385
4966
|
// src/triggers/list.ts
|
|
4386
|
-
async function
|
|
4967
|
+
async function listBody12(opts) {
|
|
4387
4968
|
const top = opts.top !== void 0 ? Number(opts.top) : void 0;
|
|
4388
4969
|
const triggers = await apiErrors(
|
|
4389
4970
|
async () => buildClient().triggers.list({
|
|
@@ -4412,7 +4993,7 @@ function registerTriggersList(triggers) {
|
|
|
4412
4993
|
);
|
|
4413
4994
|
addUniversalOptions(list);
|
|
4414
4995
|
list.action(async (opts, command) => {
|
|
4415
|
-
await runCommand(command, opts, false, () =>
|
|
4996
|
+
await runCommand(command, opts, false, () => listBody12(opts));
|
|
4416
4997
|
});
|
|
4417
4998
|
}
|
|
4418
4999
|
|
|
@@ -4451,7 +5032,7 @@ function registerTriggerDisable(triggers) {
|
|
|
4451
5032
|
}
|
|
4452
5033
|
|
|
4453
5034
|
// src/triggers/types.ts
|
|
4454
|
-
async function
|
|
5035
|
+
async function listBody13(opts) {
|
|
4455
5036
|
const types = await apiErrors(
|
|
4456
5037
|
async () => buildClient().triggers.types.list({
|
|
4457
5038
|
applicationSlug: opts.app,
|
|
@@ -4461,7 +5042,7 @@ async function listBody12(opts) {
|
|
|
4461
5042
|
);
|
|
4462
5043
|
printOutput(types);
|
|
4463
5044
|
}
|
|
4464
|
-
async function
|
|
5045
|
+
async function getBody11(slug, opts) {
|
|
4465
5046
|
if (slug === void 0 || slug === "") fail(2 /* USAGE */, "A trigger_slug is required.");
|
|
4466
5047
|
const type = await apiErrors(
|
|
4467
5048
|
async () => buildClient().triggers.types.get(slug, { applicationSlug: opts.app })
|
|
@@ -4476,14 +5057,14 @@ function registerTriggerTypes(triggers) {
|
|
|
4476
5057
|
);
|
|
4477
5058
|
addUniversalOptions(types);
|
|
4478
5059
|
types.action(async (opts, command) => {
|
|
4479
|
-
await runCommand(command, opts, false, () =>
|
|
5060
|
+
await runCommand(command, opts, false, () => listBody13(opts));
|
|
4480
5061
|
});
|
|
4481
5062
|
const get = types.command("get").description("One trigger type's config_schema, payload_schema and parameters.").argument("[trigger_slug]", "Trigger type slug").option("--app <slug>", "Disambiguate a slug shared by more than one application");
|
|
4482
5063
|
get.addHelpText("after", "\nExamples:\n engini triggers types get monday_item_created --json");
|
|
4483
5064
|
addUniversalOptions(get);
|
|
4484
5065
|
get.action(
|
|
4485
5066
|
async (slug, opts, command) => {
|
|
4486
|
-
await runCommand(command, opts, false, () =>
|
|
5067
|
+
await runCommand(command, opts, false, () => getBody11(slug, opts));
|
|
4487
5068
|
}
|
|
4488
5069
|
);
|
|
4489
5070
|
}
|