base44 0.0.34 → 0.0.35

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
@@ -1,4 +1,4 @@
1
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._posthogChunkIds=e._posthogChunkIds||{},e._posthogChunkIds[n]="019c89f2-5709-70e0-92fd-2ed2ea0125c8")}catch(e){}}();import { createRequire } from "node:module";
1
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._posthogChunkIds=e._posthogChunkIds||{},e._posthogChunkIds[n]="019c8b01-a41e-78d0-855b-1f264ec2d7de")}catch(e){}}();import { createRequire } from "node:module";
2
2
  var __create = Object.create;
3
3
  var __getProtoOf = Object.getPrototypeOf;
4
4
  var __defProp = Object.defineProperty;
@@ -185389,18 +185389,16 @@ async function fetchAgents() {
185389
185389
  }
185390
185390
  // src/core/resources/agent/config.ts
185391
185391
  import { join as join3 } from "node:path";
185392
- function toFileSlug(name2) {
185393
- return name2.toLowerCase().replace(/[^a-z0-9_]/g, "_").replace(/_+/g, "_").replace(/^_|_$/g, "");
185394
- }
185392
+ import { isDeepStrictEqual } from "node:util";
185395
185393
  async function readAgentFile(agentPath) {
185396
- const parsed = await readJsonFile(agentPath);
185397
- const result = AgentConfigSchema.safeParse(parsed);
185394
+ const raw2 = await readJsonFile(agentPath);
185395
+ const result = AgentConfigSchema.safeParse(raw2);
185398
185396
  if (!result.success) {
185399
185397
  throw new SchemaValidationError("Invalid agent file", result.error, agentPath);
185400
185398
  }
185401
- return result.data;
185399
+ return { data: result.data, raw: raw2 };
185402
185400
  }
