convex 1.37.0 → 1.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.
- package/CHANGELOG.md +14 -0
- package/dist/browser.bundle.js +1 -1
- package/dist/browser.bundle.js.map +1 -1
- package/dist/cjs/bundler/debugBundle.js +2 -1
- package/dist/cjs/bundler/debugBundle.js.map +2 -2
- package/dist/cjs/bundler/index.js +6 -3
- package/dist/cjs/bundler/index.js.map +2 -2
- package/dist/cjs/bundler/serverOnly.js +37 -0
- package/dist/cjs/bundler/serverOnly.js.map +7 -0
- package/dist/cjs/cli/configure.js +5 -32
- package/dist/cjs/cli/configure.js.map +2 -2
- package/dist/cjs/cli/deploy.js +1 -1
- package/dist/cjs/cli/deploy.js.map +1 -1
- package/dist/cjs/cli/deploymentCreate.js +21 -9
- package/dist/cjs/cli/deploymentCreate.js.map +2 -2
- package/dist/cjs/cli/deploymentSelect.js +25 -0
- package/dist/cjs/cli/deploymentSelect.js.map +2 -2
- package/dist/cjs/cli/deploymentTokenCreate.js +1 -1
- package/dist/cjs/cli/deploymentTokenCreate.js.map +2 -2
- package/dist/cjs/cli/deploymentTokenDelete.js +1 -1
- package/dist/cjs/cli/deploymentTokenDelete.js.map +2 -2
- package/dist/cjs/cli/index.js +5 -2
- package/dist/cjs/cli/index.js.map +2 -2
- package/dist/cjs/cli/lib/deploymentSelection.js +4 -7
- package/dist/cjs/cli/lib/deploymentSelection.js.map +2 -2
- package/dist/cjs/cli/lib/env.js +1 -0
- package/dist/cjs/cli/lib/env.js.map +2 -2
- package/dist/cjs/cli/lib/localDeployment/anonymous.js +4 -4
- package/dist/cjs/cli/lib/localDeployment/anonymous.js.map +2 -2
- package/dist/cjs/cli/lib/localDeployment/errors.js +1 -1
- package/dist/cjs/cli/lib/localDeployment/errors.js.map +2 -2
- package/dist/cjs/cli/lib/localDeployment/localDeployment.js +64 -9
- package/dist/cjs/cli/lib/localDeployment/localDeployment.js.map +2 -2
- package/dist/cjs/cli/lib/localDeployment/utils.js +19 -7
- package/dist/cjs/cli/lib/localDeployment/utils.js.map +3 -3
- package/dist/cjs/cli/lib/utils/globalConfig.js +1 -2
- package/dist/cjs/cli/lib/utils/globalConfig.js.map +2 -2
- package/dist/cjs/cli/lib/utils/utils.js +8 -0
- package/dist/cjs/cli/lib/utils/utils.js.map +2 -2
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/server/audit_logging.js +3 -1
- package/dist/cjs/server/audit_logging.js.map +2 -2
- package/dist/cjs/server/components/index.js +1 -12
- package/dist/cjs/server/components/index.js.map +2 -2
- package/dist/cjs/server/impl/registration_impl.js +8 -5
- package/dist/cjs/server/impl/registration_impl.js.map +2 -2
- package/dist/cjs/server/index.js.map +2 -2
- package/dist/cjs/server/log.js.map +2 -2
- package/dist/cjs/server/logVars.js.map +2 -2
- package/dist/cjs/server/meta.js.map +1 -1
- package/dist/cjs-types/bundler/debugBundle.d.ts.map +1 -1
- package/dist/cjs-types/bundler/index.d.ts.map +1 -1
- package/dist/cjs-types/bundler/serverOnly.d.ts +3 -0
- package/dist/cjs-types/bundler/serverOnly.d.ts.map +1 -0
- package/dist/cjs-types/cli/configure.d.ts.map +1 -1
- package/dist/cjs-types/cli/deploymentCreate.d.ts +4 -0
- package/dist/cjs-types/cli/deploymentCreate.d.ts.map +1 -1
- package/dist/cjs-types/cli/deploymentSelect.d.ts.map +1 -1
- package/dist/cjs-types/cli/deploymentTokenCreate.d.ts.map +1 -1
- package/dist/cjs-types/cli/deploymentTokenDelete.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/deployApi/componentDefinition.d.ts +6 -6
- package/dist/cjs-types/cli/lib/deployApi/modules.d.ts +6 -6
- package/dist/cjs-types/cli/lib/deployApi/startPush.d.ts +8 -8
- package/dist/cjs-types/cli/lib/deploymentSelection.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/env.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/localDeployment/anonymous.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/localDeployment/errors.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/localDeployment/localDeployment.d.ts +8 -0
- package/dist/cjs-types/cli/lib/localDeployment/localDeployment.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/localDeployment/utils.d.ts +13 -4
- package/dist/cjs-types/cli/lib/localDeployment/utils.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/utils/globalConfig.d.ts +0 -1
- package/dist/cjs-types/cli/lib/utils/globalConfig.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/utils/utils.d.ts +7 -0
- package/dist/cjs-types/cli/lib/utils/utils.d.ts.map +1 -1
- package/dist/cjs-types/index.d.ts +1 -1
- package/dist/cjs-types/server/audit_logging.d.ts +1 -0
- package/dist/cjs-types/server/audit_logging.d.ts.map +1 -1
- package/dist/cjs-types/server/components/index.d.ts.map +1 -1
- package/dist/cjs-types/server/impl/registration_impl.d.ts.map +1 -1
- package/dist/cjs-types/server/index.d.ts +2 -0
- package/dist/cjs-types/server/index.d.ts.map +1 -1
- package/dist/cjs-types/server/log.d.ts +28 -0
- package/dist/cjs-types/server/log.d.ts.map +1 -1
- package/dist/cjs-types/server/logVars.d.ts +1 -0
- package/dist/cjs-types/server/logVars.d.ts.map +1 -1
- package/dist/cjs-types/server/meta.d.ts +2 -0
- package/dist/cjs-types/server/meta.d.ts.map +1 -1
- package/dist/cli.bundle.cjs +1583 -1520
- package/dist/cli.bundle.cjs.map +4 -4
- package/dist/esm/bundler/debugBundle.js +2 -1
- package/dist/esm/bundler/debugBundle.js.map +2 -2
- package/dist/esm/bundler/index.js +6 -3
- package/dist/esm/bundler/index.js.map +2 -2
- package/dist/esm/bundler/serverOnly.js +15 -0
- package/dist/esm/bundler/serverOnly.js.map +7 -0
- package/dist/esm/cli/configure.js +5 -32
- package/dist/esm/cli/configure.js.map +2 -2
- package/dist/esm/cli/deploy.js +1 -1
- package/dist/esm/cli/deploy.js.map +1 -1
- package/dist/esm/cli/deploymentCreate.js +21 -10
- package/dist/esm/cli/deploymentCreate.js.map +2 -2
- package/dist/esm/cli/deploymentSelect.js +25 -0
- package/dist/esm/cli/deploymentSelect.js.map +2 -2
- package/dist/esm/cli/deploymentTokenCreate.js +2 -1
- package/dist/esm/cli/deploymentTokenCreate.js.map +2 -2
- package/dist/esm/cli/deploymentTokenDelete.js +2 -1
- package/dist/esm/cli/deploymentTokenDelete.js.map +2 -2
- package/dist/esm/cli/index.js +5 -2
- package/dist/esm/cli/index.js.map +2 -2
- package/dist/esm/cli/lib/deploymentSelection.js +5 -7
- package/dist/esm/cli/lib/deploymentSelection.js.map +2 -2
- package/dist/esm/cli/lib/env.js +2 -0
- package/dist/esm/cli/lib/env.js.map +2 -2
- package/dist/esm/cli/lib/localDeployment/anonymous.js +4 -4
- package/dist/esm/cli/lib/localDeployment/anonymous.js.map +2 -2
- package/dist/esm/cli/lib/localDeployment/errors.js +1 -1
- package/dist/esm/cli/lib/localDeployment/errors.js.map +2 -2
- package/dist/esm/cli/lib/localDeployment/localDeployment.js +70 -11
- package/dist/esm/cli/lib/localDeployment/localDeployment.js.map +2 -2
- package/dist/esm/cli/lib/localDeployment/utils.js +19 -7
- package/dist/esm/cli/lib/localDeployment/utils.js.map +3 -3
- package/dist/esm/cli/lib/utils/globalConfig.js +1 -2
- package/dist/esm/cli/lib/utils/globalConfig.js.map +2 -2
- package/dist/esm/cli/lib/utils/utils.js +6 -0
- package/dist/esm/cli/lib/utils/utils.js.map +2 -2
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/server/audit_logging.js +3 -1
- package/dist/esm/server/audit_logging.js.map +2 -2
- package/dist/esm/server/components/index.js +1 -12
- package/dist/esm/server/components/index.js.map +2 -2
- package/dist/esm/server/impl/registration_impl.js +8 -5
- package/dist/esm/server/impl/registration_impl.js.map +2 -2
- package/dist/esm/server/index.js.map +2 -2
- package/dist/esm/server/log.js.map +2 -2
- package/dist/esm/server/logVars.js.map +2 -2
- package/dist/esm-types/bundler/debugBundle.d.ts.map +1 -1
- package/dist/esm-types/bundler/index.d.ts.map +1 -1
- package/dist/esm-types/bundler/serverOnly.d.ts +3 -0
- package/dist/esm-types/bundler/serverOnly.d.ts.map +1 -0
- package/dist/esm-types/cli/configure.d.ts.map +1 -1
- package/dist/esm-types/cli/deploymentCreate.d.ts +4 -0
- package/dist/esm-types/cli/deploymentCreate.d.ts.map +1 -1
- package/dist/esm-types/cli/deploymentSelect.d.ts.map +1 -1
- package/dist/esm-types/cli/deploymentTokenCreate.d.ts.map +1 -1
- package/dist/esm-types/cli/deploymentTokenDelete.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/deployApi/componentDefinition.d.ts +6 -6
- package/dist/esm-types/cli/lib/deployApi/modules.d.ts +6 -6
- package/dist/esm-types/cli/lib/deployApi/startPush.d.ts +8 -8
- package/dist/esm-types/cli/lib/deploymentSelection.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/env.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/localDeployment/anonymous.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/localDeployment/errors.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/localDeployment/localDeployment.d.ts +8 -0
- package/dist/esm-types/cli/lib/localDeployment/localDeployment.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/localDeployment/utils.d.ts +13 -4
- package/dist/esm-types/cli/lib/localDeployment/utils.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/utils/globalConfig.d.ts +0 -1
- package/dist/esm-types/cli/lib/utils/globalConfig.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/utils/utils.d.ts +7 -0
- package/dist/esm-types/cli/lib/utils/utils.d.ts.map +1 -1
- package/dist/esm-types/index.d.ts +1 -1
- package/dist/esm-types/server/audit_logging.d.ts +1 -0
- package/dist/esm-types/server/audit_logging.d.ts.map +1 -1
- package/dist/esm-types/server/components/index.d.ts.map +1 -1
- package/dist/esm-types/server/impl/registration_impl.d.ts.map +1 -1
- package/dist/esm-types/server/index.d.ts +2 -0
- package/dist/esm-types/server/index.d.ts.map +1 -1
- package/dist/esm-types/server/log.d.ts +28 -0
- package/dist/esm-types/server/log.d.ts.map +1 -1
- package/dist/esm-types/server/logVars.d.ts +1 -0
- package/dist/esm-types/server/logVars.d.ts.map +1 -1
- package/dist/esm-types/server/meta.d.ts +2 -0
- package/dist/esm-types/server/meta.d.ts.map +1 -1
- package/dist/react.bundle.js +1 -1
- package/dist/react.bundle.js.map +1 -1
- package/package.json +1 -1
- package/schemas/convex.schema.json +1 -1
- package/src/bundler/debugBundle.ts +2 -1
- package/src/bundler/index.ts +7 -3
- package/src/bundler/serverOnly.ts +18 -0
- package/src/cli/configure.ts +2 -35
- package/src/cli/deploy.ts +1 -1
- package/src/cli/deploymentCreate.test.ts +4 -0
- package/src/cli/deploymentCreate.ts +23 -9
- package/src/cli/deploymentSelect.test.ts +60 -6
- package/src/cli/deploymentSelect.ts +34 -0
- package/src/cli/deploymentSelection.test.ts +72 -19
- package/src/cli/deploymentTokenCreate.ts +4 -1
- package/src/cli/deploymentTokenDelete.ts +9 -1
- package/src/cli/index.ts +6 -2
- package/src/cli/lib/deploymentSelection.ts +5 -7
- package/src/cli/lib/env.ts +2 -0
- package/src/cli/lib/localDeployment/anonymous.ts +5 -4
- package/src/cli/lib/localDeployment/errors.ts +1 -3
- package/src/cli/lib/localDeployment/localDeployment.ts +85 -10
- package/src/cli/lib/localDeployment/utils.ts +31 -7
- package/src/cli/lib/utils/globalConfig.ts +0 -3
- package/src/cli/lib/utils/utils.ts +15 -0
- package/src/index.ts +1 -1
- package/src/server/audit_logging.ts +2 -3
- package/src/server/components/index.ts +3 -15
- package/src/server/impl/registration_impl.ts +13 -7
- package/src/server/index.ts +0 -6
- package/src/server/log.ts +21 -3
- package/src/server/logVars.ts +0 -3
- package/src/server/meta.ts +0 -7
- package/dist/cjs/cli/disableLocalDev.js +0 -121
- package/dist/cjs/cli/disableLocalDev.js.map +0 -7
- package/dist/cjs-types/cli/disableLocalDev.d.ts +0 -6
- package/dist/cjs-types/cli/disableLocalDev.d.ts.map +0 -1
- package/dist/esm/cli/disableLocalDev.js +0 -105
- package/dist/esm/cli/disableLocalDev.js.map +0 -7
- package/dist/esm-types/cli/disableLocalDev.d.ts +0 -6
- package/dist/esm-types/cli/disableLocalDev.d.ts.map +0 -1
- package/src/cli/disableLocalDev.ts +0 -134
package/dist/cli.bundle.cjs
CHANGED
|
@@ -28695,7 +28695,7 @@ var version;
|
|
|
28695
28695
|
var init_index = __esm({
|
|
28696
28696
|
"src/index.ts"() {
|
|
28697
28697
|
"use strict";
|
|
28698
|
-
version = "1.
|
|
28698
|
+
version = "1.38.0";
|
|
28699
28699
|
}
|
|
28700
28700
|
});
|
|
28701
28701
|
|
|
@@ -31956,6 +31956,7 @@ var init_esm3 = __esm({
|
|
|
31956
31956
|
async function choosePorts(ctx, {
|
|
31957
31957
|
count,
|
|
31958
31958
|
requestedPorts,
|
|
31959
|
+
suggestedPorts,
|
|
31959
31960
|
startPort
|
|
31960
31961
|
}) {
|
|
31961
31962
|
const ports = [];
|
|
@@ -31972,6 +31973,14 @@ async function choosePorts(ctx, {
|
|
|
31972
31973
|
}
|
|
31973
31974
|
ports.push(port);
|
|
31974
31975
|
} else {
|
|
31976
|
+
const suggestedPort = (suggestedPorts == null ? void 0 : suggestedPorts[ports.length]) ?? null;
|
|
31977
|
+
if (suggestedPort !== null) {
|
|
31978
|
+
const port2 = await detect(suggestedPort);
|
|
31979
|
+
if (port2 === suggestedPort) {
|
|
31980
|
+
ports.push(suggestedPort);
|
|
31981
|
+
continue;
|
|
31982
|
+
}
|
|
31983
|
+
}
|
|
31975
31984
|
const portToTry = ports.length > 0 ? ports[ports.length - 1] + 1 : startPort;
|
|
31976
31985
|
const port = await detect(portToTry);
|
|
31977
31986
|
ports.push(port);
|
|
@@ -31979,11 +31988,19 @@ async function choosePorts(ctx, {
|
|
|
31979
31988
|
}
|
|
31980
31989
|
return ports;
|
|
31981
31990
|
}
|
|
31982
|
-
async function chooseLocalBackendPorts(ctx,
|
|
31991
|
+
async function chooseLocalBackendPorts(ctx, options) {
|
|
31992
|
+
const { suggestedPorts, requestedPorts } = options ?? {};
|
|
31983
31993
|
const [cloudPort, sitePort] = await choosePorts(ctx, {
|
|
31984
31994
|
count: 2,
|
|
31985
31995
|
startPort: 3210,
|
|
31986
|
-
requestedPorts: [
|
|
31996
|
+
requestedPorts: [
|
|
31997
|
+
(requestedPorts == null ? void 0 : requestedPorts.cloud) ?? null,
|
|
31998
|
+
(requestedPorts == null ? void 0 : requestedPorts.site) ?? null
|
|
31999
|
+
],
|
|
32000
|
+
suggestedPorts: [
|
|
32001
|
+
(suggestedPorts == null ? void 0 : suggestedPorts.cloud) ?? null,
|
|
32002
|
+
(suggestedPorts == null ? void 0 : suggestedPorts.site) ?? null
|
|
32003
|
+
]
|
|
31987
32004
|
});
|
|
31988
32005
|
return { cloudPort, sitePort };
|
|
31989
32006
|
}
|
|
@@ -31999,11 +32016,6 @@ function printLocalDeploymentWelcomeMessage() {
|
|
|
31999
32016
|
"To learn more, read the docs: https://docs.convex.dev/cli/local-deployments"
|
|
32000
32017
|
)
|
|
32001
32018
|
);
|
|
32002
|
-
logMessage(
|
|
32003
|
-
chalkStderr.cyan(
|
|
32004
|
-
"To opt out at any time, run `npx convex disable-local-deployments`"
|
|
32005
|
-
)
|
|
32006
|
-
);
|
|
32007
32019
|
}
|
|
32008
32020
|
function generateInstanceSecret() {
|
|
32009
32021
|
return import_crypto3.default.randomBytes(32).toString("hex");
|
|
@@ -32066,7 +32078,7 @@ var init_serve = __esm({
|
|
|
32066
32078
|
function printLocalDeploymentOnError() {
|
|
32067
32079
|
logFailure(`Hit an error while running local deployment.`);
|
|
32068
32080
|
logMessage(
|
|
32069
|
-
"Your error has been reported to our team, and we'll be working on it.
|
|
32081
|
+
"Your error has been reported to our team, and we'll be working on it."
|
|
32070
32082
|
);
|
|
32071
32083
|
}
|
|
32072
32084
|
var LocalDeploymentError;
|
|
@@ -53887,6 +53899,27 @@ var init_wasm = __esm({
|
|
|
53887
53899
|
}
|
|
53888
53900
|
});
|
|
53889
53901
|
|
|
53902
|
+
// src/bundler/serverOnly.ts
|
|
53903
|
+
var serverOnlyPlugin;
|
|
53904
|
+
var init_serverOnly = __esm({
|
|
53905
|
+
"src/bundler/serverOnly.ts"() {
|
|
53906
|
+
"use strict";
|
|
53907
|
+
serverOnlyPlugin = {
|
|
53908
|
+
name: "convex-server-only",
|
|
53909
|
+
setup(build) {
|
|
53910
|
+
build.onResolve({ filter: /^server-only$/ }, (args) => ({
|
|
53911
|
+
path: args.path,
|
|
53912
|
+
namespace: "server-only-stub"
|
|
53913
|
+
}));
|
|
53914
|
+
build.onLoad({ filter: /.*/, namespace: "server-only-stub" }, () => ({
|
|
53915
|
+
contents: "",
|
|
53916
|
+
loader: "js"
|
|
53917
|
+
}));
|
|
53918
|
+
}
|
|
53919
|
+
};
|
|
53920
|
+
}
|
|
53921
|
+
});
|
|
53922
|
+
|
|
53890
53923
|
// ../common/temp/node_modules/.pnpm/yocto-queue@1.2.2/node_modules/yocto-queue/index.js
|
|
53891
53924
|
var Node, _head, _tail, _size, Queue;
|
|
53892
53925
|
var init_yocto_queue = __esm({
|
|
@@ -54515,7 +54548,7 @@ async function debugIsolateBundlesSerially(ctx, {
|
|
|
54515
54548
|
chunksFolder: "_deps",
|
|
54516
54549
|
extraConditions,
|
|
54517
54550
|
dir,
|
|
54518
|
-
plugins: [plugin, wasmPlugin],
|
|
54551
|
+
plugins: [serverOnlyPlugin, plugin, wasmPlugin],
|
|
54519
54552
|
logLevel: "silent"
|
|
54520
54553
|
});
|
|
54521
54554
|
} catch (error3) {
|
|
@@ -54620,6 +54653,7 @@ var init_debugBundle = __esm({
|
|
|
54620
54653
|
import_esbuild = __toESM(require("esbuild"), 1);
|
|
54621
54654
|
init_log();
|
|
54622
54655
|
init_wasm();
|
|
54656
|
+
init_serverOnly();
|
|
54623
54657
|
init_depgraph();
|
|
54624
54658
|
}
|
|
54625
54659
|
});
|
|
@@ -54661,13 +54695,15 @@ async function doEsbuild({
|
|
|
54661
54695
|
chunksFolder,
|
|
54662
54696
|
extraConditions,
|
|
54663
54697
|
dir,
|
|
54664
|
-
//
|
|
54665
|
-
|
|
54698
|
+
// serverOnlyPlugin runs first so `server-only` is always stubbed,
|
|
54699
|
+
// even if it appears in the external packages list.
|
|
54700
|
+
// wasmPlugin runs last so it doesn't run on external modules.
|
|
54701
|
+
plugins: [serverOnlyPlugin, external.plugin, wasmPlugin],
|
|
54666
54702
|
includeSourcesContent,
|
|
54667
54703
|
splitting
|
|
54668
54704
|
});
|
|
54669
54705
|
for (const [relPath, input] of Object.entries(result.metafile.inputs)) {
|
|
54670
|
-
if (relPath.indexOf("(disabled):") !== -1 || relPath.startsWith("wasm-binary:") || relPath.startsWith("wasm-stub:")) {
|
|
54706
|
+
if (relPath.indexOf("(disabled):") !== -1 || relPath.startsWith("wasm-binary:") || relPath.startsWith("wasm-stub:") || relPath.startsWith("server-only-stub:")) {
|
|
54671
54707
|
continue;
|
|
54672
54708
|
}
|
|
54673
54709
|
const absPath = import_path8.default.resolve(relPath);
|
|
@@ -55030,6 +55066,7 @@ var init_bundler = __esm({
|
|
|
55030
55066
|
init_fs();
|
|
55031
55067
|
init_log();
|
|
55032
55068
|
init_wasm();
|
|
55069
|
+
init_serverOnly();
|
|
55033
55070
|
init_external2();
|
|
55034
55071
|
init_debugBundle();
|
|
55035
55072
|
actionsDir = "actions";
|
|
@@ -62557,6 +62594,7 @@ async function envSetFromContent(ctx, backend, options) {
|
|
|
62557
62594
|
const envVarsToSet = [];
|
|
62558
62595
|
const managedVars = /* @__PURE__ */ new Set([
|
|
62559
62596
|
CONVEX_DEPLOY_KEY_ENV_VAR_NAME,
|
|
62597
|
+
CONVEX_DEPLOYMENT_TOKEN_ENV_VAR_NAME,
|
|
62560
62598
|
CONVEX_DEPLOYMENT_ENV_VAR_NAME,
|
|
62561
62599
|
CONVEX_SELF_HOSTED_URL_VAR_NAME,
|
|
62562
62600
|
CONVEX_SELF_HOSTED_ADMIN_KEY_VAR_NAME,
|
|
@@ -78394,10 +78432,10 @@ async function handleAnonymousDeployment(ctx, options) {
|
|
|
78394
78432
|
});
|
|
78395
78433
|
adminKey = data2.adminKey;
|
|
78396
78434
|
}
|
|
78397
|
-
const { cloudPort, sitePort } = await chooseLocalBackendPorts(
|
|
78398
|
-
|
|
78399
|
-
|
|
78400
|
-
);
|
|
78435
|
+
const { cloudPort, sitePort } = await chooseLocalBackendPorts(ctx, {
|
|
78436
|
+
requestedPorts: options.ports,
|
|
78437
|
+
suggestedPorts: deployment2.kind === "existing" ? deployment2.config.ports : void 0
|
|
78438
|
+
});
|
|
78401
78439
|
const onActivity = async (isOffline2, _wasOffline) => {
|
|
78402
78440
|
await ensureBackendRunning(ctx, {
|
|
78403
78441
|
cloudPort,
|
|
@@ -78786,9 +78824,9 @@ var require_balanced_match = __commonJS({
|
|
|
78786
78824
|
}
|
|
78787
78825
|
});
|
|
78788
78826
|
|
|
78789
|
-
// ../common/temp/node_modules/.pnpm/brace-expansion@1.1.
|
|
78827
|
+
// ../common/temp/node_modules/.pnpm/brace-expansion@1.1.13/node_modules/brace-expansion/index.js
|
|
78790
78828
|
var require_brace_expansion = __commonJS({
|
|
78791
|
-
"../common/temp/node_modules/.pnpm/brace-expansion@1.1.
|
|
78829
|
+
"../common/temp/node_modules/.pnpm/brace-expansion@1.1.13/node_modules/brace-expansion/index.js"(exports2, module2) {
|
|
78792
78830
|
var concatMap = require_concat_map();
|
|
78793
78831
|
var balanced = require_balanced_match();
|
|
78794
78832
|
module2.exports = expandTop;
|
|
@@ -78883,7 +78921,7 @@ var require_brace_expansion = __commonJS({
|
|
|
78883
78921
|
var x = numeric(n[0]);
|
|
78884
78922
|
var y = numeric(n[1]);
|
|
78885
78923
|
var width = Math.max(n[0].length, n[1].length);
|
|
78886
|
-
var incr = n.length == 3 ? Math.abs(numeric(n[2])) : 1;
|
|
78924
|
+
var incr = n.length == 3 ? Math.max(Math.abs(numeric(n[2])), 1) : 1;
|
|
78887
78925
|
var test = lte;
|
|
78888
78926
|
var reverse = y < x;
|
|
78889
78927
|
if (reverse) {
|
|
@@ -88252,6 +88290,11 @@ async function processDeployKeyValue(ctx, deployKey) {
|
|
|
88252
88290
|
}
|
|
88253
88291
|
return deployKey;
|
|
88254
88292
|
}
|
|
88293
|
+
function readDeployKeyFromEnv(getEnv) {
|
|
88294
|
+
const fromDeployKey = getEnv(CONVEX_DEPLOY_KEY_ENV_VAR_NAME);
|
|
88295
|
+
const fromToken = getEnv(CONVEX_DEPLOYMENT_TOKEN_ENV_VAR_NAME);
|
|
88296
|
+
return fromDeployKey || fromToken || void 0;
|
|
88297
|
+
}
|
|
88255
88298
|
function parsePositiveInteger(value) {
|
|
88256
88299
|
const parsedValue = parseInteger(value);
|
|
88257
88300
|
if (parsedValue <= 0) {
|
|
@@ -88989,7 +89032,7 @@ async function currentPackageHomepage(ctx) {
|
|
|
88989
89032
|
}
|
|
88990
89033
|
return name;
|
|
88991
89034
|
}
|
|
88992
|
-
var import_os2, import_path29, import_child_process6, import_fetch_retry, retryingFetch, productionProvisionHost, provisionHost, BIG_BRAIN_URL, PLATFORM_MANAGEMENT_API_URL, ENV_VAR_FILE_PATH, CONVEX_DEPLOY_KEY_ENV_VAR_NAME, CONVEX_DEPLOYMENT_ENV_VAR_NAME, CONVEX_SELF_HOSTED_URL_VAR_NAME, CONVEX_SELF_HOSTED_ADMIN_KEY_VAR_NAME, MAX_RETRIES, RETRY_LOG_THRESHOLD, ThrowingFetchError, typedBigBrainClient, typedPlatformClient, BYTE_UNITS, IDEMPOTENT_METHODS;
|
|
89035
|
+
var import_os2, import_path29, import_child_process6, import_fetch_retry, retryingFetch, productionProvisionHost, provisionHost, BIG_BRAIN_URL, PLATFORM_MANAGEMENT_API_URL, ENV_VAR_FILE_PATH, CONVEX_DEPLOY_KEY_ENV_VAR_NAME, CONVEX_DEPLOYMENT_TOKEN_ENV_VAR_NAME, CONVEX_DEPLOYMENT_ENV_VAR_NAME, CONVEX_SELF_HOSTED_URL_VAR_NAME, CONVEX_SELF_HOSTED_ADMIN_KEY_VAR_NAME, MAX_RETRIES, RETRY_LOG_THRESHOLD, ThrowingFetchError, typedBigBrainClient, typedPlatformClient, BYTE_UNITS, IDEMPOTENT_METHODS;
|
|
88993
89036
|
var init_utils5 = __esm({
|
|
88994
89037
|
"src/cli/lib/utils/utils.ts"() {
|
|
88995
89038
|
"use strict";
|
|
@@ -89011,6 +89054,7 @@ var init_utils5 = __esm({
|
|
|
89011
89054
|
PLATFORM_MANAGEMENT_API_URL = `${provisionHost}/v1/`;
|
|
89012
89055
|
ENV_VAR_FILE_PATH = ".env.local";
|
|
89013
89056
|
CONVEX_DEPLOY_KEY_ENV_VAR_NAME = "CONVEX_DEPLOY_KEY";
|
|
89057
|
+
CONVEX_DEPLOYMENT_TOKEN_ENV_VAR_NAME = "CONVEX_DEPLOYMENT_TOKEN";
|
|
89014
89058
|
CONVEX_DEPLOYMENT_ENV_VAR_NAME = "CONVEX_DEPLOYMENT";
|
|
89015
89059
|
CONVEX_SELF_HOSTED_URL_VAR_NAME = "CONVEX_SELF_HOSTED_URL";
|
|
89016
89060
|
CONVEX_SELF_HOSTED_ADMIN_KEY_VAR_NAME = "CONVEX_SELF_HOSTED_ADMIN_KEY";
|
|
@@ -89638,6 +89682,64 @@ var init_deployment = __esm({
|
|
|
89638
89682
|
}
|
|
89639
89683
|
});
|
|
89640
89684
|
|
|
89685
|
+
// src/cli/lib/defaultEnv.ts
|
|
89686
|
+
function defaultEnvBackend(ctx, projectId, dtype) {
|
|
89687
|
+
return {
|
|
89688
|
+
async get(name) {
|
|
89689
|
+
const result = (await typedPlatformClient(ctx).GET(
|
|
89690
|
+
"/projects/{project_id}/list_default_environment_variables",
|
|
89691
|
+
{
|
|
89692
|
+
params: {
|
|
89693
|
+
path: { project_id: projectId },
|
|
89694
|
+
query: { name, deploymentType: dtype }
|
|
89695
|
+
}
|
|
89696
|
+
}
|
|
89697
|
+
)).data;
|
|
89698
|
+
const items = result.items;
|
|
89699
|
+
if (items.length === 0) return null;
|
|
89700
|
+
return { name: items[0].name, value: items[0].value };
|
|
89701
|
+
},
|
|
89702
|
+
async list() {
|
|
89703
|
+
const result = (await typedPlatformClient(ctx).GET(
|
|
89704
|
+
"/projects/{project_id}/list_default_environment_variables",
|
|
89705
|
+
{
|
|
89706
|
+
params: {
|
|
89707
|
+
path: { project_id: projectId },
|
|
89708
|
+
query: { deploymentType: dtype }
|
|
89709
|
+
}
|
|
89710
|
+
}
|
|
89711
|
+
)).data;
|
|
89712
|
+
return result.items.map(
|
|
89713
|
+
(item) => ({ name: item.name, value: item.value })
|
|
89714
|
+
);
|
|
89715
|
+
},
|
|
89716
|
+
async update(changes) {
|
|
89717
|
+
await typedPlatformClient(ctx).POST(
|
|
89718
|
+
"/projects/{project_id}/update_default_environment_variables",
|
|
89719
|
+
{
|
|
89720
|
+
params: {
|
|
89721
|
+
path: { project_id: projectId }
|
|
89722
|
+
},
|
|
89723
|
+
body: {
|
|
89724
|
+
changes: changes.map((c) => ({
|
|
89725
|
+
name: c.name,
|
|
89726
|
+
deploymentType: dtype,
|
|
89727
|
+
value: c.value ?? null
|
|
89728
|
+
}))
|
|
89729
|
+
}
|
|
89730
|
+
}
|
|
89731
|
+
);
|
|
89732
|
+
},
|
|
89733
|
+
notice: ` (in default env vars for ${dtype} deployments)`
|
|
89734
|
+
};
|
|
89735
|
+
}
|
|
89736
|
+
var init_defaultEnv = __esm({
|
|
89737
|
+
"src/cli/lib/defaultEnv.ts"() {
|
|
89738
|
+
"use strict";
|
|
89739
|
+
init_utils5();
|
|
89740
|
+
}
|
|
89741
|
+
});
|
|
89742
|
+
|
|
89641
89743
|
// src/cli/lib/localDeployment/localDeployment.ts
|
|
89642
89744
|
async function handleLocalDeployment(ctx, options) {
|
|
89643
89745
|
if (await isOffline()) {
|
|
@@ -89647,7 +89749,8 @@ async function handleLocalDeployment(ctx, options) {
|
|
|
89647
89749
|
projectSlug: options.projectSlug,
|
|
89648
89750
|
teamSlug: options.teamSlug
|
|
89649
89751
|
});
|
|
89650
|
-
|
|
89752
|
+
const isFirstTime = existingDeploymentForProject === null;
|
|
89753
|
+
if (isFirstTime) {
|
|
89651
89754
|
printLocalDeploymentWelcomeMessage();
|
|
89652
89755
|
}
|
|
89653
89756
|
ctx.registerCleanup(async (_exitCode, err) => {
|
|
@@ -89673,10 +89776,10 @@ async function handleLocalDeployment(ctx, options) {
|
|
|
89673
89776
|
allowedVersion: existingDeploymentForProject == null ? void 0 : existingDeploymentForProject.config.backendVersion
|
|
89674
89777
|
} : { kind: "version", version: options.backendVersion }
|
|
89675
89778
|
);
|
|
89676
|
-
const { cloudPort, sitePort } = await chooseLocalBackendPorts(
|
|
89677
|
-
|
|
89678
|
-
|
|
89679
|
-
);
|
|
89779
|
+
const { cloudPort, sitePort } = await chooseLocalBackendPorts(ctx, {
|
|
89780
|
+
requestedPorts: options.ports,
|
|
89781
|
+
suggestedPorts: existingDeploymentForProject == null ? void 0 : existingDeploymentForProject.config.ports
|
|
89782
|
+
});
|
|
89680
89783
|
const { deploymentName, adminKey } = await bigBrainStart(ctx, {
|
|
89681
89784
|
port: cloudPort,
|
|
89682
89785
|
projectSlug: options.projectSlug,
|
|
@@ -89707,6 +89810,15 @@ async function handleLocalDeployment(ctx, options) {
|
|
|
89707
89810
|
instanceSecret: LOCAL_BACKEND_INSTANCE_SECRET,
|
|
89708
89811
|
forceUpgrade: options.forceUpgrade
|
|
89709
89812
|
});
|
|
89813
|
+
if (isFirstTime) {
|
|
89814
|
+
await importDefaultEnvVars(ctx, {
|
|
89815
|
+
teamSlug: options.teamSlug,
|
|
89816
|
+
projectSlug: options.projectSlug,
|
|
89817
|
+
deploymentName,
|
|
89818
|
+
deploymentUrl: localDeploymentUrl(cloudPort),
|
|
89819
|
+
adminKey
|
|
89820
|
+
});
|
|
89821
|
+
}
|
|
89710
89822
|
let activityTimeout = null;
|
|
89711
89823
|
const scheduleActivityPing = () => {
|
|
89712
89824
|
activityTimeout = setTimeout(async () => {
|
|
@@ -89761,10 +89873,11 @@ async function handleOffline(ctx, options) {
|
|
|
89761
89873
|
kind: "version",
|
|
89762
89874
|
version: config3.backendVersion
|
|
89763
89875
|
});
|
|
89764
|
-
const { cloudPort, sitePort } = await chooseLocalBackendPorts(
|
|
89765
|
-
|
|
89766
|
-
|
|
89767
|
-
|
|
89876
|
+
const { cloudPort, sitePort } = await chooseLocalBackendPorts(ctx, {
|
|
89877
|
+
requestedPorts: options.ports
|
|
89878
|
+
// FIXME: This doesn’t try to reuse the ports already assigned in the config.
|
|
89879
|
+
// Please update this if we ever support offline mode (currently this is dead code).
|
|
89880
|
+
});
|
|
89768
89881
|
saveDeploymentConfig(ctx, "local", deploymentName, config3);
|
|
89769
89882
|
await runLocalBackend(ctx, {
|
|
89770
89883
|
binaryPath,
|
|
@@ -89878,6 +89991,46 @@ async function chooseFromExistingLocalDeployments(ctx) {
|
|
|
89878
89991
|
}))
|
|
89879
89992
|
});
|
|
89880
89993
|
}
|
|
89994
|
+
async function importDefaultEnvVars(ctx, {
|
|
89995
|
+
teamSlug,
|
|
89996
|
+
projectSlug,
|
|
89997
|
+
deploymentName,
|
|
89998
|
+
deploymentUrl,
|
|
89999
|
+
adminKey
|
|
90000
|
+
}) {
|
|
90001
|
+
showSpinner("Importing default env vars...");
|
|
90002
|
+
const project = await getProjectDetails(ctx, {
|
|
90003
|
+
kind: "teamAndProjectSlugs",
|
|
90004
|
+
teamSlug,
|
|
90005
|
+
projectSlug
|
|
90006
|
+
});
|
|
90007
|
+
const defaults = await defaultEnvBackend(ctx, project.id, "dev").list();
|
|
90008
|
+
if (defaults.length === 0) {
|
|
90009
|
+
logFinishedStep("No default env vars to import.");
|
|
90010
|
+
return;
|
|
90011
|
+
}
|
|
90012
|
+
const deployment2 = {
|
|
90013
|
+
deploymentUrl,
|
|
90014
|
+
deploymentFields: {
|
|
90015
|
+
deploymentName,
|
|
90016
|
+
deploymentType: "local",
|
|
90017
|
+
projectSlug,
|
|
90018
|
+
teamSlug
|
|
90019
|
+
}
|
|
90020
|
+
};
|
|
90021
|
+
await withRunningBackend({
|
|
90022
|
+
ctx,
|
|
90023
|
+
deployment: deployment2,
|
|
90024
|
+
action: async () => {
|
|
90025
|
+
await deploymentEnvBackend(ctx, { deploymentUrl, adminKey }).update(
|
|
90026
|
+
defaults.map((v2) => ({ name: v2.name, value: v2.value }))
|
|
90027
|
+
);
|
|
90028
|
+
logFinishedStep(
|
|
90029
|
+
`Imported ${defaults.length} environment ${defaults.length === 1 ? "variable" : "variables"} from default environment variables: ${defaults.map((v2) => v2.name).join(", ")}`
|
|
90030
|
+
);
|
|
90031
|
+
}
|
|
90032
|
+
});
|
|
90033
|
+
}
|
|
89881
90034
|
var init_localDeployment = __esm({
|
|
89882
90035
|
"src/cli/lib/localDeployment/localDeployment.ts"() {
|
|
89883
90036
|
"use strict";
|
|
@@ -89890,6 +90043,9 @@ var init_localDeployment = __esm({
|
|
|
89890
90043
|
init_errors2();
|
|
89891
90044
|
init_utils2();
|
|
89892
90045
|
init_download();
|
|
90046
|
+
init_defaultEnv();
|
|
90047
|
+
init_env();
|
|
90048
|
+
init_deploymentSelection();
|
|
89893
90049
|
}
|
|
89894
90050
|
});
|
|
89895
90051
|
|
|
@@ -90666,315 +90822,985 @@ var init_api3 = __esm({
|
|
|
90666
90822
|
}
|
|
90667
90823
|
});
|
|
90668
90824
|
|
|
90669
|
-
//
|
|
90670
|
-
|
|
90671
|
-
|
|
90672
|
-
|
|
90673
|
-
|
|
90674
|
-
|
|
90675
|
-
|
|
90676
|
-
|
|
90677
|
-
|
|
90678
|
-
|
|
90679
|
-
|
|
90680
|
-
error_uri && { error_uri },
|
|
90681
|
-
state && { state },
|
|
90682
|
-
scope && { scope },
|
|
90683
|
-
session_state && { session_state }
|
|
90684
|
-
);
|
|
90685
|
-
if (response) {
|
|
90686
|
-
Object.defineProperty(this, "response", {
|
|
90687
|
-
value: response
|
|
90688
|
-
});
|
|
90689
|
-
}
|
|
90690
|
-
this.name = this.constructor.name;
|
|
90691
|
-
Error.captureStackTrace(this, this.constructor);
|
|
90692
|
-
}
|
|
90693
|
-
};
|
|
90694
|
-
var RPError = class extends Error {
|
|
90695
|
-
constructor(...args) {
|
|
90696
|
-
if (typeof args[0] === "string") {
|
|
90697
|
-
super(format5(...args));
|
|
90698
|
-
} else {
|
|
90699
|
-
const { message, printf, response, ...rest } = args[0];
|
|
90700
|
-
if (printf) {
|
|
90701
|
-
super(format5(...printf));
|
|
90702
|
-
} else {
|
|
90703
|
-
super(message);
|
|
90704
|
-
}
|
|
90705
|
-
Object.assign(this, rest);
|
|
90706
|
-
if (response) {
|
|
90707
|
-
Object.defineProperty(this, "response", {
|
|
90708
|
-
value: response
|
|
90709
|
-
});
|
|
90710
|
-
}
|
|
90711
|
-
}
|
|
90712
|
-
this.name = this.constructor.name;
|
|
90713
|
-
Error.captureStackTrace(this, this.constructor);
|
|
90714
|
-
}
|
|
90715
|
-
};
|
|
90716
|
-
module2.exports = {
|
|
90717
|
-
OPError,
|
|
90718
|
-
RPError
|
|
90719
|
-
};
|
|
90825
|
+
// src/cli/lib/utils/globalConfig.ts
|
|
90826
|
+
function globalConfigPath() {
|
|
90827
|
+
return import_path30.default.join(rootDirectory(), "config.json");
|
|
90828
|
+
}
|
|
90829
|
+
function readGlobalConfig(ctx) {
|
|
90830
|
+
const configPath = globalConfigPath();
|
|
90831
|
+
let configFile;
|
|
90832
|
+
try {
|
|
90833
|
+
configFile = ctx.fs.readUtf8File(configPath);
|
|
90834
|
+
} catch {
|
|
90835
|
+
return null;
|
|
90720
90836
|
}
|
|
90721
|
-
|
|
90722
|
-
|
|
90723
|
-
|
|
90724
|
-
|
|
90725
|
-
|
|
90837
|
+
try {
|
|
90838
|
+
const storedConfig = JSON.parse(configFile);
|
|
90839
|
+
const config3 = schema.parse(storedConfig);
|
|
90840
|
+
return config3;
|
|
90841
|
+
} catch (err) {
|
|
90842
|
+
logError(
|
|
90843
|
+
chalkStderr.red(
|
|
90844
|
+
`Failed to parse global config in ${configPath} with error ${err}.`
|
|
90845
|
+
)
|
|
90846
|
+
);
|
|
90847
|
+
return null;
|
|
90848
|
+
}
|
|
90849
|
+
}
|
|
90850
|
+
async function modifyGlobalConfig(ctx, config3) {
|
|
90851
|
+
const configPath = globalConfigPath();
|
|
90852
|
+
let configFile;
|
|
90853
|
+
try {
|
|
90854
|
+
configFile = ctx.fs.readUtf8File(configPath);
|
|
90855
|
+
} catch {
|
|
90856
|
+
}
|
|
90857
|
+
let storedConfig = {};
|
|
90858
|
+
if (configFile) {
|
|
90859
|
+
try {
|
|
90860
|
+
storedConfig = JSON.parse(configFile);
|
|
90861
|
+
schema.parse(storedConfig);
|
|
90862
|
+
} catch (err) {
|
|
90863
|
+
logError(
|
|
90864
|
+
chalkStderr.red(
|
|
90865
|
+
`Failed to parse global config in ${configPath} with error ${err}.`
|
|
90866
|
+
)
|
|
90867
|
+
);
|
|
90868
|
+
storedConfig = {};
|
|
90869
|
+
}
|
|
90870
|
+
}
|
|
90871
|
+
const newConfig = { ...storedConfig, ...config3 };
|
|
90872
|
+
await overrwriteGlobalConfig(ctx, newConfig);
|
|
90873
|
+
}
|
|
90874
|
+
async function overrwriteGlobalConfig(ctx, config3) {
|
|
90875
|
+
const dirName = rootDirectory();
|
|
90876
|
+
ctx.fs.mkdir(dirName, { allowExisting: true });
|
|
90877
|
+
const path39 = globalConfigPath();
|
|
90878
|
+
try {
|
|
90879
|
+
ctx.fs.writeUtf8File(path39, JSON.stringify(config3, null, 2));
|
|
90880
|
+
} catch (err) {
|
|
90881
|
+
return await ctx.crash({
|
|
90882
|
+
exitCode: 1,
|
|
90883
|
+
errorType: "invalid filesystem data",
|
|
90884
|
+
errForSentry: err,
|
|
90885
|
+
printedMessage: chalkStderr.red(
|
|
90886
|
+
`Failed to write auth config to ${path39} with error: ${err}`
|
|
90887
|
+
)
|
|
90888
|
+
});
|
|
90889
|
+
}
|
|
90890
|
+
logVerbose(`Saved credentials to ${formatPathForPrinting(path39)}`);
|
|
90891
|
+
}
|
|
90892
|
+
function formatPathForPrinting(path39) {
|
|
90893
|
+
const homedir = import_os3.default.homedir();
|
|
90894
|
+
if (process.platform === "darwin" && path39.startsWith(homedir)) {
|
|
90895
|
+
return path39.replace(homedir, "~");
|
|
90896
|
+
}
|
|
90897
|
+
return path39;
|
|
90898
|
+
}
|
|
90899
|
+
var import_os3, import_path30, schema;
|
|
90900
|
+
var init_globalConfig = __esm({
|
|
90901
|
+
"src/cli/lib/utils/globalConfig.ts"() {
|
|
90726
90902
|
"use strict";
|
|
90727
|
-
|
|
90728
|
-
|
|
90729
|
-
|
|
90730
|
-
|
|
90903
|
+
init_source();
|
|
90904
|
+
import_os3 = __toESM(require("os"), 1);
|
|
90905
|
+
import_path30 = __toESM(require("path"), 1);
|
|
90906
|
+
init_utils5();
|
|
90907
|
+
init_log();
|
|
90908
|
+
init_zod();
|
|
90909
|
+
schema = external_exports.object({
|
|
90910
|
+
accessToken: external_exports.string().min(1)
|
|
90911
|
+
});
|
|
90731
90912
|
}
|
|
90732
90913
|
});
|
|
90733
90914
|
|
|
90734
|
-
//
|
|
90735
|
-
|
|
90736
|
-
|
|
90737
|
-
|
|
90738
|
-
|
|
90739
|
-
|
|
90740
|
-
|
|
90741
|
-
|
|
90742
|
-
|
|
90743
|
-
|
|
90744
|
-
|
|
90745
|
-
|
|
90746
|
-
|
|
90747
|
-
|
|
90748
|
-
|
|
90749
|
-
|
|
90750
|
-
|
|
90915
|
+
// src/cli/lib/deploymentSelection.ts
|
|
90916
|
+
async function initializeBigBrainAuth(ctx, initialArgs) {
|
|
90917
|
+
if (initialArgs.url !== void 0 && initialArgs.adminKey !== void 0) {
|
|
90918
|
+
ctx._updateBigBrainAuth(
|
|
90919
|
+
getBigBrainAuth(ctx, {
|
|
90920
|
+
previewDeployKey: null,
|
|
90921
|
+
projectKey: null,
|
|
90922
|
+
deploymentKey: null
|
|
90923
|
+
})
|
|
90924
|
+
);
|
|
90925
|
+
return;
|
|
90926
|
+
}
|
|
90927
|
+
if (initialArgs.envFile !== void 0) {
|
|
90928
|
+
const existingFile = ctx.fs.exists(initialArgs.envFile) ? ctx.fs.readUtf8File(initialArgs.envFile) : null;
|
|
90929
|
+
if (existingFile === null) {
|
|
90930
|
+
return ctx.crash({
|
|
90931
|
+
exitCode: 1,
|
|
90932
|
+
errorType: "invalid filesystem or env vars",
|
|
90933
|
+
printedMessage: "env file does not exist"
|
|
90751
90934
|
});
|
|
90752
|
-
return buf;
|
|
90753
90935
|
}
|
|
90754
|
-
|
|
90755
|
-
|
|
90756
|
-
|
|
90936
|
+
const config3 = dotenv5.parse(existingFile);
|
|
90937
|
+
const rawDeployKey2 = readDeployKeyFromEnv((name) => config3[name]);
|
|
90938
|
+
const deployKey2 = await processDeployKeyValue(ctx, rawDeployKey2);
|
|
90939
|
+
if (deployKey2 !== void 0) {
|
|
90940
|
+
const bigBrainAuth = getBigBrainAuth(ctx, {
|
|
90941
|
+
previewDeployKey: isPreviewDeployKey(deployKey2) ? deployKey2 : null,
|
|
90942
|
+
projectKey: isProjectKey(deployKey2) ? deployKey2 : null,
|
|
90943
|
+
deploymentKey: isDeploymentKey(deployKey2) ? deployKey2 : null
|
|
90944
|
+
});
|
|
90945
|
+
ctx._updateBigBrainAuth(bigBrainAuth);
|
|
90946
|
+
return;
|
|
90757
90947
|
}
|
|
90758
|
-
|
|
90759
|
-
|
|
90760
|
-
|
|
90761
|
-
|
|
90762
|
-
|
|
90763
|
-
|
|
90948
|
+
ctx._updateBigBrainAuth(
|
|
90949
|
+
getBigBrainAuth(ctx, {
|
|
90950
|
+
previewDeployKey: null,
|
|
90951
|
+
projectKey: null,
|
|
90952
|
+
deploymentKey: null
|
|
90953
|
+
})
|
|
90954
|
+
);
|
|
90955
|
+
return;
|
|
90956
|
+
}
|
|
90957
|
+
dotenv5.config({ path: ENV_VAR_FILE_PATH });
|
|
90958
|
+
dotenv5.config();
|
|
90959
|
+
const rawDeployKey = readDeployKeyFromEnv((name) => process.env[name]);
|
|
90960
|
+
const deployKey = await processDeployKeyValue(ctx, rawDeployKey);
|
|
90961
|
+
if (deployKey !== void 0) {
|
|
90962
|
+
const bigBrainAuth = getBigBrainAuth(ctx, {
|
|
90963
|
+
previewDeployKey: isPreviewDeployKey(deployKey) ? deployKey : null,
|
|
90964
|
+
projectKey: isProjectKey(deployKey) ? deployKey : null,
|
|
90965
|
+
deploymentKey: isDeploymentKey(deployKey) ? deployKey : null
|
|
90966
|
+
});
|
|
90967
|
+
ctx._updateBigBrainAuth(bigBrainAuth);
|
|
90968
|
+
return;
|
|
90969
|
+
}
|
|
90970
|
+
ctx._updateBigBrainAuth(
|
|
90971
|
+
getBigBrainAuth(ctx, {
|
|
90972
|
+
previewDeployKey: null,
|
|
90973
|
+
projectKey: null,
|
|
90974
|
+
deploymentKey: null
|
|
90975
|
+
})
|
|
90976
|
+
);
|
|
90977
|
+
return;
|
|
90978
|
+
}
|
|
90979
|
+
async function updateBigBrainAuthAfterLogin(ctx, accessToken) {
|
|
90980
|
+
const existingAuth = ctx.bigBrainAuth();
|
|
90981
|
+
if (existingAuth !== null && existingAuth.kind === "projectKey") {
|
|
90982
|
+
logVerbose(
|
|
90983
|
+
`Ignoring update to big brain auth since project key takes precedence`
|
|
90984
|
+
);
|
|
90985
|
+
return;
|
|
90986
|
+
}
|
|
90987
|
+
ctx._updateBigBrainAuth({
|
|
90988
|
+
accessToken,
|
|
90989
|
+
kind: "accessToken",
|
|
90990
|
+
header: `Bearer ${accessToken}`
|
|
90991
|
+
});
|
|
90992
|
+
}
|
|
90993
|
+
function getBigBrainAuth(ctx, opts) {
|
|
90994
|
+
if (process.env.CONVEX_OVERRIDE_ACCESS_TOKEN) {
|
|
90995
|
+
return {
|
|
90996
|
+
accessToken: process.env.CONVEX_OVERRIDE_ACCESS_TOKEN,
|
|
90997
|
+
kind: "accessToken",
|
|
90998
|
+
header: `Bearer ${process.env.CONVEX_OVERRIDE_ACCESS_TOKEN}`
|
|
90999
|
+
};
|
|
91000
|
+
}
|
|
91001
|
+
if (opts.projectKey !== null) {
|
|
91002
|
+
return {
|
|
91003
|
+
header: `Bearer ${opts.projectKey}`,
|
|
91004
|
+
kind: "projectKey",
|
|
91005
|
+
projectKey: opts.projectKey
|
|
91006
|
+
};
|
|
91007
|
+
}
|
|
91008
|
+
if (opts.deploymentKey !== null) {
|
|
91009
|
+
return {
|
|
91010
|
+
header: `Bearer ${opts.deploymentKey}`,
|
|
91011
|
+
kind: "deploymentKey",
|
|
91012
|
+
deploymentKey: opts.deploymentKey
|
|
91013
|
+
};
|
|
91014
|
+
}
|
|
91015
|
+
const globalConfig2 = readGlobalConfig(ctx);
|
|
91016
|
+
if (globalConfig2) {
|
|
91017
|
+
return {
|
|
91018
|
+
kind: "accessToken",
|
|
91019
|
+
header: `Bearer ${globalConfig2.accessToken}`,
|
|
91020
|
+
accessToken: globalConfig2.accessToken
|
|
91021
|
+
};
|
|
91022
|
+
}
|
|
91023
|
+
if (opts.previewDeployKey !== null) {
|
|
91024
|
+
return {
|
|
91025
|
+
header: `Bearer ${opts.previewDeployKey}`,
|
|
91026
|
+
kind: "previewDeployKey",
|
|
91027
|
+
previewDeployKey: opts.previewDeployKey
|
|
91028
|
+
};
|
|
91029
|
+
}
|
|
91030
|
+
return null;
|
|
91031
|
+
}
|
|
91032
|
+
async function getDeploymentSelection(ctx, cliArgs) {
|
|
91033
|
+
const metadata = await _getDeploymentSelection(ctx, cliArgs);
|
|
91034
|
+
if (metadata.kind === "existingDeployment") {
|
|
91035
|
+
const selectionWithinProject = deploymentSelectionWithinProjectFromOptions(cliArgs);
|
|
91036
|
+
await validateDeploymentSelectionForExistingDeployment(
|
|
91037
|
+
ctx,
|
|
91038
|
+
selectionWithinProject,
|
|
91039
|
+
metadata.deploymentToActOn.source
|
|
91040
|
+
);
|
|
91041
|
+
}
|
|
91042
|
+
logDeploymentSelection(ctx, metadata);
|
|
91043
|
+
return metadata;
|
|
91044
|
+
}
|
|
91045
|
+
function logDeploymentSelection(_ctx, selection) {
|
|
91046
|
+
switch (selection.kind) {
|
|
91047
|
+
case "existingDeployment": {
|
|
91048
|
+
logVerbose(
|
|
91049
|
+
`Existing deployment: ${selection.deploymentToActOn.url} ${selection.deploymentToActOn.source}`
|
|
91050
|
+
);
|
|
91051
|
+
break;
|
|
90764
91052
|
}
|
|
90765
|
-
|
|
90766
|
-
|
|
90767
|
-
|
|
90768
|
-
|
|
90769
|
-
|
|
90770
|
-
writeUInt32BE(buf, low, 4);
|
|
90771
|
-
return buf;
|
|
91053
|
+
case "deploymentWithinProject": {
|
|
91054
|
+
logVerbose(
|
|
91055
|
+
`Deployment within project: ${prettyProjectSelection(selection.targetProject)}`
|
|
91056
|
+
);
|
|
91057
|
+
break;
|
|
90772
91058
|
}
|
|
90773
|
-
|
|
90774
|
-
|
|
90775
|
-
|
|
90776
|
-
writeUInt32BE(buf, value);
|
|
90777
|
-
return buf;
|
|
91059
|
+
case "preview": {
|
|
91060
|
+
logVerbose(`Preview deploy key`);
|
|
91061
|
+
break;
|
|
90778
91062
|
}
|
|
90779
|
-
|
|
90780
|
-
|
|
90781
|
-
|
|
91063
|
+
case "chooseProject": {
|
|
91064
|
+
logVerbose(`Choose project`);
|
|
91065
|
+
break;
|
|
90782
91066
|
}
|
|
90783
|
-
|
|
90784
|
-
|
|
90785
|
-
|
|
90786
|
-
|
|
90787
|
-
|
|
90788
|
-
|
|
90789
|
-
|
|
90790
|
-
|
|
90791
|
-
|
|
90792
|
-
res.set(await (0, digest_js_1.default)("sha256", buf), iter * 32);
|
|
90793
|
-
}
|
|
90794
|
-
return res.slice(0, bits >> 3);
|
|
91067
|
+
case "anonymous": {
|
|
91068
|
+
logVerbose(
|
|
91069
|
+
`Anonymous, has selected deployment?: ${selection.deploymentName !== null}`
|
|
91070
|
+
);
|
|
91071
|
+
break;
|
|
91072
|
+
}
|
|
91073
|
+
default: {
|
|
91074
|
+
selection;
|
|
91075
|
+
logVerbose(`Unknown deployment selection`);
|
|
90795
91076
|
}
|
|
90796
|
-
exports2.concatKdf = concatKdf;
|
|
90797
91077
|
}
|
|
90798
|
-
|
|
90799
|
-
|
|
90800
|
-
|
|
90801
|
-
|
|
90802
|
-
|
|
90803
|
-
|
|
90804
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
90805
|
-
exports2.decode = exports2.encode = exports2.encodeBase64 = exports2.decodeBase64 = void 0;
|
|
90806
|
-
var buffer_1 = require("buffer");
|
|
90807
|
-
var buffer_utils_js_1 = require_buffer_utils();
|
|
90808
|
-
var encode;
|
|
90809
|
-
function normalize(input) {
|
|
90810
|
-
let encoded = input;
|
|
90811
|
-
if (encoded instanceof Uint8Array) {
|
|
90812
|
-
encoded = buffer_utils_js_1.decoder.decode(encoded);
|
|
90813
|
-
}
|
|
90814
|
-
return encoded;
|
|
91078
|
+
return null;
|
|
91079
|
+
}
|
|
91080
|
+
function prettyProjectSelection(selection) {
|
|
91081
|
+
switch (selection.kind) {
|
|
91082
|
+
case "teamAndProjectSlugs": {
|
|
91083
|
+
return `Team and project slugs: ${selection.teamSlug} ${selection.projectSlug}`;
|
|
90815
91084
|
}
|
|
90816
|
-
|
|
90817
|
-
|
|
90818
|
-
}
|
|
90819
|
-
|
|
91085
|
+
case "deploymentName": {
|
|
91086
|
+
return `Deployment name: ${selection.deploymentName}`;
|
|
91087
|
+
}
|
|
91088
|
+
case "projectDeployKey": {
|
|
91089
|
+
return `Project deploy key`;
|
|
91090
|
+
}
|
|
91091
|
+
default: {
|
|
91092
|
+
selection;
|
|
91093
|
+
return `Unknown`;
|
|
90820
91094
|
}
|
|
90821
|
-
var decodeBase64 = (input) => buffer_1.Buffer.from(input, "base64");
|
|
90822
|
-
exports2.decodeBase64 = decodeBase64;
|
|
90823
|
-
var encodeBase64 = (input) => buffer_1.Buffer.from(input).toString("base64");
|
|
90824
|
-
exports2.encodeBase64 = encodeBase64;
|
|
90825
|
-
var decode = (input) => buffer_1.Buffer.from(normalize(input), "base64");
|
|
90826
|
-
exports2.decode = decode;
|
|
90827
91095
|
}
|
|
90828
|
-
}
|
|
90829
|
-
|
|
90830
|
-
|
|
90831
|
-
|
|
90832
|
-
|
|
90833
|
-
|
|
90834
|
-
|
|
90835
|
-
|
|
90836
|
-
|
|
90837
|
-
|
|
90838
|
-
|
|
90839
|
-
}
|
|
90840
|
-
constructor(message) {
|
|
90841
|
-
var _a2;
|
|
90842
|
-
super(message);
|
|
90843
|
-
this.code = "ERR_JOSE_GENERIC";
|
|
90844
|
-
this.name = this.constructor.name;
|
|
90845
|
-
(_a2 = Error.captureStackTrace) === null || _a2 === void 0 ? void 0 : _a2.call(Error, this, this.constructor);
|
|
91096
|
+
}
|
|
91097
|
+
async function _getDeploymentSelection(ctx, cliArgs) {
|
|
91098
|
+
const selectionWithinProject = deploymentSelectionWithinProjectFromOptions(cliArgs);
|
|
91099
|
+
if (cliArgs.url !== void 0 && cliArgs.adminKey !== void 0) {
|
|
91100
|
+
return {
|
|
91101
|
+
kind: "existingDeployment",
|
|
91102
|
+
deploymentToActOn: {
|
|
91103
|
+
url: cliArgs.url,
|
|
91104
|
+
adminKey: cliArgs.adminKey,
|
|
91105
|
+
deploymentFields: null,
|
|
91106
|
+
source: "cliArgs"
|
|
90846
91107
|
}
|
|
90847
91108
|
};
|
|
90848
|
-
|
|
90849
|
-
|
|
90850
|
-
|
|
90851
|
-
|
|
91109
|
+
}
|
|
91110
|
+
if (cliArgs.deployment !== void 0) {
|
|
91111
|
+
const parsed = parseDeploymentSelector(cliArgs.deployment);
|
|
91112
|
+
if (parsed.kind === "inTeamProject") {
|
|
91113
|
+
return {
|
|
91114
|
+
kind: "deploymentWithinProject",
|
|
91115
|
+
targetProject: {
|
|
91116
|
+
kind: "teamAndProjectSlugs",
|
|
91117
|
+
teamSlug: parsed.teamSlug,
|
|
91118
|
+
projectSlug: parsed.projectSlug
|
|
91119
|
+
},
|
|
91120
|
+
selectionWithinProject: {
|
|
91121
|
+
kind: "deploymentSelector",
|
|
91122
|
+
selector: cliArgs.deployment
|
|
91123
|
+
}
|
|
91124
|
+
};
|
|
91125
|
+
}
|
|
91126
|
+
if (parsed.kind === "deploymentName") {
|
|
91127
|
+
return {
|
|
91128
|
+
kind: "deploymentWithinProject",
|
|
91129
|
+
targetProject: {
|
|
91130
|
+
kind: "deploymentName",
|
|
91131
|
+
deploymentName: parsed.deploymentName,
|
|
91132
|
+
deploymentType: null
|
|
91133
|
+
},
|
|
91134
|
+
selectionWithinProject: {
|
|
91135
|
+
kind: "deploymentSelector",
|
|
91136
|
+
selector: cliArgs.deployment
|
|
91137
|
+
}
|
|
91138
|
+
};
|
|
91139
|
+
}
|
|
91140
|
+
if (parsed.kind === "local") {
|
|
91141
|
+
const localConfig = loadProjectLocalConfig(ctx);
|
|
91142
|
+
if (localConfig !== null) {
|
|
91143
|
+
return {
|
|
91144
|
+
kind: "deploymentWithinProject",
|
|
91145
|
+
targetProject: {
|
|
91146
|
+
kind: "deploymentName",
|
|
91147
|
+
deploymentName: localConfig.deploymentName,
|
|
91148
|
+
deploymentType: "local"
|
|
91149
|
+
},
|
|
91150
|
+
selectionWithinProject
|
|
91151
|
+
};
|
|
90852
91152
|
}
|
|
90853
|
-
|
|
90854
|
-
|
|
90855
|
-
|
|
90856
|
-
|
|
90857
|
-
|
|
91153
|
+
return ctx.crash({
|
|
91154
|
+
exitCode: 1,
|
|
91155
|
+
errorType: "fatal",
|
|
91156
|
+
printedMessage: `No local deployment found. Run ${chalkStderr.bold("npx convex deployment create local")} to create one.`
|
|
91157
|
+
});
|
|
91158
|
+
}
|
|
91159
|
+
}
|
|
91160
|
+
if (cliArgs.envFile !== void 0) {
|
|
91161
|
+
logVerbose(`Checking env file: ${cliArgs.envFile}`);
|
|
91162
|
+
const existingFile = ctx.fs.exists(cliArgs.envFile) ? ctx.fs.readUtf8File(cliArgs.envFile) : null;
|
|
91163
|
+
if (existingFile === null) {
|
|
91164
|
+
return ctx.crash({
|
|
91165
|
+
exitCode: 1,
|
|
91166
|
+
errorType: "invalid filesystem or env vars",
|
|
91167
|
+
printedMessage: "env file does not exist"
|
|
91168
|
+
});
|
|
91169
|
+
}
|
|
91170
|
+
const config3 = dotenv5.parse(existingFile);
|
|
91171
|
+
const result2 = await getDeploymentSelectionFromEnv(
|
|
91172
|
+
ctx,
|
|
91173
|
+
selectionWithinProject,
|
|
91174
|
+
(name) => config3[name] === void 0 || config3[name] === "" ? null : config3[name]
|
|
91175
|
+
);
|
|
91176
|
+
if (result2.kind === "unknown") {
|
|
91177
|
+
return ctx.crash({
|
|
91178
|
+
exitCode: 1,
|
|
91179
|
+
errorType: "invalid filesystem or env vars",
|
|
91180
|
+
printedMessage: `env file \`${cliArgs.envFile}\` did not contain environment variables for a Convex deployment. Expected \`${CONVEX_DEPLOY_KEY_ENV_VAR_NAME}\`, \`${CONVEX_DEPLOYMENT_ENV_VAR_NAME}\`, or both \`${CONVEX_SELF_HOSTED_URL_VAR_NAME}\` and \`${CONVEX_SELF_HOSTED_ADMIN_KEY_VAR_NAME}\` to be set.`
|
|
91181
|
+
});
|
|
91182
|
+
}
|
|
91183
|
+
return result2.metadata;
|
|
91184
|
+
}
|
|
91185
|
+
dotenv5.config({ path: ENV_VAR_FILE_PATH });
|
|
91186
|
+
dotenv5.config();
|
|
91187
|
+
const result = await getDeploymentSelectionFromEnv(
|
|
91188
|
+
ctx,
|
|
91189
|
+
selectionWithinProject,
|
|
91190
|
+
(name) => {
|
|
91191
|
+
const value = process.env[name];
|
|
91192
|
+
if (value === void 0 || value === "") {
|
|
91193
|
+
return null;
|
|
90858
91194
|
}
|
|
91195
|
+
return value;
|
|
91196
|
+
}
|
|
91197
|
+
);
|
|
91198
|
+
if (result.kind !== "unknown") {
|
|
91199
|
+
return result.metadata;
|
|
91200
|
+
}
|
|
91201
|
+
const isLoggedIn = ctx.bigBrainAuth() !== null;
|
|
91202
|
+
if ((!isLoggedIn || process.env.CONVEX_AGENT_MODE === "anonymous" || !process.stdin.isTTY) && !cliArgs.implicitProd && shouldAllowAnonymousDevelopment()) {
|
|
91203
|
+
return {
|
|
91204
|
+
kind: "anonymous",
|
|
91205
|
+
deploymentName: null,
|
|
91206
|
+
selectionWithinProject
|
|
90859
91207
|
};
|
|
90860
|
-
|
|
90861
|
-
|
|
90862
|
-
|
|
90863
|
-
|
|
90864
|
-
|
|
90865
|
-
|
|
90866
|
-
|
|
90867
|
-
|
|
90868
|
-
|
|
90869
|
-
|
|
91208
|
+
}
|
|
91209
|
+
return {
|
|
91210
|
+
kind: "chooseProject",
|
|
91211
|
+
selectionWithinProject
|
|
91212
|
+
};
|
|
91213
|
+
}
|
|
91214
|
+
async function getDeploymentSelectionFromEnv(ctx, selectionWithinProject, getEnv) {
|
|
91215
|
+
const rawDeployKey = readDeployKeyFromEnv(getEnv);
|
|
91216
|
+
const deployKey = await processDeployKeyValue(ctx, rawDeployKey);
|
|
91217
|
+
if (deployKey !== void 0) {
|
|
91218
|
+
const deployKeyType = isPreviewDeployKey(deployKey) ? "preview" : isProjectKey(deployKey) ? "project" : "deployment";
|
|
91219
|
+
switch (deployKeyType) {
|
|
91220
|
+
case "preview": {
|
|
91221
|
+
return {
|
|
91222
|
+
kind: "success",
|
|
91223
|
+
metadata: {
|
|
91224
|
+
kind: "preview",
|
|
91225
|
+
previewDeployKey: deployKey,
|
|
91226
|
+
selectionWithinProject
|
|
91227
|
+
}
|
|
91228
|
+
};
|
|
90870
91229
|
}
|
|
90871
|
-
|
|
90872
|
-
|
|
90873
|
-
|
|
90874
|
-
|
|
90875
|
-
|
|
90876
|
-
|
|
91230
|
+
case "project": {
|
|
91231
|
+
return {
|
|
91232
|
+
kind: "success",
|
|
91233
|
+
metadata: {
|
|
91234
|
+
kind: "deploymentWithinProject",
|
|
91235
|
+
targetProject: {
|
|
91236
|
+
kind: "projectDeployKey",
|
|
91237
|
+
projectDeployKey: deployKey
|
|
91238
|
+
},
|
|
91239
|
+
selectionWithinProject
|
|
91240
|
+
}
|
|
91241
|
+
};
|
|
90877
91242
|
}
|
|
90878
|
-
|
|
90879
|
-
|
|
91243
|
+
case "deployment": {
|
|
91244
|
+
const deploymentName = await deploymentNameFromAdminKeyOrCrash(
|
|
91245
|
+
ctx,
|
|
91246
|
+
deployKey
|
|
91247
|
+
);
|
|
91248
|
+
const deploymentType = deploymentTypeFromAdminKey(deployKey);
|
|
91249
|
+
const url = await bigBrainAPI({
|
|
91250
|
+
ctx,
|
|
91251
|
+
method: "POST",
|
|
91252
|
+
path: "deployment/url_for_key",
|
|
91253
|
+
data: {
|
|
91254
|
+
deployKey
|
|
91255
|
+
}
|
|
91256
|
+
});
|
|
91257
|
+
const slugs = await fetchTeamAndProjectForKey(ctx, deployKey);
|
|
91258
|
+
return {
|
|
91259
|
+
kind: "success",
|
|
91260
|
+
metadata: {
|
|
91261
|
+
kind: "existingDeployment",
|
|
91262
|
+
deploymentToActOn: {
|
|
91263
|
+
url,
|
|
91264
|
+
adminKey: deployKey,
|
|
91265
|
+
deploymentFields: {
|
|
91266
|
+
deploymentName,
|
|
91267
|
+
deploymentType,
|
|
91268
|
+
teamSlug: slugs.team,
|
|
91269
|
+
projectSlug: slugs.project
|
|
91270
|
+
},
|
|
91271
|
+
source: "deployKey"
|
|
91272
|
+
}
|
|
91273
|
+
}
|
|
91274
|
+
};
|
|
90880
91275
|
}
|
|
90881
|
-
|
|
90882
|
-
|
|
90883
|
-
|
|
90884
|
-
|
|
90885
|
-
|
|
90886
|
-
|
|
91276
|
+
default: {
|
|
91277
|
+
deployKeyType;
|
|
91278
|
+
return ctx.crash({
|
|
91279
|
+
exitCode: 1,
|
|
91280
|
+
errorType: "fatal",
|
|
91281
|
+
printedMessage: `Unexpected deploy key type: ${deployKeyType}`
|
|
91282
|
+
});
|
|
90887
91283
|
}
|
|
90888
|
-
|
|
90889
|
-
|
|
91284
|
+
}
|
|
91285
|
+
}
|
|
91286
|
+
const convexDeployment = getEnv(CONVEX_DEPLOYMENT_ENV_VAR_NAME);
|
|
91287
|
+
const selfHostedUrl = getEnv(CONVEX_SELF_HOSTED_URL_VAR_NAME);
|
|
91288
|
+
const selfHostedAdminKey = getEnv(CONVEX_SELF_HOSTED_ADMIN_KEY_VAR_NAME);
|
|
91289
|
+
if (selfHostedUrl !== null && selfHostedAdminKey !== null) {
|
|
91290
|
+
if (convexDeployment !== null) {
|
|
91291
|
+
return await ctx.crash({
|
|
91292
|
+
exitCode: 1,
|
|
91293
|
+
errorType: "invalid filesystem or env vars",
|
|
91294
|
+
printedMessage: `${CONVEX_DEPLOYMENT_ENV_VAR_NAME} must not be set when ${CONVEX_SELF_HOSTED_URL_VAR_NAME} and ${CONVEX_SELF_HOSTED_ADMIN_KEY_VAR_NAME} are set`
|
|
91295
|
+
});
|
|
91296
|
+
}
|
|
91297
|
+
return {
|
|
91298
|
+
kind: "success",
|
|
91299
|
+
metadata: {
|
|
91300
|
+
kind: "existingDeployment",
|
|
91301
|
+
deploymentToActOn: {
|
|
91302
|
+
url: selfHostedUrl,
|
|
91303
|
+
adminKey: selfHostedAdminKey,
|
|
91304
|
+
deploymentFields: null,
|
|
91305
|
+
source: "selfHosted"
|
|
91306
|
+
}
|
|
90890
91307
|
}
|
|
90891
91308
|
};
|
|
90892
|
-
|
|
90893
|
-
|
|
90894
|
-
|
|
90895
|
-
|
|
90896
|
-
|
|
90897
|
-
|
|
90898
|
-
|
|
90899
|
-
|
|
90900
|
-
|
|
91309
|
+
}
|
|
91310
|
+
if (selectionWithinProject.kind === "deploymentName") {
|
|
91311
|
+
return {
|
|
91312
|
+
kind: "success",
|
|
91313
|
+
metadata: {
|
|
91314
|
+
kind: "deploymentWithinProject",
|
|
91315
|
+
targetProject: {
|
|
91316
|
+
kind: "deploymentName",
|
|
91317
|
+
deploymentName: selectionWithinProject.deploymentName,
|
|
91318
|
+
deploymentType: null
|
|
91319
|
+
},
|
|
91320
|
+
selectionWithinProject
|
|
90901
91321
|
}
|
|
90902
91322
|
};
|
|
90903
|
-
|
|
90904
|
-
|
|
90905
|
-
|
|
90906
|
-
|
|
90907
|
-
|
|
90908
|
-
|
|
91323
|
+
}
|
|
91324
|
+
if (convexDeployment !== null) {
|
|
91325
|
+
if (selfHostedUrl !== null || selfHostedAdminKey !== null) {
|
|
91326
|
+
return await ctx.crash({
|
|
91327
|
+
exitCode: 1,
|
|
91328
|
+
errorType: "invalid filesystem or env vars",
|
|
91329
|
+
printedMessage: `${CONVEX_SELF_HOSTED_URL_VAR_NAME} and ${CONVEX_SELF_HOSTED_ADMIN_KEY_VAR_NAME} must not be set when ${CONVEX_DEPLOYMENT_ENV_VAR_NAME} is set`
|
|
91330
|
+
});
|
|
91331
|
+
}
|
|
91332
|
+
const targetDeploymentType = getDeploymentTypeFromConfiguredDeployment(convexDeployment);
|
|
91333
|
+
const targetDeploymentName = stripDeploymentTypePrefix(convexDeployment);
|
|
91334
|
+
const isAnonymous = isAnonymousDeployment(targetDeploymentName);
|
|
91335
|
+
if (isAnonymous) {
|
|
91336
|
+
if (!shouldAllowAnonymousDevelopment()) {
|
|
91337
|
+
return {
|
|
91338
|
+
kind: "unknown"
|
|
91339
|
+
};
|
|
90909
91340
|
}
|
|
90910
|
-
|
|
90911
|
-
|
|
91341
|
+
return {
|
|
91342
|
+
kind: "success",
|
|
91343
|
+
metadata: {
|
|
91344
|
+
kind: "anonymous",
|
|
91345
|
+
deploymentName: targetDeploymentName,
|
|
91346
|
+
selectionWithinProject
|
|
91347
|
+
}
|
|
91348
|
+
};
|
|
91349
|
+
}
|
|
91350
|
+
const newSelectionWithinProject = selectionWithinProject.kind === "unspecified" && // Fetching local deployment credentials uses the "unspecified" code path
|
|
91351
|
+
targetDeploymentType !== "local" ? {
|
|
91352
|
+
kind: "deploymentName",
|
|
91353
|
+
deploymentName: targetDeploymentName
|
|
91354
|
+
} : selectionWithinProject;
|
|
91355
|
+
return {
|
|
91356
|
+
kind: "success",
|
|
91357
|
+
metadata: {
|
|
91358
|
+
kind: "deploymentWithinProject",
|
|
91359
|
+
targetProject: {
|
|
91360
|
+
kind: "deploymentName",
|
|
91361
|
+
deploymentName: targetDeploymentName,
|
|
91362
|
+
deploymentType: targetDeploymentType
|
|
91363
|
+
},
|
|
91364
|
+
selectionWithinProject: newSelectionWithinProject
|
|
90912
91365
|
}
|
|
90913
91366
|
};
|
|
90914
|
-
|
|
90915
|
-
|
|
90916
|
-
|
|
90917
|
-
|
|
90918
|
-
|
|
90919
|
-
|
|
90920
|
-
|
|
90921
|
-
|
|
91367
|
+
}
|
|
91368
|
+
await checkIfBuildEnvironmentRequiresDeploymentConfig(ctx);
|
|
91369
|
+
return { kind: "unknown" };
|
|
91370
|
+
}
|
|
91371
|
+
async function checkIfBuildEnvironmentRequiresDeploymentConfig(ctx) {
|
|
91372
|
+
const buildEnvironment = getBuildEnvironment();
|
|
91373
|
+
if (buildEnvironment) {
|
|
91374
|
+
return await ctx.crash({
|
|
91375
|
+
exitCode: 1,
|
|
91376
|
+
errorType: "fatal",
|
|
91377
|
+
printedMessage: `${buildEnvironment} build environment detected but no Convex deployment configuration found.
|
|
91378
|
+
Set one of:
|
|
91379
|
+
\u2022 ${CONVEX_DEPLOY_KEY_ENV_VAR_NAME} for Convex Cloud deployments
|
|
91380
|
+
\u2022 ${CONVEX_SELF_HOSTED_URL_VAR_NAME} and ${CONVEX_SELF_HOSTED_ADMIN_KEY_VAR_NAME} for self-hosted deployments
|
|
91381
|
+
See https://docs.convex.dev/production/hosting or https://docs.convex.dev/self-hosting`
|
|
91382
|
+
});
|
|
91383
|
+
}
|
|
91384
|
+
}
|
|
91385
|
+
async function getProjectDetails(ctx, projectSelection) {
|
|
91386
|
+
switch (projectSelection.kind) {
|
|
91387
|
+
case "deploymentName": {
|
|
91388
|
+
if (projectSelection.deploymentType === "local") {
|
|
91389
|
+
const result = await getTeamAndProjectSlugForDeployment(ctx, {
|
|
91390
|
+
deploymentName: projectSelection.deploymentName
|
|
91391
|
+
});
|
|
91392
|
+
if (result === null) {
|
|
91393
|
+
return ctx.crash({
|
|
91394
|
+
exitCode: 1,
|
|
91395
|
+
errorType: "fatal",
|
|
91396
|
+
printedMessage: "You don't have access to the selected project. Run `npx convex dev` to select a different project."
|
|
91397
|
+
});
|
|
91398
|
+
}
|
|
91399
|
+
return await getProjectDetails(ctx, {
|
|
91400
|
+
kind: "teamAndProjectSlugs",
|
|
91401
|
+
teamSlug: result.teamSlug,
|
|
91402
|
+
projectSlug: result.projectSlug
|
|
91403
|
+
});
|
|
90922
91404
|
}
|
|
91405
|
+
const deployment2 = (await typedPlatformClient(ctx).GET("/deployments/{deployment_name}", {
|
|
91406
|
+
params: {
|
|
91407
|
+
path: { deployment_name: projectSelection.deploymentName }
|
|
91408
|
+
}
|
|
91409
|
+
})).data;
|
|
91410
|
+
return (await typedPlatformClient(ctx).GET("/projects/{project_id}", {
|
|
91411
|
+
params: { path: { project_id: deployment2.projectId } }
|
|
91412
|
+
})).data;
|
|
91413
|
+
}
|
|
91414
|
+
case "teamAndProjectSlugs": {
|
|
91415
|
+
return (await typedPlatformClient(ctx).GET(
|
|
91416
|
+
"/teams/{team_id_or_slug}/projects/{project_slug}",
|
|
91417
|
+
{
|
|
91418
|
+
params: {
|
|
91419
|
+
path: {
|
|
91420
|
+
team_id_or_slug: projectSelection.teamSlug,
|
|
91421
|
+
project_slug: projectSelection.projectSlug
|
|
91422
|
+
}
|
|
91423
|
+
}
|
|
91424
|
+
}
|
|
91425
|
+
)).data;
|
|
91426
|
+
}
|
|
91427
|
+
case "projectDeployKey": {
|
|
91428
|
+
const result = await fetchTeamAndProjectForKey(
|
|
91429
|
+
ctx,
|
|
91430
|
+
projectSelection.projectDeployKey
|
|
91431
|
+
);
|
|
91432
|
+
return (await typedPlatformClient(ctx).GET("/projects/{project_id}", {
|
|
91433
|
+
params: { path: { project_id: result.projectId } }
|
|
91434
|
+
})).data;
|
|
91435
|
+
}
|
|
91436
|
+
}
|
|
91437
|
+
}
|
|
91438
|
+
var dotenv5, deploymentNameFromSelection, deploymentNameAndTypeFromSelection, shouldAllowAnonymousDevelopment;
|
|
91439
|
+
var init_deploymentSelection = __esm({
|
|
91440
|
+
"src/cli/lib/deploymentSelection.ts"() {
|
|
91441
|
+
"use strict";
|
|
91442
|
+
init_log();
|
|
91443
|
+
init_api3();
|
|
91444
|
+
init_deployment();
|
|
91445
|
+
init_deploymentSelector();
|
|
91446
|
+
init_filePaths();
|
|
91447
|
+
init_source();
|
|
91448
|
+
init_envvars();
|
|
91449
|
+
init_globalConfig();
|
|
91450
|
+
init_utils5();
|
|
91451
|
+
dotenv5 = __toESM(require_main(), 1);
|
|
91452
|
+
deploymentNameFromSelection = (selection) => {
|
|
91453
|
+
var _a2;
|
|
91454
|
+
return ((_a2 = deploymentNameAndTypeFromSelection(selection)) == null ? void 0 : _a2.name) ?? null;
|
|
90923
91455
|
};
|
|
90924
|
-
|
|
90925
|
-
|
|
90926
|
-
|
|
90927
|
-
|
|
90928
|
-
|
|
90929
|
-
|
|
90930
|
-
|
|
90931
|
-
|
|
91456
|
+
deploymentNameAndTypeFromSelection = (selection) => {
|
|
91457
|
+
var _a2, _b2;
|
|
91458
|
+
switch (selection.kind) {
|
|
91459
|
+
case "existingDeployment": {
|
|
91460
|
+
return {
|
|
91461
|
+
name: ((_a2 = selection.deploymentToActOn.deploymentFields) == null ? void 0 : _a2.deploymentName) ?? null,
|
|
91462
|
+
type: ((_b2 = selection.deploymentToActOn.deploymentFields) == null ? void 0 : _b2.deploymentType) ?? null
|
|
91463
|
+
};
|
|
91464
|
+
}
|
|
91465
|
+
case "deploymentWithinProject": {
|
|
91466
|
+
return selection.targetProject.kind === "deploymentName" ? {
|
|
91467
|
+
name: selection.targetProject.deploymentName,
|
|
91468
|
+
type: selection.targetProject.deploymentType
|
|
91469
|
+
} : null;
|
|
91470
|
+
}
|
|
91471
|
+
case "preview": {
|
|
91472
|
+
return null;
|
|
91473
|
+
}
|
|
91474
|
+
case "chooseProject": {
|
|
91475
|
+
return null;
|
|
91476
|
+
}
|
|
91477
|
+
case "anonymous": {
|
|
91478
|
+
return null;
|
|
91479
|
+
}
|
|
91480
|
+
default: {
|
|
91481
|
+
selection;
|
|
91482
|
+
}
|
|
90932
91483
|
}
|
|
91484
|
+
return null;
|
|
90933
91485
|
};
|
|
90934
|
-
|
|
90935
|
-
|
|
90936
|
-
|
|
90937
|
-
super(...arguments);
|
|
90938
|
-
this.code = "ERR_JWT_INVALID";
|
|
90939
|
-
}
|
|
90940
|
-
static get code() {
|
|
90941
|
-
return "ERR_JWT_INVALID";
|
|
91486
|
+
shouldAllowAnonymousDevelopment = () => {
|
|
91487
|
+
if (process.env.CONVEX_ALLOW_ANONYMOUS === "false") {
|
|
91488
|
+
return false;
|
|
90942
91489
|
}
|
|
91490
|
+
return true;
|
|
90943
91491
|
};
|
|
90944
|
-
|
|
90945
|
-
|
|
90946
|
-
|
|
90947
|
-
|
|
90948
|
-
|
|
90949
|
-
|
|
90950
|
-
|
|
90951
|
-
|
|
91492
|
+
}
|
|
91493
|
+
});
|
|
91494
|
+
|
|
91495
|
+
// ../common/temp/node_modules/.pnpm/openid-client@5.7.1/node_modules/openid-client/lib/errors.js
|
|
91496
|
+
var require_errors3 = __commonJS({
|
|
91497
|
+
"../common/temp/node_modules/.pnpm/openid-client@5.7.1/node_modules/openid-client/lib/errors.js"(exports2, module2) {
|
|
91498
|
+
var { format: format5 } = require("util");
|
|
91499
|
+
var OPError = class extends Error {
|
|
91500
|
+
constructor({ error_description, error: error3, error_uri, session_state, state, scope }, response) {
|
|
91501
|
+
super(!error_description ? error3 : `${error3} (${error_description})`);
|
|
91502
|
+
Object.assign(
|
|
91503
|
+
this,
|
|
91504
|
+
{ error: error3 },
|
|
91505
|
+
error_description && { error_description },
|
|
91506
|
+
error_uri && { error_uri },
|
|
91507
|
+
state && { state },
|
|
91508
|
+
scope && { scope },
|
|
91509
|
+
session_state && { session_state }
|
|
91510
|
+
);
|
|
91511
|
+
if (response) {
|
|
91512
|
+
Object.defineProperty(this, "response", {
|
|
91513
|
+
value: response
|
|
91514
|
+
});
|
|
91515
|
+
}
|
|
91516
|
+
this.name = this.constructor.name;
|
|
91517
|
+
Error.captureStackTrace(this, this.constructor);
|
|
90952
91518
|
}
|
|
90953
91519
|
};
|
|
90954
|
-
|
|
90955
|
-
|
|
90956
|
-
|
|
90957
|
-
|
|
90958
|
-
|
|
90959
|
-
|
|
90960
|
-
|
|
90961
|
-
|
|
91520
|
+
var RPError = class extends Error {
|
|
91521
|
+
constructor(...args) {
|
|
91522
|
+
if (typeof args[0] === "string") {
|
|
91523
|
+
super(format5(...args));
|
|
91524
|
+
} else {
|
|
91525
|
+
const { message, printf, response, ...rest } = args[0];
|
|
91526
|
+
if (printf) {
|
|
91527
|
+
super(format5(...printf));
|
|
91528
|
+
} else {
|
|
91529
|
+
super(message);
|
|
91530
|
+
}
|
|
91531
|
+
Object.assign(this, rest);
|
|
91532
|
+
if (response) {
|
|
91533
|
+
Object.defineProperty(this, "response", {
|
|
91534
|
+
value: response
|
|
91535
|
+
});
|
|
91536
|
+
}
|
|
91537
|
+
}
|
|
91538
|
+
this.name = this.constructor.name;
|
|
91539
|
+
Error.captureStackTrace(this, this.constructor);
|
|
90962
91540
|
}
|
|
90963
91541
|
};
|
|
90964
|
-
|
|
90965
|
-
|
|
90966
|
-
|
|
90967
|
-
super(...arguments);
|
|
90968
|
-
this.code = "ERR_JWKS_NO_MATCHING_KEY";
|
|
90969
|
-
this.message = "no applicable key found in the JSON Web Key Set";
|
|
90970
|
-
}
|
|
90971
|
-
static get code() {
|
|
90972
|
-
return "ERR_JWKS_NO_MATCHING_KEY";
|
|
90973
|
-
}
|
|
91542
|
+
module2.exports = {
|
|
91543
|
+
OPError,
|
|
91544
|
+
RPError
|
|
90974
91545
|
};
|
|
90975
|
-
|
|
90976
|
-
|
|
90977
|
-
|
|
91546
|
+
}
|
|
91547
|
+
});
|
|
91548
|
+
|
|
91549
|
+
// ../common/temp/node_modules/.pnpm/jose@4.15.9/node_modules/jose/dist/node/cjs/runtime/digest.js
|
|
91550
|
+
var require_digest = __commonJS({
|
|
91551
|
+
"../common/temp/node_modules/.pnpm/jose@4.15.9/node_modules/jose/dist/node/cjs/runtime/digest.js"(exports2) {
|
|
91552
|
+
"use strict";
|
|
91553
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
91554
|
+
var crypto_1 = require("crypto");
|
|
91555
|
+
var digest = (algorithm, data2) => (0, crypto_1.createHash)(algorithm).update(data2).digest();
|
|
91556
|
+
exports2.default = digest;
|
|
91557
|
+
}
|
|
91558
|
+
});
|
|
91559
|
+
|
|
91560
|
+
// ../common/temp/node_modules/.pnpm/jose@4.15.9/node_modules/jose/dist/node/cjs/lib/buffer_utils.js
|
|
91561
|
+
var require_buffer_utils = __commonJS({
|
|
91562
|
+
"../common/temp/node_modules/.pnpm/jose@4.15.9/node_modules/jose/dist/node/cjs/lib/buffer_utils.js"(exports2) {
|
|
91563
|
+
"use strict";
|
|
91564
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
91565
|
+
exports2.concatKdf = exports2.lengthAndInput = exports2.uint32be = exports2.uint64be = exports2.p2s = exports2.concat = exports2.decoder = exports2.encoder = void 0;
|
|
91566
|
+
var digest_js_1 = require_digest();
|
|
91567
|
+
exports2.encoder = new TextEncoder();
|
|
91568
|
+
exports2.decoder = new TextDecoder();
|
|
91569
|
+
var MAX_INT32 = 2 ** 32;
|
|
91570
|
+
function concat(...buffers) {
|
|
91571
|
+
const size = buffers.reduce((acc, { length }) => acc + length, 0);
|
|
91572
|
+
const buf = new Uint8Array(size);
|
|
91573
|
+
let i = 0;
|
|
91574
|
+
buffers.forEach((buffer) => {
|
|
91575
|
+
buf.set(buffer, i);
|
|
91576
|
+
i += buffer.length;
|
|
91577
|
+
});
|
|
91578
|
+
return buf;
|
|
91579
|
+
}
|
|
91580
|
+
exports2.concat = concat;
|
|
91581
|
+
function p2s(alg, p2sInput) {
|
|
91582
|
+
return concat(exports2.encoder.encode(alg), new Uint8Array([0]), p2sInput);
|
|
91583
|
+
}
|
|
91584
|
+
exports2.p2s = p2s;
|
|
91585
|
+
function writeUInt32BE(buf, value, offset) {
|
|
91586
|
+
if (value < 0 || value >= MAX_INT32) {
|
|
91587
|
+
throw new RangeError(`value must be >= 0 and <= ${MAX_INT32 - 1}. Received ${value}`);
|
|
91588
|
+
}
|
|
91589
|
+
buf.set([value >>> 24, value >>> 16, value >>> 8, value & 255], offset);
|
|
91590
|
+
}
|
|
91591
|
+
function uint64be(value) {
|
|
91592
|
+
const high = Math.floor(value / MAX_INT32);
|
|
91593
|
+
const low = value % MAX_INT32;
|
|
91594
|
+
const buf = new Uint8Array(8);
|
|
91595
|
+
writeUInt32BE(buf, high, 0);
|
|
91596
|
+
writeUInt32BE(buf, low, 4);
|
|
91597
|
+
return buf;
|
|
91598
|
+
}
|
|
91599
|
+
exports2.uint64be = uint64be;
|
|
91600
|
+
function uint32be(value) {
|
|
91601
|
+
const buf = new Uint8Array(4);
|
|
91602
|
+
writeUInt32BE(buf, value);
|
|
91603
|
+
return buf;
|
|
91604
|
+
}
|
|
91605
|
+
exports2.uint32be = uint32be;
|
|
91606
|
+
function lengthAndInput(input) {
|
|
91607
|
+
return concat(uint32be(input.length), input);
|
|
91608
|
+
}
|
|
91609
|
+
exports2.lengthAndInput = lengthAndInput;
|
|
91610
|
+
async function concatKdf(secret, bits, value) {
|
|
91611
|
+
const iterations = Math.ceil((bits >> 3) / 32);
|
|
91612
|
+
const res = new Uint8Array(iterations * 32);
|
|
91613
|
+
for (let iter = 0; iter < iterations; iter++) {
|
|
91614
|
+
const buf = new Uint8Array(4 + secret.length + value.length);
|
|
91615
|
+
buf.set(uint32be(iter + 1));
|
|
91616
|
+
buf.set(secret, 4);
|
|
91617
|
+
buf.set(value, 4 + secret.length);
|
|
91618
|
+
res.set(await (0, digest_js_1.default)("sha256", buf), iter * 32);
|
|
91619
|
+
}
|
|
91620
|
+
return res.slice(0, bits >> 3);
|
|
91621
|
+
}
|
|
91622
|
+
exports2.concatKdf = concatKdf;
|
|
91623
|
+
}
|
|
91624
|
+
});
|
|
91625
|
+
|
|
91626
|
+
// ../common/temp/node_modules/.pnpm/jose@4.15.9/node_modules/jose/dist/node/cjs/runtime/base64url.js
|
|
91627
|
+
var require_base64url = __commonJS({
|
|
91628
|
+
"../common/temp/node_modules/.pnpm/jose@4.15.9/node_modules/jose/dist/node/cjs/runtime/base64url.js"(exports2) {
|
|
91629
|
+
"use strict";
|
|
91630
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
91631
|
+
exports2.decode = exports2.encode = exports2.encodeBase64 = exports2.decodeBase64 = void 0;
|
|
91632
|
+
var buffer_1 = require("buffer");
|
|
91633
|
+
var buffer_utils_js_1 = require_buffer_utils();
|
|
91634
|
+
var encode;
|
|
91635
|
+
function normalize(input) {
|
|
91636
|
+
let encoded = input;
|
|
91637
|
+
if (encoded instanceof Uint8Array) {
|
|
91638
|
+
encoded = buffer_utils_js_1.decoder.decode(encoded);
|
|
91639
|
+
}
|
|
91640
|
+
return encoded;
|
|
91641
|
+
}
|
|
91642
|
+
if (buffer_1.Buffer.isEncoding("base64url")) {
|
|
91643
|
+
exports2.encode = encode = (input) => buffer_1.Buffer.from(input).toString("base64url");
|
|
91644
|
+
} else {
|
|
91645
|
+
exports2.encode = encode = (input) => buffer_1.Buffer.from(input).toString("base64").replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
|
|
91646
|
+
}
|
|
91647
|
+
var decodeBase64 = (input) => buffer_1.Buffer.from(input, "base64");
|
|
91648
|
+
exports2.decodeBase64 = decodeBase64;
|
|
91649
|
+
var encodeBase64 = (input) => buffer_1.Buffer.from(input).toString("base64");
|
|
91650
|
+
exports2.encodeBase64 = encodeBase64;
|
|
91651
|
+
var decode = (input) => buffer_1.Buffer.from(normalize(input), "base64");
|
|
91652
|
+
exports2.decode = decode;
|
|
91653
|
+
}
|
|
91654
|
+
});
|
|
91655
|
+
|
|
91656
|
+
// ../common/temp/node_modules/.pnpm/jose@4.15.9/node_modules/jose/dist/node/cjs/util/errors.js
|
|
91657
|
+
var require_errors4 = __commonJS({
|
|
91658
|
+
"../common/temp/node_modules/.pnpm/jose@4.15.9/node_modules/jose/dist/node/cjs/util/errors.js"(exports2) {
|
|
91659
|
+
"use strict";
|
|
91660
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
91661
|
+
exports2.JWSSignatureVerificationFailed = exports2.JWKSTimeout = exports2.JWKSMultipleMatchingKeys = exports2.JWKSNoMatchingKey = exports2.JWKSInvalid = exports2.JWKInvalid = exports2.JWTInvalid = exports2.JWSInvalid = exports2.JWEInvalid = exports2.JWEDecompressionFailed = exports2.JWEDecryptionFailed = exports2.JOSENotSupported = exports2.JOSEAlgNotAllowed = exports2.JWTExpired = exports2.JWTClaimValidationFailed = exports2.JOSEError = void 0;
|
|
91662
|
+
var JOSEError = class extends Error {
|
|
91663
|
+
static get code() {
|
|
91664
|
+
return "ERR_JOSE_GENERIC";
|
|
91665
|
+
}
|
|
91666
|
+
constructor(message) {
|
|
91667
|
+
var _a2;
|
|
91668
|
+
super(message);
|
|
91669
|
+
this.code = "ERR_JOSE_GENERIC";
|
|
91670
|
+
this.name = this.constructor.name;
|
|
91671
|
+
(_a2 = Error.captureStackTrace) === null || _a2 === void 0 ? void 0 : _a2.call(Error, this, this.constructor);
|
|
91672
|
+
}
|
|
91673
|
+
};
|
|
91674
|
+
exports2.JOSEError = JOSEError;
|
|
91675
|
+
var JWTClaimValidationFailed = class extends JOSEError {
|
|
91676
|
+
static get code() {
|
|
91677
|
+
return "ERR_JWT_CLAIM_VALIDATION_FAILED";
|
|
91678
|
+
}
|
|
91679
|
+
constructor(message, claim = "unspecified", reason = "unspecified") {
|
|
91680
|
+
super(message);
|
|
91681
|
+
this.code = "ERR_JWT_CLAIM_VALIDATION_FAILED";
|
|
91682
|
+
this.claim = claim;
|
|
91683
|
+
this.reason = reason;
|
|
91684
|
+
}
|
|
91685
|
+
};
|
|
91686
|
+
exports2.JWTClaimValidationFailed = JWTClaimValidationFailed;
|
|
91687
|
+
var JWTExpired = class extends JOSEError {
|
|
91688
|
+
static get code() {
|
|
91689
|
+
return "ERR_JWT_EXPIRED";
|
|
91690
|
+
}
|
|
91691
|
+
constructor(message, claim = "unspecified", reason = "unspecified") {
|
|
91692
|
+
super(message);
|
|
91693
|
+
this.code = "ERR_JWT_EXPIRED";
|
|
91694
|
+
this.claim = claim;
|
|
91695
|
+
this.reason = reason;
|
|
91696
|
+
}
|
|
91697
|
+
};
|
|
91698
|
+
exports2.JWTExpired = JWTExpired;
|
|
91699
|
+
var JOSEAlgNotAllowed = class extends JOSEError {
|
|
91700
|
+
constructor() {
|
|
91701
|
+
super(...arguments);
|
|
91702
|
+
this.code = "ERR_JOSE_ALG_NOT_ALLOWED";
|
|
91703
|
+
}
|
|
91704
|
+
static get code() {
|
|
91705
|
+
return "ERR_JOSE_ALG_NOT_ALLOWED";
|
|
91706
|
+
}
|
|
91707
|
+
};
|
|
91708
|
+
exports2.JOSEAlgNotAllowed = JOSEAlgNotAllowed;
|
|
91709
|
+
var JOSENotSupported = class extends JOSEError {
|
|
91710
|
+
constructor() {
|
|
91711
|
+
super(...arguments);
|
|
91712
|
+
this.code = "ERR_JOSE_NOT_SUPPORTED";
|
|
91713
|
+
}
|
|
91714
|
+
static get code() {
|
|
91715
|
+
return "ERR_JOSE_NOT_SUPPORTED";
|
|
91716
|
+
}
|
|
91717
|
+
};
|
|
91718
|
+
exports2.JOSENotSupported = JOSENotSupported;
|
|
91719
|
+
var JWEDecryptionFailed = class extends JOSEError {
|
|
91720
|
+
constructor() {
|
|
91721
|
+
super(...arguments);
|
|
91722
|
+
this.code = "ERR_JWE_DECRYPTION_FAILED";
|
|
91723
|
+
this.message = "decryption operation failed";
|
|
91724
|
+
}
|
|
91725
|
+
static get code() {
|
|
91726
|
+
return "ERR_JWE_DECRYPTION_FAILED";
|
|
91727
|
+
}
|
|
91728
|
+
};
|
|
91729
|
+
exports2.JWEDecryptionFailed = JWEDecryptionFailed;
|
|
91730
|
+
var JWEDecompressionFailed = class extends JOSEError {
|
|
91731
|
+
constructor() {
|
|
91732
|
+
super(...arguments);
|
|
91733
|
+
this.code = "ERR_JWE_DECOMPRESSION_FAILED";
|
|
91734
|
+
this.message = "decompression operation failed";
|
|
91735
|
+
}
|
|
91736
|
+
static get code() {
|
|
91737
|
+
return "ERR_JWE_DECOMPRESSION_FAILED";
|
|
91738
|
+
}
|
|
91739
|
+
};
|
|
91740
|
+
exports2.JWEDecompressionFailed = JWEDecompressionFailed;
|
|
91741
|
+
var JWEInvalid = class extends JOSEError {
|
|
91742
|
+
constructor() {
|
|
91743
|
+
super(...arguments);
|
|
91744
|
+
this.code = "ERR_JWE_INVALID";
|
|
91745
|
+
}
|
|
91746
|
+
static get code() {
|
|
91747
|
+
return "ERR_JWE_INVALID";
|
|
91748
|
+
}
|
|
91749
|
+
};
|
|
91750
|
+
exports2.JWEInvalid = JWEInvalid;
|
|
91751
|
+
var JWSInvalid = class extends JOSEError {
|
|
91752
|
+
constructor() {
|
|
91753
|
+
super(...arguments);
|
|
91754
|
+
this.code = "ERR_JWS_INVALID";
|
|
91755
|
+
}
|
|
91756
|
+
static get code() {
|
|
91757
|
+
return "ERR_JWS_INVALID";
|
|
91758
|
+
}
|
|
91759
|
+
};
|
|
91760
|
+
exports2.JWSInvalid = JWSInvalid;
|
|
91761
|
+
var JWTInvalid = class extends JOSEError {
|
|
91762
|
+
constructor() {
|
|
91763
|
+
super(...arguments);
|
|
91764
|
+
this.code = "ERR_JWT_INVALID";
|
|
91765
|
+
}
|
|
91766
|
+
static get code() {
|
|
91767
|
+
return "ERR_JWT_INVALID";
|
|
91768
|
+
}
|
|
91769
|
+
};
|
|
91770
|
+
exports2.JWTInvalid = JWTInvalid;
|
|
91771
|
+
var JWKInvalid = class extends JOSEError {
|
|
91772
|
+
constructor() {
|
|
91773
|
+
super(...arguments);
|
|
91774
|
+
this.code = "ERR_JWK_INVALID";
|
|
91775
|
+
}
|
|
91776
|
+
static get code() {
|
|
91777
|
+
return "ERR_JWK_INVALID";
|
|
91778
|
+
}
|
|
91779
|
+
};
|
|
91780
|
+
exports2.JWKInvalid = JWKInvalid;
|
|
91781
|
+
var JWKSInvalid = class extends JOSEError {
|
|
91782
|
+
constructor() {
|
|
91783
|
+
super(...arguments);
|
|
91784
|
+
this.code = "ERR_JWKS_INVALID";
|
|
91785
|
+
}
|
|
91786
|
+
static get code() {
|
|
91787
|
+
return "ERR_JWKS_INVALID";
|
|
91788
|
+
}
|
|
91789
|
+
};
|
|
91790
|
+
exports2.JWKSInvalid = JWKSInvalid;
|
|
91791
|
+
var JWKSNoMatchingKey = class extends JOSEError {
|
|
91792
|
+
constructor() {
|
|
91793
|
+
super(...arguments);
|
|
91794
|
+
this.code = "ERR_JWKS_NO_MATCHING_KEY";
|
|
91795
|
+
this.message = "no applicable key found in the JSON Web Key Set";
|
|
91796
|
+
}
|
|
91797
|
+
static get code() {
|
|
91798
|
+
return "ERR_JWKS_NO_MATCHING_KEY";
|
|
91799
|
+
}
|
|
91800
|
+
};
|
|
91801
|
+
exports2.JWKSNoMatchingKey = JWKSNoMatchingKey;
|
|
91802
|
+
var JWKSMultipleMatchingKeys = class extends JOSEError {
|
|
91803
|
+
constructor() {
|
|
90978
91804
|
super(...arguments);
|
|
90979
91805
|
this.code = "ERR_JWKS_MULTIPLE_MATCHING_KEYS";
|
|
90980
91806
|
this.message = "multiple matching keys found in the JSON Web Key Set";
|
|
@@ -131340,992 +132166,328 @@ var require_eventsource = __commonJS({
|
|
|
131340
132166
|
const eventSourceStream = new EventSourceStream({
|
|
131341
132167
|
eventSourceSettings: __privateGet(this, _state),
|
|
131342
132168
|
push: (event) => {
|
|
131343
|
-
this.dispatchEvent(createFastMessageEvent(
|
|
131344
|
-
event.type,
|
|
131345
|
-
event.options
|
|
131346
|
-
));
|
|
131347
|
-
}
|
|
131348
|
-
});
|
|
131349
|
-
pipeline(
|
|
131350
|
-
response.body.stream,
|
|
131351
|
-
eventSourceStream,
|
|
131352
|
-
(error3) => {
|
|
131353
|
-
if ((error3 == null ? void 0 : error3.aborted) === false) {
|
|
131354
|
-
this.close();
|
|
131355
|
-
this.dispatchEvent(new Event("error"));
|
|
131356
|
-
}
|
|
131357
|
-
}
|
|
131358
|
-
);
|
|
131359
|
-
};
|
|
131360
|
-
__privateSet(this, _controller, fetching(fetchParams));
|
|
131361
|
-
};
|
|
131362
|
-
/**
|
|
131363
|
-
* @see https://html.spec.whatwg.org/multipage/server-sent-events.html#sse-processing-model
|
|
131364
|
-
* @returns {void}
|
|
131365
|
-
*/
|
|
131366
|
-
reconnect_fn = function() {
|
|
131367
|
-
var _a2;
|
|
131368
|
-
if (__privateGet(this, _readyState) === CLOSED) return;
|
|
131369
|
-
__privateSet(this, _readyState, CONNECTING);
|
|
131370
|
-
this.dispatchEvent(new Event("error"));
|
|
131371
|
-
(_a2 = setTimeout(() => {
|
|
131372
|
-
if (__privateGet(this, _readyState) !== CONNECTING) return;
|
|
131373
|
-
if (__privateGet(this, _state).lastEventId.length) {
|
|
131374
|
-
__privateGet(this, _request).headersList.set("last-event-id", __privateGet(this, _state).lastEventId, true);
|
|
131375
|
-
}
|
|
131376
|
-
__privateMethod(this, _EventSource_instances, connect_fn).call(this);
|
|
131377
|
-
}, __privateGet(this, _state).reconnectionTime)) == null ? void 0 : _a2.unref();
|
|
131378
|
-
};
|
|
131379
|
-
var EventSource = _EventSource;
|
|
131380
|
-
var constantsPropertyDescriptors = {
|
|
131381
|
-
CONNECTING: {
|
|
131382
|
-
__proto__: null,
|
|
131383
|
-
configurable: false,
|
|
131384
|
-
enumerable: true,
|
|
131385
|
-
value: CONNECTING,
|
|
131386
|
-
writable: false
|
|
131387
|
-
},
|
|
131388
|
-
OPEN: {
|
|
131389
|
-
__proto__: null,
|
|
131390
|
-
configurable: false,
|
|
131391
|
-
enumerable: true,
|
|
131392
|
-
value: OPEN,
|
|
131393
|
-
writable: false
|
|
131394
|
-
},
|
|
131395
|
-
CLOSED: {
|
|
131396
|
-
__proto__: null,
|
|
131397
|
-
configurable: false,
|
|
131398
|
-
enumerable: true,
|
|
131399
|
-
value: CLOSED,
|
|
131400
|
-
writable: false
|
|
131401
|
-
}
|
|
131402
|
-
};
|
|
131403
|
-
Object.defineProperties(EventSource, constantsPropertyDescriptors);
|
|
131404
|
-
Object.defineProperties(EventSource.prototype, constantsPropertyDescriptors);
|
|
131405
|
-
Object.defineProperties(EventSource.prototype, {
|
|
131406
|
-
close: kEnumerableProperty,
|
|
131407
|
-
onerror: kEnumerableProperty,
|
|
131408
|
-
onmessage: kEnumerableProperty,
|
|
131409
|
-
onopen: kEnumerableProperty,
|
|
131410
|
-
readyState: kEnumerableProperty,
|
|
131411
|
-
url: kEnumerableProperty,
|
|
131412
|
-
withCredentials: kEnumerableProperty
|
|
131413
|
-
});
|
|
131414
|
-
webidl.converters.EventSourceInitDict = webidl.dictionaryConverter([
|
|
131415
|
-
{
|
|
131416
|
-
key: "withCredentials",
|
|
131417
|
-
converter: webidl.converters.boolean,
|
|
131418
|
-
defaultValue: () => false
|
|
131419
|
-
},
|
|
131420
|
-
{
|
|
131421
|
-
key: "dispatcher",
|
|
131422
|
-
// undici only
|
|
131423
|
-
converter: webidl.converters.any
|
|
131424
|
-
},
|
|
131425
|
-
{
|
|
131426
|
-
key: "node",
|
|
131427
|
-
// undici only
|
|
131428
|
-
converter: webidl.dictionaryConverter([
|
|
131429
|
-
{
|
|
131430
|
-
key: "reconnectionTime",
|
|
131431
|
-
converter: webidl.converters["unsigned long"],
|
|
131432
|
-
defaultValue: () => defaultReconnectionTime
|
|
131433
|
-
},
|
|
131434
|
-
{
|
|
131435
|
-
key: "dispatcher",
|
|
131436
|
-
converter: webidl.converters.any
|
|
131437
|
-
}
|
|
131438
|
-
]),
|
|
131439
|
-
defaultValue: () => ({})
|
|
131440
|
-
}
|
|
131441
|
-
]);
|
|
131442
|
-
module2.exports = {
|
|
131443
|
-
EventSource,
|
|
131444
|
-
defaultReconnectionTime
|
|
131445
|
-
};
|
|
131446
|
-
}
|
|
131447
|
-
});
|
|
131448
|
-
|
|
131449
|
-
// ../common/temp/node_modules/.pnpm/undici@7.24.0/node_modules/undici/index.js
|
|
131450
|
-
var require_undici2 = __commonJS({
|
|
131451
|
-
"../common/temp/node_modules/.pnpm/undici@7.24.0/node_modules/undici/index.js"(exports2, module2) {
|
|
131452
|
-
"use strict";
|
|
131453
|
-
var Client = require_client4();
|
|
131454
|
-
var Dispatcher = require_dispatcher();
|
|
131455
|
-
var Pool = require_pool();
|
|
131456
|
-
var BalancedPool = require_balanced_pool();
|
|
131457
|
-
var RoundRobinPool = require_round_robin_pool();
|
|
131458
|
-
var Agent = require_agent();
|
|
131459
|
-
var ProxyAgent = require_proxy_agent();
|
|
131460
|
-
var Socks5ProxyAgent = require_socks5_proxy_agent();
|
|
131461
|
-
var EnvHttpProxyAgent2 = require_env_http_proxy_agent();
|
|
131462
|
-
var RetryAgent = require_retry_agent();
|
|
131463
|
-
var H2CClient = require_h2c_client();
|
|
131464
|
-
var errors2 = require_errors6();
|
|
131465
|
-
var util3 = require_util4();
|
|
131466
|
-
var { InvalidArgumentError: InvalidArgumentError3 } = errors2;
|
|
131467
|
-
var api = require_api2();
|
|
131468
|
-
var buildConnector = require_connect();
|
|
131469
|
-
var MockClient = require_mock_client();
|
|
131470
|
-
var { MockCallHistory, MockCallHistoryLog } = require_mock_call_history();
|
|
131471
|
-
var MockAgent = require_mock_agent();
|
|
131472
|
-
var MockPool = require_mock_pool();
|
|
131473
|
-
var SnapshotAgent = require_snapshot_agent();
|
|
131474
|
-
var mockErrors = require_mock_errors();
|
|
131475
|
-
var RetryHandler = require_retry_handler();
|
|
131476
|
-
var { getGlobalDispatcher, setGlobalDispatcher: setGlobalDispatcher2 } = require_global2();
|
|
131477
|
-
var DecoratorHandler = require_decorator_handler();
|
|
131478
|
-
var RedirectHandler = require_redirect_handler();
|
|
131479
|
-
Object.assign(Dispatcher.prototype, api);
|
|
131480
|
-
module2.exports.Dispatcher = Dispatcher;
|
|
131481
|
-
module2.exports.Client = Client;
|
|
131482
|
-
module2.exports.Pool = Pool;
|
|
131483
|
-
module2.exports.BalancedPool = BalancedPool;
|
|
131484
|
-
module2.exports.RoundRobinPool = RoundRobinPool;
|
|
131485
|
-
module2.exports.Agent = Agent;
|
|
131486
|
-
module2.exports.ProxyAgent = ProxyAgent;
|
|
131487
|
-
module2.exports.Socks5ProxyAgent = Socks5ProxyAgent;
|
|
131488
|
-
module2.exports.EnvHttpProxyAgent = EnvHttpProxyAgent2;
|
|
131489
|
-
module2.exports.RetryAgent = RetryAgent;
|
|
131490
|
-
module2.exports.H2CClient = H2CClient;
|
|
131491
|
-
module2.exports.RetryHandler = RetryHandler;
|
|
131492
|
-
module2.exports.DecoratorHandler = DecoratorHandler;
|
|
131493
|
-
module2.exports.RedirectHandler = RedirectHandler;
|
|
131494
|
-
module2.exports.interceptors = {
|
|
131495
|
-
redirect: require_redirect(),
|
|
131496
|
-
responseError: require_response_error(),
|
|
131497
|
-
retry: require_retry(),
|
|
131498
|
-
dump: require_dump(),
|
|
131499
|
-
dns: require_dns(),
|
|
131500
|
-
cache: require_cache3(),
|
|
131501
|
-
decompress: require_decompress(),
|
|
131502
|
-
deduplicate: require_deduplicate()
|
|
131503
|
-
};
|
|
131504
|
-
module2.exports.cacheStores = {
|
|
131505
|
-
MemoryCacheStore: require_memory_cache_store()
|
|
131506
|
-
};
|
|
131507
|
-
var SqliteCacheStore = require_sqlite_cache_store();
|
|
131508
|
-
module2.exports.cacheStores.SqliteCacheStore = SqliteCacheStore;
|
|
131509
|
-
module2.exports.buildConnector = buildConnector;
|
|
131510
|
-
module2.exports.errors = errors2;
|
|
131511
|
-
module2.exports.util = {
|
|
131512
|
-
parseHeaders: util3.parseHeaders,
|
|
131513
|
-
headerNameToString: util3.headerNameToString
|
|
131514
|
-
};
|
|
131515
|
-
function makeDispatcher(fn) {
|
|
131516
|
-
return (url, opts, handler) => {
|
|
131517
|
-
if (typeof opts === "function") {
|
|
131518
|
-
handler = opts;
|
|
131519
|
-
opts = null;
|
|
131520
|
-
}
|
|
131521
|
-
if (!url || typeof url !== "string" && typeof url !== "object" && !(url instanceof URL)) {
|
|
131522
|
-
throw new InvalidArgumentError3("invalid url");
|
|
131523
|
-
}
|
|
131524
|
-
if (opts != null && typeof opts !== "object") {
|
|
131525
|
-
throw new InvalidArgumentError3("invalid opts");
|
|
131526
|
-
}
|
|
131527
|
-
if (opts && opts.path != null) {
|
|
131528
|
-
if (typeof opts.path !== "string") {
|
|
131529
|
-
throw new InvalidArgumentError3("invalid opts.path");
|
|
131530
|
-
}
|
|
131531
|
-
let path39 = opts.path;
|
|
131532
|
-
if (!opts.path.startsWith("/")) {
|
|
131533
|
-
path39 = `/${path39}`;
|
|
131534
|
-
}
|
|
131535
|
-
url = new URL(util3.parseOrigin(url).origin + path39);
|
|
131536
|
-
} else {
|
|
131537
|
-
if (!opts) {
|
|
131538
|
-
opts = typeof url === "object" ? url : {};
|
|
131539
|
-
}
|
|
131540
|
-
url = util3.parseURL(url);
|
|
131541
|
-
}
|
|
131542
|
-
const { agent, dispatcher = getGlobalDispatcher() } = opts;
|
|
131543
|
-
if (agent) {
|
|
131544
|
-
throw new InvalidArgumentError3("unsupported opts.agent. Did you mean opts.client?");
|
|
131545
|
-
}
|
|
131546
|
-
return fn.call(dispatcher, {
|
|
131547
|
-
...opts,
|
|
131548
|
-
origin: url.origin,
|
|
131549
|
-
path: url.search ? `${url.pathname}${url.search}` : url.pathname,
|
|
131550
|
-
method: opts.method || (opts.body ? "PUT" : "GET")
|
|
131551
|
-
}, handler);
|
|
131552
|
-
};
|
|
131553
|
-
}
|
|
131554
|
-
module2.exports.setGlobalDispatcher = setGlobalDispatcher2;
|
|
131555
|
-
module2.exports.getGlobalDispatcher = getGlobalDispatcher;
|
|
131556
|
-
var fetchImpl = require_fetch3().fetch;
|
|
131557
|
-
var currentFilename = typeof __filename !== "undefined" ? __filename : void 0;
|
|
131558
|
-
function appendFetchStackTrace(err, filename) {
|
|
131559
|
-
if (!err || typeof err !== "object") {
|
|
131560
|
-
return;
|
|
131561
|
-
}
|
|
131562
|
-
const stack = typeof err.stack === "string" ? err.stack : "";
|
|
131563
|
-
const normalizedFilename = filename.replace(/\\/g, "/");
|
|
131564
|
-
if (stack && (stack.includes(filename) || stack.includes(normalizedFilename))) {
|
|
131565
|
-
return;
|
|
131566
|
-
}
|
|
131567
|
-
const capture = {};
|
|
131568
|
-
Error.captureStackTrace(capture, appendFetchStackTrace);
|
|
131569
|
-
if (!capture.stack) {
|
|
131570
|
-
return;
|
|
131571
|
-
}
|
|
131572
|
-
const captureLines = capture.stack.split("\n").slice(1).join("\n");
|
|
131573
|
-
err.stack = stack ? `${stack}
|
|
131574
|
-
${captureLines}` : capture.stack;
|
|
131575
|
-
}
|
|
131576
|
-
module2.exports.fetch = function fetch2(init3, options = void 0) {
|
|
131577
|
-
return fetchImpl(init3, options).catch((err) => {
|
|
131578
|
-
if (currentFilename) {
|
|
131579
|
-
appendFetchStackTrace(err, currentFilename);
|
|
131580
|
-
} else if (err && typeof err === "object") {
|
|
131581
|
-
Error.captureStackTrace(err, module2.exports.fetch);
|
|
131582
|
-
}
|
|
131583
|
-
throw err;
|
|
131584
|
-
});
|
|
131585
|
-
};
|
|
131586
|
-
module2.exports.Headers = require_headers2().Headers;
|
|
131587
|
-
module2.exports.Response = require_response().Response;
|
|
131588
|
-
module2.exports.Request = require_request4().Request;
|
|
131589
|
-
module2.exports.FormData = require_formdata().FormData;
|
|
131590
|
-
var { setGlobalOrigin, getGlobalOrigin } = require_global();
|
|
131591
|
-
module2.exports.setGlobalOrigin = setGlobalOrigin;
|
|
131592
|
-
module2.exports.getGlobalOrigin = getGlobalOrigin;
|
|
131593
|
-
var { CacheStorage } = require_cachestorage();
|
|
131594
|
-
var { kConstruct } = require_symbols();
|
|
131595
|
-
module2.exports.caches = new CacheStorage(kConstruct);
|
|
131596
|
-
var { deleteCookie, getCookies, getSetCookies, setCookie, parseCookie } = require_cookies();
|
|
131597
|
-
module2.exports.deleteCookie = deleteCookie;
|
|
131598
|
-
module2.exports.getCookies = getCookies;
|
|
131599
|
-
module2.exports.getSetCookies = getSetCookies;
|
|
131600
|
-
module2.exports.setCookie = setCookie;
|
|
131601
|
-
module2.exports.parseCookie = parseCookie;
|
|
131602
|
-
var { parseMIMEType, serializeAMimeType } = require_data_url();
|
|
131603
|
-
module2.exports.parseMIMEType = parseMIMEType;
|
|
131604
|
-
module2.exports.serializeAMimeType = serializeAMimeType;
|
|
131605
|
-
var { CloseEvent, ErrorEvent: ErrorEvent2, MessageEvent } = require_events();
|
|
131606
|
-
var { WebSocket: WebSocket2, ping } = require_websocket();
|
|
131607
|
-
module2.exports.WebSocket = WebSocket2;
|
|
131608
|
-
module2.exports.CloseEvent = CloseEvent;
|
|
131609
|
-
module2.exports.ErrorEvent = ErrorEvent2;
|
|
131610
|
-
module2.exports.MessageEvent = MessageEvent;
|
|
131611
|
-
module2.exports.ping = ping;
|
|
131612
|
-
module2.exports.WebSocketStream = require_websocketstream().WebSocketStream;
|
|
131613
|
-
module2.exports.WebSocketError = require_websocketerror().WebSocketError;
|
|
131614
|
-
module2.exports.request = makeDispatcher(api.request);
|
|
131615
|
-
module2.exports.stream = makeDispatcher(api.stream);
|
|
131616
|
-
module2.exports.pipeline = makeDispatcher(api.pipeline);
|
|
131617
|
-
module2.exports.connect = makeDispatcher(api.connect);
|
|
131618
|
-
module2.exports.upgrade = makeDispatcher(api.upgrade);
|
|
131619
|
-
module2.exports.MockClient = MockClient;
|
|
131620
|
-
module2.exports.MockCallHistory = MockCallHistory;
|
|
131621
|
-
module2.exports.MockCallHistoryLog = MockCallHistoryLog;
|
|
131622
|
-
module2.exports.MockPool = MockPool;
|
|
131623
|
-
module2.exports.MockAgent = MockAgent;
|
|
131624
|
-
module2.exports.SnapshotAgent = SnapshotAgent;
|
|
131625
|
-
module2.exports.mockErrors = mockErrors;
|
|
131626
|
-
var { EventSource } = require_eventsource();
|
|
131627
|
-
module2.exports.EventSource = EventSource;
|
|
131628
|
-
function install() {
|
|
131629
|
-
globalThis.fetch = module2.exports.fetch;
|
|
131630
|
-
globalThis.Headers = module2.exports.Headers;
|
|
131631
|
-
globalThis.Response = module2.exports.Response;
|
|
131632
|
-
globalThis.Request = module2.exports.Request;
|
|
131633
|
-
globalThis.FormData = module2.exports.FormData;
|
|
131634
|
-
globalThis.WebSocket = module2.exports.WebSocket;
|
|
131635
|
-
globalThis.CloseEvent = module2.exports.CloseEvent;
|
|
131636
|
-
globalThis.ErrorEvent = module2.exports.ErrorEvent;
|
|
131637
|
-
globalThis.MessageEvent = module2.exports.MessageEvent;
|
|
131638
|
-
globalThis.EventSource = module2.exports.EventSource;
|
|
131639
|
-
}
|
|
131640
|
-
module2.exports.install = install;
|
|
131641
|
-
}
|
|
131642
|
-
});
|
|
131643
|
-
|
|
131644
|
-
// ../common/temp/node_modules/.pnpm/@commander-js+extra-typings@14.0.0_commander@14.0.3/node_modules/@commander-js/extra-typings/esm.mjs
|
|
131645
|
-
var import_index = __toESM(require_extra_typings(), 1);
|
|
131646
|
-
var {
|
|
131647
|
-
program,
|
|
131648
|
-
createCommand,
|
|
131649
|
-
createArgument,
|
|
131650
|
-
createOption,
|
|
131651
|
-
CommanderError,
|
|
131652
|
-
InvalidArgumentError,
|
|
131653
|
-
InvalidOptionArgumentError,
|
|
131654
|
-
// deprecated old name
|
|
131655
|
-
Command,
|
|
131656
|
-
Argument,
|
|
131657
|
-
Option,
|
|
131658
|
-
Help
|
|
131659
|
-
} = import_index.default;
|
|
131660
|
-
|
|
131661
|
-
// src/bundler/context.ts
|
|
131662
|
-
var Sentry8 = __toESM(require_cjs5(), 1);
|
|
131663
|
-
init_fs();
|
|
131664
|
-
|
|
131665
|
-
// src/cli/lib/deploymentSelection.ts
|
|
131666
|
-
init_log();
|
|
131667
|
-
init_api3();
|
|
131668
|
-
init_deployment();
|
|
131669
|
-
init_deploymentSelector();
|
|
131670
|
-
init_filePaths();
|
|
131671
|
-
init_source();
|
|
131672
|
-
init_envvars();
|
|
131673
|
-
|
|
131674
|
-
// src/cli/lib/utils/globalConfig.ts
|
|
131675
|
-
init_source();
|
|
131676
|
-
var import_os3 = __toESM(require("os"), 1);
|
|
131677
|
-
var import_path30 = __toESM(require("path"), 1);
|
|
131678
|
-
init_utils5();
|
|
131679
|
-
init_log();
|
|
131680
|
-
init_zod();
|
|
131681
|
-
function globalConfigPath() {
|
|
131682
|
-
return import_path30.default.join(rootDirectory(), "config.json");
|
|
131683
|
-
}
|
|
131684
|
-
var schema = external_exports.object({
|
|
131685
|
-
accessToken: external_exports.string().min(1),
|
|
131686
|
-
optOutOfLocalDevDeploymentsUntilBetaOver: external_exports.boolean().optional()
|
|
131687
|
-
});
|
|
131688
|
-
function readGlobalConfig(ctx) {
|
|
131689
|
-
const configPath = globalConfigPath();
|
|
131690
|
-
let configFile;
|
|
131691
|
-
try {
|
|
131692
|
-
configFile = ctx.fs.readUtf8File(configPath);
|
|
131693
|
-
} catch {
|
|
131694
|
-
return null;
|
|
131695
|
-
}
|
|
131696
|
-
try {
|
|
131697
|
-
const storedConfig = JSON.parse(configFile);
|
|
131698
|
-
const config3 = schema.parse(storedConfig);
|
|
131699
|
-
return config3;
|
|
131700
|
-
} catch (err) {
|
|
131701
|
-
logError(
|
|
131702
|
-
chalkStderr.red(
|
|
131703
|
-
`Failed to parse global config in ${configPath} with error ${err}.`
|
|
131704
|
-
)
|
|
131705
|
-
);
|
|
131706
|
-
return null;
|
|
131707
|
-
}
|
|
131708
|
-
}
|
|
131709
|
-
async function modifyGlobalConfig(ctx, config3) {
|
|
131710
|
-
const configPath = globalConfigPath();
|
|
131711
|
-
let configFile;
|
|
131712
|
-
try {
|
|
131713
|
-
configFile = ctx.fs.readUtf8File(configPath);
|
|
131714
|
-
} catch {
|
|
131715
|
-
}
|
|
131716
|
-
let storedConfig = {};
|
|
131717
|
-
if (configFile) {
|
|
131718
|
-
try {
|
|
131719
|
-
storedConfig = JSON.parse(configFile);
|
|
131720
|
-
schema.parse(storedConfig);
|
|
131721
|
-
} catch (err) {
|
|
131722
|
-
logError(
|
|
131723
|
-
chalkStderr.red(
|
|
131724
|
-
`Failed to parse global config in ${configPath} with error ${err}.`
|
|
131725
|
-
)
|
|
131726
|
-
);
|
|
131727
|
-
storedConfig = {};
|
|
131728
|
-
}
|
|
131729
|
-
}
|
|
131730
|
-
const newConfig = { ...storedConfig, ...config3 };
|
|
131731
|
-
await overrwriteGlobalConfig(ctx, newConfig);
|
|
131732
|
-
}
|
|
131733
|
-
async function overrwriteGlobalConfig(ctx, config3) {
|
|
131734
|
-
const dirName = rootDirectory();
|
|
131735
|
-
ctx.fs.mkdir(dirName, { allowExisting: true });
|
|
131736
|
-
const path39 = globalConfigPath();
|
|
131737
|
-
try {
|
|
131738
|
-
ctx.fs.writeUtf8File(path39, JSON.stringify(config3, null, 2));
|
|
131739
|
-
} catch (err) {
|
|
131740
|
-
return await ctx.crash({
|
|
131741
|
-
exitCode: 1,
|
|
131742
|
-
errorType: "invalid filesystem data",
|
|
131743
|
-
errForSentry: err,
|
|
131744
|
-
printedMessage: chalkStderr.red(
|
|
131745
|
-
`Failed to write auth config to ${path39} with error: ${err}`
|
|
131746
|
-
)
|
|
131747
|
-
});
|
|
131748
|
-
}
|
|
131749
|
-
logVerbose(`Saved credentials to ${formatPathForPrinting(path39)}`);
|
|
131750
|
-
}
|
|
131751
|
-
function formatPathForPrinting(path39) {
|
|
131752
|
-
const homedir = import_os3.default.homedir();
|
|
131753
|
-
if (process.platform === "darwin" && path39.startsWith(homedir)) {
|
|
131754
|
-
return path39.replace(homedir, "~");
|
|
131755
|
-
}
|
|
131756
|
-
return path39;
|
|
131757
|
-
}
|
|
131758
|
-
|
|
131759
|
-
// src/cli/lib/deploymentSelection.ts
|
|
131760
|
-
init_utils5();
|
|
131761
|
-
var dotenv5 = __toESM(require_main(), 1);
|
|
131762
|
-
async function initializeBigBrainAuth(ctx, initialArgs) {
|
|
131763
|
-
if (initialArgs.url !== void 0 && initialArgs.adminKey !== void 0) {
|
|
131764
|
-
ctx._updateBigBrainAuth(
|
|
131765
|
-
getBigBrainAuth(ctx, {
|
|
131766
|
-
previewDeployKey: null,
|
|
131767
|
-
projectKey: null,
|
|
131768
|
-
deploymentKey: null
|
|
131769
|
-
})
|
|
131770
|
-
);
|
|
131771
|
-
return;
|
|
131772
|
-
}
|
|
131773
|
-
if (initialArgs.envFile !== void 0) {
|
|
131774
|
-
const existingFile = ctx.fs.exists(initialArgs.envFile) ? ctx.fs.readUtf8File(initialArgs.envFile) : null;
|
|
131775
|
-
if (existingFile === null) {
|
|
131776
|
-
return ctx.crash({
|
|
131777
|
-
exitCode: 1,
|
|
131778
|
-
errorType: "invalid filesystem or env vars",
|
|
131779
|
-
printedMessage: "env file does not exist"
|
|
131780
|
-
});
|
|
131781
|
-
}
|
|
131782
|
-
const config3 = dotenv5.parse(existingFile);
|
|
131783
|
-
const rawDeployKey2 = config3[CONVEX_DEPLOY_KEY_ENV_VAR_NAME];
|
|
131784
|
-
const deployKey2 = await processDeployKeyValue(ctx, rawDeployKey2);
|
|
131785
|
-
if (deployKey2 !== void 0) {
|
|
131786
|
-
const bigBrainAuth = getBigBrainAuth(ctx, {
|
|
131787
|
-
previewDeployKey: isPreviewDeployKey(deployKey2) ? deployKey2 : null,
|
|
131788
|
-
projectKey: isProjectKey(deployKey2) ? deployKey2 : null,
|
|
131789
|
-
deploymentKey: isDeploymentKey(deployKey2) ? deployKey2 : null
|
|
131790
|
-
});
|
|
131791
|
-
ctx._updateBigBrainAuth(bigBrainAuth);
|
|
131792
|
-
return;
|
|
131793
|
-
}
|
|
131794
|
-
ctx._updateBigBrainAuth(
|
|
131795
|
-
getBigBrainAuth(ctx, {
|
|
131796
|
-
previewDeployKey: null,
|
|
131797
|
-
projectKey: null,
|
|
131798
|
-
deploymentKey: null
|
|
131799
|
-
})
|
|
131800
|
-
);
|
|
131801
|
-
return;
|
|
131802
|
-
}
|
|
131803
|
-
dotenv5.config({ path: ENV_VAR_FILE_PATH });
|
|
131804
|
-
dotenv5.config();
|
|
131805
|
-
const rawDeployKey = process.env[CONVEX_DEPLOY_KEY_ENV_VAR_NAME];
|
|
131806
|
-
const deployKey = await processDeployKeyValue(ctx, rawDeployKey);
|
|
131807
|
-
if (deployKey !== void 0) {
|
|
131808
|
-
const bigBrainAuth = getBigBrainAuth(ctx, {
|
|
131809
|
-
previewDeployKey: isPreviewDeployKey(deployKey) ? deployKey : null,
|
|
131810
|
-
projectKey: isProjectKey(deployKey) ? deployKey : null,
|
|
131811
|
-
deploymentKey: isDeploymentKey(deployKey) ? deployKey : null
|
|
131812
|
-
});
|
|
131813
|
-
ctx._updateBigBrainAuth(bigBrainAuth);
|
|
131814
|
-
return;
|
|
131815
|
-
}
|
|
131816
|
-
ctx._updateBigBrainAuth(
|
|
131817
|
-
getBigBrainAuth(ctx, {
|
|
131818
|
-
previewDeployKey: null,
|
|
131819
|
-
projectKey: null,
|
|
131820
|
-
deploymentKey: null
|
|
131821
|
-
})
|
|
131822
|
-
);
|
|
131823
|
-
return;
|
|
131824
|
-
}
|
|
131825
|
-
async function updateBigBrainAuthAfterLogin(ctx, accessToken) {
|
|
131826
|
-
const existingAuth = ctx.bigBrainAuth();
|
|
131827
|
-
if (existingAuth !== null && existingAuth.kind === "projectKey") {
|
|
131828
|
-
logVerbose(
|
|
131829
|
-
`Ignoring update to big brain auth since project key takes precedence`
|
|
131830
|
-
);
|
|
131831
|
-
return;
|
|
131832
|
-
}
|
|
131833
|
-
ctx._updateBigBrainAuth({
|
|
131834
|
-
accessToken,
|
|
131835
|
-
kind: "accessToken",
|
|
131836
|
-
header: `Bearer ${accessToken}`
|
|
131837
|
-
});
|
|
131838
|
-
}
|
|
131839
|
-
function getBigBrainAuth(ctx, opts) {
|
|
131840
|
-
if (process.env.CONVEX_OVERRIDE_ACCESS_TOKEN) {
|
|
131841
|
-
return {
|
|
131842
|
-
accessToken: process.env.CONVEX_OVERRIDE_ACCESS_TOKEN,
|
|
131843
|
-
kind: "accessToken",
|
|
131844
|
-
header: `Bearer ${process.env.CONVEX_OVERRIDE_ACCESS_TOKEN}`
|
|
131845
|
-
};
|
|
131846
|
-
}
|
|
131847
|
-
if (opts.projectKey !== null) {
|
|
131848
|
-
return {
|
|
131849
|
-
header: `Bearer ${opts.projectKey}`,
|
|
131850
|
-
kind: "projectKey",
|
|
131851
|
-
projectKey: opts.projectKey
|
|
131852
|
-
};
|
|
131853
|
-
}
|
|
131854
|
-
if (opts.deploymentKey !== null) {
|
|
131855
|
-
return {
|
|
131856
|
-
header: `Bearer ${opts.deploymentKey}`,
|
|
131857
|
-
kind: "deploymentKey",
|
|
131858
|
-
deploymentKey: opts.deploymentKey
|
|
131859
|
-
};
|
|
131860
|
-
}
|
|
131861
|
-
const globalConfig2 = readGlobalConfig(ctx);
|
|
131862
|
-
if (globalConfig2) {
|
|
131863
|
-
return {
|
|
131864
|
-
kind: "accessToken",
|
|
131865
|
-
header: `Bearer ${globalConfig2.accessToken}`,
|
|
131866
|
-
accessToken: globalConfig2.accessToken
|
|
131867
|
-
};
|
|
131868
|
-
}
|
|
131869
|
-
if (opts.previewDeployKey !== null) {
|
|
131870
|
-
return {
|
|
131871
|
-
header: `Bearer ${opts.previewDeployKey}`,
|
|
131872
|
-
kind: "previewDeployKey",
|
|
131873
|
-
previewDeployKey: opts.previewDeployKey
|
|
131874
|
-
};
|
|
131875
|
-
}
|
|
131876
|
-
return null;
|
|
131877
|
-
}
|
|
131878
|
-
async function getDeploymentSelection(ctx, cliArgs) {
|
|
131879
|
-
const metadata = await _getDeploymentSelection(ctx, cliArgs);
|
|
131880
|
-
if (metadata.kind === "existingDeployment") {
|
|
131881
|
-
const selectionWithinProject = deploymentSelectionWithinProjectFromOptions(cliArgs);
|
|
131882
|
-
await validateDeploymentSelectionForExistingDeployment(
|
|
131883
|
-
ctx,
|
|
131884
|
-
selectionWithinProject,
|
|
131885
|
-
metadata.deploymentToActOn.source
|
|
131886
|
-
);
|
|
131887
|
-
}
|
|
131888
|
-
logDeploymentSelection(ctx, metadata);
|
|
131889
|
-
return metadata;
|
|
131890
|
-
}
|
|
131891
|
-
function logDeploymentSelection(_ctx, selection) {
|
|
131892
|
-
switch (selection.kind) {
|
|
131893
|
-
case "existingDeployment": {
|
|
131894
|
-
logVerbose(
|
|
131895
|
-
`Existing deployment: ${selection.deploymentToActOn.url} ${selection.deploymentToActOn.source}`
|
|
131896
|
-
);
|
|
131897
|
-
break;
|
|
131898
|
-
}
|
|
131899
|
-
case "deploymentWithinProject": {
|
|
131900
|
-
logVerbose(
|
|
131901
|
-
`Deployment within project: ${prettyProjectSelection(selection.targetProject)}`
|
|
131902
|
-
);
|
|
131903
|
-
break;
|
|
131904
|
-
}
|
|
131905
|
-
case "preview": {
|
|
131906
|
-
logVerbose(`Preview deploy key`);
|
|
131907
|
-
break;
|
|
131908
|
-
}
|
|
131909
|
-
case "chooseProject": {
|
|
131910
|
-
logVerbose(`Choose project`);
|
|
131911
|
-
break;
|
|
131912
|
-
}
|
|
131913
|
-
case "anonymous": {
|
|
131914
|
-
logVerbose(
|
|
131915
|
-
`Anonymous, has selected deployment?: ${selection.deploymentName !== null}`
|
|
131916
|
-
);
|
|
131917
|
-
break;
|
|
131918
|
-
}
|
|
131919
|
-
default: {
|
|
131920
|
-
selection;
|
|
131921
|
-
logVerbose(`Unknown deployment selection`);
|
|
131922
|
-
}
|
|
131923
|
-
}
|
|
131924
|
-
return null;
|
|
131925
|
-
}
|
|
131926
|
-
function prettyProjectSelection(selection) {
|
|
131927
|
-
switch (selection.kind) {
|
|
131928
|
-
case "teamAndProjectSlugs": {
|
|
131929
|
-
return `Team and project slugs: ${selection.teamSlug} ${selection.projectSlug}`;
|
|
131930
|
-
}
|
|
131931
|
-
case "deploymentName": {
|
|
131932
|
-
return `Deployment name: ${selection.deploymentName}`;
|
|
131933
|
-
}
|
|
131934
|
-
case "projectDeployKey": {
|
|
131935
|
-
return `Project deploy key`;
|
|
131936
|
-
}
|
|
131937
|
-
default: {
|
|
131938
|
-
selection;
|
|
131939
|
-
return `Unknown`;
|
|
131940
|
-
}
|
|
131941
|
-
}
|
|
131942
|
-
}
|
|
131943
|
-
async function _getDeploymentSelection(ctx, cliArgs) {
|
|
131944
|
-
const selectionWithinProject = deploymentSelectionWithinProjectFromOptions(cliArgs);
|
|
131945
|
-
if (cliArgs.url !== void 0 && cliArgs.adminKey !== void 0) {
|
|
131946
|
-
return {
|
|
131947
|
-
kind: "existingDeployment",
|
|
131948
|
-
deploymentToActOn: {
|
|
131949
|
-
url: cliArgs.url,
|
|
131950
|
-
adminKey: cliArgs.adminKey,
|
|
131951
|
-
deploymentFields: null,
|
|
131952
|
-
source: "cliArgs"
|
|
131953
|
-
}
|
|
131954
|
-
};
|
|
131955
|
-
}
|
|
131956
|
-
if (cliArgs.deployment !== void 0) {
|
|
131957
|
-
const parsed = parseDeploymentSelector(cliArgs.deployment);
|
|
131958
|
-
if (parsed.kind === "inTeamProject") {
|
|
131959
|
-
return {
|
|
131960
|
-
kind: "deploymentWithinProject",
|
|
131961
|
-
targetProject: {
|
|
131962
|
-
kind: "teamAndProjectSlugs",
|
|
131963
|
-
teamSlug: parsed.teamSlug,
|
|
131964
|
-
projectSlug: parsed.projectSlug
|
|
131965
|
-
},
|
|
131966
|
-
selectionWithinProject: {
|
|
131967
|
-
kind: "deploymentSelector",
|
|
131968
|
-
selector: cliArgs.deployment
|
|
131969
|
-
}
|
|
131970
|
-
};
|
|
131971
|
-
}
|
|
131972
|
-
if (parsed.kind === "deploymentName") {
|
|
131973
|
-
return {
|
|
131974
|
-
kind: "deploymentWithinProject",
|
|
131975
|
-
targetProject: {
|
|
131976
|
-
kind: "deploymentName",
|
|
131977
|
-
deploymentName: parsed.deploymentName,
|
|
131978
|
-
deploymentType: null
|
|
131979
|
-
},
|
|
131980
|
-
selectionWithinProject: {
|
|
131981
|
-
kind: "deploymentSelector",
|
|
131982
|
-
selector: cliArgs.deployment
|
|
131983
|
-
}
|
|
131984
|
-
};
|
|
131985
|
-
}
|
|
131986
|
-
if (parsed.kind === "local") {
|
|
131987
|
-
const localConfig = loadProjectLocalConfig(ctx);
|
|
131988
|
-
if (localConfig !== null) {
|
|
131989
|
-
return {
|
|
131990
|
-
kind: "deploymentWithinProject",
|
|
131991
|
-
targetProject: {
|
|
131992
|
-
kind: "deploymentName",
|
|
131993
|
-
deploymentName: localConfig.deploymentName,
|
|
131994
|
-
deploymentType: "local"
|
|
131995
|
-
},
|
|
131996
|
-
selectionWithinProject
|
|
131997
|
-
};
|
|
131998
|
-
}
|
|
131999
|
-
return ctx.crash({
|
|
132000
|
-
exitCode: 1,
|
|
132001
|
-
errorType: "fatal",
|
|
132002
|
-
printedMessage: `No local deployment found. Run ${chalkStderr.bold("npx convex deployment create local")} to create one.`
|
|
132003
|
-
});
|
|
132004
|
-
}
|
|
132005
|
-
}
|
|
132006
|
-
if (cliArgs.envFile !== void 0) {
|
|
132007
|
-
logVerbose(`Checking env file: ${cliArgs.envFile}`);
|
|
132008
|
-
const existingFile = ctx.fs.exists(cliArgs.envFile) ? ctx.fs.readUtf8File(cliArgs.envFile) : null;
|
|
132009
|
-
if (existingFile === null) {
|
|
132010
|
-
return ctx.crash({
|
|
132011
|
-
exitCode: 1,
|
|
132012
|
-
errorType: "invalid filesystem or env vars",
|
|
132013
|
-
printedMessage: "env file does not exist"
|
|
132014
|
-
});
|
|
132015
|
-
}
|
|
132016
|
-
const config3 = dotenv5.parse(existingFile);
|
|
132017
|
-
const result2 = await getDeploymentSelectionFromEnv(
|
|
132018
|
-
ctx,
|
|
132019
|
-
selectionWithinProject,
|
|
132020
|
-
(name) => config3[name] === void 0 || config3[name] === "" ? null : config3[name]
|
|
132021
|
-
);
|
|
132022
|
-
if (result2.kind === "unknown") {
|
|
132023
|
-
return ctx.crash({
|
|
132024
|
-
exitCode: 1,
|
|
132025
|
-
errorType: "invalid filesystem or env vars",
|
|
132026
|
-
printedMessage: `env file \`${cliArgs.envFile}\` did not contain environment variables for a Convex deployment. Expected \`${CONVEX_DEPLOY_KEY_ENV_VAR_NAME}\`, \`${CONVEX_DEPLOYMENT_ENV_VAR_NAME}\`, or both \`${CONVEX_SELF_HOSTED_URL_VAR_NAME}\` and \`${CONVEX_SELF_HOSTED_ADMIN_KEY_VAR_NAME}\` to be set.`
|
|
132027
|
-
});
|
|
132028
|
-
}
|
|
132029
|
-
return result2.metadata;
|
|
132030
|
-
}
|
|
132031
|
-
dotenv5.config({ path: ENV_VAR_FILE_PATH });
|
|
132032
|
-
dotenv5.config();
|
|
132033
|
-
const result = await getDeploymentSelectionFromEnv(
|
|
132034
|
-
ctx,
|
|
132035
|
-
selectionWithinProject,
|
|
132036
|
-
(name) => {
|
|
132037
|
-
const value = process.env[name];
|
|
132038
|
-
if (value === void 0 || value === "") {
|
|
132039
|
-
return null;
|
|
132040
|
-
}
|
|
132041
|
-
return value;
|
|
132042
|
-
}
|
|
132043
|
-
);
|
|
132044
|
-
if (result.kind !== "unknown") {
|
|
132045
|
-
return result.metadata;
|
|
132046
|
-
}
|
|
132047
|
-
const isLoggedIn = ctx.bigBrainAuth() !== null;
|
|
132048
|
-
if ((!isLoggedIn || process.env.CONVEX_AGENT_MODE === "anonymous" || !process.stdin.isTTY) && !cliArgs.implicitProd && shouldAllowAnonymousDevelopment()) {
|
|
132049
|
-
return {
|
|
132050
|
-
kind: "anonymous",
|
|
132051
|
-
deploymentName: null,
|
|
132052
|
-
selectionWithinProject
|
|
132053
|
-
};
|
|
132054
|
-
}
|
|
132055
|
-
return {
|
|
132056
|
-
kind: "chooseProject",
|
|
132057
|
-
selectionWithinProject
|
|
132058
|
-
};
|
|
132059
|
-
}
|
|
132060
|
-
async function getDeploymentSelectionFromEnv(ctx, selectionWithinProject, getEnv) {
|
|
132061
|
-
const rawDeployKey = getEnv(CONVEX_DEPLOY_KEY_ENV_VAR_NAME);
|
|
132062
|
-
const deployKey = await processDeployKeyValue(
|
|
132063
|
-
ctx,
|
|
132064
|
-
rawDeployKey === null ? void 0 : rawDeployKey
|
|
132065
|
-
);
|
|
132066
|
-
if (deployKey !== void 0) {
|
|
132067
|
-
const deployKeyType = isPreviewDeployKey(deployKey) ? "preview" : isProjectKey(deployKey) ? "project" : "deployment";
|
|
132068
|
-
switch (deployKeyType) {
|
|
132069
|
-
case "preview": {
|
|
132070
|
-
return {
|
|
132071
|
-
kind: "success",
|
|
132072
|
-
metadata: {
|
|
132073
|
-
kind: "preview",
|
|
132074
|
-
previewDeployKey: deployKey,
|
|
132075
|
-
selectionWithinProject
|
|
132076
|
-
}
|
|
132077
|
-
};
|
|
132078
|
-
}
|
|
132079
|
-
case "project": {
|
|
132080
|
-
return {
|
|
132081
|
-
kind: "success",
|
|
132082
|
-
metadata: {
|
|
132083
|
-
kind: "deploymentWithinProject",
|
|
132084
|
-
targetProject: {
|
|
132085
|
-
kind: "projectDeployKey",
|
|
132086
|
-
projectDeployKey: deployKey
|
|
132087
|
-
},
|
|
132088
|
-
selectionWithinProject
|
|
132089
|
-
}
|
|
132090
|
-
};
|
|
132091
|
-
}
|
|
132092
|
-
case "deployment": {
|
|
132093
|
-
const deploymentName = await deploymentNameFromAdminKeyOrCrash(
|
|
132094
|
-
ctx,
|
|
132095
|
-
deployKey
|
|
132096
|
-
);
|
|
132097
|
-
const deploymentType = deploymentTypeFromAdminKey(deployKey);
|
|
132098
|
-
const url = await bigBrainAPI({
|
|
132099
|
-
ctx,
|
|
132100
|
-
method: "POST",
|
|
132101
|
-
path: "deployment/url_for_key",
|
|
132102
|
-
data: {
|
|
132103
|
-
deployKey
|
|
132169
|
+
this.dispatchEvent(createFastMessageEvent(
|
|
132170
|
+
event.type,
|
|
132171
|
+
event.options
|
|
132172
|
+
));
|
|
132104
132173
|
}
|
|
132105
132174
|
});
|
|
132106
|
-
|
|
132107
|
-
|
|
132108
|
-
|
|
132109
|
-
|
|
132110
|
-
|
|
132111
|
-
|
|
132112
|
-
|
|
132113
|
-
adminKey: deployKey,
|
|
132114
|
-
deploymentFields: {
|
|
132115
|
-
deploymentName,
|
|
132116
|
-
deploymentType,
|
|
132117
|
-
teamSlug: slugs.team,
|
|
132118
|
-
projectSlug: slugs.project
|
|
132119
|
-
},
|
|
132120
|
-
source: "deployKey"
|
|
132175
|
+
pipeline(
|
|
132176
|
+
response.body.stream,
|
|
132177
|
+
eventSourceStream,
|
|
132178
|
+
(error3) => {
|
|
132179
|
+
if ((error3 == null ? void 0 : error3.aborted) === false) {
|
|
132180
|
+
this.close();
|
|
132181
|
+
this.dispatchEvent(new Event("error"));
|
|
132121
132182
|
}
|
|
132122
132183
|
}
|
|
132123
|
-
|
|
132124
|
-
}
|
|
132125
|
-
|
|
132126
|
-
|
|
132127
|
-
|
|
132128
|
-
|
|
132129
|
-
|
|
132130
|
-
|
|
132131
|
-
|
|
132132
|
-
|
|
132133
|
-
|
|
132134
|
-
|
|
132135
|
-
|
|
132136
|
-
|
|
132137
|
-
|
|
132138
|
-
|
|
132139
|
-
|
|
132140
|
-
return await ctx.crash({
|
|
132141
|
-
exitCode: 1,
|
|
132142
|
-
errorType: "invalid filesystem or env vars",
|
|
132143
|
-
printedMessage: `${CONVEX_DEPLOYMENT_ENV_VAR_NAME} must not be set when ${CONVEX_SELF_HOSTED_URL_VAR_NAME} and ${CONVEX_SELF_HOSTED_ADMIN_KEY_VAR_NAME} are set`
|
|
132144
|
-
});
|
|
132145
|
-
}
|
|
132146
|
-
return {
|
|
132147
|
-
kind: "success",
|
|
132148
|
-
metadata: {
|
|
132149
|
-
kind: "existingDeployment",
|
|
132150
|
-
deploymentToActOn: {
|
|
132151
|
-
url: selfHostedUrl,
|
|
132152
|
-
adminKey: selfHostedAdminKey,
|
|
132153
|
-
deploymentFields: null,
|
|
132154
|
-
source: "selfHosted"
|
|
132184
|
+
);
|
|
132185
|
+
};
|
|
132186
|
+
__privateSet(this, _controller, fetching(fetchParams));
|
|
132187
|
+
};
|
|
132188
|
+
/**
|
|
132189
|
+
* @see https://html.spec.whatwg.org/multipage/server-sent-events.html#sse-processing-model
|
|
132190
|
+
* @returns {void}
|
|
132191
|
+
*/
|
|
132192
|
+
reconnect_fn = function() {
|
|
132193
|
+
var _a2;
|
|
132194
|
+
if (__privateGet(this, _readyState) === CLOSED) return;
|
|
132195
|
+
__privateSet(this, _readyState, CONNECTING);
|
|
132196
|
+
this.dispatchEvent(new Event("error"));
|
|
132197
|
+
(_a2 = setTimeout(() => {
|
|
132198
|
+
if (__privateGet(this, _readyState) !== CONNECTING) return;
|
|
132199
|
+
if (__privateGet(this, _state).lastEventId.length) {
|
|
132200
|
+
__privateGet(this, _request).headersList.set("last-event-id", __privateGet(this, _state).lastEventId, true);
|
|
132155
132201
|
}
|
|
132202
|
+
__privateMethod(this, _EventSource_instances, connect_fn).call(this);
|
|
132203
|
+
}, __privateGet(this, _state).reconnectionTime)) == null ? void 0 : _a2.unref();
|
|
132204
|
+
};
|
|
132205
|
+
var EventSource = _EventSource;
|
|
132206
|
+
var constantsPropertyDescriptors = {
|
|
132207
|
+
CONNECTING: {
|
|
132208
|
+
__proto__: null,
|
|
132209
|
+
configurable: false,
|
|
132210
|
+
enumerable: true,
|
|
132211
|
+
value: CONNECTING,
|
|
132212
|
+
writable: false
|
|
132213
|
+
},
|
|
132214
|
+
OPEN: {
|
|
132215
|
+
__proto__: null,
|
|
132216
|
+
configurable: false,
|
|
132217
|
+
enumerable: true,
|
|
132218
|
+
value: OPEN,
|
|
132219
|
+
writable: false
|
|
132220
|
+
},
|
|
132221
|
+
CLOSED: {
|
|
132222
|
+
__proto__: null,
|
|
132223
|
+
configurable: false,
|
|
132224
|
+
enumerable: true,
|
|
132225
|
+
value: CLOSED,
|
|
132226
|
+
writable: false
|
|
132156
132227
|
}
|
|
132157
132228
|
};
|
|
132158
|
-
|
|
132159
|
-
|
|
132160
|
-
|
|
132161
|
-
|
|
132162
|
-
|
|
132163
|
-
|
|
132164
|
-
|
|
132165
|
-
|
|
132166
|
-
|
|
132167
|
-
|
|
132168
|
-
|
|
132169
|
-
|
|
132229
|
+
Object.defineProperties(EventSource, constantsPropertyDescriptors);
|
|
132230
|
+
Object.defineProperties(EventSource.prototype, constantsPropertyDescriptors);
|
|
132231
|
+
Object.defineProperties(EventSource.prototype, {
|
|
132232
|
+
close: kEnumerableProperty,
|
|
132233
|
+
onerror: kEnumerableProperty,
|
|
132234
|
+
onmessage: kEnumerableProperty,
|
|
132235
|
+
onopen: kEnumerableProperty,
|
|
132236
|
+
readyState: kEnumerableProperty,
|
|
132237
|
+
url: kEnumerableProperty,
|
|
132238
|
+
withCredentials: kEnumerableProperty
|
|
132239
|
+
});
|
|
132240
|
+
webidl.converters.EventSourceInitDict = webidl.dictionaryConverter([
|
|
132241
|
+
{
|
|
132242
|
+
key: "withCredentials",
|
|
132243
|
+
converter: webidl.converters.boolean,
|
|
132244
|
+
defaultValue: () => false
|
|
132245
|
+
},
|
|
132246
|
+
{
|
|
132247
|
+
key: "dispatcher",
|
|
132248
|
+
// undici only
|
|
132249
|
+
converter: webidl.converters.any
|
|
132250
|
+
},
|
|
132251
|
+
{
|
|
132252
|
+
key: "node",
|
|
132253
|
+
// undici only
|
|
132254
|
+
converter: webidl.dictionaryConverter([
|
|
132255
|
+
{
|
|
132256
|
+
key: "reconnectionTime",
|
|
132257
|
+
converter: webidl.converters["unsigned long"],
|
|
132258
|
+
defaultValue: () => defaultReconnectionTime
|
|
132259
|
+
},
|
|
132260
|
+
{
|
|
132261
|
+
key: "dispatcher",
|
|
132262
|
+
converter: webidl.converters.any
|
|
132263
|
+
}
|
|
132264
|
+
]),
|
|
132265
|
+
defaultValue: () => ({})
|
|
132170
132266
|
}
|
|
132267
|
+
]);
|
|
132268
|
+
module2.exports = {
|
|
132269
|
+
EventSource,
|
|
132270
|
+
defaultReconnectionTime
|
|
132171
132271
|
};
|
|
132172
132272
|
}
|
|
132173
|
-
|
|
132174
|
-
|
|
132175
|
-
|
|
132176
|
-
|
|
132177
|
-
|
|
132178
|
-
|
|
132179
|
-
|
|
132180
|
-
|
|
132181
|
-
|
|
132182
|
-
|
|
132183
|
-
|
|
132184
|
-
|
|
132185
|
-
|
|
132186
|
-
|
|
132187
|
-
|
|
132188
|
-
|
|
132189
|
-
|
|
132190
|
-
|
|
132191
|
-
|
|
132192
|
-
|
|
132193
|
-
|
|
132194
|
-
|
|
132195
|
-
|
|
132273
|
+
});
|
|
132274
|
+
|
|
132275
|
+
// ../common/temp/node_modules/.pnpm/undici@7.24.0/node_modules/undici/index.js
|
|
132276
|
+
var require_undici2 = __commonJS({
|
|
132277
|
+
"../common/temp/node_modules/.pnpm/undici@7.24.0/node_modules/undici/index.js"(exports2, module2) {
|
|
132278
|
+
"use strict";
|
|
132279
|
+
var Client = require_client4();
|
|
132280
|
+
var Dispatcher = require_dispatcher();
|
|
132281
|
+
var Pool = require_pool();
|
|
132282
|
+
var BalancedPool = require_balanced_pool();
|
|
132283
|
+
var RoundRobinPool = require_round_robin_pool();
|
|
132284
|
+
var Agent = require_agent();
|
|
132285
|
+
var ProxyAgent = require_proxy_agent();
|
|
132286
|
+
var Socks5ProxyAgent = require_socks5_proxy_agent();
|
|
132287
|
+
var EnvHttpProxyAgent2 = require_env_http_proxy_agent();
|
|
132288
|
+
var RetryAgent = require_retry_agent();
|
|
132289
|
+
var H2CClient = require_h2c_client();
|
|
132290
|
+
var errors2 = require_errors6();
|
|
132291
|
+
var util3 = require_util4();
|
|
132292
|
+
var { InvalidArgumentError: InvalidArgumentError3 } = errors2;
|
|
132293
|
+
var api = require_api2();
|
|
132294
|
+
var buildConnector = require_connect();
|
|
132295
|
+
var MockClient = require_mock_client();
|
|
132296
|
+
var { MockCallHistory, MockCallHistoryLog } = require_mock_call_history();
|
|
132297
|
+
var MockAgent = require_mock_agent();
|
|
132298
|
+
var MockPool = require_mock_pool();
|
|
132299
|
+
var SnapshotAgent = require_snapshot_agent();
|
|
132300
|
+
var mockErrors = require_mock_errors();
|
|
132301
|
+
var RetryHandler = require_retry_handler();
|
|
132302
|
+
var { getGlobalDispatcher, setGlobalDispatcher: setGlobalDispatcher2 } = require_global2();
|
|
132303
|
+
var DecoratorHandler = require_decorator_handler();
|
|
132304
|
+
var RedirectHandler = require_redirect_handler();
|
|
132305
|
+
Object.assign(Dispatcher.prototype, api);
|
|
132306
|
+
module2.exports.Dispatcher = Dispatcher;
|
|
132307
|
+
module2.exports.Client = Client;
|
|
132308
|
+
module2.exports.Pool = Pool;
|
|
132309
|
+
module2.exports.BalancedPool = BalancedPool;
|
|
132310
|
+
module2.exports.RoundRobinPool = RoundRobinPool;
|
|
132311
|
+
module2.exports.Agent = Agent;
|
|
132312
|
+
module2.exports.ProxyAgent = ProxyAgent;
|
|
132313
|
+
module2.exports.Socks5ProxyAgent = Socks5ProxyAgent;
|
|
132314
|
+
module2.exports.EnvHttpProxyAgent = EnvHttpProxyAgent2;
|
|
132315
|
+
module2.exports.RetryAgent = RetryAgent;
|
|
132316
|
+
module2.exports.H2CClient = H2CClient;
|
|
132317
|
+
module2.exports.RetryHandler = RetryHandler;
|
|
132318
|
+
module2.exports.DecoratorHandler = DecoratorHandler;
|
|
132319
|
+
module2.exports.RedirectHandler = RedirectHandler;
|
|
132320
|
+
module2.exports.interceptors = {
|
|
132321
|
+
redirect: require_redirect(),
|
|
132322
|
+
responseError: require_response_error(),
|
|
132323
|
+
retry: require_retry(),
|
|
132324
|
+
dump: require_dump(),
|
|
132325
|
+
dns: require_dns(),
|
|
132326
|
+
cache: require_cache3(),
|
|
132327
|
+
decompress: require_decompress(),
|
|
132328
|
+
deduplicate: require_deduplicate()
|
|
132329
|
+
};
|
|
132330
|
+
module2.exports.cacheStores = {
|
|
132331
|
+
MemoryCacheStore: require_memory_cache_store()
|
|
132332
|
+
};
|
|
132333
|
+
var SqliteCacheStore = require_sqlite_cache_store();
|
|
132334
|
+
module2.exports.cacheStores.SqliteCacheStore = SqliteCacheStore;
|
|
132335
|
+
module2.exports.buildConnector = buildConnector;
|
|
132336
|
+
module2.exports.errors = errors2;
|
|
132337
|
+
module2.exports.util = {
|
|
132338
|
+
parseHeaders: util3.parseHeaders,
|
|
132339
|
+
headerNameToString: util3.headerNameToString
|
|
132340
|
+
};
|
|
132341
|
+
function makeDispatcher(fn) {
|
|
132342
|
+
return (url, opts, handler) => {
|
|
132343
|
+
if (typeof opts === "function") {
|
|
132344
|
+
handler = opts;
|
|
132345
|
+
opts = null;
|
|
132346
|
+
}
|
|
132347
|
+
if (!url || typeof url !== "string" && typeof url !== "object" && !(url instanceof URL)) {
|
|
132348
|
+
throw new InvalidArgumentError3("invalid url");
|
|
132349
|
+
}
|
|
132350
|
+
if (opts != null && typeof opts !== "object") {
|
|
132351
|
+
throw new InvalidArgumentError3("invalid opts");
|
|
132352
|
+
}
|
|
132353
|
+
if (opts && opts.path != null) {
|
|
132354
|
+
if (typeof opts.path !== "string") {
|
|
132355
|
+
throw new InvalidArgumentError3("invalid opts.path");
|
|
132356
|
+
}
|
|
132357
|
+
let path39 = opts.path;
|
|
132358
|
+
if (!opts.path.startsWith("/")) {
|
|
132359
|
+
path39 = `/${path39}`;
|
|
132360
|
+
}
|
|
132361
|
+
url = new URL(util3.parseOrigin(url).origin + path39);
|
|
132362
|
+
} else {
|
|
132363
|
+
if (!opts) {
|
|
132364
|
+
opts = typeof url === "object" ? url : {};
|
|
132365
|
+
}
|
|
132366
|
+
url = util3.parseURL(url);
|
|
132367
|
+
}
|
|
132368
|
+
const { agent, dispatcher = getGlobalDispatcher() } = opts;
|
|
132369
|
+
if (agent) {
|
|
132370
|
+
throw new InvalidArgumentError3("unsupported opts.agent. Did you mean opts.client?");
|
|
132196
132371
|
}
|
|
132372
|
+
return fn.call(dispatcher, {
|
|
132373
|
+
...opts,
|
|
132374
|
+
origin: url.origin,
|
|
132375
|
+
path: url.search ? `${url.pathname}${url.search}` : url.pathname,
|
|
132376
|
+
method: opts.method || (opts.body ? "PUT" : "GET")
|
|
132377
|
+
}, handler);
|
|
132197
132378
|
};
|
|
132198
132379
|
}
|
|
132199
|
-
|
|
132200
|
-
|
|
132201
|
-
|
|
132202
|
-
|
|
132203
|
-
|
|
132204
|
-
|
|
132205
|
-
|
|
132206
|
-
metadata: {
|
|
132207
|
-
kind: "deploymentWithinProject",
|
|
132208
|
-
targetProject: {
|
|
132209
|
-
kind: "deploymentName",
|
|
132210
|
-
deploymentName: targetDeploymentName,
|
|
132211
|
-
deploymentType: targetDeploymentType
|
|
132212
|
-
},
|
|
132213
|
-
selectionWithinProject: newSelectionWithinProject
|
|
132380
|
+
module2.exports.setGlobalDispatcher = setGlobalDispatcher2;
|
|
132381
|
+
module2.exports.getGlobalDispatcher = getGlobalDispatcher;
|
|
132382
|
+
var fetchImpl = require_fetch3().fetch;
|
|
132383
|
+
var currentFilename = typeof __filename !== "undefined" ? __filename : void 0;
|
|
132384
|
+
function appendFetchStackTrace(err, filename) {
|
|
132385
|
+
if (!err || typeof err !== "object") {
|
|
132386
|
+
return;
|
|
132214
132387
|
}
|
|
132215
|
-
|
|
132216
|
-
|
|
132217
|
-
|
|
132218
|
-
|
|
132219
|
-
}
|
|
132220
|
-
async function checkIfBuildEnvironmentRequiresDeploymentConfig(ctx) {
|
|
132221
|
-
const buildEnvironment = getBuildEnvironment();
|
|
132222
|
-
if (buildEnvironment) {
|
|
132223
|
-
return await ctx.crash({
|
|
132224
|
-
exitCode: 1,
|
|
132225
|
-
errorType: "fatal",
|
|
132226
|
-
printedMessage: `${buildEnvironment} build environment detected but no Convex deployment configuration found.
|
|
132227
|
-
Set one of:
|
|
132228
|
-
\u2022 ${CONVEX_DEPLOY_KEY_ENV_VAR_NAME} for Convex Cloud deployments
|
|
132229
|
-
\u2022 ${CONVEX_SELF_HOSTED_URL_VAR_NAME} and ${CONVEX_SELF_HOSTED_ADMIN_KEY_VAR_NAME} for self-hosted deployments
|
|
132230
|
-
See https://docs.convex.dev/production/hosting or https://docs.convex.dev/self-hosting`
|
|
132231
|
-
});
|
|
132232
|
-
}
|
|
132233
|
-
}
|
|
132234
|
-
var deploymentNameFromSelection = (selection) => {
|
|
132235
|
-
var _a2;
|
|
132236
|
-
return ((_a2 = deploymentNameAndTypeFromSelection(selection)) == null ? void 0 : _a2.name) ?? null;
|
|
132237
|
-
};
|
|
132238
|
-
var deploymentNameAndTypeFromSelection = (selection) => {
|
|
132239
|
-
var _a2, _b2;
|
|
132240
|
-
switch (selection.kind) {
|
|
132241
|
-
case "existingDeployment": {
|
|
132242
|
-
return {
|
|
132243
|
-
name: ((_a2 = selection.deploymentToActOn.deploymentFields) == null ? void 0 : _a2.deploymentName) ?? null,
|
|
132244
|
-
type: ((_b2 = selection.deploymentToActOn.deploymentFields) == null ? void 0 : _b2.deploymentType) ?? null
|
|
132245
|
-
};
|
|
132246
|
-
}
|
|
132247
|
-
case "deploymentWithinProject": {
|
|
132248
|
-
return selection.targetProject.kind === "deploymentName" ? {
|
|
132249
|
-
name: selection.targetProject.deploymentName,
|
|
132250
|
-
type: selection.targetProject.deploymentType
|
|
132251
|
-
} : null;
|
|
132252
|
-
}
|
|
132253
|
-
case "preview": {
|
|
132254
|
-
return null;
|
|
132255
|
-
}
|
|
132256
|
-
case "chooseProject": {
|
|
132257
|
-
return null;
|
|
132258
|
-
}
|
|
132259
|
-
case "anonymous": {
|
|
132260
|
-
return null;
|
|
132261
|
-
}
|
|
132262
|
-
default: {
|
|
132263
|
-
selection;
|
|
132264
|
-
}
|
|
132265
|
-
}
|
|
132266
|
-
return null;
|
|
132267
|
-
};
|
|
132268
|
-
var shouldAllowAnonymousDevelopment = () => {
|
|
132269
|
-
if (process.env.CONVEX_ALLOW_ANONYMOUS === "false") {
|
|
132270
|
-
return false;
|
|
132271
|
-
}
|
|
132272
|
-
return true;
|
|
132273
|
-
};
|
|
132274
|
-
async function getProjectDetails(ctx, projectSelection) {
|
|
132275
|
-
switch (projectSelection.kind) {
|
|
132276
|
-
case "deploymentName": {
|
|
132277
|
-
if (projectSelection.deploymentType === "local") {
|
|
132278
|
-
const result = await getTeamAndProjectSlugForDeployment(ctx, {
|
|
132279
|
-
deploymentName: projectSelection.deploymentName
|
|
132280
|
-
});
|
|
132281
|
-
if (result === null) {
|
|
132282
|
-
return ctx.crash({
|
|
132283
|
-
exitCode: 1,
|
|
132284
|
-
errorType: "fatal",
|
|
132285
|
-
printedMessage: "You don't have access to the selected project. Run `npx convex dev` to select a different project."
|
|
132286
|
-
});
|
|
132287
|
-
}
|
|
132288
|
-
return await getProjectDetails(ctx, {
|
|
132289
|
-
kind: "teamAndProjectSlugs",
|
|
132290
|
-
teamSlug: result.teamSlug,
|
|
132291
|
-
projectSlug: result.projectSlug
|
|
132292
|
-
});
|
|
132388
|
+
const stack = typeof err.stack === "string" ? err.stack : "";
|
|
132389
|
+
const normalizedFilename = filename.replace(/\\/g, "/");
|
|
132390
|
+
if (stack && (stack.includes(filename) || stack.includes(normalizedFilename))) {
|
|
132391
|
+
return;
|
|
132293
132392
|
}
|
|
132294
|
-
const
|
|
132295
|
-
|
|
132296
|
-
|
|
132297
|
-
|
|
132298
|
-
}
|
|
132299
|
-
|
|
132300
|
-
|
|
132301
|
-
|
|
132393
|
+
const capture = {};
|
|
132394
|
+
Error.captureStackTrace(capture, appendFetchStackTrace);
|
|
132395
|
+
if (!capture.stack) {
|
|
132396
|
+
return;
|
|
132397
|
+
}
|
|
132398
|
+
const captureLines = capture.stack.split("\n").slice(1).join("\n");
|
|
132399
|
+
err.stack = stack ? `${stack}
|
|
132400
|
+
${captureLines}` : capture.stack;
|
|
132302
132401
|
}
|
|
132303
|
-
|
|
132304
|
-
return (
|
|
132305
|
-
|
|
132306
|
-
|
|
132307
|
-
|
|
132308
|
-
|
|
132309
|
-
team_id_or_slug: projectSelection.teamSlug,
|
|
132310
|
-
project_slug: projectSelection.projectSlug
|
|
132311
|
-
}
|
|
132312
|
-
}
|
|
132402
|
+
module2.exports.fetch = function fetch2(init3, options = void 0) {
|
|
132403
|
+
return fetchImpl(init3, options).catch((err) => {
|
|
132404
|
+
if (currentFilename) {
|
|
132405
|
+
appendFetchStackTrace(err, currentFilename);
|
|
132406
|
+
} else if (err && typeof err === "object") {
|
|
132407
|
+
Error.captureStackTrace(err, module2.exports.fetch);
|
|
132313
132408
|
}
|
|
132314
|
-
|
|
132315
|
-
|
|
132316
|
-
|
|
132317
|
-
|
|
132318
|
-
|
|
132319
|
-
|
|
132320
|
-
|
|
132321
|
-
|
|
132322
|
-
|
|
132323
|
-
|
|
132409
|
+
throw err;
|
|
132410
|
+
});
|
|
132411
|
+
};
|
|
132412
|
+
module2.exports.Headers = require_headers2().Headers;
|
|
132413
|
+
module2.exports.Response = require_response().Response;
|
|
132414
|
+
module2.exports.Request = require_request4().Request;
|
|
132415
|
+
module2.exports.FormData = require_formdata().FormData;
|
|
132416
|
+
var { setGlobalOrigin, getGlobalOrigin } = require_global();
|
|
132417
|
+
module2.exports.setGlobalOrigin = setGlobalOrigin;
|
|
132418
|
+
module2.exports.getGlobalOrigin = getGlobalOrigin;
|
|
132419
|
+
var { CacheStorage } = require_cachestorage();
|
|
132420
|
+
var { kConstruct } = require_symbols();
|
|
132421
|
+
module2.exports.caches = new CacheStorage(kConstruct);
|
|
132422
|
+
var { deleteCookie, getCookies, getSetCookies, setCookie, parseCookie } = require_cookies();
|
|
132423
|
+
module2.exports.deleteCookie = deleteCookie;
|
|
132424
|
+
module2.exports.getCookies = getCookies;
|
|
132425
|
+
module2.exports.getSetCookies = getSetCookies;
|
|
132426
|
+
module2.exports.setCookie = setCookie;
|
|
132427
|
+
module2.exports.parseCookie = parseCookie;
|
|
132428
|
+
var { parseMIMEType, serializeAMimeType } = require_data_url();
|
|
132429
|
+
module2.exports.parseMIMEType = parseMIMEType;
|
|
132430
|
+
module2.exports.serializeAMimeType = serializeAMimeType;
|
|
132431
|
+
var { CloseEvent, ErrorEvent: ErrorEvent2, MessageEvent } = require_events();
|
|
132432
|
+
var { WebSocket: WebSocket2, ping } = require_websocket();
|
|
132433
|
+
module2.exports.WebSocket = WebSocket2;
|
|
132434
|
+
module2.exports.CloseEvent = CloseEvent;
|
|
132435
|
+
module2.exports.ErrorEvent = ErrorEvent2;
|
|
132436
|
+
module2.exports.MessageEvent = MessageEvent;
|
|
132437
|
+
module2.exports.ping = ping;
|
|
132438
|
+
module2.exports.WebSocketStream = require_websocketstream().WebSocketStream;
|
|
132439
|
+
module2.exports.WebSocketError = require_websocketerror().WebSocketError;
|
|
132440
|
+
module2.exports.request = makeDispatcher(api.request);
|
|
132441
|
+
module2.exports.stream = makeDispatcher(api.stream);
|
|
132442
|
+
module2.exports.pipeline = makeDispatcher(api.pipeline);
|
|
132443
|
+
module2.exports.connect = makeDispatcher(api.connect);
|
|
132444
|
+
module2.exports.upgrade = makeDispatcher(api.upgrade);
|
|
132445
|
+
module2.exports.MockClient = MockClient;
|
|
132446
|
+
module2.exports.MockCallHistory = MockCallHistory;
|
|
132447
|
+
module2.exports.MockCallHistoryLog = MockCallHistoryLog;
|
|
132448
|
+
module2.exports.MockPool = MockPool;
|
|
132449
|
+
module2.exports.MockAgent = MockAgent;
|
|
132450
|
+
module2.exports.SnapshotAgent = SnapshotAgent;
|
|
132451
|
+
module2.exports.mockErrors = mockErrors;
|
|
132452
|
+
var { EventSource } = require_eventsource();
|
|
132453
|
+
module2.exports.EventSource = EventSource;
|
|
132454
|
+
function install() {
|
|
132455
|
+
globalThis.fetch = module2.exports.fetch;
|
|
132456
|
+
globalThis.Headers = module2.exports.Headers;
|
|
132457
|
+
globalThis.Response = module2.exports.Response;
|
|
132458
|
+
globalThis.Request = module2.exports.Request;
|
|
132459
|
+
globalThis.FormData = module2.exports.FormData;
|
|
132460
|
+
globalThis.WebSocket = module2.exports.WebSocket;
|
|
132461
|
+
globalThis.CloseEvent = module2.exports.CloseEvent;
|
|
132462
|
+
globalThis.ErrorEvent = module2.exports.ErrorEvent;
|
|
132463
|
+
globalThis.MessageEvent = module2.exports.MessageEvent;
|
|
132464
|
+
globalThis.EventSource = module2.exports.EventSource;
|
|
132324
132465
|
}
|
|
132466
|
+
module2.exports.install = install;
|
|
132325
132467
|
}
|
|
132326
|
-
}
|
|
132468
|
+
});
|
|
132469
|
+
|
|
132470
|
+
// ../common/temp/node_modules/.pnpm/@commander-js+extra-typings@14.0.0_commander@14.0.3/node_modules/@commander-js/extra-typings/esm.mjs
|
|
132471
|
+
var import_index = __toESM(require_extra_typings(), 1);
|
|
132472
|
+
var {
|
|
132473
|
+
program,
|
|
132474
|
+
createCommand,
|
|
132475
|
+
createArgument,
|
|
132476
|
+
createOption,
|
|
132477
|
+
CommanderError,
|
|
132478
|
+
InvalidArgumentError,
|
|
132479
|
+
InvalidOptionArgumentError,
|
|
132480
|
+
// deprecated old name
|
|
132481
|
+
Command,
|
|
132482
|
+
Argument,
|
|
132483
|
+
Option,
|
|
132484
|
+
Help
|
|
132485
|
+
} = import_index.default;
|
|
132327
132486
|
|
|
132328
132487
|
// src/bundler/context.ts
|
|
132488
|
+
var Sentry8 = __toESM(require_cjs5(), 1);
|
|
132489
|
+
init_fs();
|
|
132490
|
+
init_deploymentSelection();
|
|
132329
132491
|
init_envvars();
|
|
132330
132492
|
init_log();
|
|
132331
132493
|
async function flushAndExit(exitCode, err) {
|
|
@@ -132506,6 +132668,7 @@ init_codegen();
|
|
|
132506
132668
|
init_localDeployment();
|
|
132507
132669
|
init_prompts();
|
|
132508
132670
|
init_aiFiles();
|
|
132671
|
+
init_deploymentSelection();
|
|
132509
132672
|
|
|
132510
132673
|
// ../common/temp/node_modules/.pnpm/openid-client@5.7.1/node_modules/openid-client/lib/index.mjs
|
|
132511
132674
|
var import_index3 = __toESM(require_lib5(), 1);
|
|
@@ -133137,6 +133300,8 @@ init_log();
|
|
|
133137
133300
|
var import_os4 = require("os");
|
|
133138
133301
|
var import_child_process7 = require("child_process");
|
|
133139
133302
|
init_prompts();
|
|
133303
|
+
init_globalConfig();
|
|
133304
|
+
init_deploymentSelection();
|
|
133140
133305
|
custom2.setHttpOptionsDefaults({
|
|
133141
133306
|
timeout: parseInt(process.env.OPENID_CLIENT_TIMEOUT || "10000")
|
|
133142
133307
|
});
|
|
@@ -133568,15 +133733,6 @@ async function deploymentCredentialsOrConfigure(ctx, deploymentSelection, chosen
|
|
|
133568
133733
|
};
|
|
133569
133734
|
}
|
|
133570
133735
|
async function _deploymentCredentialsOrConfigure(ctx, deploymentSelection, chosenConfiguration, cmdOptions) {
|
|
133571
|
-
const config3 = readGlobalConfig(ctx);
|
|
133572
|
-
const globallyForceCloud = !!(config3 == null ? void 0 : config3.optOutOfLocalDevDeploymentsUntilBetaOver);
|
|
133573
|
-
if (globallyForceCloud && cmdOptions.local) {
|
|
133574
|
-
return await ctx.crash({
|
|
133575
|
-
exitCode: 1,
|
|
133576
|
-
errorType: "fatal",
|
|
133577
|
-
printedMessage: "Can't specify --local when local deployments are disabled on this machine. Run `npx convex disable-local-deployments --undo-global` to allow use of --local."
|
|
133578
|
-
});
|
|
133579
|
-
}
|
|
133580
133736
|
switch (deploymentSelection.kind) {
|
|
133581
133737
|
case "existingDeployment":
|
|
133582
133738
|
return {
|
|
@@ -133595,9 +133751,6 @@ async function _deploymentCredentialsOrConfigure(ctx, deploymentSelection, chose
|
|
|
133595
133751
|
ctx,
|
|
133596
133752
|
chosenConfiguration,
|
|
133597
133753
|
deploymentSelection.selectionWithinProject,
|
|
133598
|
-
{
|
|
133599
|
-
globallyForceCloud
|
|
133600
|
-
},
|
|
133601
133754
|
cmdOptions
|
|
133602
133755
|
);
|
|
133603
133756
|
}
|
|
@@ -133611,8 +133764,7 @@ async function _deploymentCredentialsOrConfigure(ctx, deploymentSelection, chose
|
|
|
133611
133764
|
return await handleDeploymentWithinProject(ctx, {
|
|
133612
133765
|
chosenConfiguration,
|
|
133613
133766
|
deploymentSelection,
|
|
133614
|
-
cmdOptions
|
|
133615
|
-
globallyForceCloud
|
|
133767
|
+
cmdOptions
|
|
133616
133768
|
});
|
|
133617
133769
|
}
|
|
133618
133770
|
case "anonymous": {
|
|
@@ -133627,9 +133779,6 @@ async function _deploymentCredentialsOrConfigure(ctx, deploymentSelection, chose
|
|
|
133627
133779
|
ctx,
|
|
133628
133780
|
chosenConfiguration,
|
|
133629
133781
|
deploymentSelection.selectionWithinProject,
|
|
133630
|
-
{
|
|
133631
|
-
globallyForceCloud
|
|
133632
|
-
},
|
|
133633
133782
|
cmdOptions
|
|
133634
133783
|
);
|
|
133635
133784
|
}
|
|
@@ -133674,9 +133823,6 @@ async function _deploymentCredentialsOrConfigure(ctx, deploymentSelection, chose
|
|
|
133674
133823
|
ctx,
|
|
133675
133824
|
chosenConfiguration,
|
|
133676
133825
|
deploymentSelection.selectionWithinProject,
|
|
133677
|
-
{
|
|
133678
|
-
globallyForceCloud
|
|
133679
|
-
},
|
|
133680
133826
|
cmdOptions
|
|
133681
133827
|
);
|
|
133682
133828
|
}
|
|
@@ -133685,8 +133831,7 @@ async function _deploymentCredentialsOrConfigure(ctx, deploymentSelection, chose
|
|
|
133685
133831
|
async function handleDeploymentWithinProject(ctx, {
|
|
133686
133832
|
chosenConfiguration,
|
|
133687
133833
|
deploymentSelection,
|
|
133688
|
-
cmdOptions
|
|
133689
|
-
globallyForceCloud
|
|
133834
|
+
cmdOptions
|
|
133690
133835
|
}) {
|
|
133691
133836
|
const hasAuth = ctx.bigBrainAuth() !== null;
|
|
133692
133837
|
const loginMessage = hasAuth && shouldAllowAnonymousDevelopment() ? void 0 : `Tip: You can try out Convex without creating an account by clearing the ${CONVEX_DEPLOYMENT_ENV_VAR_NAME} environment variable (often in .env.local).`;
|
|
@@ -133702,9 +133847,6 @@ async function handleDeploymentWithinProject(ctx, {
|
|
|
133702
133847
|
ctx,
|
|
133703
133848
|
chosenConfiguration,
|
|
133704
133849
|
deploymentSelection.selectionWithinProject,
|
|
133705
|
-
{
|
|
133706
|
-
globallyForceCloud
|
|
133707
|
-
},
|
|
133708
133850
|
cmdOptions
|
|
133709
133851
|
);
|
|
133710
133852
|
return result;
|
|
@@ -133719,9 +133861,6 @@ async function handleDeploymentWithinProject(ctx, {
|
|
|
133719
133861
|
ctx,
|
|
133720
133862
|
chosenConfiguration,
|
|
133721
133863
|
deploymentSelection.selectionWithinProject,
|
|
133722
|
-
{
|
|
133723
|
-
globallyForceCloud
|
|
133724
|
-
},
|
|
133725
133864
|
cmdOptions
|
|
133726
133865
|
);
|
|
133727
133866
|
return result;
|
|
@@ -133752,7 +133891,7 @@ async function handleDeploymentWithinProject(ctx, {
|
|
|
133752
133891
|
deploymentFields: selectedDeployment.deploymentFields
|
|
133753
133892
|
};
|
|
133754
133893
|
}
|
|
133755
|
-
async function handleChooseProject(ctx, chosenConfiguration, selectionWithinProject,
|
|
133894
|
+
async function handleChooseProject(ctx, chosenConfiguration, selectionWithinProject, cmdOptions) {
|
|
133756
133895
|
await ensureLoggedIn(ctx, {
|
|
133757
133896
|
overrideAuthUrl: cmdOptions.overrideAuthUrl,
|
|
133758
133897
|
overrideAuthClient: cmdOptions.overrideAuthClient,
|
|
@@ -133763,8 +133902,8 @@ async function handleChooseProject(ctx, chosenConfiguration, selectionWithinProj
|
|
|
133763
133902
|
team: cmdOptions.team,
|
|
133764
133903
|
project: cmdOptions.project,
|
|
133765
133904
|
devDeployment: cmdOptions.devDeployment,
|
|
133766
|
-
local:
|
|
133767
|
-
cloud:
|
|
133905
|
+
local: cmdOptions.local,
|
|
133906
|
+
cloud: cmdOptions.cloud
|
|
133768
133907
|
});
|
|
133769
133908
|
const deploymentOptions = selectionWithinProject.kind === "prod" ? { kind: "prod" } : project.devDeployment === "local" ? { kind: "local", ...cmdOptions.localOptions } : { kind: "dev" };
|
|
133770
133909
|
const {
|
|
@@ -133987,6 +134126,9 @@ async function updateEnvAndConfigForDeploymentSelection(ctx, options, existingVa
|
|
|
133987
134126
|
});
|
|
133988
134127
|
}
|
|
133989
134128
|
|
|
134129
|
+
// src/cli/init.ts
|
|
134130
|
+
init_deploymentSelection();
|
|
134131
|
+
|
|
133990
134132
|
// src/cli/lib/updates.ts
|
|
133991
134133
|
var import_path32 = __toESM(require("path"), 1);
|
|
133992
134134
|
init_log();
|
|
@@ -134492,6 +134634,7 @@ Command.prototype.addNetworkTestOptions = function() {
|
|
|
134492
134634
|
};
|
|
134493
134635
|
|
|
134494
134636
|
// src/cli/dashboard.ts
|
|
134637
|
+
init_deploymentSelection();
|
|
134495
134638
|
init_dashboard();
|
|
134496
134639
|
init_dashboard2();
|
|
134497
134640
|
init_deployment();
|
|
@@ -134551,6 +134694,7 @@ Please visit: ${url}`
|
|
|
134551
134694
|
|
|
134552
134695
|
// src/cli/deployments.ts
|
|
134553
134696
|
init_log();
|
|
134697
|
+
init_deploymentSelection();
|
|
134554
134698
|
init_api3();
|
|
134555
134699
|
var deployments = new Command("deployments").description("List deployments associated with a project").allowExcessArguments(false).action(async () => {
|
|
134556
134700
|
const ctx = await oneoffContext({
|
|
@@ -134630,6 +134774,7 @@ async function displayCurrentDeploymentInfo(ctx, selection) {
|
|
|
134630
134774
|
init_source();
|
|
134631
134775
|
init_log();
|
|
134632
134776
|
init_utils5();
|
|
134777
|
+
init_deploymentSelection();
|
|
134633
134778
|
var docs = new Command("docs").description("Open the docs in the browser").allowExcessArguments(false).option("--no-open", "Print docs URL instead of opening it in your browser").action(async (options) => {
|
|
134634
134779
|
const ctx = await oneoffContext({
|
|
134635
134780
|
url: void 0,
|
|
@@ -134680,6 +134825,7 @@ init_value();
|
|
|
134680
134825
|
init_api3();
|
|
134681
134826
|
init_run2();
|
|
134682
134827
|
init_utils5();
|
|
134828
|
+
init_deploymentSelection();
|
|
134683
134829
|
init_run();
|
|
134684
134830
|
init_utils5();
|
|
134685
134831
|
var run = new Command("run").description(
|
|
@@ -134914,6 +135060,7 @@ var auth = new Command("auth").addCommand(list).addCommand(rm).addCommand(add);
|
|
|
134914
135060
|
|
|
134915
135061
|
// src/cli/codegen.ts
|
|
134916
135062
|
init_components();
|
|
135063
|
+
init_deploymentSelection();
|
|
134917
135064
|
init_api3();
|
|
134918
135065
|
init_run();
|
|
134919
135066
|
var codegen = new Command("codegen").summary("Generate backend type definitions").description(
|
|
@@ -135091,7 +135238,9 @@ init_anonymous();
|
|
|
135091
135238
|
init_dashboard2();
|
|
135092
135239
|
init_prompts();
|
|
135093
135240
|
init_utils5();
|
|
135241
|
+
init_deploymentSelection();
|
|
135094
135242
|
init_deployment();
|
|
135243
|
+
init_globalConfig();
|
|
135095
135244
|
init_api3();
|
|
135096
135245
|
var loginStatus = new Command("status").description("Check login status and list accessible teams").allowExcessArguments(false).action(async () => {
|
|
135097
135246
|
const ctx = await oneoffContext({
|
|
@@ -135359,6 +135508,7 @@ You can alternatively run \`npx convex login --link-deployments\` to interactive
|
|
|
135359
135508
|
// src/cli/logout.ts
|
|
135360
135509
|
init_log();
|
|
135361
135510
|
init_fsUtils();
|
|
135511
|
+
init_globalConfig();
|
|
135362
135512
|
var logout = new Command("logout").description("Log out of Convex on this machine").allowExcessArguments(false).action(async () => {
|
|
135363
135513
|
const ctx = await oneoffContext({
|
|
135364
135514
|
url: void 0,
|
|
@@ -135382,6 +135532,7 @@ init_sentry();
|
|
|
135382
135532
|
init_source();
|
|
135383
135533
|
init_dev();
|
|
135384
135534
|
init_utils5();
|
|
135535
|
+
init_deploymentSelection();
|
|
135385
135536
|
var dev = new Command("dev").summary("Develop against a dev deployment, watching for changes").description(
|
|
135386
135537
|
"Develop against a dev deployment, watching for changes\n\n 1. Configures a new or existing project (if needed)\n 2. Updates generated types and pushes code to the configured dev deployment\n 3. Runs the provided command (if `--start` or `--run` is used)\n 4. Watches for file changes, and repeats step 2\n"
|
|
135387
135538
|
).allowExcessArguments(false).option("-v, --verbose", "Show full listing of changes").addOption(
|
|
@@ -135567,6 +135718,8 @@ init_deployment();
|
|
|
135567
135718
|
init_components();
|
|
135568
135719
|
init_prompts();
|
|
135569
135720
|
init_deploy2();
|
|
135721
|
+
init_deploymentSelection();
|
|
135722
|
+
init_deploymentSelection();
|
|
135570
135723
|
init_config();
|
|
135571
135724
|
init_workos();
|
|
135572
135725
|
init_dashboard2();
|
|
@@ -135695,7 +135848,7 @@ async function deployToNewPreviewDeployment(ctx, deploymentSelection, options) {
|
|
|
135695
135848
|
await ctx.crash({
|
|
135696
135849
|
exitCode: 1,
|
|
135697
135850
|
errorType: "fatal",
|
|
135698
|
-
printedMessage: "`npx convex deploy` to a preview deployment could not determine the preview name. Provide one using `--preview-
|
|
135851
|
+
printedMessage: "`npx convex deploy` to a preview deployment could not determine the preview name. Provide one using `--preview-name`"
|
|
135699
135852
|
});
|
|
135700
135853
|
}
|
|
135701
135854
|
if (options.dryRun) {
|
|
@@ -135851,6 +136004,7 @@ Make sure that your published client is configured with this URL (for instructio
|
|
|
135851
136004
|
// src/cli/logs.ts
|
|
135852
136005
|
init_api3();
|
|
135853
136006
|
init_logs();
|
|
136007
|
+
init_deploymentSelection();
|
|
135854
136008
|
var logs = new Command("logs").summary("Watch logs from your deployment").description(
|
|
135855
136009
|
"Stream function logs from your Convex deployment.\nBy default, this streams from your project's dev deployment."
|
|
135856
136010
|
).allowExcessArguments(false).addLogsOptions().addDeploymentSelectionOptions(actionDescription("Watch logs from")).showHelpAfterError().action(async (cmdOptions) => {
|
|
@@ -136147,6 +136301,7 @@ async function withTimeout(ctx, name, timeoutMs, f) {
|
|
|
136147
136301
|
}
|
|
136148
136302
|
|
|
136149
136303
|
// src/cli/network_test.ts
|
|
136304
|
+
init_deploymentSelection();
|
|
136150
136305
|
var networkTest = new Command("network-test").description("Run a network test to Convex's servers").allowExcessArguments(false).addNetworkTestOptions().addDeploymentSelectionOptions(
|
|
136151
136306
|
actionDescription("Perform the network test on"),
|
|
136152
136307
|
{ showUrlHelp: true }
|
|
@@ -136189,6 +136344,7 @@ init_utils5();
|
|
|
136189
136344
|
init_api3();
|
|
136190
136345
|
init_dashboard2();
|
|
136191
136346
|
init_convexExport();
|
|
136347
|
+
init_deploymentSelection();
|
|
136192
136348
|
var convexExport = new Command("export").summary("Export data from your deployment to a ZIP file").description(
|
|
136193
136349
|
"Export data, and optionally file storage, from your Convex deployment to a ZIP file.\nBy default, this exports from your dev deployment."
|
|
136194
136350
|
).allowExcessArguments(false).addExportOptions().addDeploymentSelectionOptions(actionDescription("Export data from")).showHelpAfterError().action(async (options) => {
|
|
@@ -136219,6 +136375,7 @@ init_utils5();
|
|
|
136219
136375
|
init_api3();
|
|
136220
136376
|
init_dashboard2();
|
|
136221
136377
|
init_convexImport();
|
|
136378
|
+
init_deploymentSelection();
|
|
136222
136379
|
var convexImport = new Command("import").summary("Import data from a file to your deployment").description(
|
|
136223
136380
|
"Import data from a file to your Convex deployment.\n\n From a snapshot: `npx convex import snapshot.zip`\n For a single table: `npx convex import --table tableName file.json`\n\nBy default, this imports into your dev deployment."
|
|
136224
136381
|
).allowExcessArguments(false).addImportOptions().addDeploymentSelectionOptions(actionDescription("Import data into")).showHelpAfterError().action(async (filePath, options) => {
|
|
@@ -136250,67 +136407,15 @@ init_source();
|
|
|
136250
136407
|
init_api3();
|
|
136251
136408
|
init_utils5();
|
|
136252
136409
|
init_env();
|
|
136410
|
+
init_deploymentSelection();
|
|
136253
136411
|
init_run();
|
|
136254
136412
|
|
|
136255
136413
|
// src/cli/envDefault.ts
|
|
136256
136414
|
init_env();
|
|
136257
136415
|
init_utils5();
|
|
136258
|
-
|
|
136259
|
-
// src/cli/lib/defaultEnv.ts
|
|
136260
|
-
init_utils5();
|
|
136261
|
-
function defaultEnvBackend(ctx, projectId, dtype) {
|
|
136262
|
-
return {
|
|
136263
|
-
async get(name) {
|
|
136264
|
-
const result = (await typedPlatformClient(ctx).GET(
|
|
136265
|
-
"/projects/{project_id}/list_default_environment_variables",
|
|
136266
|
-
{
|
|
136267
|
-
params: {
|
|
136268
|
-
path: { project_id: projectId },
|
|
136269
|
-
query: { name, deploymentType: dtype }
|
|
136270
|
-
}
|
|
136271
|
-
}
|
|
136272
|
-
)).data;
|
|
136273
|
-
const items = result.items;
|
|
136274
|
-
if (items.length === 0) return null;
|
|
136275
|
-
return { name: items[0].name, value: items[0].value };
|
|
136276
|
-
},
|
|
136277
|
-
async list() {
|
|
136278
|
-
const result = (await typedPlatformClient(ctx).GET(
|
|
136279
|
-
"/projects/{project_id}/list_default_environment_variables",
|
|
136280
|
-
{
|
|
136281
|
-
params: {
|
|
136282
|
-
path: { project_id: projectId },
|
|
136283
|
-
query: { deploymentType: dtype }
|
|
136284
|
-
}
|
|
136285
|
-
}
|
|
136286
|
-
)).data;
|
|
136287
|
-
return result.items.map(
|
|
136288
|
-
(item) => ({ name: item.name, value: item.value })
|
|
136289
|
-
);
|
|
136290
|
-
},
|
|
136291
|
-
async update(changes) {
|
|
136292
|
-
await typedPlatformClient(ctx).POST(
|
|
136293
|
-
"/projects/{project_id}/update_default_environment_variables",
|
|
136294
|
-
{
|
|
136295
|
-
params: {
|
|
136296
|
-
path: { project_id: projectId }
|
|
136297
|
-
},
|
|
136298
|
-
body: {
|
|
136299
|
-
changes: changes.map((c) => ({
|
|
136300
|
-
name: c.name,
|
|
136301
|
-
deploymentType: dtype,
|
|
136302
|
-
value: c.value ?? null
|
|
136303
|
-
}))
|
|
136304
|
-
}
|
|
136305
|
-
}
|
|
136306
|
-
);
|
|
136307
|
-
},
|
|
136308
|
-
notice: ` (in default env vars for ${dtype} deployments)`
|
|
136309
|
-
};
|
|
136310
|
-
}
|
|
136311
|
-
|
|
136312
|
-
// src/cli/envDefault.ts
|
|
136416
|
+
init_defaultEnv();
|
|
136313
136417
|
init_api3();
|
|
136418
|
+
init_deploymentSelection();
|
|
136314
136419
|
function addEnvDefaultOptions(cmd) {
|
|
136315
136420
|
return cmd.addOption(
|
|
136316
136421
|
new Option(
|
|
@@ -136767,6 +136872,7 @@ function stringify(value) {
|
|
|
136767
136872
|
}
|
|
136768
136873
|
|
|
136769
136874
|
// src/cli/data.ts
|
|
136875
|
+
init_deploymentSelection();
|
|
136770
136876
|
var data = new Command("data").summary("List tables and print data from your database").description(
|
|
136771
136877
|
"Inspect your Convex deployment's database.\n\n List tables: `npx convex data`\n List documents in a table: `npx convex data tableName`\n\nBy default, this inspects your dev deployment."
|
|
136772
136878
|
).allowExcessArguments(false).addDataOptions().addDeploymentSelectionOptions(actionDescription("Inspect the database in")).showHelpAfterError().action(async (tableName, options) => {
|
|
@@ -136828,6 +136934,7 @@ async function functionSpecForDeployment(ctx, options) {
|
|
|
136828
136934
|
}
|
|
136829
136935
|
|
|
136830
136936
|
// src/cli/functionSpec.ts
|
|
136937
|
+
init_deploymentSelection();
|
|
136831
136938
|
var functionSpec = new Command("function-spec").summary("List function metadata from your deployment").description(
|
|
136832
136939
|
"List argument and return values to your Convex functions.\n\nBy default, this inspects your dev deployment."
|
|
136833
136940
|
).allowExcessArguments(false).addOption(new Option("--file", "Output as JSON to a file.")).addDeploymentSelectionOptions(
|
|
@@ -136848,6 +136955,7 @@ init_source();
|
|
|
136848
136955
|
init_log();
|
|
136849
136956
|
init_api3();
|
|
136850
136957
|
init_dashboard2();
|
|
136958
|
+
init_deploymentSelection();
|
|
136851
136959
|
|
|
136852
136960
|
// src/cli/lib/insights.ts
|
|
136853
136961
|
init_api3();
|
|
@@ -137092,100 +137200,6 @@ var insights = new Command("insights").summary("Show health insights for your de
|
|
|
137092
137200
|
Dashboard: ${source_default.cyan(dashboardUrl2)}`);
|
|
137093
137201
|
});
|
|
137094
137202
|
|
|
137095
|
-
// src/cli/disableLocalDev.ts
|
|
137096
|
-
init_log();
|
|
137097
|
-
var disableLocalDeployments = new Command("disable-local-deployments").description(
|
|
137098
|
-
"Stop using a local deployment for the current project, or globally disable local depoyments with --global"
|
|
137099
|
-
).option(
|
|
137100
|
-
"--global",
|
|
137101
|
-
"Disable local deployments on this machine until a future release when this feature is more stable."
|
|
137102
|
-
).option("--undo-global", "Re-enable local deployments on this machine.").allowExcessArguments(false).action(async (cmdOptions) => {
|
|
137103
|
-
const ctx = await oneoffContext({
|
|
137104
|
-
url: void 0,
|
|
137105
|
-
adminKey: void 0,
|
|
137106
|
-
envFile: void 0
|
|
137107
|
-
});
|
|
137108
|
-
if (cmdOptions.undoGlobal) {
|
|
137109
|
-
return disableLocalDeploymentsGloballyUntilBetaOver(true);
|
|
137110
|
-
}
|
|
137111
|
-
if (cmdOptions.global) {
|
|
137112
|
-
return disableLocalDeploymentsGloballyUntilBetaOver(
|
|
137113
|
-
!!cmdOptions.undoGlobal
|
|
137114
|
-
);
|
|
137115
|
-
}
|
|
137116
|
-
const deploymentSelection = await getDeploymentSelection(ctx, {
|
|
137117
|
-
url: void 0,
|
|
137118
|
-
adminKey: void 0,
|
|
137119
|
-
envFile: void 0
|
|
137120
|
-
});
|
|
137121
|
-
const configuredDeployment = deploymentNameAndTypeFromSelection(deploymentSelection);
|
|
137122
|
-
if ((configuredDeployment == null ? void 0 : configuredDeployment.type) !== null && (configuredDeployment == null ? void 0 : configuredDeployment.type) !== "local") {
|
|
137123
|
-
logFinishedStep("Local development is already not being used.");
|
|
137124
|
-
return;
|
|
137125
|
-
}
|
|
137126
|
-
await deploymentCredentialsOrConfigure(ctx, deploymentSelection, "ask", {
|
|
137127
|
-
prod: false,
|
|
137128
|
-
localOptions: {
|
|
137129
|
-
forceUpgrade: false
|
|
137130
|
-
},
|
|
137131
|
-
cloud: true
|
|
137132
|
-
});
|
|
137133
|
-
logFinishedStep(
|
|
137134
|
-
"You are no longer using a local deployment for development."
|
|
137135
|
-
);
|
|
137136
|
-
});
|
|
137137
|
-
async function disableLocalDeploymentsGloballyUntilBetaOver(reenable) {
|
|
137138
|
-
const ctx = await oneoffContext({
|
|
137139
|
-
url: void 0,
|
|
137140
|
-
adminKey: void 0,
|
|
137141
|
-
envFile: void 0
|
|
137142
|
-
});
|
|
137143
|
-
if (!process.stdin.isTTY) {
|
|
137144
|
-
return ctx.crash({
|
|
137145
|
-
exitCode: 1,
|
|
137146
|
-
errorType: "fatal",
|
|
137147
|
-
printedMessage: "`disable-local-deployments --global` is not for scripting, it is temporary and only for interactive use."
|
|
137148
|
-
});
|
|
137149
|
-
}
|
|
137150
|
-
const config3 = readGlobalConfig(ctx);
|
|
137151
|
-
if (config3 === null) {
|
|
137152
|
-
return ctx.crash({
|
|
137153
|
-
exitCode: 1,
|
|
137154
|
-
errorType: "fatal",
|
|
137155
|
-
printedMessage: "Log in first with `npx convex login"
|
|
137156
|
-
});
|
|
137157
|
-
}
|
|
137158
|
-
if (reenable) {
|
|
137159
|
-
if (!("optOutOfLocalDevDeploymentsUntilBetaOver" in config3) || !config3.optOutOfLocalDevDeploymentsUntilBetaOver) {
|
|
137160
|
-
logFinishedStep(
|
|
137161
|
-
"You are already opted into allowing local deployents on this machine."
|
|
137162
|
-
);
|
|
137163
|
-
return;
|
|
137164
|
-
}
|
|
137165
|
-
await modifyGlobalConfig(ctx, {
|
|
137166
|
-
...config3,
|
|
137167
|
-
optOutOfLocalDevDeploymentsUntilBetaOver: false
|
|
137168
|
-
});
|
|
137169
|
-
logFinishedStep(
|
|
137170
|
-
"You have been opted back into allowing local deployents on this machine."
|
|
137171
|
-
);
|
|
137172
|
-
return;
|
|
137173
|
-
}
|
|
137174
|
-
if ("optOutOfLocalDevDeploymentsUntilBetaOver" in config3 && config3.optOutOfLocalDevDeploymentsUntilBetaOver) {
|
|
137175
|
-
logFinishedStep(
|
|
137176
|
-
"You are already opted out of local deployents on this machine."
|
|
137177
|
-
);
|
|
137178
|
-
return;
|
|
137179
|
-
}
|
|
137180
|
-
await modifyGlobalConfig(ctx, {
|
|
137181
|
-
...config3,
|
|
137182
|
-
optOutOfLocalDevDeploymentsUntilBetaOver: true
|
|
137183
|
-
});
|
|
137184
|
-
logFinishedStep(
|
|
137185
|
-
"You have been opted out of local deployents on this machine until the beta is over. Run `npx convex disable-local-deployments --undo-global` to opt back in."
|
|
137186
|
-
);
|
|
137187
|
-
}
|
|
137188
|
-
|
|
137189
137203
|
// ../common/temp/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/core/core.js
|
|
137190
137204
|
var NEVER2 = Object.freeze({
|
|
137191
137205
|
status: "aborted"
|
|
@@ -144167,6 +144181,7 @@ var StdioServerTransport = class {
|
|
|
144167
144181
|
init_fs();
|
|
144168
144182
|
init_api3();
|
|
144169
144183
|
init_zod();
|
|
144184
|
+
init_deploymentSelection();
|
|
144170
144185
|
var RequestContext = class {
|
|
144171
144186
|
constructor(options) {
|
|
144172
144187
|
this.options = options;
|
|
@@ -145725,6 +145740,7 @@ var DataTool = {
|
|
|
145725
145740
|
init_api3();
|
|
145726
145741
|
init_zod();
|
|
145727
145742
|
init_dashboard2();
|
|
145743
|
+
init_deploymentSelection();
|
|
145728
145744
|
var projectDirDescription = `
|
|
145729
145745
|
The root directory of the Convex project. This is usually the editor's workspace directory
|
|
145730
145746
|
and often includes the 'package.json' file and the 'convex/' folder.
|
|
@@ -146562,6 +146578,7 @@ var Mutex = class {
|
|
|
146562
146578
|
};
|
|
146563
146579
|
|
|
146564
146580
|
// src/cli/mcp.ts
|
|
146581
|
+
init_deploymentSelection();
|
|
146565
146582
|
var allToolNames = convexTools.map((t) => t.name).sort();
|
|
146566
146583
|
var mcp = new Command("mcp").summary("Manage the Model Context Protocol server for Convex [BETA]").description(
|
|
146567
146584
|
"Commands to initialize and run a Model Context Protocol server for Convex that can be used with AI tools.\nThis server exposes your Convex codebase to AI tools in a structured way."
|
|
@@ -146703,79 +146720,16 @@ function makeServer(options) {
|
|
|
146703
146720
|
|
|
146704
146721
|
// src/cli/deploymentSelect.ts
|
|
146705
146722
|
init_api3();
|
|
146723
|
+
init_deploymentSelection();
|
|
146706
146724
|
init_deploymentSelector();
|
|
146707
146725
|
init_deploy2();
|
|
146708
|
-
|
|
146709
|
-
|
|
146710
|
-
"Select the deployment to use when running commands.\n\nThe deployment will be used by all `npx convex` commands, except `npx convex deploy`. You can also run individual commands on another deployment by using the --deployment flag on that command.\n\nExamples:\n npx convex select dev # Select your personal cloud dev deployment in the current project\n npx convex select local # Select your local deployment\n npx convex select dev/james # Select a deployment in the same project by its reference\n npx convex select some-project:dev/james # Select a deployment in another project in the same team\n npx convex select some-team:some-project:dev/james # Select a deployment in a particular team/project\n"
|
|
146711
|
-
).argument("<deployment>", "The deployment to use").allowExcessArguments(false).action(async (selector) => {
|
|
146712
|
-
const ctx = await oneoffContext({
|
|
146713
|
-
url: void 0,
|
|
146714
|
-
adminKey: void 0,
|
|
146715
|
-
envFile: void 0
|
|
146716
|
-
});
|
|
146717
|
-
const currentSelection = await getDeploymentSelection(ctx, {});
|
|
146718
|
-
const parsed = parseDeploymentSelector(selector);
|
|
146719
|
-
if (currentSelection.kind === "chooseProject" && parsed.kind !== "inTeamProject" && parsed.kind !== "deploymentName" && parsed.kind !== "local") {
|
|
146720
|
-
return await ctx.crash({
|
|
146721
|
-
exitCode: 1,
|
|
146722
|
-
errorType: "fatal",
|
|
146723
|
-
printedMessage: `No project configured. Run \`npx convex dev\` to set up a project first, or use a full selector like 'my-team:my-project:dev/james' or 'happy-capybara-123'.`
|
|
146724
|
-
});
|
|
146725
|
-
}
|
|
146726
|
-
const newSelection = await getDeploymentSelection(ctx, {
|
|
146727
|
-
url: void 0,
|
|
146728
|
-
adminKey: void 0,
|
|
146729
|
-
envFile: void 0,
|
|
146730
|
-
deployment: selector
|
|
146731
|
-
});
|
|
146732
|
-
await saveSelectedDeployment(
|
|
146733
|
-
ctx,
|
|
146734
|
-
selector,
|
|
146735
|
-
newSelection,
|
|
146736
|
-
deploymentNameFromSelection(currentSelection)
|
|
146737
|
-
);
|
|
146738
|
-
});
|
|
146739
|
-
async function saveSelectedDeployment(ctx, selector, selection, previousDeploymentName) {
|
|
146740
|
-
const deployment2 = await loadSelectedDeploymentCredentials(ctx, selection, {
|
|
146741
|
-
ensureLocalRunning: false
|
|
146742
|
-
});
|
|
146743
|
-
if (deployment2.deploymentFields === null) {
|
|
146744
|
-
return ctx.crash({
|
|
146745
|
-
exitCode: 1,
|
|
146746
|
-
errorType: "fatal",
|
|
146747
|
-
printedMessage: null,
|
|
146748
|
-
errForSentry: `Unexpected selection in select: ${JSON.stringify(deployment2)}`
|
|
146749
|
-
});
|
|
146750
|
-
}
|
|
146751
|
-
if (deployment2.deploymentFields.deploymentType === "prod") {
|
|
146752
|
-
return await ctx.crash({
|
|
146753
|
-
exitCode: 1,
|
|
146754
|
-
errorType: "fatal",
|
|
146755
|
-
printedMessage: `Selecting a production deployment is unsupported. To run commands on a production deployment, pass the ${chalkStderr.bold(`--deployment ${selector}`)} flag to each command.`
|
|
146756
|
-
});
|
|
146757
|
-
}
|
|
146758
|
-
const { convexSiteUrl: siteUrl } = deployment2.deploymentFields.deploymentType === "local" ? { convexSiteUrl: null } : await fetchDeploymentCanonicalUrls(ctx, {
|
|
146759
|
-
adminKey: deployment2.adminKey,
|
|
146760
|
-
deploymentUrl: deployment2.url
|
|
146761
|
-
});
|
|
146762
|
-
await updateEnvAndConfigForDeploymentSelection(
|
|
146763
|
-
ctx,
|
|
146764
|
-
{
|
|
146765
|
-
url: deployment2.url,
|
|
146766
|
-
siteUrl,
|
|
146767
|
-
deploymentName: deployment2.deploymentFields.deploymentName,
|
|
146768
|
-
teamSlug: deployment2.deploymentFields.teamSlug,
|
|
146769
|
-
projectSlug: deployment2.deploymentFields.projectSlug,
|
|
146770
|
-
deploymentType: deployment2.deploymentFields.deploymentType
|
|
146771
|
-
},
|
|
146772
|
-
previousDeploymentName
|
|
146773
|
-
);
|
|
146774
|
-
}
|
|
146726
|
+
init_filePaths();
|
|
146727
|
+
init_prompts();
|
|
146775
146728
|
|
|
146776
146729
|
// src/cli/deploymentCreate.ts
|
|
146777
146730
|
var import_child_process8 = require("child_process");
|
|
146778
146731
|
init_log();
|
|
146732
|
+
init_deploymentSelection();
|
|
146779
146733
|
init_utils5();
|
|
146780
146734
|
init_deployment();
|
|
146781
146735
|
init_prompts();
|
|
@@ -146867,6 +146821,8 @@ init_download();
|
|
|
146867
146821
|
init_filePaths();
|
|
146868
146822
|
init_utils2();
|
|
146869
146823
|
init_bigBrain();
|
|
146824
|
+
init_localDeployment();
|
|
146825
|
+
init_run();
|
|
146870
146826
|
var SUPPORTED_TYPES = ["dev", "prod", "preview"];
|
|
146871
146827
|
var deploymentCreate = new Command("create").summary("Create a new deployment for a project").description(
|
|
146872
146828
|
"Create a new deployment for a project.\n\n Create a dev deployment and select it: `npx convex deployment create dev/my-new-feature --type dev --select`\n Create a prod deployment named \u201Cstaging\u201D: `npx convex deployment create staging --type prod`\n Create a local deployment: `npx convex deployment create local`\n"
|
|
@@ -146881,7 +146837,8 @@ var deploymentCreate = new Command("create").summary("Create a new deployment fo
|
|
|
146881
146837
|
).option(
|
|
146882
146838
|
"--expiration <value>",
|
|
146883
146839
|
'When the deployment expires (e.g. "none", "in 7 days", "2026-04-01T00:00:00Z", or a UNIX timestamp in seconds or milliseconds)'
|
|
146884
|
-
).action(async (refParam, options) => {
|
|
146840
|
+
).addOption(new Option("--expiry <value>").hideHelp()).addOption(new Option("--expires <value>").hideHelp()).action(async (refParam, options) => {
|
|
146841
|
+
const expiration = options.expiration ?? options.expiry ?? options.expires;
|
|
146885
146842
|
const ctx = await oneoffContext({
|
|
146886
146843
|
url: void 0,
|
|
146887
146844
|
adminKey: void 0,
|
|
@@ -146894,13 +146851,7 @@ var deploymentCreate = new Command("create").summary("Create a new deployment fo
|
|
|
146894
146851
|
});
|
|
146895
146852
|
if (refParam !== void 0) {
|
|
146896
146853
|
if (refParam === "local") {
|
|
146897
|
-
const cloudOnlyFlags = [
|
|
146898
|
-
"type",
|
|
146899
|
-
"region",
|
|
146900
|
-
"class",
|
|
146901
|
-
"default",
|
|
146902
|
-
"expiration"
|
|
146903
|
-
];
|
|
146854
|
+
const cloudOnlyFlags = ["type", "region", "class", "default"];
|
|
146904
146855
|
for (const flag of cloudOnlyFlags) {
|
|
146905
146856
|
if (options[flag]) {
|
|
146906
146857
|
return await ctx.crash({
|
|
@@ -146910,6 +146861,13 @@ var deploymentCreate = new Command("create").summary("Create a new deployment fo
|
|
|
146910
146861
|
});
|
|
146911
146862
|
}
|
|
146912
146863
|
}
|
|
146864
|
+
if (expiration !== void 0) {
|
|
146865
|
+
return await ctx.crash({
|
|
146866
|
+
exitCode: 1,
|
|
146867
|
+
errorType: "fatal",
|
|
146868
|
+
printedMessage: `--expiration cannot be used when creating a local deployment`
|
|
146869
|
+
});
|
|
146870
|
+
}
|
|
146913
146871
|
await createLocalDeployment(
|
|
146914
146872
|
ctx,
|
|
146915
146873
|
currentDeployment,
|
|
@@ -146918,7 +146876,7 @@ var deploymentCreate = new Command("create").summary("Create a new deployment fo
|
|
|
146918
146876
|
return;
|
|
146919
146877
|
}
|
|
146920
146878
|
}
|
|
146921
|
-
const expiresAt = await resolveExpiresAtOrCrash(ctx,
|
|
146879
|
+
const expiresAt = await resolveExpiresAtOrCrash(ctx, expiration);
|
|
146922
146880
|
const {
|
|
146923
146881
|
ref,
|
|
146924
146882
|
regionDetails,
|
|
@@ -147037,6 +146995,13 @@ async function createLocalDeployment(ctx, currentDeployment, select) {
|
|
|
147037
146995
|
instanceSecret: LOCAL_BACKEND_INSTANCE_SECRET
|
|
147038
146996
|
});
|
|
147039
146997
|
logFinishedStep("Created local deployment.");
|
|
146998
|
+
await importDefaultEnvVars(ctx, {
|
|
146999
|
+
teamSlug,
|
|
147000
|
+
projectSlug,
|
|
147001
|
+
deploymentName,
|
|
147002
|
+
deploymentUrl: localDeploymentUrl(cloudPort),
|
|
147003
|
+
adminKey
|
|
147004
|
+
});
|
|
147040
147005
|
if (select) {
|
|
147041
147006
|
const selection = {
|
|
147042
147007
|
kind: "deploymentWithinProject",
|
|
@@ -147524,10 +147489,102 @@ function defaultRef(branch, deploymentType) {
|
|
|
147524
147489
|
return ref;
|
|
147525
147490
|
}
|
|
147526
147491
|
|
|
147492
|
+
// src/cli/deploymentSelect.ts
|
|
147493
|
+
init_source();
|
|
147494
|
+
var deploymentSelect = new Command("select").summary("Select the deployment to use when running commands").description(
|
|
147495
|
+
"Select the deployment to use when running commands.\n\nThe deployment will be used by all `npx convex` commands, except `npx convex deploy`. You can also run individual commands on another deployment by using the --deployment flag on that command.\n\nExamples:\n npx convex select dev # Select your personal cloud dev deployment in the current project\n npx convex select local # Select your local deployment\n npx convex select dev/james # Select a deployment in the same project by its reference\n npx convex select some-project:dev/james # Select a deployment in another project in the same team\n npx convex select some-team:some-project:dev/james # Select a deployment in a particular team/project\n"
|
|
147496
|
+
).argument("<deployment>", "The deployment to use").allowExcessArguments(false).action(async (selector) => {
|
|
147497
|
+
const ctx = await oneoffContext({
|
|
147498
|
+
url: void 0,
|
|
147499
|
+
adminKey: void 0,
|
|
147500
|
+
envFile: void 0
|
|
147501
|
+
});
|
|
147502
|
+
const currentSelection = await getDeploymentSelection(ctx, {});
|
|
147503
|
+
const parsed = parseDeploymentSelector(selector);
|
|
147504
|
+
if (currentSelection.kind === "chooseProject" && parsed.kind !== "inTeamProject" && parsed.kind !== "deploymentName" && parsed.kind !== "local") {
|
|
147505
|
+
return await ctx.crash({
|
|
147506
|
+
exitCode: 1,
|
|
147507
|
+
errorType: "fatal",
|
|
147508
|
+
printedMessage: `No project configured. Run \`npx convex dev\` to set up a project first, or use a full selector like 'my-team:my-project:dev/james' or 'happy-capybara-123'.`
|
|
147509
|
+
});
|
|
147510
|
+
}
|
|
147511
|
+
if (parsed.kind === "local" && process.stdin.isTTY && loadProjectLocalConfig(ctx) === null) {
|
|
147512
|
+
if (currentSelection.kind === "chooseProject") {
|
|
147513
|
+
return await ctx.crash({
|
|
147514
|
+
exitCode: 1,
|
|
147515
|
+
errorType: "fatal",
|
|
147516
|
+
printedMessage: `No project configured. Run \`npx convex dev\` to set up a project first.`
|
|
147517
|
+
});
|
|
147518
|
+
}
|
|
147519
|
+
const wantsToCreate = await promptYesNo(ctx, {
|
|
147520
|
+
message: "No local deployment found. Create one now?",
|
|
147521
|
+
default: true
|
|
147522
|
+
});
|
|
147523
|
+
if (!wantsToCreate) {
|
|
147524
|
+
return await ctx.crash({
|
|
147525
|
+
exitCode: 1,
|
|
147526
|
+
errorType: "fatal",
|
|
147527
|
+
printedMessage: `No local deployment found. Run ${chalkStderr.bold("npx convex deployment create local")} to create one.`
|
|
147528
|
+
});
|
|
147529
|
+
}
|
|
147530
|
+
await createLocalDeployment(ctx, currentSelection, true);
|
|
147531
|
+
return;
|
|
147532
|
+
}
|
|
147533
|
+
const newSelection = await getDeploymentSelection(ctx, {
|
|
147534
|
+
url: void 0,
|
|
147535
|
+
adminKey: void 0,
|
|
147536
|
+
envFile: void 0,
|
|
147537
|
+
deployment: selector
|
|
147538
|
+
});
|
|
147539
|
+
await saveSelectedDeployment(
|
|
147540
|
+
ctx,
|
|
147541
|
+
selector,
|
|
147542
|
+
newSelection,
|
|
147543
|
+
deploymentNameFromSelection(currentSelection)
|
|
147544
|
+
);
|
|
147545
|
+
});
|
|
147546
|
+
async function saveSelectedDeployment(ctx, selector, selection, previousDeploymentName) {
|
|
147547
|
+
const deployment2 = await loadSelectedDeploymentCredentials(ctx, selection, {
|
|
147548
|
+
ensureLocalRunning: false
|
|
147549
|
+
});
|
|
147550
|
+
if (deployment2.deploymentFields === null) {
|
|
147551
|
+
return ctx.crash({
|
|
147552
|
+
exitCode: 1,
|
|
147553
|
+
errorType: "fatal",
|
|
147554
|
+
printedMessage: null,
|
|
147555
|
+
errForSentry: `Unexpected selection in select: ${JSON.stringify(deployment2)}`
|
|
147556
|
+
});
|
|
147557
|
+
}
|
|
147558
|
+
if (deployment2.deploymentFields.deploymentType === "prod") {
|
|
147559
|
+
return await ctx.crash({
|
|
147560
|
+
exitCode: 1,
|
|
147561
|
+
errorType: "fatal",
|
|
147562
|
+
printedMessage: `Selecting a production deployment is unsupported. To run commands on a production deployment, pass the ${chalkStderr.bold(`--deployment ${selector}`)} flag to each command.`
|
|
147563
|
+
});
|
|
147564
|
+
}
|
|
147565
|
+
const { convexSiteUrl: siteUrl } = deployment2.deploymentFields.deploymentType === "local" ? { convexSiteUrl: null } : await fetchDeploymentCanonicalUrls(ctx, {
|
|
147566
|
+
adminKey: deployment2.adminKey,
|
|
147567
|
+
deploymentUrl: deployment2.url
|
|
147568
|
+
});
|
|
147569
|
+
await updateEnvAndConfigForDeploymentSelection(
|
|
147570
|
+
ctx,
|
|
147571
|
+
{
|
|
147572
|
+
url: deployment2.url,
|
|
147573
|
+
siteUrl,
|
|
147574
|
+
deploymentName: deployment2.deploymentFields.deploymentName,
|
|
147575
|
+
teamSlug: deployment2.deploymentFields.teamSlug,
|
|
147576
|
+
projectSlug: deployment2.deploymentFields.projectSlug,
|
|
147577
|
+
deploymentType: deployment2.deploymentFields.deploymentType
|
|
147578
|
+
},
|
|
147579
|
+
previousDeploymentName
|
|
147580
|
+
);
|
|
147581
|
+
}
|
|
147582
|
+
|
|
147527
147583
|
// src/cli/deploymentTokenCreate.ts
|
|
147528
147584
|
init_source();
|
|
147529
147585
|
init_log();
|
|
147530
147586
|
init_api3();
|
|
147587
|
+
init_deploymentSelection();
|
|
147531
147588
|
init_envvars();
|
|
147532
147589
|
init_utils5();
|
|
147533
147590
|
var deploymentTokenCreate = new Command("create").summary("Create an access token").description(
|
|
@@ -147548,7 +147605,7 @@ var deploymentTokenCreate = new Command("create").summary("Create an access toke
|
|
|
147548
147605
|
return await ctx.crash({
|
|
147549
147606
|
exitCode: 1,
|
|
147550
147607
|
errorType: "fatal",
|
|
147551
|
-
printedMessage: `Creating a deploy key currently requires being logged in with a personal access token. ${process.env[CONVEX_DEPLOY_KEY_ENV_VAR_NAME] ? `Unset ${CONVEX_DEPLOY_KEY_ENV_VAR_NAME}` : `Run ${chalkStderr.bold("npx convex login")}`} and try again.`
|
|
147608
|
+
printedMessage: `Creating a deploy key currently requires being logged in with a personal access token. ${process.env[CONVEX_DEPLOY_KEY_ENV_VAR_NAME] ? `Unset ${CONVEX_DEPLOY_KEY_ENV_VAR_NAME}` : process.env[CONVEX_DEPLOYMENT_TOKEN_ENV_VAR_NAME] ? `Unset ${CONVEX_DEPLOYMENT_TOKEN_ENV_VAR_NAME}` : `Run ${chalkStderr.bold("npx convex login")}`} and try again.`
|
|
147552
147609
|
});
|
|
147553
147610
|
}
|
|
147554
147611
|
const deploymentSelection = await getDeploymentSelection(ctx, options);
|
|
@@ -147611,6 +147668,7 @@ var deploymentTokenCreate = new Command("create").summary("Create an access toke
|
|
|
147611
147668
|
init_source();
|
|
147612
147669
|
init_log();
|
|
147613
147670
|
init_api3();
|
|
147671
|
+
init_deploymentSelection();
|
|
147614
147672
|
init_utils5();
|
|
147615
147673
|
var deploymentTokenDelete = new Command("delete").summary("Delete an access token").description(
|
|
147616
147674
|
"Delete an access token. Currently only deploy keys (deployment-scoped access tokens) are supported.\n\nThe positional `<nameOrToken>` can be the unique name of the deploy key (as passed to `token create`) or the deploy key value itself. The target deployment defaults to the currently-selected one; pass `--deployment` to target a different deployment.\n\n Delete by name: `npx convex deployment token delete my-token`\n Delete by value: `npx convex deployment token delete 'dev:happy-animal-123|ey...'`\n Target prod: `npx convex deployment token delete ci-token --deployment prod`"
|
|
@@ -147624,7 +147682,7 @@ var deploymentTokenDelete = new Command("delete").summary("Delete an access toke
|
|
|
147624
147682
|
return await ctx.crash({
|
|
147625
147683
|
exitCode: 1,
|
|
147626
147684
|
errorType: "fatal",
|
|
147627
|
-
printedMessage: `Deleting a deploy key requires being logged in with a personal access token. ${auth2 === null ? "Run " : `Unset ${CONVEX_DEPLOY_KEY_ENV_VAR_NAME} and run `}${chalkStderr.bold("npx convex login")} and try again.`
|
|
147685
|
+
printedMessage: `Deleting a deploy key requires being logged in with a personal access token. ${auth2 === null ? "Run " : process.env[CONVEX_DEPLOYMENT_TOKEN_ENV_VAR_NAME] && !process.env[CONVEX_DEPLOY_KEY_ENV_VAR_NAME] ? `Unset ${CONVEX_DEPLOYMENT_TOKEN_ENV_VAR_NAME} and run ` : `Unset ${CONVEX_DEPLOY_KEY_ENV_VAR_NAME} and run `}${chalkStderr.bold("npx convex login")} and try again.`
|
|
147628
147686
|
});
|
|
147629
147687
|
}
|
|
147630
147688
|
const deploymentSelection = await getDeploymentSelection(ctx, options);
|
|
@@ -147928,6 +147986,7 @@ var import_node_net2 = __toESM(require("net"), 1);
|
|
|
147928
147986
|
init_source();
|
|
147929
147987
|
init_api3();
|
|
147930
147988
|
init_utils5();
|
|
147989
|
+
init_deploymentSelection();
|
|
147931
147990
|
init_workos();
|
|
147932
147991
|
init_platformApi();
|
|
147933
147992
|
init_log();
|
|
@@ -148470,7 +148529,7 @@ async function main() {
|
|
|
148470
148529
|
);
|
|
148471
148530
|
}
|
|
148472
148531
|
const program3 = new Command();
|
|
148473
|
-
program3.name("convex").usage("<command> [options]").description("Start developing with Convex by running `npx convex dev`.").addCommand(login, { hidden: true }).addCommand(init2, { hidden: true }).addCommand(reinit, { hidden: true }).addCommand(dev).addCommand(deploy).addCommand(deployment).addCommand(deployments, { hidden: true }).addCommand(run).addCommand(convexImport).addCommand(dashboard).addCommand(docs).addCommand(logs).addCommand(typecheck, { hidden: true }).addCommand(auth, { hidden: true }).addCommand(convexExport).addCommand(env2).addCommand(data).addCommand(codegen).addCommand(update).addCommand(logout).addCommand(networkTest, { hidden: true }).addCommand(integration, { hidden: true }).addCommand(functionSpec).addCommand(insights).addCommand(
|
|
148532
|
+
program3.name("convex").usage("<command> [options]").description("Start developing with Convex by running `npx convex dev`.").addCommand(login, { hidden: true }).addCommand(init2, { hidden: true }).addCommand(reinit, { hidden: true }).addCommand(dev).addCommand(deploy).addCommand(deployment).addCommand(deployments, { hidden: true }).addCommand(run).addCommand(convexImport).addCommand(dashboard).addCommand(docs).addCommand(logs).addCommand(typecheck, { hidden: true }).addCommand(auth, { hidden: true }).addCommand(convexExport).addCommand(env2).addCommand(data).addCommand(codegen).addCommand(update).addCommand(logout).addCommand(networkTest, { hidden: true }).addCommand(integration, { hidden: true }).addCommand(functionSpec).addCommand(insights).addCommand(mcp).addCommand(aiFiles).helpCommand("help <command>", "Show help for given <command>").version(version2).configureHelp({ visibleOptions: () => [] }).showHelpAfterError();
|
|
148474
148533
|
try {
|
|
148475
148534
|
await program3.parseAsync(process.argv);
|
|
148476
148535
|
} catch (e) {
|
|
@@ -148480,6 +148539,10 @@ async function main() {
|
|
|
148480
148539
|
} finally {
|
|
148481
148540
|
await Sentry9.close();
|
|
148482
148541
|
}
|
|
148542
|
+
await Promise.all([
|
|
148543
|
+
new Promise((resolve2) => process.stdout.write("", () => resolve2())),
|
|
148544
|
+
new Promise((resolve2) => process.stderr.write("", () => resolve2()))
|
|
148545
|
+
]);
|
|
148483
148546
|
process.exit();
|
|
148484
148547
|
}
|
|
148485
148548
|
void main();
|