@base44-preview/cli 0.0.32-pr.249.f254b7b → 0.0.32-pr.249.f2df6fa

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
@@ -178102,6 +178102,18 @@ class InvalidInputError extends UserError {
178102
178102
  code = "INVALID_INPUT";
178103
178103
  }
178104
178104
 
178105
+ class DependencyNotFoundError extends UserError {
178106
+ code = "DEPENDENCY_NOT_FOUND";
178107
+ constructor(message, options) {
178108
+ super(message, {
178109
+ hints: options?.hints ?? [
178110
+ { message: "Install the required dependency and try again" }
178111
+ ],
178112
+ cause: options?.cause
178113
+ });
178114
+ }
178115
+ }
178116
+
178105
178117
  class ApiError extends SystemError {
178106
178118
  code = "API_ERROR";
178107
178119
  statusCode;
@@ -178217,6 +178229,21 @@ class FileReadError extends SystemError {
178217
178229
  });
178218
178230
  }
178219
178231
  }
178232
+
178233
+ class InternalError extends SystemError {
178234
+ code = "INTERNAL_ERROR";
178235
+ constructor(message, options) {
178236
+ super(message, {
178237
+ hints: options?.hints ?? [
178238
+ {
178239
+ message: "This is an unexpected error. Please report it if it persists."
178240
+ }
178241
+ ],
178242
+ cause: options?.cause
178243
+ });
178244
+ }
178245
+ }
178246
+
178220
178247
  class TypeGenerationError extends SystemError {
178221
178248
  code = "TYPE_GENERATION_ERROR";
178222
178249
  entityName;
@@ -185051,6 +185078,10 @@ var TikTokConnectorSchema = exports_external.object({
185051
185078
  type: exports_external.literal("tiktok"),
185052
185079
  scopes: exports_external.array(exports_external.string()).default([])
185053
185080
  });
185081
+ var GoogleBigQueryConnectorSchema = exports_external.object({
185082
+ type: exports_external.literal("googlebigquery"),
185083
+ scopes: exports_external.array(exports_external.string()).default([])
185084
+ });
185054
185085
  var CustomTypeSchema = exports_external.string().min(1).regex(/^[a-z0-9_-]+$/i);
185055
185086
  var GenericConnectorSchema = exports_external.object({
185056
185087
  type: CustomTypeSchema,
@@ -185063,6 +185094,7 @@ var ConnectorResourceSchema = exports_external.union([
185063
185094
  GoogleSheetsConnectorSchema,
185064
185095
  GoogleDocsConnectorSchema,
185065
185096
  GoogleSlidesConnectorSchema,
185097
+ GoogleBigQueryConnectorSchema,
185066
185098
  SlackConnectorSchema,
185067
185099
  NotionConnectorSchema,
185068
185100
  SalesforceConnectorSchema,
@@ -185078,6 +185110,7 @@ var KnownIntegrationTypes = [
185078
185110
  "googlesheets",
185079
185111
  "googledocs",
185080
185112
  "googleslides",
185113
+ "googlebigquery",
185081
185114
  "slack",
185082
185115
  "notion",
185083
185116
  "salesforce",
@@ -185340,7 +185373,10 @@ var connectorResource = {
185340
185373
  // src/core/resources/entity/schema.ts
185341
185374
  var FieldConditionSchema = exports_external.union([
185342
185375
  exports_external.string(),
185343
- exports_external.object({
185376
+ exports_external.number(),
185377
+ exports_external.boolean(),
185378
+ exports_external.null(),
185379
+ exports_external.looseObject({
185344
185380
  $in: exports_external.unknown().optional(),
185345
185381
  $nin: exports_external.unknown().optional(),
185346
185382
  $ne: exports_external.unknown().optional(),
@@ -185357,6 +185393,15 @@ var rlsConditionAllowedKeys = new Set([
185357
185393
  "user_condition",
185358
185394
  "created_by",
185359
185395
  "created_by_id",
185396
+ "id",
185397
+ "_id",
185398
+ "created_date",
185399
+ "updated_date",
185400
+ "app_id",
185401
+ "entity_name",
185402
+ "is_deleted",
185403
+ "deleted_date",
185404
+ "environment",
185360
185405
  "$or",
185361
185406
  "$and",
185362
185407
  "$nor"
@@ -185385,60 +185430,33 @@ var isValidFieldCondition = (value) => {
185385
185430
  }
185386
185431
  return false;
185387
185432
  };
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");
185433
+ 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
185434
  var RLSRuleSchema = exports_external.union([exports_external.boolean(), RefineRLSConditionSchema]);
185398
- var EntityRLSSchema = exports_external.strictObject({
185435
+ var EntityRLSSchema = exports_external.looseObject({
185399
185436
  create: RLSRuleSchema.optional(),
185400
185437
  read: RLSRuleSchema.optional(),
185401
185438
  update: RLSRuleSchema.optional(),
185402
185439
  delete: RLSRuleSchema.optional(),
185403
185440
  write: RLSRuleSchema.optional()
185404
185441
  });
185405
- var FieldRLSSchema = exports_external.strictObject({
185442
+ var FieldRLSSchema = exports_external.looseObject({
185406
185443
  read: RLSRuleSchema.optional(),
185407
185444
  write: RLSRuleSchema.optional(),
185408
185445
  create: RLSRuleSchema.optional(),
185409
185446
  update: RLSRuleSchema.optional(),
185410
185447
  delete: RLSRuleSchema.optional()
185411
185448
  });
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,
185449
+ var PropertyDefinitionSchema = exports_external.looseObject({
185450
+ type: exports_external.string().optional(),
185433
185451
  title: exports_external.string().optional(),
185434
185452
  description: exports_external.string().optional(),
185435
185453
  minLength: exports_external.number().int().min(0).optional(),
185436
185454
  maxLength: exports_external.number().int().min(0).optional(),
185437
185455
  pattern: exports_external.string().optional(),
185438
- format: StringFormatSchema.optional(),
185456
+ format: exports_external.string().optional(),
185439
185457
  minimum: exports_external.number().optional(),
185440
185458
  maximum: exports_external.number().optional(),
185441
- enum: exports_external.array(exports_external.string()).optional(),
185459
+ enum: exports_external.array(exports_external.unknown()).optional(),
185442
185460
  enumNames: exports_external.array(exports_external.string()).optional(),
185443
185461
  default: exports_external.unknown().optional(),
185444
185462
  $ref: exports_external.string().optional(),
@@ -185451,12 +185469,12 @@ var PropertyDefinitionSchema = exports_external.object({
185451
185469
  return exports_external.record(exports_external.string(), PropertyDefinitionSchema).optional();
185452
185470
  }
185453
185471
  });
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"),
185472
+ var EntitySchema = exports_external.looseObject({
185473
+ type: exports_external.literal("object").default("object"),
185474
+ name: exports_external.string().min(1).regex(/^[a-zA-Z0-9]+$/, "Entity name must be alphanumeric only"),
185457
185475
  title: exports_external.string().optional(),
185458
185476
  description: exports_external.string().optional(),
185459
- properties: exports_external.record(exports_external.string(), PropertyDefinitionSchema),
185477
+ properties: exports_external.record(exports_external.string(), PropertyDefinitionSchema).default({}),
185460
185478
  required: exports_external.array(exports_external.string()).optional(),
185461
185479
  rls: EntityRLSSchema.optional()
185462
185480
  });
@@ -186663,7 +186681,9 @@ var theme = {
186663
186681
  styles: {
186664
186682
  header: source_default.dim,
186665
186683
  bold: source_default.bold,
186666
- dim: source_default.dim
186684
+ dim: source_default.dim,
186685
+ error: source_default.red,
186686
+ warn: source_default.yellow
186667
186687
  },
186668
186688
  format: {
186669
186689
  errorContext(ctx) {
@@ -195336,8 +195356,8 @@ var dateTimeFormat = new Intl.DateTimeFormat([], {
195336
195356
  hour12: false
195337
195357
  });
195338
195358
  var colorByType = {
195339
- error: source_default.red,
195340
- warn: source_default.yellow,
195359
+ error: theme.styles.error,
195360
+ warn: theme.styles.warn,
195341
195361
  log: (text) => text
195342
195362
  };
195343
195363
  function createDevLogger(isPrefixed = true) {
@@ -195357,7 +195377,7 @@ function createDevLogger(isPrefixed = true) {
195357
195377
  const prefixedLog = (type, msg) => {
195358
195378
  const timestamp = dateTimeFormat.format(new Date);
195359
195379
  const colorize = colorByType[type];
195360
- console.log(`${source_default.gray(timestamp)} ${colorize(msg)}`);
195380
+ console.log(`${theme.styles.dim(timestamp)} ${colorize(msg)}`);
195361
195381
  };
195362
195382
  return isPrefixed ? {
195363
195383
  log: (msg) => prefixedLog("log", msg),
@@ -195381,7 +195401,7 @@ function createDevLogger(isPrefixed = true) {
195381
195401
  }
195382
195402
 
195383
195403
  // src/cli/dev/dev-server/function-manager.ts
195384
- import { spawn as spawn2 } from "node:child_process";
195404
+ import { spawn as spawn2, spawnSync as spawnSync2 } from "node:child_process";
195385
195405
  import { dirname as dirname11, join as join15 } from "node:path";
195386
195406
  import { fileURLToPath as fileURLToPath7 } from "node:url";
195387
195407
  var __dirname5 = dirname11(fileURLToPath7(import.meta.url));
@@ -195396,9 +195416,22 @@ class FunctionManager {
195396
195416
  this.functions = new Map(functions.map((f7) => [f7.name, f7]));
195397
195417
  this.logger = logger;
195398
195418
  }
195419
+ functionNames() {
195420
+ return Array.from(this.functions.keys());
195421
+ }
195399
195422
  getFunction(name2) {
195400
195423
  return this.functions.get(name2);
195401
195424
  }
195425
+ verifyDenoIsInstalled() {
195426
+ if (this.functions.size > 0) {
195427
+ const result = spawnSync2("deno", ["--version"]);
195428
+ if (result.error) {
195429
+ throw new DependencyNotFoundError("Deno is required to run functions", {
195430
+ hints: [{ message: "Install Deno from https://deno.com/download" }]
195431
+ });
195432
+ }
195433
+ }
195434
+ }
195402
195435
  async ensureRunning(name2) {
195403
195436
  const existing = this.running.get(name2);
195404
195437
  if (existing?.ready) {
@@ -195406,7 +195439,9 @@ class FunctionManager {
195406
195439
  }
195407
195440
  const backendFunction = this.functions.get(name2);
195408
195441
  if (!backendFunction) {
195409
- throw new Error(`Function "${name2}" not found`);
195442
+ throw new InvalidInputError(`Function "${name2}" not found`, {
195443
+ hints: [{ message: "Check available functions in your project" }]
195444
+ });
195410
195445
  }
195411
195446
  if (existing && !existing.ready) {
195412
195447
  return this.waitForReady(name2, existing);
@@ -195485,7 +195520,11 @@ class FunctionManager {
195485
195520
  waitForReady(name2, runningFunc) {
195486
195521
  return new Promise((resolve5, reject) => {
195487
195522
  const timeout3 = setTimeout(() => {
195488
- reject(new Error(`Function "${name2}" failed to start within timeout`));
195523
+ reject(new InternalError(`Function "${name2}" failed to start within ${READY_TIMEOUT / 1000}s timeout`, {
195524
+ hints: [
195525
+ { message: "Check the function code for startup errors" }
195526
+ ]
195527
+ }));
195489
195528
  }, READY_TIMEOUT);
195490
195529
  const onData = (data) => {
195491
195530
  const output = data.toString();
@@ -195500,7 +195539,9 @@ class FunctionManager {
195500
195539
  runningFunc.process.on("exit", (code2) => {
195501
195540
  if (!runningFunc.ready) {
195502
195541
  clearTimeout(timeout3);
195503
- reject(new Error(`Function "${name2}" exited with code ${code2}`));
195542
+ reject(new InternalError(`Function "${name2}" exited with code ${code2}`, {
195543
+ hints: [{ message: "Check the function code for errors" }]
195544
+ }));
195504
195545
  }
195505
195546
  });
195506
195547
  });
@@ -195603,12 +195644,13 @@ async function createDevServer(options8) {
195603
195644
  }
195604
195645
  next();
195605
195646
  });
195606
- const [functions] = await Promise.all([
195607
- functionResource.readAll(join16(configDir, project2.functionsDir))
195608
- ]);
195647
+ const functions = await functionResource.readAll(join16(configDir, project2.functionsDir));
195609
195648
  const devLogger = createDevLogger(false);
195610
195649
  const functionManager = new FunctionManager(functions, devLogger);
195611
- M2.info(`Loaded functions: ${functions.map((f7) => f7.name).join(", ") || "(none)"}`);
195650
+ functionManager.verifyDenoIsInstalled();
195651
+ if (functionManager.functionNames().length > 0) {
195652
+ M2.info(`Loaded functions: ${functionManager.functionNames().join(", ")}`);
195653
+ }
195612
195654
  const functionRoutes = createFunctionRoutes(functionManager, devLogger);
195613
195655
  app.use("/api/apps/:appId/functions", functionRoutes);
195614
195656
  app.use((req, res, next) => {
@@ -195623,6 +195665,12 @@ async function createDevServer(options8) {
195623
195665
  reject(err);
195624
195666
  }
195625
195667
  } else {
195668
+ const shutdown = () => {
195669
+ functionManager.stopAll();
195670
+ server.close();
195671
+ };
195672
+ process.on("SIGINT", shutdown);
195673
+ process.on("SIGTERM", shutdown);
195626
195674
  resolve5({
195627
195675
  port,
195628
195676
  server
@@ -200027,4 +200075,4 @@ export {
200027
200075
  CLIExitError
200028
200076
  };
200029
200077
 
200030
- //# debugId=63AA06F29016555964756E2164756E21
200078
+ //# debugId=C673BE16F37436A364756E2164756E21