fix: resolve deprecation warning for apiKey value
Use the explicit $COMMANDCODE_API_KEY environment variable reference expected by newer pi versions while keeping compatibility with the legacy placeholder handling.
This commit is contained in:
@@ -83,7 +83,7 @@ export default async function (pi: ExtensionAPI) {
|
|||||||
pi.registerProvider("commandcode", {
|
pi.registerProvider("commandcode", {
|
||||||
name: "Command Code",
|
name: "Command Code",
|
||||||
baseUrl: API_BASE,
|
baseUrl: API_BASE,
|
||||||
apiKey: "COMMANDCODE_API_KEY",
|
apiKey: "$COMMANDCODE_API_KEY",
|
||||||
authHeader: true,
|
authHeader: true,
|
||||||
api: "commandcode-custom",
|
api: "commandcode-custom",
|
||||||
streamSimple: streamCommandCode,
|
streamSimple: streamCommandCode,
|
||||||
|
|||||||
+10
-3
@@ -193,10 +193,17 @@ export function createStreamCommandCode(deps: CoreDependencies) {
|
|||||||
const stream = deps.createStream()
|
const stream = deps.createStream()
|
||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
// OMP may pass the env-var name "COMMANDCODE_API_KEY" as the apiKey
|
// OMP may pass the legacy env-var name "COMMANDCODE_API_KEY" (old pi)
|
||||||
// value instead of resolving it. Filter out this specific string.
|
// or "$COMMANDCODE_API_KEY" (new pi) as the apiKey value instead of
|
||||||
|
// resolving it. Filter out these specific strings.
|
||||||
|
const LEGACY_API_KEY_REF = "$COMMANDCODE_API_KEY"
|
||||||
|
const OLD_API_KEY_REF = "COMMANDCODE_API_KEY"
|
||||||
const hostKey =
|
const hostKey =
|
||||||
options?.apiKey && options.apiKey !== "COMMANDCODE_API_KEY" ? options.apiKey : undefined
|
options?.apiKey &&
|
||||||
|
options.apiKey !== LEGACY_API_KEY_REF &&
|
||||||
|
options.apiKey !== OLD_API_KEY_REF
|
||||||
|
? options.apiKey
|
||||||
|
: undefined
|
||||||
|
|
||||||
const apiKey =
|
const apiKey =
|
||||||
hostKey ??
|
hostKey ??
|
||||||
|
|||||||
Reference in New Issue
Block a user