@base44-preview/cli 0.1.2-pr.563.1f1fb0e → 0.1.2-pr.563.37a52bb

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli/index.js CHANGED
@@ -233593,6 +233593,9 @@ var ApiErrorResponseSchema = exports_external.looseObject({
233593
233593
  });
233594
233594
 
233595
233595
  // src/core/errors.ts
233596
+ function usingWorkspaceApiKey() {
233597
+ return process.env.BASE44_API_KEY?.trim().startsWith("b44k_") ?? false;
233598
+ }
233596
233599
  function formatApiError(errorBody, parsed) {
233597
233600
  const data = parsed ?? ApiErrorResponseSchema.safeParse(errorBody).data;
233598
233601
  if (data) {
@@ -233787,6 +233790,13 @@ class ApiError extends SystemError {
233787
233790
  ];
233788
233791
  }
233789
233792
  if (statusCode === 401) {
233793
+ if (usingWorkspaceApiKey()) {
233794
+ return [
233795
+ {
233796
+ message: "The workspace API key (BASE44_API_KEY) was rejected. Verify it is valid and authorized for this app."
233797
+ }
233798
+ ];
233799
+ }
233790
233800
  return [{ message: "Try logging in again", command: "base44 login" }];
233791
233801
  }
233792
233802
  if (statusCode === 403) {
@@ -236102,7 +236112,19 @@ function getTestOverrides() {
236102
236112
 
236103
236113
  // src/core/auth/config.ts
236104
236114
  var TOKEN_REFRESH_BUFFER_MS = 60 * 1000;
236115
+ var WORKSPACE_API_KEY_PREFIX = "b44k_";
236105
236116
  var refreshPromise = null;
236117
+ function getWorkspaceApiKeyFromEnv() {
236118
+ const key = process.env.BASE44_API_KEY?.trim();
236119
+ return key ? key : null;
236120
+ }
236121
+ function isWorkspaceApiKey(value) {
236122
+ return value.startsWith(WORKSPACE_API_KEY_PREFIX);
236123
+ }
236124
+ function hasWorkspaceApiKeyAuth() {
236125
+ const key = getWorkspaceApiKeyFromEnv();
236126
+ return key !== null && isWorkspaceApiKey(key);
236127
+ }
236106
236128
  async function seedAuthFromEnv() {
236107
236129
  const accessToken = process.env.BASE44_ACCESS_TOKEN;
236108
236130
  if (!accessToken) {
@@ -244297,7 +244319,8 @@ async function deployAll(projectData, options) {
244297
244319
  });
244298
244320
  await agentResource.push(agents);
244299
244321
  await authConfigResource.push(authConfig);
244300
- const { results: connectorResults } = await pushConnectors(connectors);
244322
+ const skipConnectorSync = connectors.length === 0 && hasWorkspaceApiKeyAuth();
244323
+ const connectorResults = skipConnectorSync ? [] : (await pushConnectors(connectors)).results;
244301
244324
  if (project.site?.outputDirectory) {
244302
244325
  const outputDir = resolve4(project.root, project.site.outputDirectory);
244303
244326
  const { appUrl } = await deploySite(outputDir);
@@ -244321,6 +244344,9 @@ async function handleUnauthorized(request, _options, response) {
244321
244344
  if (response.status !== 401) {
244322
244345
  return;
244323
244346
  }
244347
+ if (hasWorkspaceApiKeyAuth()) {
244348
+ return;
244349
+ }
244324
244350
  if (retriedRequests.has(request)) {
244325
244351
  return;
244326
244352
  }
@@ -244349,6 +244375,11 @@ var base44Client = distribution_default.create({
244349
244375
  },
244350
244376
  captureRequestBody,
244351
244377
  async (request) => {
244378
+ const workspaceApiKey = getWorkspaceApiKeyFromEnv();
244379
+ if (workspaceApiKey && isWorkspaceApiKey(workspaceApiKey)) {
244380
+ request.headers.set("api_key", workspaceApiKey);
244381
+ return;
244382
+ }
244352
244383
  try {
244353
244384
  const auth = await readAuth();
244354
244385
  if (isTokenExpired(auth)) {
@@ -244554,6 +244585,12 @@ async function login({
244554
244585
 
244555
244586
  // src/cli/utils/command/middleware.ts
244556
244587
  async function ensureAuth(ctx) {
244588
+ if (hasWorkspaceApiKeyAuth()) {
244589
+ ctx.errorReporter.setContext({
244590
+ user: { email: "workspace-api-key", name: "Workspace API key" }
244591
+ });
244592
+ return;
244593
+ }
244557
244594
  await seedAuthFromEnv();
244558
244595
  const loggedIn = await isLoggedIn();
244559
244596
  if (!loggedIn) {
@@ -251978,6 +252015,12 @@ function getLogoutCommand() {
251978
252015
 
251979
252016
  // src/cli/commands/auth/whoami.ts
251980
252017
  async function whoami(_ctx) {
252018
+ const workspaceApiKey = getWorkspaceApiKeyFromEnv();
252019
+ if (workspaceApiKey && isWorkspaceApiKey(workspaceApiKey)) {
252020
+ return {
252021
+ outroMessage: `Using workspace API key: ${theme.styles.bold(workspaceApiKey.slice(0, 10))}`
252022
+ };
252023
+ }
251981
252024
  const auth2 = await readAuth();
251982
252025
  return { outroMessage: `Logged in as: ${theme.styles.bold(auth2.email)}` };
251983
252026
  }
@@ -253871,7 +253914,8 @@ async function fetchLogsForFunctions(functionNames, options, availableFunctionNa
253871
253914
  }
253872
253915
  throw error48;
253873
253916
  }
253874
- allEntries.push(...logs.map((entry) => normalizeLogEntry(entry, functionName)));
253917
+ const matchingLogs = filters.level ? logs.filter((entry) => entry.level === filters.level) : logs;
253918
+ allEntries.push(...matchingLogs.map((entry) => normalizeLogEntry(entry, functionName)));
253875
253919
  }
253876
253920
  if (functionNames.length > 1) {
253877
253921
  const order = options.order?.toUpperCase() === "ASC" ? 1 : -1;
@@ -262620,4 +262664,4 @@ export {
262620
262664
  CLIExitError
262621
262665
  };
262622
262666
 
262623
- //# debugId=B8C7F17D9436926E64756E2164756E21
262667
+ //# debugId=3549116E1982FEC664756E2164756E21