@base44-preview/cli 0.0.32-pr.248.70443e1 → 0.0.32-pr.249.2ca946e

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
@@ -185051,6 +185051,10 @@ var TikTokConnectorSchema = exports_external.object({
185051
185051
  type: exports_external.literal("tiktok"),
185052
185052
  scopes: exports_external.array(exports_external.string()).default([])
185053
185053
  });
185054
+ var GoogleBigQueryConnectorSchema = exports_external.object({
185055
+ type: exports_external.literal("googlebigquery"),
185056
+ scopes: exports_external.array(exports_external.string()).default([])
185057
+ });
185054
185058
  var CustomTypeSchema = exports_external.string().min(1).regex(/^[a-z0-9_-]+$/i);
185055
185059
  var GenericConnectorSchema = exports_external.object({
185056
185060
  type: CustomTypeSchema,
@@ -185063,6 +185067,7 @@ var ConnectorResourceSchema = exports_external.union([
185063
185067
  GoogleSheetsConnectorSchema,
185064
185068
  GoogleDocsConnectorSchema,
185065
185069
  GoogleSlidesConnectorSchema,
185070
+ GoogleBigQueryConnectorSchema,
185066
185071
  SlackConnectorSchema,
185067
185072
  NotionConnectorSchema,
185068
185073
  SalesforceConnectorSchema,
@@ -185078,6 +185083,7 @@ var KnownIntegrationTypes = [
185078
185083
  "googlesheets",
185079
185084
  "googledocs",
185080
185085
  "googleslides",
185086
+ "googlebigquery",
185081
185087
  "slack",
185082
185088
  "notion",
185083
185089
  "salesforce",
@@ -185340,7 +185346,10 @@ var connectorResource = {
185340
185346
  // src/core/resources/entity/schema.ts
185341
185347
  var FieldConditionSchema = exports_external.union([
185342
185348
  exports_external.string(),
185343
- exports_external.object({
185349
+ exports_external.number(),
185350
+ exports_external.boolean(),
185351
+ exports_external.null(),
185352
+ exports_external.looseObject({
185344
185353
  $in: exports_external.unknown().optional(),
185345
185354
  $nin: exports_external.unknown().optional(),
185346
185355
  $ne: exports_external.unknown().optional(),
@@ -185357,6 +185366,15 @@ var rlsConditionAllowedKeys = new Set([
185357
185366
  "user_condition",
185358
185367
  "created_by",
185359
185368
  "created_by_id",
185369
+ "id",
185370
+ "_id",
185371
+ "created_date",
185372
+ "updated_date",
185373
+ "app_id",
185374
+ "entity_name",
185375
+ "is_deleted",
185376
+ "deleted_date",
185377
+ "environment",
185360
185378
  "$or",
185361
185379
  "$and",
185362
185380
  "$nor"
@@ -185385,60 +185403,33 @@ var isValidFieldCondition = (value) => {
185385
185403
  }
185386
185404
  return false;
185387
185405
  };
185388
- var RefineRLSConditionSchema = RLSConditionSchema.refine((val) => Object.entries(val).every(([key, value]) => {
185389
- if (rlsConditionAllowedKeys.has(key)) {
185390
- return true;
185391
- }
185392
- if (!key.startsWith("data.")) {
185393
- return false;
185394
- }
185395
- return isValidFieldCondition(value);
185396
- }), "Keys must be known RLS keys or match data.* pattern with valid value");
185406
+ var RefineRLSConditionSchema = RLSConditionSchema.refine((val) => Object.entries(val).every(([key, value]) => rlsConditionAllowedKeys.has(key) || isValidFieldCondition(value)), "Field condition values must be a primitive or an operator object ($in, $nin, $ne, $all)");
185397
185407
  var RLSRuleSchema = exports_external.union([exports_external.boolean(), RefineRLSConditionSchema]);
185398
- var EntityRLSSchema = exports_external.strictObject({
185408
+ var EntityRLSSchema = exports_external.looseObject({
185399
185409
  create: RLSRuleSchema.optional(),
185400
185410
  read: RLSRuleSchema.optional(),
185401
185411
  update: RLSRuleSchema.optional(),
185402
185412
  delete: RLSRuleSchema.optional(),
185403
185413
  write: RLSRuleSchema.optional()
185404
185414
  });
185405
- var FieldRLSSchema = exports_external.strictObject({
185415
+ var FieldRLSSchema = exports_external.looseObject({
185406
185416
  read: RLSRuleSchema.optional(),
185407
185417
  write: RLSRuleSchema.optional(),
185408
185418
  create: RLSRuleSchema.optional(),
185409
185419
  update: RLSRuleSchema.optional(),
185410
185420
  delete: RLSRuleSchema.optional()
185411
185421
  });
185412
- var PropertyTypeSchema = exports_external.enum([
185413
- "string",
185414
- "number",
185415
- "integer",
185416
- "boolean",
185417
- "array",
185418
- "object"
185419
- ]);
185420
- var StringFormatSchema = exports_external.enum([
185421
- "date",
185422
- "date-time",
185423
- "time",
185424
- "email",
185425
- "uri",
185426
- "hostname",
185427
- "ipv4",
185428
- "ipv6",
185429
- "uuid"
185430
- ]);
185431
- var PropertyDefinitionSchema = exports_external.object({
185432
- type: PropertyTypeSchema,
185422
+ var PropertyDefinitionSchema = exports_external.looseObject({
185423
+ type: exports_external.string().optional(),
185433
185424
  title: exports_external.string().optional(),
185434
185425
  description: exports_external.string().optional(),
185435
185426
  minLength: exports_external.number().int().min(0).optional(),
185436
185427
  maxLength: exports_external.number().int().min(0).optional(),
185437
185428
  pattern: exports_external.string().optional(),
185438
- format: StringFormatSchema.optional(),
185429
+ format: exports_external.string().optional(),
185439
185430
  minimum: exports_external.number().optional(),
185440
185431
  maximum: exports_external.number().optional(),
185441
- enum: exports_external.array(exports_external.string()).optional(),
185432
+ enum: exports_external.array(exports_external.unknown()).optional(),
185442
185433
  enumNames: exports_external.array(exports_external.string()).optional(),
185443
185434
  default: exports_external.unknown().optional(),
185444
185435
  $ref: exports_external.string().optional(),
@@ -185451,12 +185442,12 @@ var PropertyDefinitionSchema = exports_external.object({
185451
185442
  return exports_external.record(exports_external.string(), PropertyDefinitionSchema).optional();
185452
185443
  }
185453
185444
  });
185454
- var EntitySchema = exports_external.object({
185455
- type: exports_external.literal("object"),
185456
- name: exports_external.string().regex(/^[a-zA-Z0-9]+$/, "Entity name must be alphanumeric only"),
185445
+ var EntitySchema = exports_external.looseObject({
185446
+ type: exports_external.literal("object").default("object"),
185447
+ name: exports_external.string().min(1).regex(/^[a-zA-Z0-9]+$/, "Entity name must be alphanumeric only"),
185457
185448
  title: exports_external.string().optional(),
185458
185449
  description: exports_external.string().optional(),
185459
- properties: exports_external.record(exports_external.string(), PropertyDefinitionSchema),
185450
+ properties: exports_external.record(exports_external.string(), PropertyDefinitionSchema).default({}),
185460
185451
  required: exports_external.array(exports_external.string()).optional(),
185461
185452
  rls: EntityRLSSchema.optional()
185462
185453
  });
@@ -186024,7 +186015,7 @@ async function handleUnauthorized(request, _options, response) {
186024
186015
  return;
186025
186016
  }
186026
186017
  retriedRequests.add(request);
186027
- return distribution_default(request, {
186018
+ return distribution_default(request.clone(), {
186028
186019
  headers: { Authorization: `Bearer ${newAccessToken}` }
186029
186020
  });
186030
186021
  }
@@ -193486,6 +193477,7 @@ var package_default = {
193486
193477
  "@types/bun": "^1.2.15",
193487
193478
  "@types/common-tags": "^1.8.4",
193488
193479
  "@types/cors": "^2.8.19",
193480
+ "@types/deno": "^2.5.0",
193489
193481
  "@types/ejs": "^3.1.5",
193490
193482
  "@types/express": "^5.0.6",
193491
193483
  "@types/json-schema": "^7.0.15",
@@ -195206,8 +195198,9 @@ function getTypesCommand(context) {
195206
195198
  }
195207
195199
 
195208
195200
  // src/cli/dev/dev-server/main.ts
195201
+ import { dirname as dirname12, join as join16 } from "node:path";
195209
195202
  var import_cors = __toESM(require_lib4(), 1);
195210
- var import_express = __toESM(require_express(), 1);
195203
+ var import_express2 = __toESM(require_express(), 1);
195211
195204
 
195212
195205
  // node_modules/get-port/index.js
195213
195206
  import net from "node:net";
@@ -195325,11 +195318,266 @@ async function getPorts(options8) {
195325
195318
 
195326
195319
  // src/cli/dev/dev-server/main.ts
195327
195320
  var import_http_proxy_middleware = __toESM(require_dist2(), 1);
195321
+
195322
+ // src/cli/dev/createDevLogger.ts
195323
+ var dateTimeFormat = new Intl.DateTimeFormat([], {
195324
+ hour: "2-digit",
195325
+ minute: "2-digit",
195326
+ second: "2-digit",
195327
+ hour12: false
195328
+ });
195329
+ var colorByType = {
195330
+ error: source_default.red,
195331
+ warn: source_default.yellow,
195332
+ log: (text) => text
195333
+ };
195334
+ function createDevLogger(isPrefixed = true) {
195335
+ const print = (type, msg) => {
195336
+ const colorize = colorByType[type];
195337
+ switch (type) {
195338
+ case "error":
195339
+ console.error(colorize(msg));
195340
+ break;
195341
+ case "warn":
195342
+ console.warn(colorize(msg));
195343
+ break;
195344
+ default:
195345
+ console.log(msg);
195346
+ }
195347
+ };
195348
+ const prefixedLog = (type, msg) => {
195349
+ const timestamp = dateTimeFormat.format(new Date);
195350
+ const colorize = colorByType[type];
195351
+ console.log(`${source_default.gray(timestamp)} ${colorize(msg)}`);
195352
+ };
195353
+ return isPrefixed ? {
195354
+ log: (msg) => prefixedLog("log", msg),
195355
+ error: (msg, err) => {
195356
+ prefixedLog("error", msg);
195357
+ if (err) {
195358
+ prefixedLog("error", String(err));
195359
+ }
195360
+ },
195361
+ warn: (msg) => prefixedLog("warn", msg)
195362
+ } : {
195363
+ log: (msg) => print("log", msg),
195364
+ error: (msg, err) => {
195365
+ print("error", msg);
195366
+ if (err) {
195367
+ print("error", String(err));
195368
+ }
195369
+ },
195370
+ warn: (msg) => print("warn", msg)
195371
+ };
195372
+ }
195373
+
195374
+ // src/cli/dev/dev-server/function-manager.ts
195375
+ import { spawn as spawn2 } from "node:child_process";
195376
+ import { dirname as dirname11, join as join15 } from "node:path";
195377
+ import { fileURLToPath as fileURLToPath7 } from "node:url";
195378
+ var __dirname5 = dirname11(fileURLToPath7(import.meta.url));
195379
+ var WRAPPER_PATH = join15(__dirname5, "../deno-runtime/main.js");
195380
+ var READY_TIMEOUT = 30000;
195381
+
195382
+ class FunctionManager {
195383
+ functions;
195384
+ running = new Map;
195385
+ logger;
195386
+ constructor(functions, logger) {
195387
+ this.functions = new Map(functions.map((f7) => [f7.name, f7]));
195388
+ this.logger = logger;
195389
+ }
195390
+ getFunction(name2) {
195391
+ return this.functions.get(name2);
195392
+ }
195393
+ async ensureRunning(name2) {
195394
+ const existing = this.running.get(name2);
195395
+ if (existing?.ready) {
195396
+ return existing.port;
195397
+ }
195398
+ const backendFunction = this.functions.get(name2);
195399
+ if (!backendFunction) {
195400
+ throw new Error(`Function "${name2}" not found`);
195401
+ }
195402
+ if (existing && !existing.ready) {
195403
+ return this.waitForReady(name2, existing);
195404
+ }
195405
+ const port = await this.allocatePort();
195406
+ const process21 = this.spawnFunction(backendFunction, port);
195407
+ const runningFunc = {
195408
+ process: process21,
195409
+ port,
195410
+ ready: false
195411
+ };
195412
+ this.running.set(name2, runningFunc);
195413
+ this.setupProcessHandlers(name2, process21);
195414
+ return this.waitForReady(name2, runningFunc);
195415
+ }
195416
+ getPort(name2) {
195417
+ const running = this.running.get(name2);
195418
+ return running?.ready ? running.port : undefined;
195419
+ }
195420
+ stopAll() {
195421
+ for (const [name2, { process: process21 }] of this.running) {
195422
+ this.logger.log(`[dev-server] Stopping function: ${name2}`);
195423
+ process21.kill();
195424
+ }
195425
+ this.running.clear();
195426
+ }
195427
+ stop(name2) {
195428
+ const running = this.running.get(name2);
195429
+ if (running) {
195430
+ this.logger.log(`Stopping function: ${name2}`);
195431
+ running.process.kill();
195432
+ this.running.delete(name2);
195433
+ }
195434
+ }
195435
+ async allocatePort() {
195436
+ const usedPorts = Array.from(this.running.values()).map((r5) => r5.port);
195437
+ return getPorts({ exclude: usedPorts });
195438
+ }
195439
+ spawnFunction(func, port) {
195440
+ this.logger.log(`[dev-server] Spawning function "${func.name}" on port ${port}`);
195441
+ const process21 = spawn2("deno", ["run", "--allow-all", WRAPPER_PATH], {
195442
+ env: {
195443
+ ...globalThis.process.env,
195444
+ FUNCTION_PATH: func.entryPath,
195445
+ FUNCTION_PORT: String(port),
195446
+ FUNCTION_NAME: func.name
195447
+ },
195448
+ stdio: ["pipe", "pipe", "pipe"]
195449
+ });
195450
+ return process21;
195451
+ }
195452
+ setupProcessHandlers(name2, process21) {
195453
+ process21.stdout?.on("data", (data) => {
195454
+ const lines = data.toString().trim().split(`
195455
+ `);
195456
+ for (const line3 of lines) {
195457
+ this.logger.log(line3);
195458
+ }
195459
+ });
195460
+ process21.stderr?.on("data", (data) => {
195461
+ const lines = data.toString().trim().split(`
195462
+ `);
195463
+ for (const line3 of lines) {
195464
+ this.logger.error(line3);
195465
+ }
195466
+ });
195467
+ process21.on("exit", (code2) => {
195468
+ this.logger.log(`[dev-server] Function "${name2}" exited with code ${code2}`);
195469
+ this.running.delete(name2);
195470
+ });
195471
+ process21.on("error", (error48) => {
195472
+ this.logger.error(`[dev-server] Function "${name2}" error:`, error48);
195473
+ this.running.delete(name2);
195474
+ });
195475
+ }
195476
+ waitForReady(name2, runningFunc) {
195477
+ return new Promise((resolve5, reject) => {
195478
+ const timeout3 = setTimeout(() => {
195479
+ reject(new Error(`Function "${name2}" failed to start within timeout`));
195480
+ }, READY_TIMEOUT);
195481
+ const onData = (data) => {
195482
+ const output = data.toString();
195483
+ if (output.includes("Listening on")) {
195484
+ runningFunc.ready = true;
195485
+ clearTimeout(timeout3);
195486
+ runningFunc.process.stdout?.off("data", onData);
195487
+ resolve5(runningFunc.port);
195488
+ }
195489
+ };
195490
+ runningFunc.process.stdout?.on("data", onData);
195491
+ runningFunc.process.on("exit", (code2) => {
195492
+ if (!runningFunc.ready) {
195493
+ clearTimeout(timeout3);
195494
+ reject(new Error(`Function "${name2}" exited with code ${code2}`));
195495
+ }
195496
+ });
195497
+ });
195498
+ }
195499
+ }
195500
+
195501
+ // src/cli/dev/dev-server/routes/functions.ts
195502
+ var import_express = __toESM(require_express(), 1);
195503
+ import { request as httpRequest } from "node:http";
195504
+ function createFunctionRoutes(manager, logger) {
195505
+ const router = import_express.Router({ mergeParams: true });
195506
+ router.all("/:functionName", async (req, res) => {
195507
+ const { functionName } = req.params;
195508
+ try {
195509
+ const func = manager.getFunction(functionName);
195510
+ if (!func) {
195511
+ res.status(404).json({
195512
+ error: `Function "${functionName}" not found`
195513
+ });
195514
+ return;
195515
+ }
195516
+ const port = await manager.ensureRunning(functionName);
195517
+ await proxyRequest(req, res, port, logger);
195518
+ } catch (error48) {
195519
+ logger.error(`Function error:`, error48);
195520
+ const message = error48 instanceof Error ? error48.message : String(error48);
195521
+ res.status(500).json({ error: message });
195522
+ }
195523
+ });
195524
+ return router;
195525
+ }
195526
+ function proxyRequest(req, res, port, logger) {
195527
+ return new Promise((resolve5, reject) => {
195528
+ const headers = {
195529
+ ...req.headers
195530
+ };
195531
+ delete headers.host;
195532
+ if (headers["x-app-id"]) {
195533
+ headers["Base44-App-Id"] = headers["x-app-id"];
195534
+ }
195535
+ headers["Base44-Api-Url"] = `${req.protocol}://${req.get("host")}`;
195536
+ const options8 = {
195537
+ hostname: "localhost",
195538
+ port,
195539
+ path: req.url,
195540
+ method: req.method,
195541
+ headers
195542
+ };
195543
+ const proxyReq = httpRequest(options8, (proxyRes) => {
195544
+ res.status(proxyRes.statusCode || 200);
195545
+ for (const [key2, value] of Object.entries(proxyRes.headers)) {
195546
+ if (value !== undefined) {
195547
+ res.setHeader(key2, value);
195548
+ }
195549
+ }
195550
+ proxyRes.pipe(res);
195551
+ proxyRes.on("end", () => {
195552
+ resolve5();
195553
+ });
195554
+ proxyRes.on("error", (error48) => {
195555
+ reject(error48);
195556
+ });
195557
+ });
195558
+ proxyReq.on("error", (error48) => {
195559
+ logger.error(`Function proxy error:`, error48);
195560
+ if (!res.headersSent) {
195561
+ res.status(502).json({
195562
+ error: "Failed to proxy request to function",
195563
+ details: error48.message
195564
+ });
195565
+ }
195566
+ resolve5();
195567
+ });
195568
+ req.pipe(proxyReq);
195569
+ });
195570
+ }
195571
+
195572
+ // src/cli/dev/dev-server/main.ts
195328
195573
  var DEFAULT_PORT = 4400;
195329
195574
  var BASE44_APP_URL = "https://base44.app";
195330
- async function createDevServer(options8 = {}) {
195331
- const port = options8.port ?? await getPorts({ port: DEFAULT_PORT });
195332
- const app = import_express.default();
195575
+ async function createDevServer(options8) {
195576
+ const { port: userPort } = options8;
195577
+ const port = userPort ?? await getPorts({ port: DEFAULT_PORT });
195578
+ const { project: project2 } = await readProjectConfig();
195579
+ const configDir = dirname12(project2.configPath);
195580
+ const app = import_express2.default();
195333
195581
  const remoteProxy = import_http_proxy_middleware.createProxyMiddleware({
195334
195582
  target: BASE44_APP_URL,
195335
195583
  changeOrigin: true
@@ -195346,6 +195594,14 @@ async function createDevServer(options8 = {}) {
195346
195594
  }
195347
195595
  next();
195348
195596
  });
195597
+ const [functions] = await Promise.all([
195598
+ functionResource.readAll(join16(configDir, project2.functionsDir))
195599
+ ]);
195600
+ const devLogger = createDevLogger(false);
195601
+ const functionManager = new FunctionManager(functions, devLogger);
195602
+ M2.info(`Loaded functions: ${functions.map((f7) => f7.name).join(", ") || "(none)"}`);
195603
+ const functionRoutes = createFunctionRoutes(functionManager, devLogger);
195604
+ app.use("/api/apps/:appId/functions", functionRoutes);
195349
195605
  app.use((req, res, next) => {
195350
195606
  return remoteProxy(req, res, next);
195351
195607
  });
@@ -195357,6 +195613,11 @@ async function createDevServer(options8 = {}) {
195357
195613
  } else {
195358
195614
  reject(err);
195359
195615
  }
195616
+ const shutdown = () => {
195617
+ functionManager.stopAll();
195618
+ };
195619
+ process.on("SIGINT", shutdown);
195620
+ process.on("SIGTERM", shutdown);
195360
195621
  } else {
195361
195622
  resolve5({
195362
195623
  port,
@@ -195370,7 +195631,9 @@ async function createDevServer(options8 = {}) {
195370
195631
  // src/cli/commands/dev.ts
195371
195632
  async function devAction(options8) {
195372
195633
  const port = options8.port ? Number(options8.port) : undefined;
195373
- const { port: resolvedPort } = await createDevServer({ port });
195634
+ const { port: resolvedPort } = await createDevServer({
195635
+ port
195636
+ });
195374
195637
  return {
195375
195638
  outroMessage: `Dev server is available at ${theme.colors.links(`http://localhost:${resolvedPort}`)}`
195376
195639
  };
@@ -195532,7 +195795,7 @@ function nanoid3(size = 21) {
195532
195795
  }
195533
195796
 
195534
195797
  // node_modules/posthog-node/dist/extensions/error-tracking/modifiers/module.node.mjs
195535
- import { dirname as dirname11, posix, sep } from "path";
195798
+ import { dirname as dirname13, posix, sep } from "path";
195536
195799
  function createModulerModifier() {
195537
195800
  const getModuleFromFileName = createGetModuleFromFilename();
195538
195801
  return async (frames) => {
@@ -195541,7 +195804,7 @@ function createModulerModifier() {
195541
195804
  return frames;
195542
195805
  };
195543
195806
  }
195544
- function createGetModuleFromFilename(basePath = process.argv[1] ? dirname11(process.argv[1]) : process.cwd(), isWindows4 = sep === "\\") {
195807
+ function createGetModuleFromFilename(basePath = process.argv[1] ? dirname13(process.argv[1]) : process.cwd(), isWindows4 = sep === "\\") {
195545
195808
  const normalizedBase = isWindows4 ? normalizeWindowsPath2(basePath) : basePath;
195546
195809
  return (filename) => {
195547
195810
  if (!filename)
@@ -199760,4 +200023,4 @@ export {
199760
200023
  CLIExitError
199761
200024
  };
199762
200025
 
199763
- //# debugId=BE87F2C8EFF5B4AD64756E2164756E21
200026
+ //# debugId=AA59D5B15FB6A1E264756E2164756E21