185403
- async function readAllAgents(agentsDir) {
185401
+ async function readAgentFiles(agentsDir) {
185404
185402
  if (!await pathExists(agentsDir)) {
185405
185403
  return [];
185406
185404
  }
@@ -185408,37 +185406,72 @@ async function readAllAgents(agentsDir) {
185408
185406
  cwd: agentsDir,
185409
185407
  absolute: true
185410
185408
  });
185411
- const agents = await Promise.all(files.map((filePath) => readAgentFile(filePath)));
185412
- const names = new Set;
185413
- for (const agent of agents) {
185414
- if (names.has(agent.name)) {
185415
- throw new Error(`Duplicate agent name "${agent.name}"`);
185409
+ return await Promise.all(files.map(async (filePath) => {
185410
+ const { data, raw: raw2 } = await readAgentFile(filePath);
185411
+ return { data, raw: raw2, filePath };
185412
+ }));
185413
+ }
185414
+ function buildNameToEntryMap(entries) {
185415
+ const nameToEntry = new Map;
185416
+ for (const entry of entries) {
185417
+ if (nameToEntry.has(entry.data.name)) {
185418
+ throw new InvalidInputError(`Duplicate agent name "${entry.data.name}"`, {
185419
+ hints: [
185420
+ {
185421
+ message: `Remove duplicate agents with name "${entry.data.name}" - only one agent per name is allowed`
185422
+ }
185423
+ ]
185424
+ });
185425
+ }
185426
+ nameToEntry.set(entry.data.name, entry);
185427
+ }
185428
+ return nameToEntry;
185429
+ }
185430
+ async function readAllAgents(agentsDir) {
185431
+ const entries = await readAgentFiles(agentsDir);
185432
+ const nameToEntry = buildNameToEntryMap(entries);
185433
+ return [...nameToEntry.values()].map((e2) => e2.data);
185434
+ }
185435
+ function findAvailablePath(agentsDir, name2, claimedPaths) {
185436
+ const base = join3(agentsDir, `${name2}.${CONFIG_FILE_EXTENSION}`);
185437
+ if (!claimedPaths.has(base)) {
185438
+ return base;
185439
+ }
185440
+ for (let i = 1;; i++) {
185441
+ const candidate = join3(agentsDir, `${name2}_${i}.${CONFIG_FILE_EXTENSION}`);
185442
+ if (!claimedPaths.has(candidate)) {
185443
+ return candidate;
185416
185444
  }
185417
- names.add(agent.name);
185418
185445
  }
185419
- return agents;
185420
185446
  }
185421
185447
  async function writeAgents(agentsDir, remoteAgents) {
185422
- const existingAgents = await readAllAgents(agentsDir);
185448
+ const entries = await readAgentFiles(agentsDir);
185449
+ const nameToEntry = buildNameToEntryMap(entries);
185423
185450
  const newNames = new Set(remoteAgents.map((a) => a.name));
185424
- const toDelete = existingAgents.filter((a) => !newNames.has(a.name));
185425
- for (const agent of toDelete) {
185426
- const slug = toFileSlug(agent.name);
185427
- const files = await globby(`${slug}.${CONFIG_FILE_EXTENSION_GLOB}`, {
185428
- cwd: agentsDir,
185429
- absolute: true
185430
- });
185431
- for (const filePath of files) {
185432
- await deleteFile(filePath);
185451
+ const deleted = [];
185452
+ for (const [name2, entry] of nameToEntry) {
185453
+ if (!newNames.has(name2)) {
185454
+ await deleteFile(entry.filePath);
185455
+ deleted.push(name2);
185456
+ }
185457
+ }
185458
+ const claimedPaths = new Set;
185459
+ for (const [name2, entry] of nameToEntry) {
185460
+ if (newNames.has(name2)) {
185461
+ claimedPaths.add(entry.filePath);
185433
185462
  }
185434
185463
  }
185464
+ const written = [];
185435
185465
  for (const agent of remoteAgents) {
185436
- const slug = toFileSlug(agent.name);
185437
- const filePath = join3(agentsDir, `${slug}.${CONFIG_FILE_EXTENSION}`);
185466
+ const existing = nameToEntry.get(agent.name);
185467
+ if (existing && isDeepStrictEqual(existing.raw, agent)) {
185468
+ continue;
185469
+ }
185470
+ const filePath = existing?.filePath ?? findAvailablePath(agentsDir, agent.name, claimedPaths);
185471
+ claimedPaths.add(filePath);
185438
185472
  await writeJsonFile(filePath, agent);
185473
+ written.push(agent.name);
185439
185474
  }
185440
- const written = remoteAgents.map((a) => a.name);
185441
- const deleted = toDelete.map((a) => a.name);
185442
185475
  return { written, deleted };
185443
185476
  }
185444
185477
  // src/core/resources/agent/resource.ts
@@ -185655,7 +185688,7 @@ async function removeConnector(integrationType) {
185655
185688
  }
185656
185689
  // src/core/resources/connector/config.ts
185657
185690
  import { join as join4 } from "node:path";
185658
- import { isDeepStrictEqual } from "node:util";
185691
+ import { isDeepStrictEqual as isDeepStrictEqual2 } from "node:util";
185659
185692
  async function readConnectorFile(connectorPath) {
185660
185693
  const parsed = await readJsonFile(connectorPath);
185661
185694
  const result = ConnectorResourceSchema.safeParse(parsed);
@@ -185716,7 +185749,7 @@ async function writeConnectors(connectorsDir, remoteConnectors) {
185716
185749
  type: connector.integrationType,
185717
185750
  scopes: connector.scopes
185718
185751
  };
185719
- if (existing && isDeepStrictEqual(existing.data, localConnector)) {
185752
+ if (existing && isDeepStrictEqual2(existing.data, localConnector)) {
185720
185753
  continue;
185721
185754
  }
185722
185755
  const filePath = existing?.filePath ?? join4(connectorsDir, `${connector.integrationType}.${CONFIG_FILE_EXTENSION}`);
@@ -186019,7 +186052,7 @@ var DeployFunctionsResponseSchema = exports_external.object({
186019
186052
  skipped: exports_external.array(exports_external.string()).optional().nullable(),
186020
186053
  errors: exports_external.array(exports_external.object({ name: exports_external.string(), message: exports_external.string() })).nullable()
186021
186054
  });
186022
- var LogLevelSchema = exports_external.enum(["log", "info", "warn", "error", "debug"]);
186055
+ var LogLevelSchema = exports_external.enum(["info", "warning", "error", "debug"]);
186023
186056
  var FunctionLogEntrySchema = exports_external.object({
186024
186057
  time: exports_external.string(),
186025
186058
  level: LogLevelSchema,
@@ -193925,7 +193958,7 @@ var {
193925
193958
  // package.json
193926
193959
  var package_default = {
193927
193960
  name: "base44",
193928
- version: "0.0.34",
193961
+ version: "0.0.35",
193929
193962
  description: "Base44 CLI - Unified interface for managing Base44 applications",
193930
193963
  type: "module",
193931
193964
  bin: {
@@ -194130,14 +194163,11 @@ async function pullAgentsAction() {
194130
194163
  successMessage: "Agents fetched successfully",
194131
194164
  errorMessage: "Failed to fetch agents"
194132
194165
  });
194133
- if (remoteAgents.items.length === 0) {
194134
- return { outroMessage: "No agents found on Base44" };
194135
- }
194136
- const { written, deleted } = await runTask("Writing agent files", async () => {
194166
+ const { written, deleted } = await runTask("Syncing agent files", async () => {
194137
194167
  return await writeAgents(agentsDir, remoteAgents.items);
194138
194168
  }, {
194139
- successMessage: "Agent files written successfully",
194140
- errorMessage: "Failed to write agent files"
194169
+ successMessage: "Agent files synced successfully",
194170
+ errorMessage: "Failed to sync agent files"
194141
194171
  });
194142
194172
  if (written.length > 0) {
194143
194173
  R2.success(`Written: ${written.join(", ")}`);
@@ -194145,6 +194175,9 @@ async function pullAgentsAction() {
194145
194175
  if (deleted.length > 0) {
194146
194176
  R2.warn(`Deleted: ${deleted.join(", ")}`);
194147
194177
  }
194178
+ if (written.length === 0 && deleted.length === 0) {
194179
+ R2.info("All agents are already up to date");
194180
+ }
194148
194181
  return {
194149
194182
  outroMessage: `Pulled ${remoteAgents.total} agents to ${agentsDir}`
194150
194183
  };
@@ -195512,6 +195545,9 @@ function parseFunctionFilters(options) {
195512
195545
  if (options.until) {
195513
195546
  filters.until = options.until;
195514
195547
  }
195548
+ if (options.level) {
195549
+ filters.level = options.level;
195550
+ }
195515
195551
  if (options.limit) {
195516
195552
  filters.limit = Number.parseInt(options.limit, 10);
195517
195553
  }
@@ -195608,13 +195644,13 @@ async function logsAction(options) {
195608
195644
  return { outroMessage: "Fetched logs", stdout: logsOutput };
195609
195645
  }
195610
195646
  function getLogsCommand(context) {
195611
- return new Command("logs").description("Fetch function logs for this app").option("--function <names>", "Filter by function name(s), comma-separated. If omitted, fetches logs for all project functions").option("--since <datetime>", "Show logs from this time (ISO format)", normalizeDatetime).option("--until <datetime>", "Show logs until this time (ISO format)", normalizeDatetime).option("-n, --limit <n>", "Results per page (1-1000, default: 50)", (v) => {
195647
+ return new Command("logs").description("Fetch function logs for this app").option("--function <names>", "Filter by function name(s), comma-separated. If omitted, fetches logs for all project functions").option("--since <datetime>", "Show logs from this time (ISO format)", normalizeDatetime).option("--until <datetime>", "Show logs until this time (ISO format)", normalizeDatetime).addOption(new Option("--level <level>", "Filter by log level").choices([...LogLevelSchema.options]).hideHelp()).option("-n, --limit <n>", "Results per page (1-1000, default: 50)", (v) => {
195612
195648
  const n2 = Number.parseInt(v, 10);
195613
195649
  if (Number.isNaN(n2) || n2 < 1 || n2 > 1000) {
195614
195650
  throw new InvalidInputError(`Invalid limit: "${v}". Must be a number between 1 and 1000.`);
195615
195651
  }
195616
195652
  return v;
195617
- }).addOption(new Option("--order <order>", "Sort order").choices(["asc", "desc"])).option("--json", "Output raw JSON").action(async (options) => {
195653
+ }).addOption(new Option("--order <order>", "Sort order").choices(["asc", "desc"])).action(async (options) => {
195618
195654
  await runCommand(() => logsAction(options), { requireAuth: true }, context);
195619
195655
  });
195620
195656
  }
@@ -200605,6 +200641,6 @@ export {
200605
200641
  CLIExitError
200606
200642
  };
200607
200643
 
200608
- //# debugId=5F7AE36175BE8E7364756E2164756E21
200644
+ //# debugId=97F60A57F6E2DA7C64756E2164756E21
200609
200645
 
200610
- //# chunkId=019c89f2-5709-70e0-92fd-2ed2ea0125c8
200646
+ //# chunkId=019c8b01-a41e-78d0-855b-1f264ec2d7de