@primitivedotdev/cli 0.37.0 → 0.38.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.
|
@@ -949,6 +949,22 @@ function deleteCliCredentials(configDir) {
|
|
|
949
949
|
rmSync(credentialsPath(configDir), { force: true });
|
|
950
950
|
deleteChatState(configDir);
|
|
951
951
|
}
|
|
952
|
+
function saveSignupCredentials(params) {
|
|
953
|
+
deleteChatState(params.configDir);
|
|
954
|
+
saveCliCredentials(params.configDir, {
|
|
955
|
+
access_token: params.signup.access_token,
|
|
956
|
+
api_base_url: params.apiBaseUrl,
|
|
957
|
+
auth_method: "oauth",
|
|
958
|
+
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
959
|
+
expires_at: cliAccessTokenExpiresAt(params.signup.expires_in),
|
|
960
|
+
oauth_client_id: params.signup.oauth_client_id,
|
|
961
|
+
oauth_grant_id: params.signup.oauth_grant_id,
|
|
962
|
+
org_id: params.signup.org_id,
|
|
963
|
+
org_name: params.signup.org_name,
|
|
964
|
+
refresh_token: params.signup.refresh_token,
|
|
965
|
+
token_type: params.signup.token_type
|
|
966
|
+
});
|
|
967
|
+
}
|
|
952
968
|
function deleteCliCredentialsLock(configDir) {
|
|
953
969
|
rmSync(credentialsLockPath(configDir), {
|
|
954
970
|
force: true,
|
|
@@ -1311,4 +1327,4 @@ function redactCliEnvironment(environment) {
|
|
|
1311
1327
|
};
|
|
1312
1328
|
}
|
|
1313
1329
|
//#endregion
|
|
1314
|
-
export {
|
|
1330
|
+
export { PrimitiveApiClient as A, saveCliCredentials as C, loadActiveChatState as D, deleteChatState as E, createConfig as M, loadChatConversationByLocalId as O, resolveCliAuth as S, chatStatePath as T, deleteCliCredentials as _, normalizeCliEnvironmentName as a, loadCliCredentials as b, resolveConfigEnvironment as c, validateCliHeaderName as d, validateCliHeaderValue as f, credentialsPath as g, credentialsLockPath as h, loadCliConfig as i, createClient as j, saveActiveChatState as k, saveCliConfig as l, cliAccessTokenExpiresAt as m, deleteCliConfig as n, redactCliEnvironment as o, acquireCliCredentialsLock as p, emptyCliConfig as r, removeCliEnvironment as s, DEFAULT_ENVIRONMENT as t, upsertCliEnvironment as u, deleteCliCredentialsLock as v, saveSignupCredentials as w, normalizeApiBaseUrl as x, detectPrimitiveKeyEnvMisname as y };
|
package/dist/oclif/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as PrimitiveApiClient, C as saveCliCredentials, D as loadActiveChatState, E as deleteChatState, M as createConfig, O as loadChatConversationByLocalId, S as resolveCliAuth, T as chatStatePath, _ as deleteCliCredentials, a as normalizeCliEnvironmentName, b as loadCliCredentials, c as resolveConfigEnvironment, d as validateCliHeaderName, f as validateCliHeaderValue, g as credentialsPath, h as credentialsLockPath, i as loadCliConfig, j as createClient, k as saveActiveChatState, l as saveCliConfig, m as cliAccessTokenExpiresAt, n as deleteCliConfig, o as redactCliEnvironment, p as acquireCliCredentialsLock, r as emptyCliConfig, s as removeCliEnvironment, u as upsertCliEnvironment, v as deleteCliCredentialsLock, w as saveSignupCredentials, x as normalizeApiBaseUrl, y as detectPrimitiveKeyEnvMisname } from "../cli-config-B5hrwe8q.js";
|
|
2
2
|
import { Args, Command, Errors, Flags, ux } from "@oclif/core";
|
|
3
3
|
import { chmodSync, existsSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
@@ -14570,6 +14570,16 @@ const OPERATION_HINTS = {
|
|
|
14570
14570
|
verifyAgentSignup: "Tip: pass --verification-code <code> (or --code; both work). The response carries OAuth tokens but not your assigned inbox domain; run `primitive domains list` (or `primitive whoami`) after success to see the managed *.primitive.email address that routes to this account."
|
|
14571
14571
|
};
|
|
14572
14572
|
const OPERATION_FLAG_ALIASES = { verifyAgentSignup: { verification_code: ["code"] } };
|
|
14573
|
+
const OPERATION_SUCCESS_HOOKS = { verifyAgentSignup: ({ envelope, configDir, apiBaseUrl, writeStderr }) => {
|
|
14574
|
+
const data = envelope?.data;
|
|
14575
|
+
if (!data?.access_token || !data?.refresh_token) return;
|
|
14576
|
+
saveSignupCredentials({
|
|
14577
|
+
apiBaseUrl,
|
|
14578
|
+
configDir,
|
|
14579
|
+
signup: data
|
|
14580
|
+
});
|
|
14581
|
+
writeStderr("Credentials saved to the CLI config; `primitive whoami` will work on the next call.\n");
|
|
14582
|
+
} };
|
|
14573
14583
|
function createOperationCommand(operation) {
|
|
14574
14584
|
const { flags, bodyFieldFlagToProperty } = buildFlags(operation);
|
|
14575
14585
|
const baseDescription = operation.description !== null && operation.description !== void 0 ? canonicalizeCliReferences(operation.description) : `${operation.method} ${operation.path}`;
|
|
@@ -14663,6 +14673,20 @@ function createOperationCommand(operation) {
|
|
|
14663
14673
|
writeIdempotentReplayBannerIfReplay(envelope?.data, { write: (chunk) => {
|
|
14664
14674
|
process.stderr.write(chunk);
|
|
14665
14675
|
} });
|
|
14676
|
+
const successHook = OPERATION_SUCCESS_HOOKS[operation.sdkName];
|
|
14677
|
+
if (successHook) try {
|
|
14678
|
+
successHook({
|
|
14679
|
+
envelope,
|
|
14680
|
+
configDir: this.config.configDir,
|
|
14681
|
+
apiBaseUrl: auth.apiBaseUrl,
|
|
14682
|
+
writeStderr: (chunk) => {
|
|
14683
|
+
process.stderr.write(chunk);
|
|
14684
|
+
}
|
|
14685
|
+
});
|
|
14686
|
+
} catch (hookError) {
|
|
14687
|
+
const detail = hookError instanceof Error ? hookError.message : String(hookError);
|
|
14688
|
+
process.stderr.write(`Warning: ${operation.sdkName} succeeded but its post-success hook threw (${detail}). The response below is still valid; act on it manually.\n`);
|
|
14689
|
+
}
|
|
14666
14690
|
this.log(JSON.stringify(operationOutputPayload(envelope, parsedFlags.envelope === true), null, 2));
|
|
14667
14691
|
if (isIncompleteDomainVerification(operation, envelope)) {
|
|
14668
14692
|
writeIncompleteDomainVerificationHint();
|
|
@@ -17684,8 +17708,8 @@ const PRIMITIVE_TEAM_AUTHOR = {
|
|
|
17684
17708
|
name: "Primitive Team",
|
|
17685
17709
|
url: "https://primitive.dev"
|
|
17686
17710
|
};
|
|
17687
|
-
const SDK_VERSION_RANGE = "^0.
|
|
17688
|
-
const CLI_VERSION_RANGE = "^0.
|
|
17711
|
+
const SDK_VERSION_RANGE = "^0.38.0";
|
|
17712
|
+
const CLI_VERSION_RANGE = "^0.38.0";
|
|
17689
17713
|
const ESBUILD_VERSION_RANGE = "^0.27.0";
|
|
17690
17714
|
function renderHandler() {
|
|
17691
17715
|
return `// env.PRIMITIVE_API_KEY, env.PRIMITIVE_WEBHOOK_SECRET, and
|
|
@@ -20189,22 +20213,6 @@ async function checkExistingCredentials(params) {
|
|
|
20189
20213
|
}
|
|
20190
20214
|
throw cliError$2(`Already logged in${existing.org_name ? ` for ${existing.org_name}` : ""}. Run \`primitive logout\` before ${copy.actionGerund}.`);
|
|
20191
20215
|
}
|
|
20192
|
-
function saveSignupCredentials(params) {
|
|
20193
|
-
deleteChatState(params.configDir);
|
|
20194
|
-
saveCliCredentials(params.configDir, {
|
|
20195
|
-
access_token: params.signup.access_token,
|
|
20196
|
-
api_base_url: params.apiBaseUrl,
|
|
20197
|
-
auth_method: "oauth",
|
|
20198
|
-
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
20199
|
-
expires_at: cliAccessTokenExpiresAt(params.signup.expires_in),
|
|
20200
|
-
oauth_client_id: params.signup.oauth_client_id,
|
|
20201
|
-
oauth_grant_id: params.signup.oauth_grant_id,
|
|
20202
|
-
org_id: params.signup.org_id,
|
|
20203
|
-
org_name: params.signup.org_name,
|
|
20204
|
-
refresh_token: params.signup.refresh_token,
|
|
20205
|
-
token_type: params.signup.token_type
|
|
20206
|
-
});
|
|
20207
|
-
}
|
|
20208
20216
|
function writeStartInstructions(start, copy = DEFAULT_SIGNUP_COMMAND_COPY) {
|
|
20209
20217
|
process$1.stderr.write(`Sent a ${start.verification_code_length}-digit verification code to ${start.email}.\n`);
|
|
20210
20218
|
process$1.stderr.write(`The code expires in ${formatSignupSeconds(start.expires_in)}.\n`);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as resolveConfigEnvironment, i as loadCliConfig, x as normalizeApiBaseUrl } from "../cli-config-
|
|
1
|
+
import { c as resolveConfigEnvironment, i as loadCliConfig, x as normalizeApiBaseUrl } from "../cli-config-B5hrwe8q.js";
|
|
2
2
|
import { existsSync, readFileSync } from "node:fs";
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import { homedir } from "node:os";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@primitivedotdev/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.38.0",
|
|
4
4
|
"description": "Official Primitive CLI: deploy Primitive Functions, send and inspect mail, manage endpoints, all from the terminal. Wraps the @primitivedotdev/sdk runtime client with one-shot commands.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|