thinkwork-cli 0.12.1 → 0.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +81 -16
- package/dist/terraform/schema.graphql +10 -40
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1744,13 +1744,66 @@ function finalizeAws(profile, mode) {
|
|
|
1744
1744
|
` Override per-command with --profile <other>, or unset with \`rm ~/.thinkwork/config.json\`.`
|
|
1745
1745
|
)
|
|
1746
1746
|
);
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
);
|
|
1751
|
-
|
|
1752
|
-
|
|
1747
|
+
return identity;
|
|
1748
|
+
}
|
|
1749
|
+
async function offerApiLoginChain(opts) {
|
|
1750
|
+
const stages = listDeployedStages(opts.region);
|
|
1751
|
+
const candidates = stages.filter(
|
|
1752
|
+
(stage) => loadStageSession(stage) === null
|
|
1753
1753
|
);
|
|
1754
|
+
if (candidates.length === 0 || !isInteractive()) {
|
|
1755
|
+
console.log("");
|
|
1756
|
+
console.log(
|
|
1757
|
+
` ${chalk7.bold("Next:")} run ${chalk7.cyan("thinkwork login --stage <stage>")} if you also need`
|
|
1758
|
+
);
|
|
1759
|
+
console.log(
|
|
1760
|
+
` an API session (required for ${chalk7.cyan("eval")}, ${chalk7.cyan("agent")}, ${chalk7.cyan("thread")}, etc.).`
|
|
1761
|
+
);
|
|
1762
|
+
return;
|
|
1763
|
+
}
|
|
1764
|
+
console.log("");
|
|
1765
|
+
let chosen;
|
|
1766
|
+
if (candidates.length === 1) {
|
|
1767
|
+
const stage = candidates[0];
|
|
1768
|
+
const answer = await select2({
|
|
1769
|
+
message: `Also sign in to the API for stage "${stage}"? (required for eval / agent / thread)`,
|
|
1770
|
+
choices: [
|
|
1771
|
+
{ name: `Yes \u2014 sign in to ${stage}`, value: stage },
|
|
1772
|
+
{ name: "No \u2014 skip", value: null }
|
|
1773
|
+
]
|
|
1774
|
+
});
|
|
1775
|
+
chosen = answer ?? null;
|
|
1776
|
+
} else {
|
|
1777
|
+
const skip = "__skip__";
|
|
1778
|
+
const answer = await select2({
|
|
1779
|
+
message: "Also sign in to an API stage now?",
|
|
1780
|
+
choices: [
|
|
1781
|
+
...candidates.map((stage) => ({
|
|
1782
|
+
name: `Yes \u2014 ${stage}`,
|
|
1783
|
+
value: stage
|
|
1784
|
+
})),
|
|
1785
|
+
new Separator(),
|
|
1786
|
+
{ name: "Skip", value: skip }
|
|
1787
|
+
]
|
|
1788
|
+
});
|
|
1789
|
+
chosen = answer === skip ? null : answer;
|
|
1790
|
+
}
|
|
1791
|
+
if (!chosen) {
|
|
1792
|
+
console.log("");
|
|
1793
|
+
console.log(
|
|
1794
|
+
chalk7.dim(
|
|
1795
|
+
` Skipped. Run ${chalk7.cyan("thinkwork login --stage <stage>")} later for an API session.`
|
|
1796
|
+
)
|
|
1797
|
+
);
|
|
1798
|
+
return;
|
|
1799
|
+
}
|
|
1800
|
+
console.log("");
|
|
1801
|
+
await doCognitoLogin({
|
|
1802
|
+
stage: chosen,
|
|
1803
|
+
region: opts.region,
|
|
1804
|
+
port: opts.port,
|
|
1805
|
+
noBrowser: opts.noBrowser
|
|
1806
|
+
});
|
|
1754
1807
|
}
|
|
1755
1808
|
async function bootstrapUserAndTenant(stage, region, idToken) {
|
|
1756
1809
|
const baseUrl = getApiEndpoint(stage, region);
|
|
@@ -1879,7 +1932,7 @@ async function doApiKeyLogin(opts) {
|
|
|
1879
1932
|
}
|
|
1880
1933
|
function registerLoginCommand(program2) {
|
|
1881
1934
|
program2.command("login").description(
|
|
1882
|
-
"Sign in. Without --stage: configure AWS credentials (
|
|
1935
|
+
"Sign in. Without --stage: configure AWS credentials AND offer to sign in to a deployed stack's API (the natural one-step UX). With --stage <s>: go straight to that stack's Cognito / API login and cache a session for API-backed commands."
|
|
1883
1936
|
).option(
|
|
1884
1937
|
"--profile <name>",
|
|
1885
1938
|
'AWS profile name to configure (used when entering new keys or SSO). Defaults to "thinkwork" only on the AWS-credentials branch; the Cognito branch leaves AWS_PROFILE alone.'
|
|
@@ -1950,15 +2003,15 @@ Registered callback URL:
|
|
|
1950
2003
|
});
|
|
1951
2004
|
return;
|
|
1952
2005
|
}
|
|
1953
|
-
const
|
|
1954
|
-
if (!Number.isFinite(
|
|
2006
|
+
const port2 = Number.parseInt(opts.port, 10);
|
|
2007
|
+
if (!Number.isFinite(port2) || port2 < 1 || port2 > 65535) {
|
|
1955
2008
|
printError(`Invalid --port value: "${opts.port}".`);
|
|
1956
2009
|
process.exit(1);
|
|
1957
2010
|
}
|
|
1958
2011
|
await doCognitoLogin({
|
|
1959
2012
|
stage: opts.stage,
|
|
1960
2013
|
region: opts.region,
|
|
1961
|
-
port,
|
|
2014
|
+
port: port2,
|
|
1962
2015
|
noBrowser: opts.browser === false
|
|
1963
2016
|
});
|
|
1964
2017
|
return;
|
|
@@ -1967,16 +2020,24 @@ Registered callback URL:
|
|
|
1967
2020
|
printHeader("login", targetProfile);
|
|
1968
2021
|
const awsOk = await ensureAwsCli();
|
|
1969
2022
|
if (!awsOk) process.exit(1);
|
|
2023
|
+
const port = Number.parseInt(opts.port, 10);
|
|
2024
|
+
if (!Number.isFinite(port) || port < 1 || port > 65535) {
|
|
2025
|
+
printError(`Invalid --port value: "${opts.port}".`);
|
|
2026
|
+
process.exit(1);
|
|
2027
|
+
}
|
|
2028
|
+
const chainOpts = { port, noBrowser: opts.browser === false };
|
|
1970
2029
|
if (opts.sso) {
|
|
1971
2030
|
if (!runSsoLogin(targetProfile)) process.exit(1);
|
|
1972
2031
|
process.env.AWS_PROFILE = targetProfile;
|
|
1973
|
-
finalizeAws(targetProfile, "SSO");
|
|
2032
|
+
const { region: region2 } = finalizeAws(targetProfile, "SSO");
|
|
2033
|
+
await offerApiLoginChain({ region: region2, ...chainOpts });
|
|
1974
2034
|
return;
|
|
1975
2035
|
}
|
|
1976
2036
|
if (opts.keys) {
|
|
1977
2037
|
if (!await runKeyEntry(targetProfile)) process.exit(1);
|
|
1978
2038
|
process.env.AWS_PROFILE = targetProfile;
|
|
1979
|
-
finalizeAws(targetProfile, "access keys");
|
|
2039
|
+
const { region: region2 } = finalizeAws(targetProfile, "access keys");
|
|
2040
|
+
await offerApiLoginChain({ region: region2, ...chainOpts });
|
|
1980
2041
|
return;
|
|
1981
2042
|
}
|
|
1982
2043
|
const profiles = listAwsProfiles();
|
|
@@ -1988,7 +2049,8 @@ Registered callback URL:
|
|
|
1988
2049
|
);
|
|
1989
2050
|
if (!await runKeyEntry(targetProfile)) process.exit(1);
|
|
1990
2051
|
process.env.AWS_PROFILE = targetProfile;
|
|
1991
|
-
finalizeAws(targetProfile, "access keys");
|
|
2052
|
+
const { region: region2 } = finalizeAws(targetProfile, "access keys");
|
|
2053
|
+
await offerApiLoginChain({ region: region2, ...chainOpts });
|
|
1992
2054
|
return;
|
|
1993
2055
|
}
|
|
1994
2056
|
const choice = await pickProfile(profiles);
|
|
@@ -2000,13 +2062,15 @@ Registered callback URL:
|
|
|
2000
2062
|
if (choice.kind === "keys") {
|
|
2001
2063
|
if (!await runKeyEntry(targetProfile)) process.exit(1);
|
|
2002
2064
|
process.env.AWS_PROFILE = targetProfile;
|
|
2003
|
-
finalizeAws(targetProfile, "access keys");
|
|
2065
|
+
const { region: region2 } = finalizeAws(targetProfile, "access keys");
|
|
2066
|
+
await offerApiLoginChain({ region: region2, ...chainOpts });
|
|
2004
2067
|
return;
|
|
2005
2068
|
}
|
|
2006
2069
|
if (choice.kind === "sso") {
|
|
2007
2070
|
if (!runSsoLogin(targetProfile)) process.exit(1);
|
|
2008
2071
|
process.env.AWS_PROFILE = targetProfile;
|
|
2009
|
-
finalizeAws(targetProfile, "SSO");
|
|
2072
|
+
const { region: region2 } = finalizeAws(targetProfile, "SSO");
|
|
2073
|
+
await offerApiLoginChain({ region: region2, ...chainOpts });
|
|
2010
2074
|
return;
|
|
2011
2075
|
}
|
|
2012
2076
|
const picked = choice.name;
|
|
@@ -2020,7 +2084,8 @@ Registered callback URL:
|
|
|
2020
2084
|
process.exit(1);
|
|
2021
2085
|
}
|
|
2022
2086
|
process.env.AWS_PROFILE = picked;
|
|
2023
|
-
finalizeAws(picked, "existing profile");
|
|
2087
|
+
const { region } = finalizeAws(picked, "existing profile");
|
|
2088
|
+
await offerApiLoginChain({ region, ...chainOpts });
|
|
2024
2089
|
}
|
|
2025
2090
|
);
|
|
2026
2091
|
}
|
|
@@ -212,63 +212,33 @@ type Mutation {
|
|
|
212
212
|
|
|
213
213
|
type Subscription {
|
|
214
214
|
_empty: String
|
|
215
|
-
onAgentStatusChanged(tenantId: ID!): AgentStatusEvent
|
|
216
|
-
@aws_api_key
|
|
217
|
-
@aws_cognito_user_pools
|
|
218
|
-
@aws_iam
|
|
215
|
+
onAgentStatusChanged(tenantId: ID!): AgentStatusEvent @aws_api_key @aws_cognito_user_pools @aws_iam
|
|
219
216
|
@aws_subscribe(mutations: ["notifyAgentStatus"])
|
|
220
217
|
|
|
221
|
-
onNewMessage(threadId: ID!): NewMessageEvent
|
|
222
|
-
@aws_api_key
|
|
223
|
-
@aws_cognito_user_pools
|
|
224
|
-
@aws_iam
|
|
218
|
+
onNewMessage(threadId: ID!): NewMessageEvent @aws_api_key @aws_cognito_user_pools @aws_iam
|
|
225
219
|
@aws_subscribe(mutations: ["notifyNewMessage"])
|
|
226
220
|
|
|
227
|
-
onHeartbeatActivity(tenantId: ID!): HeartbeatActivityEvent
|
|
228
|
-
@aws_api_key
|
|
229
|
-
@aws_cognito_user_pools
|
|
230
|
-
@aws_iam
|
|
221
|
+
onHeartbeatActivity(tenantId: ID!): HeartbeatActivityEvent @aws_api_key @aws_cognito_user_pools @aws_iam
|
|
231
222
|
@aws_subscribe(mutations: ["notifyHeartbeatActivity"])
|
|
232
223
|
|
|
233
|
-
onThreadUpdated(tenantId: ID!): ThreadUpdateEvent
|
|
234
|
-
@aws_api_key
|
|
235
|
-
@aws_cognito_user_pools
|
|
236
|
-
@aws_iam
|
|
224
|
+
onThreadUpdated(tenantId: ID!): ThreadUpdateEvent @aws_api_key @aws_cognito_user_pools @aws_iam
|
|
237
225
|
@aws_subscribe(mutations: ["notifyThreadUpdate"])
|
|
238
226
|
|
|
239
|
-
onInboxItemStatusChanged(tenantId: ID!): InboxItemStatusEvent
|
|
240
|
-
@aws_api_key
|
|
241
|
-
@aws_cognito_user_pools
|
|
242
|
-
@aws_iam
|
|
227
|
+
onInboxItemStatusChanged(tenantId: ID!): InboxItemStatusEvent @aws_api_key @aws_cognito_user_pools @aws_iam
|
|
243
228
|
@aws_subscribe(mutations: ["notifyInboxItemUpdate"])
|
|
244
229
|
|
|
245
|
-
onThreadTurnUpdated(tenantId: ID!): ThreadTurnUpdateEvent
|
|
246
|
-
@aws_api_key
|
|
247
|
-
@aws_cognito_user_pools
|
|
248
|
-
@aws_iam
|
|
230
|
+
onThreadTurnUpdated(tenantId: ID!): ThreadTurnUpdateEvent @aws_api_key @aws_cognito_user_pools @aws_iam
|
|
249
231
|
@aws_subscribe(mutations: ["notifyThreadTurnUpdate"])
|
|
250
232
|
|
|
251
|
-
onComputerThreadChunk(threadId: ID!): ComputerThreadChunkEvent
|
|
252
|
-
@aws_api_key
|
|
253
|
-
@aws_cognito_user_pools
|
|
254
|
-
@aws_iam
|
|
233
|
+
onComputerThreadChunk(threadId: ID!): ComputerThreadChunkEvent @aws_api_key @aws_cognito_user_pools @aws_iam
|
|
255
234
|
@aws_subscribe(mutations: ["publishComputerThreadChunk"])
|
|
256
235
|
|
|
257
|
-
onOrgUpdated(tenantId: ID!): OrgUpdateEvent
|
|
258
|
-
@aws_api_key
|
|
259
|
-
@aws_cognito_user_pools
|
|
260
|
-
@aws_iam
|
|
236
|
+
onOrgUpdated(tenantId: ID!): OrgUpdateEvent @aws_api_key @aws_cognito_user_pools @aws_iam
|
|
261
237
|
@aws_subscribe(mutations: ["notifyOrgUpdate"])
|
|
262
238
|
|
|
263
|
-
onCostRecorded(tenantId: ID!): CostRecordedEvent
|
|
264
|
-
@aws_api_key
|
|
265
|
-
@aws_cognito_user_pools
|
|
266
|
-
@aws_iam
|
|
239
|
+
onCostRecorded(tenantId: ID!): CostRecordedEvent @aws_api_key @aws_cognito_user_pools @aws_iam
|
|
267
240
|
@aws_subscribe(mutations: ["notifyCostRecorded"])
|
|
268
241
|
|
|
269
|
-
onEvalRunUpdated(tenantId: ID!): EvalRunUpdateEvent
|
|
270
|
-
@aws_api_key
|
|
271
|
-
@aws_cognito_user_pools
|
|
272
|
-
@aws_iam
|
|
242
|
+
onEvalRunUpdated(tenantId: ID!): EvalRunUpdateEvent @aws_api_key @aws_cognito_user_pools @aws_iam
|
|
273
243
|
@aws_subscribe(mutations: ["notifyEvalRunUpdate"])
|
|
274
244
|
}
|