@base44-preview/cli 0.0.50-pr.484.ff9acc3 → 0.0.51-pr.481.a2befc3

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
@@ -27503,7 +27503,7 @@ function cleanDoc(doc2) {
27503
27503
  return mapDoc(doc2, (currentDoc) => cleanDocFn(currentDoc));
27504
27504
  }
27505
27505
  function replaceEndOfLine(doc2, replacement = literalline) {
27506
- return mapDoc(doc2, (currentDoc) => typeof currentDoc === "string" ? join20(replacement, currentDoc.split(`
27506
+ return mapDoc(doc2, (currentDoc) => typeof currentDoc === "string" ? join19(replacement, currentDoc.split(`
27507
27507
  `)) : currentDoc);
27508
27508
  }
27509
27509
  function canBreakFn(doc2) {
@@ -27583,7 +27583,7 @@ function indentIfBreak(contents, options) {
27583
27583
  negate: options.negate
27584
27584
  };
27585
27585
  }
27586
- function join20(separator, docs) {
27586
+ function join19(separator, docs) {
27587
27587
  assertDoc(separator);
27588
27588
  assertDocArray(docs);
27589
27589
  const parts = [];
@@ -28294,7 +28294,7 @@ var init_doc = __esm(() => {
28294
28294
  MODE_FLAT = Symbol("MODE_FLAT");
28295
28295
  DOC_FILL_PRINTED_LENGTH = Symbol("DOC_FILL_PRINTED_LENGTH");
28296
28296
  builders = {
28297
- join: join20,
28297
+ join: join19,
28298
28298
  line,
28299
28299
  softline,
28300
28300
  hardline,
@@ -133208,7 +133208,7 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`;
133208
133208
  return mapDoc2(doc2, (currentDoc) => cleanDocFn2(currentDoc));
133209
133209
  }
133210
133210
  function replaceEndOfLine2(doc2, replacement = literalline2) {
133211
- return mapDoc2(doc2, (currentDoc) => typeof currentDoc === "string" ? join22(replacement, currentDoc.split(`
133211
+ return mapDoc2(doc2, (currentDoc) => typeof currentDoc === "string" ? join21(replacement, currentDoc.split(`
133212
133212
  `)) : currentDoc);
133213
133213
  }
133214
133214
  function canBreakFn2(doc2) {
@@ -133294,7 +133294,7 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`;
133294
133294
  negate: options8.negate
133295
133295
  };
133296
133296
  }
133297
- function join22(separator, docs) {
133297
+ function join21(separator, docs) {
133298
133298
  assertDoc2(separator);
133299
133299
  assertDocArray2(docs);
133300
133300
  const parts = [];
@@ -133959,7 +133959,7 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`;
133959
133959
  }
133960
133960
  }
133961
133961
  var builders2 = {
133962
- join: join22,
133962
+ join: join21,
133963
133963
  line: line3,
133964
133964
  softline: softline2,
133965
133965
  hardline: hardline4,
@@ -134614,11 +134614,11 @@ var require_prettier = __commonJS((exports, module) => {
134614
134614
  var require_formatter = __commonJS((exports) => {
134615
134615
  var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P9, generator) {
134616
134616
  function adopt(value) {
134617
- return value instanceof P9 ? value : new P9(function(resolve8) {
134618
- resolve8(value);
134617
+ return value instanceof P9 ? value : new P9(function(resolve7) {
134618
+ resolve7(value);
134619
134619
  });
134620
134620
  }
134621
- return new (P9 || (P9 = Promise))(function(resolve8, reject) {
134621
+ return new (P9 || (P9 = Promise))(function(resolve7, reject) {
134622
134622
  function fulfilled(value) {
134623
134623
  try {
134624
134624
  step(generator.next(value));
@@ -134634,7 +134634,7 @@ var require_formatter = __commonJS((exports) => {
134634
134634
  }
134635
134635
  }
134636
134636
  function step(result) {
134637
- result.done ? resolve8(result.value) : adopt(result.value).then(fulfilled, rejected);
134637
+ result.done ? resolve7(result.value) : adopt(result.value).then(fulfilled, rejected);
134638
134638
  }
134639
134639
  step((generator = generator.apply(thisArg, _arguments || [])).next());
134640
134640
  });
@@ -139287,7 +139287,7 @@ var require_url = __commonJS((exports) => {
139287
139287
  };
139288
139288
  Object.defineProperty(exports, "__esModule", { value: true });
139289
139289
  exports.parse = undefined;
139290
- exports.resolve = resolve8;
139290
+ exports.resolve = resolve7;
139291
139291
  exports.cwd = cwd;
139292
139292
  exports.getProtocol = getProtocol;
139293
139293
  exports.getExtension = getExtension;
@@ -139315,7 +139315,7 @@ var require_url = __commonJS((exports) => {
139315
139315
  var urlDecodePatterns = [/%23/g, "#", /%24/g, "$", /%26/g, "&", /%2C/g, ",", /%40/g, "@"];
139316
139316
  var parse11 = (u4) => new URL(u4);
139317
139317
  exports.parse = parse11;
139318
- function resolve8(from, to5) {
139318
+ function resolve7(from, to5) {
139319
139319
  const fromUrl = new URL((0, convert_path_to_posix_1.default)(from), "https://aaa.nonexistanturl.com");
139320
139320
  const resolvedUrl = new URL((0, convert_path_to_posix_1.default)(to5), fromUrl);
139321
139321
  const endSpaces = to5.match(/(\s*)$/)?.[1] || "";
@@ -139451,7 +139451,7 @@ var require_url = __commonJS((exports) => {
139451
139451
  }
139452
139452
  function relative4(from, to5) {
139453
139453
  if (!isFileSystemPath(from) || !isFileSystemPath(to5)) {
139454
- return resolve8(from, to5);
139454
+ return resolve7(from, to5);
139455
139455
  }
139456
139456
  const fromDir = path_1.default.dirname(stripHash(from));
139457
139457
  const toPath4 = stripHash(to5);
@@ -140127,7 +140127,7 @@ var require_plugins = __commonJS((exports) => {
140127
140127
  let plugin;
140128
140128
  let lastError;
140129
140129
  let index = 0;
140130
- return new Promise((resolve8, reject) => {
140130
+ return new Promise((resolve7, reject) => {
140131
140131
  runNextPlugin();
140132
140132
  function runNextPlugin() {
140133
140133
  plugin = plugins[index++];
@@ -140155,7 +140155,7 @@ var require_plugins = __commonJS((exports) => {
140155
140155
  }
140156
140156
  }
140157
140157
  function onSuccess(result) {
140158
- resolve8({
140158
+ resolve7({
140159
140159
  plugin,
140160
140160
  result
140161
140161
  });
@@ -141488,11 +141488,11 @@ var require_lib3 = __commonJS((exports) => {
141488
141488
  var require_resolver = __commonJS((exports) => {
141489
141489
  var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P9, generator) {
141490
141490
  function adopt(value) {
141491
- return value instanceof P9 ? value : new P9(function(resolve8) {
141492
- resolve8(value);
141491
+ return value instanceof P9 ? value : new P9(function(resolve7) {
141492
+ resolve7(value);
141493
141493
  });
141494
141494
  }
141495
- return new (P9 || (P9 = Promise))(function(resolve8, reject) {
141495
+ return new (P9 || (P9 = Promise))(function(resolve7, reject) {
141496
141496
  function fulfilled(value) {
141497
141497
  try {
141498
141498
  step(generator.next(value));
@@ -141508,7 +141508,7 @@ var require_resolver = __commonJS((exports) => {
141508
141508
  }
141509
141509
  }
141510
141510
  function step(result) {
141511
- result.done ? resolve8(result.value) : adopt(result.value).then(fulfilled, rejected);
141511
+ result.done ? resolve7(result.value) : adopt(result.value).then(fulfilled, rejected);
141512
141512
  }
141513
141513
  step((generator = generator.apply(thisArg, _arguments || [])).next());
141514
141514
  });
@@ -141629,11 +141629,11 @@ var require_optionValidator = __commonJS((exports) => {
141629
141629
  var require_src3 = __commonJS((exports) => {
141630
141630
  var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P9, generator) {
141631
141631
  function adopt(value) {
141632
- return value instanceof P9 ? value : new P9(function(resolve8) {
141633
- resolve8(value);
141632
+ return value instanceof P9 ? value : new P9(function(resolve7) {
141633
+ resolve7(value);
141634
141634
  });
141635
141635
  }
141636
- return new (P9 || (P9 = Promise))(function(resolve8, reject) {
141636
+ return new (P9 || (P9 = Promise))(function(resolve7, reject) {
141637
141637
  function fulfilled(value) {
141638
141638
  try {
141639
141639
  step(generator.next(value));
@@ -141649,7 +141649,7 @@ var require_src3 = __commonJS((exports) => {
141649
141649
  }
141650
141650
  }
141651
141651
  function step(result) {
141652
- result.done ? resolve8(result.value) : adopt(result.value).then(fulfilled, rejected);
141652
+ result.done ? resolve7(result.value) : adopt(result.value).then(fulfilled, rejected);
141653
141653
  }
141654
141654
  step((generator = generator.apply(thisArg, _arguments || [])).next());
141655
141655
  });
@@ -147274,11 +147274,11 @@ var require_raw_body = __commonJS((exports, module) => {
147274
147274
  if (done) {
147275
147275
  return readStream(stream, encoding, length, limit, wrap(done));
147276
147276
  }
147277
- return new Promise(function executor(resolve8, reject) {
147277
+ return new Promise(function executor(resolve7, reject) {
147278
147278
  readStream(stream, encoding, length, limit, function onRead2(err, buf) {
147279
147279
  if (err)
147280
147280
  return reject(err);
147281
- resolve8(buf);
147281
+ resolve7(buf);
147282
147282
  });
147283
147283
  });
147284
147284
  }
@@ -160399,11 +160399,11 @@ var require_view = __commonJS((exports, module) => {
160399
160399
  var debug = require_src4()("express:view");
160400
160400
  var path18 = __require("node:path");
160401
160401
  var fs28 = __require("node:fs");
160402
- var dirname16 = path18.dirname;
160402
+ var dirname15 = path18.dirname;
160403
160403
  var basename4 = path18.basename;
160404
160404
  var extname2 = path18.extname;
160405
- var join23 = path18.join;
160406
- var resolve8 = path18.resolve;
160405
+ var join22 = path18.join;
160406
+ var resolve7 = path18.resolve;
160407
160407
  module.exports = View;
160408
160408
  function View(name2, options8) {
160409
160409
  var opts = options8 || {};
@@ -160437,8 +160437,8 @@ var require_view = __commonJS((exports, module) => {
160437
160437
  debug('lookup "%s"', name2);
160438
160438
  for (var i5 = 0;i5 < roots.length && !path19; i5++) {
160439
160439
  var root2 = roots[i5];
160440
- var loc = resolve8(root2, name2);
160441
- var dir = dirname16(loc);
160440
+ var loc = resolve7(root2, name2);
160441
+ var dir = dirname15(loc);
160442
160442
  var file2 = basename4(loc);
160443
160443
  path19 = this.resolve(dir, file2);
160444
160444
  }
@@ -160462,14 +160462,14 @@ var require_view = __commonJS((exports, module) => {
160462
160462
  });
160463
160463
  sync = false;
160464
160464
  };
160465
- View.prototype.resolve = function resolve9(dir, file2) {
160465
+ View.prototype.resolve = function resolve8(dir, file2) {
160466
160466
  var ext = this.ext;
160467
- var path19 = join23(dir, file2);
160467
+ var path19 = join22(dir, file2);
160468
160468
  var stat2 = tryStat(path19);
160469
160469
  if (stat2 && stat2.isFile()) {
160470
160470
  return path19;
160471
160471
  }
160472
- path19 = join23(dir, basename4(file2, ext), "index" + ext);
160472
+ path19 = join22(dir, basename4(file2, ext), "index" + ext);
160473
160473
  stat2 = tryStat(path19);
160474
160474
  if (stat2 && stat2.isFile()) {
160475
160475
  return path19;
@@ -162621,7 +162621,7 @@ var require_application = __commonJS((exports, module) => {
162621
162621
  var compileETag = require_utils10().compileETag;
162622
162622
  var compileQueryParser = require_utils10().compileQueryParser;
162623
162623
  var compileTrust = require_utils10().compileTrust;
162624
- var resolve8 = __require("node:path").resolve;
162624
+ var resolve7 = __require("node:path").resolve;
162625
162625
  var once9 = require_once();
162626
162626
  var Router = require_router();
162627
162627
  var slice = Array.prototype.slice;
@@ -162675,7 +162675,7 @@ var require_application = __commonJS((exports, module) => {
162675
162675
  this.mountpath = "/";
162676
162676
  this.locals.settings = this.settings;
162677
162677
  this.set("view", View);
162678
- this.set("views", resolve8("views"));
162678
+ this.set("views", resolve7("views"));
162679
162679
  this.set("jsonp callback name", "callback");
162680
162680
  if (env3 === "production") {
162681
162681
  this.enable("view cache");
@@ -164164,9 +164164,9 @@ var require_send = __commonJS((exports, module) => {
164164
164164
  var Stream2 = __require("stream");
164165
164165
  var util2 = __require("util");
164166
164166
  var extname2 = path18.extname;
164167
- var join23 = path18.join;
164167
+ var join22 = path18.join;
164168
164168
  var normalize2 = path18.normalize;
164169
- var resolve8 = path18.resolve;
164169
+ var resolve7 = path18.resolve;
164170
164170
  var sep = path18.sep;
164171
164171
  var BYTES_RANGE_REGEXP = /^ *bytes=/;
164172
164172
  var MAX_MAXAGE = 60 * 60 * 24 * 365 * 1000;
@@ -164195,7 +164195,7 @@ var require_send = __commonJS((exports, module) => {
164195
164195
  this._maxage = opts.maxAge || opts.maxage;
164196
164196
  this._maxage = typeof this._maxage === "string" ? ms8(this._maxage) : Number(this._maxage);
164197
164197
  this._maxage = !isNaN(this._maxage) ? Math.min(Math.max(0, this._maxage), MAX_MAXAGE) : 0;
164198
- this._root = opts.root ? resolve8(opts.root) : null;
164198
+ this._root = opts.root ? resolve7(opts.root) : null;
164199
164199
  }
164200
164200
  util2.inherits(SendStream, Stream2);
164201
164201
  SendStream.prototype.error = function error48(status, err) {
@@ -164336,7 +164336,7 @@ var require_send = __commonJS((exports, module) => {
164336
164336
  return res;
164337
164337
  }
164338
164338
  parts = path19.split(sep);
164339
- path19 = normalize2(join23(root2, path19));
164339
+ path19 = normalize2(join22(root2, path19));
164340
164340
  } else {
164341
164341
  if (UP_PATH_REGEXP.test(path19)) {
164342
164342
  debug('malicious path "%s"', path19);
@@ -164344,7 +164344,7 @@ var require_send = __commonJS((exports, module) => {
164344
164344
  return res;
164345
164345
  }
164346
164346
  parts = normalize2(path19).split(sep);
164347
- path19 = resolve8(path19);
164347
+ path19 = resolve7(path19);
164348
164348
  }
164349
164349
  if (containsDotFile(parts)) {
164350
164350
  debug('%s dotfile "%s"', this._dotfiles, path19);
@@ -164476,7 +164476,7 @@ var require_send = __commonJS((exports, module) => {
164476
164476
  return self2.onStatError(err);
164477
164477
  return self2.error(404);
164478
164478
  }
164479
- var p4 = join23(path19, self2._index[i5]);
164479
+ var p4 = join22(path19, self2._index[i5]);
164480
164480
  debug('stat "%s"', p4);
164481
164481
  fs28.stat(p4, function(err2, stat2) {
164482
164482
  if (err2)
@@ -164672,7 +164672,7 @@ var require_response = __commonJS((exports, module) => {
164672
164672
  var cookie = require_cookie();
164673
164673
  var send = require_send();
164674
164674
  var extname2 = path18.extname;
164675
- var resolve8 = path18.resolve;
164675
+ var resolve7 = path18.resolve;
164676
164676
  var vary = require_vary();
164677
164677
  var { Buffer: Buffer7 } = __require("node:buffer");
164678
164678
  var res = Object.create(http.ServerResponse.prototype);
@@ -164881,7 +164881,7 @@ var require_response = __commonJS((exports, module) => {
164881
164881
  }
164882
164882
  opts = Object.create(opts);
164883
164883
  opts.headers = headers;
164884
- var fullPath = !opts.root ? resolve8(path19) : path19;
164884
+ var fullPath = !opts.root ? resolve7(path19) : path19;
164885
164885
  return this.sendFile(fullPath, opts, done);
164886
164886
  };
164887
164887
  res.contentType = res.type = function contentType(type) {
@@ -165142,7 +165142,7 @@ var require_serve_static = __commonJS((exports, module) => {
165142
165142
  var encodeUrl = require_encodeurl();
165143
165143
  var escapeHtml = require_escape_html();
165144
165144
  var parseUrl = require_parseurl();
165145
- var resolve8 = __require("path").resolve;
165145
+ var resolve7 = __require("path").resolve;
165146
165146
  var send = require_send();
165147
165147
  var url3 = __require("url");
165148
165148
  module.exports = serveStatic;
@@ -165161,7 +165161,7 @@ var require_serve_static = __commonJS((exports, module) => {
165161
165161
  throw new TypeError("option setHeaders must be function");
165162
165162
  }
165163
165163
  opts.maxage = opts.maxage || opts.maxAge || 0;
165164
- opts.root = resolve8(root2);
165164
+ opts.root = resolve7(root2);
165165
165165
  var onDirectory = redirect ? createRedirectDirectoryListener() : createNotFoundDirectoryListener();
165166
165166
  return function serveStatic2(req, res, next) {
165167
165167
  if (req.method !== "GET" && req.method !== "HEAD") {
@@ -168535,8 +168535,8 @@ var require_executor = __commonJS((exports, module) => {
168535
168535
  }
168536
168536
  resetBuffer() {
168537
168537
  this.buffer = new Waterfall;
168538
- this.buffer.chain(new Promise((resolve8) => {
168539
- this._triggerBuffer = resolve8;
168538
+ this.buffer.chain(new Promise((resolve7) => {
168539
+ this._triggerBuffer = resolve7;
168540
168540
  }));
168541
168541
  if (this.ready)
168542
168542
  this._triggerBuffer();
@@ -169556,7 +169556,7 @@ var require_storage = __commonJS((exports, module) => {
169556
169556
  throw e8;
169557
169557
  }
169558
169558
  };
169559
- var writeFileLinesAsync = (filename, lines, mode = DEFAULT_FILE_MODE) => new Promise((resolve8, reject) => {
169559
+ var writeFileLinesAsync = (filename, lines, mode = DEFAULT_FILE_MODE) => new Promise((resolve7, reject) => {
169560
169560
  try {
169561
169561
  const stream = writeFileStream(filename, { mode });
169562
169562
  const readable2 = Readable6.from(lines);
@@ -169573,7 +169573,7 @@ var require_storage = __commonJS((exports, module) => {
169573
169573
  if (err)
169574
169574
  reject(err);
169575
169575
  else
169576
- resolve8();
169576
+ resolve7();
169577
169577
  });
169578
169578
  });
169579
169579
  readable2.on("error", (err) => {
@@ -169744,7 +169744,7 @@ var require_persistence = __commonJS((exports, module) => {
169744
169744
  return { data: tdata, indexes };
169745
169745
  }
169746
169746
  treatRawStreamAsync(rawStream) {
169747
- return new Promise((resolve8, reject) => {
169747
+ return new Promise((resolve7, reject) => {
169748
169748
  const dataById = {};
169749
169749
  const indexes = {};
169750
169750
  let corruptItems = 0;
@@ -169787,7 +169787,7 @@ var require_persistence = __commonJS((exports, module) => {
169787
169787
  }
169788
169788
  }
169789
169789
  const data = Object.values(dataById);
169790
- resolve8({ data, indexes });
169790
+ resolve7({ data, indexes });
169791
169791
  });
169792
169792
  lineStream.on("error", function(err) {
169793
169793
  reject(err, null);
@@ -195398,13 +195398,13 @@ var require_broadcast_operator = __commonJS((exports) => {
195398
195398
  return true;
195399
195399
  }
195400
195400
  emitWithAck(ev2, ...args) {
195401
- return new Promise((resolve8, reject) => {
195401
+ return new Promise((resolve7, reject) => {
195402
195402
  args.push((err, responses) => {
195403
195403
  if (err) {
195404
195404
  err.responses = responses;
195405
195405
  return reject(err);
195406
195406
  } else {
195407
- return resolve8(responses);
195407
+ return resolve7(responses);
195408
195408
  }
195409
195409
  });
195410
195410
  this.emit(ev2, ...args);
@@ -195592,12 +195592,12 @@ var require_socket2 = __commonJS((exports) => {
195592
195592
  }
195593
195593
  emitWithAck(ev2, ...args) {
195594
195594
  const withErr = this.flags.timeout !== undefined;
195595
- return new Promise((resolve8, reject) => {
195595
+ return new Promise((resolve7, reject) => {
195596
195596
  args.push((arg1, arg2) => {
195597
195597
  if (withErr) {
195598
- return arg1 ? reject(arg1) : resolve8(arg2);
195598
+ return arg1 ? reject(arg1) : resolve7(arg2);
195599
195599
  } else {
195600
- return resolve8(arg1);
195600
+ return resolve7(arg1);
195601
195601
  }
195602
195602
  });
195603
195603
  this.emit(ev2, ...args);
@@ -196052,13 +196052,13 @@ var require_namespace = __commonJS((exports) => {
196052
196052
  return true;
196053
196053
  }
196054
196054
  serverSideEmitWithAck(ev2, ...args) {
196055
- return new Promise((resolve8, reject) => {
196055
+ return new Promise((resolve7, reject) => {
196056
196056
  args.push((err, responses) => {
196057
196057
  if (err) {
196058
196058
  err.responses = responses;
196059
196059
  return reject(err);
196060
196060
  } else {
196061
- return resolve8(responses);
196061
+ return resolve7(responses);
196062
196062
  }
196063
196063
  });
196064
196064
  this.serverSideEmit(ev2, ...args);
@@ -196742,7 +196742,7 @@ var require_cluster_adapter = __commonJS((exports) => {
196742
196742
  return localSockets;
196743
196743
  }
196744
196744
  const requestId = randomId();
196745
- return new Promise((resolve8, reject) => {
196745
+ return new Promise((resolve7, reject) => {
196746
196746
  const timeout3 = setTimeout(() => {
196747
196747
  const storedRequest2 = this.requests.get(requestId);
196748
196748
  if (storedRequest2) {
@@ -196752,7 +196752,7 @@ var require_cluster_adapter = __commonJS((exports) => {
196752
196752
  }, opts.flags.timeout || DEFAULT_TIMEOUT);
196753
196753
  const storedRequest = {
196754
196754
  type: MessageType.FETCH_SOCKETS,
196755
- resolve: resolve8,
196755
+ resolve: resolve7,
196756
196756
  timeout: timeout3,
196757
196757
  current: 0,
196758
196758
  expected: expectedResponseCount,
@@ -196962,7 +196962,7 @@ var require_cluster_adapter = __commonJS((exports) => {
196962
196962
  return localSockets;
196963
196963
  }
196964
196964
  const requestId = randomId();
196965
- return new Promise((resolve8, reject) => {
196965
+ return new Promise((resolve7, reject) => {
196966
196966
  const timeout3 = setTimeout(() => {
196967
196967
  const storedRequest2 = this.customRequests.get(requestId);
196968
196968
  if (storedRequest2) {
@@ -196972,7 +196972,7 @@ var require_cluster_adapter = __commonJS((exports) => {
196972
196972
  }, opts.flags.timeout || DEFAULT_TIMEOUT);
196973
196973
  const storedRequest = {
196974
196974
  type: MessageType.FETCH_SOCKETS,
196975
- resolve: resolve8,
196975
+ resolve: resolve7,
196976
196976
  timeout: timeout3,
196977
196977
  missingUids: new Set([...this.nodesMap.keys()]),
196978
196978
  responses: localSockets
@@ -197701,13 +197701,13 @@ var require_dist4 = __commonJS((exports, module) => {
197701
197701
  this.engine.close();
197702
197702
  (0, uws_1.restoreAdapter)();
197703
197703
  if (this.httpServer) {
197704
- return new Promise((resolve8) => {
197704
+ return new Promise((resolve7) => {
197705
197705
  this.httpServer.close((err) => {
197706
197706
  fn9 && fn9(err);
197707
197707
  if (err) {
197708
197708
  debug("server was not running");
197709
197709
  }
197710
- resolve8();
197710
+ resolve7();
197711
197711
  });
197712
197712
  });
197713
197713
  } else {
@@ -214616,7 +214616,7 @@ var require_buffer_list = __commonJS((exports, module) => {
214616
214616
  }
214617
214617
  }, {
214618
214618
  key: "join",
214619
- value: function join23(s5) {
214619
+ value: function join22(s5) {
214620
214620
  if (this.length === 0)
214621
214621
  return "";
214622
214622
  var p4 = this.head;
@@ -215914,14 +215914,14 @@ var require_async_iterator = __commonJS((exports, module) => {
215914
215914
  };
215915
215915
  }
215916
215916
  function readAndResolve(iter) {
215917
- var resolve8 = iter[kLastResolve];
215918
- if (resolve8 !== null) {
215917
+ var resolve7 = iter[kLastResolve];
215918
+ if (resolve7 !== null) {
215919
215919
  var data = iter[kStream].read();
215920
215920
  if (data !== null) {
215921
215921
  iter[kLastPromise] = null;
215922
215922
  iter[kLastResolve] = null;
215923
215923
  iter[kLastReject] = null;
215924
- resolve8(createIterResult(data, false));
215924
+ resolve7(createIterResult(data, false));
215925
215925
  }
215926
215926
  }
215927
215927
  }
@@ -215929,13 +215929,13 @@ var require_async_iterator = __commonJS((exports, module) => {
215929
215929
  process.nextTick(readAndResolve, iter);
215930
215930
  }
215931
215931
  function wrapForNext(lastPromise, iter) {
215932
- return function(resolve8, reject) {
215932
+ return function(resolve7, reject) {
215933
215933
  lastPromise.then(function() {
215934
215934
  if (iter[kEnded]) {
215935
- resolve8(createIterResult(undefined, true));
215935
+ resolve7(createIterResult(undefined, true));
215936
215936
  return;
215937
215937
  }
215938
- iter[kHandlePromise](resolve8, reject);
215938
+ iter[kHandlePromise](resolve7, reject);
215939
215939
  }, reject);
215940
215940
  };
215941
215941
  }
@@ -215954,12 +215954,12 @@ var require_async_iterator = __commonJS((exports, module) => {
215954
215954
  return Promise.resolve(createIterResult(undefined, true));
215955
215955
  }
215956
215956
  if (this[kStream].destroyed) {
215957
- return new Promise(function(resolve8, reject) {
215957
+ return new Promise(function(resolve7, reject) {
215958
215958
  process.nextTick(function() {
215959
215959
  if (_this[kError]) {
215960
215960
  reject(_this[kError]);
215961
215961
  } else {
215962
- resolve8(createIterResult(undefined, true));
215962
+ resolve7(createIterResult(undefined, true));
215963
215963
  }
215964
215964
  });
215965
215965
  });
@@ -215982,13 +215982,13 @@ var require_async_iterator = __commonJS((exports, module) => {
215982
215982
  return this;
215983
215983
  }), _defineProperty(_Object$setPrototypeO, "return", function _return() {
215984
215984
  var _this2 = this;
215985
- return new Promise(function(resolve8, reject) {
215985
+ return new Promise(function(resolve7, reject) {
215986
215986
  _this2[kStream].destroy(null, function(err) {
215987
215987
  if (err) {
215988
215988
  reject(err);
215989
215989
  return;
215990
215990
  }
215991
- resolve8(createIterResult(undefined, true));
215991
+ resolve7(createIterResult(undefined, true));
215992
215992
  });
215993
215993
  });
215994
215994
  }), _Object$setPrototypeO), AsyncIteratorPrototype);
@@ -216010,15 +216010,15 @@ var require_async_iterator = __commonJS((exports, module) => {
216010
216010
  value: stream._readableState.endEmitted,
216011
216011
  writable: true
216012
216012
  }), _defineProperty(_Object$create, kHandlePromise, {
216013
- value: function value(resolve8, reject) {
216013
+ value: function value(resolve7, reject) {
216014
216014
  var data = iterator[kStream].read();
216015
216015
  if (data) {
216016
216016
  iterator[kLastPromise] = null;
216017
216017
  iterator[kLastResolve] = null;
216018
216018
  iterator[kLastReject] = null;
216019
- resolve8(createIterResult(data, false));
216019
+ resolve7(createIterResult(data, false));
216020
216020
  } else {
216021
- iterator[kLastResolve] = resolve8;
216021
+ iterator[kLastResolve] = resolve7;
216022
216022
  iterator[kLastReject] = reject;
216023
216023
  }
216024
216024
  },
@@ -216037,12 +216037,12 @@ var require_async_iterator = __commonJS((exports, module) => {
216037
216037
  iterator[kError] = err;
216038
216038
  return;
216039
216039
  }
216040
- var resolve8 = iterator[kLastResolve];
216041
- if (resolve8 !== null) {
216040
+ var resolve7 = iterator[kLastResolve];
216041
+ if (resolve7 !== null) {
216042
216042
  iterator[kLastPromise] = null;
216043
216043
  iterator[kLastResolve] = null;
216044
216044
  iterator[kLastReject] = null;
216045
- resolve8(createIterResult(undefined, true));
216045
+ resolve7(createIterResult(undefined, true));
216046
216046
  }
216047
216047
  iterator[kEnded] = true;
216048
216048
  });
@@ -216054,7 +216054,7 @@ var require_async_iterator = __commonJS((exports, module) => {
216054
216054
 
216055
216055
  // ../../node_modules/readable-stream/lib/internal/streams/from.js
216056
216056
  var require_from = __commonJS((exports, module) => {
216057
- function asyncGeneratorStep(gen, resolve8, reject, _next, _throw, key2, arg) {
216057
+ function asyncGeneratorStep(gen, resolve7, reject, _next, _throw, key2, arg) {
216058
216058
  try {
216059
216059
  var info = gen[key2](arg);
216060
216060
  var value = info.value;
@@ -216063,7 +216063,7 @@ var require_from = __commonJS((exports, module) => {
216063
216063
  return;
216064
216064
  }
216065
216065
  if (info.done) {
216066
- resolve8(value);
216066
+ resolve7(value);
216067
216067
  } else {
216068
216068
  Promise.resolve(value).then(_next, _throw);
216069
216069
  }
@@ -216071,13 +216071,13 @@ var require_from = __commonJS((exports, module) => {
216071
216071
  function _asyncToGenerator(fn9) {
216072
216072
  return function() {
216073
216073
  var self2 = this, args = arguments;
216074
- return new Promise(function(resolve8, reject) {
216074
+ return new Promise(function(resolve7, reject) {
216075
216075
  var gen = fn9.apply(self2, args);
216076
216076
  function _next(value) {
216077
- asyncGeneratorStep(gen, resolve8, reject, _next, _throw, "next", value);
216077
+ asyncGeneratorStep(gen, resolve7, reject, _next, _throw, "next", value);
216078
216078
  }
216079
216079
  function _throw(err) {
216080
- asyncGeneratorStep(gen, resolve8, reject, _next, _throw, "throw", err);
216080
+ asyncGeneratorStep(gen, resolve7, reject, _next, _throw, "throw", err);
216081
216081
  }
216082
216082
  _next(undefined);
216083
216083
  });
@@ -218270,7 +218270,7 @@ var require_dist5 = __commonJS((exports, module) => {
218270
218270
  });
218271
218271
 
218272
218272
  // src/cli/index.ts
218273
- import { dirname as dirname20, join as join26 } from "node:path";
218273
+ import { dirname as dirname19, join as join25 } from "node:path";
218274
218274
  import { fileURLToPath as fileURLToPath6 } from "node:url";
218275
218275
 
218276
218276
  // ../../node_modules/@clack/core/dist/index.mjs
@@ -235098,8 +235098,8 @@ var TOKEN_REFRESH_BUFFER_MS = 60 * 1000;
235098
235098
  var refreshPromise = null;
235099
235099
  async function readAuth() {
235100
235100
  try {
235101
- const parsed = await readJsonFile(getAuthFilePath());
235102
- const result = AuthDataSchema.safeParse(parsed);
235101
+ const authData = await readJsonFile(getAuthFilePath());
235102
+ const result = AuthDataSchema.safeParse(authData);
235103
235103
  if (!result.success) {
235104
235104
  throw new SchemaValidationError("Invalid authentication data", result.error, getAuthFilePath());
235105
235105
  }
@@ -241974,11 +241974,7 @@ async function updateSocialLoginConfig(authDir, provider, enable, customOAuth) {
241974
241974
  const current = await readAuthConfig(authDir) ?? DEFAULT_AUTH_CONFIG;
241975
241975
  const merged = {
241976
241976
  ...current,
241977
- [providerInfo.field]: enable,
241978
- ...enable && {
241979
- enableSSOLogin: false,
241980
- ssoProviderName: null
241981
- }
241977
+ [providerInfo.field]: enable
241982
241978
  };
241983
241979
  if (providerInfo.customOAuth) {
241984
241980
  const oauth = providerInfo.customOAuth;
@@ -242002,182 +241998,6 @@ async function pushCustomOAuthSecret(provider, clientSecret) {
242002
241998
  [providerInfo.customOAuth.secretKey]: clientSecret
242003
241999
  });
242004
242000
  }
242005
- // src/core/resources/auth-config/sso/secret-keys.ts
242006
- var SSOSecretKey;
242007
- ((SSOSecretKey2) => {
242008
- SSOSecretKey2["Name"] = "sso_name";
242009
- SSOSecretKey2["ClientId"] = "sso_client_id";
242010
- SSOSecretKey2["ClientSecret"] = "sso_client_secret";
242011
- SSOSecretKey2["Scope"] = "sso_scope";
242012
- SSOSecretKey2["DiscoveryUrl"] = "sso_discovery_url";
242013
- SSOSecretKey2["TenantId"] = "sso_tenant_id";
242014
- SSOSecretKey2["AuthEndpoint"] = "sso_auth_endpoint";
242015
- SSOSecretKey2["TokenEndpoint"] = "sso_token_endpoint";
242016
- SSOSecretKey2["UserinfoEndpoint"] = "sso_userinfo_endpoint";
242017
- SSOSecretKey2["OktaDomain"] = "sso_okta_domain";
242018
- SSOSecretKey2["JwksUri"] = "sso_jwks_uri";
242019
- })(SSOSecretKey ||= {});
242020
- var ALL_SSO_SECRET_KEYS = Object.values(SSOSecretKey);
242021
- var DEFAULT_OIDC_SCOPE = "openid email profile";
242022
- var DEFAULT_GITHUB_SCOPE = "user:email";
242023
-
242024
- // src/core/resources/auth-config/sso/providers/custom.ts
242025
- var customProvider = {
242026
- requiredKeys: [
242027
- "sso_auth_endpoint" /* AuthEndpoint */,
242028
- "sso_token_endpoint" /* TokenEndpoint */,
242029
- "sso_userinfo_endpoint" /* UserinfoEndpoint */,
242030
- "sso_jwks_uri" /* JwksUri */
242031
- ],
242032
- defaults: {
242033
- ["sso_scope" /* Scope */]: DEFAULT_OIDC_SCOPE
242034
- }
242035
- };
242036
-
242037
- // src/core/resources/auth-config/sso/providers/github.ts
242038
- var githubProvider = {
242039
- requiredKeys: [],
242040
- defaults: {
242041
- ["sso_scope" /* Scope */]: DEFAULT_GITHUB_SCOPE,
242042
- ["sso_auth_endpoint" /* AuthEndpoint */]: "https://github.com/login/oauth/authorize",
242043
- ["sso_token_endpoint" /* TokenEndpoint */]: "https://github.com/login/oauth/access_token",
242044
- ["sso_userinfo_endpoint" /* UserinfoEndpoint */]: "https://api.github.com/user"
242045
- }
242046
- };
242047
-
242048
- // src/core/resources/auth-config/sso/providers/google.ts
242049
- var googleProvider = {
242050
- requiredKeys: [],
242051
- defaults: {
242052
- ["sso_scope" /* Scope */]: DEFAULT_OIDC_SCOPE,
242053
- ["sso_discovery_url" /* DiscoveryUrl */]: "https://accounts.google.com/.well-known/openid-configuration"
242054
- }
242055
- };
242056
-
242057
- // src/core/resources/auth-config/sso/providers/microsoft.ts
242058
- var microsoftProvider = {
242059
- requiredKeys: ["sso_tenant_id" /* TenantId */],
242060
- defaults: {
242061
- ["sso_scope" /* Scope */]: DEFAULT_OIDC_SCOPE
242062
- },
242063
- deriveDefaults: (secrets) => {
242064
- const tenantId = secrets["sso_tenant_id" /* TenantId */];
242065
- if (tenantId) {
242066
- return {
242067
- ["sso_discovery_url" /* DiscoveryUrl */]: `https://login.microsoftonline.com/${tenantId}/v2.0/.well-known/openid-configuration`
242068
- };
242069
- }
242070
- return {};
242071
- }
242072
- };
242073
-
242074
- // src/core/resources/auth-config/sso/providers/okta.ts
242075
- var oktaProvider = {
242076
- requiredKeys: ["sso_okta_domain" /* OktaDomain */],
242077
- defaults: {
242078
- ["sso_scope" /* Scope */]: DEFAULT_OIDC_SCOPE
242079
- },
242080
- deriveDefaults: (secrets) => {
242081
- const domain2 = secrets["sso_okta_domain" /* OktaDomain */];
242082
- if (domain2) {
242083
- return {
242084
- ["sso_discovery_url" /* DiscoveryUrl */]: `https://${domain2}/.well-known/openid-configuration`
242085
- };
242086
- }
242087
- return {};
242088
- }
242089
- };
242090
-
242091
- // src/core/resources/auth-config/sso/providers/index.ts
242092
- var SSO_PROVIDER_SCHEMAS = {
242093
- google: googleProvider,
242094
- microsoft: microsoftProvider,
242095
- github: githubProvider,
242096
- okta: oktaProvider,
242097
- custom: customProvider
242098
- };
242099
-
242100
- // src/core/resources/auth-config/sso/types.ts
242101
- var KNOWN_SSO_PROVIDERS = {
242102
- google: "google",
242103
- microsoft: "microsoft",
242104
- github: "github",
242105
- okta: "okta",
242106
- custom: "custom"
242107
- };
242108
-
242109
- // src/core/resources/auth-config/sso/operations.ts
242110
- var OPTION_TO_SECRET_KEY = {
242111
- scope: "sso_scope" /* Scope */,
242112
- discoveryUrl: "sso_discovery_url" /* DiscoveryUrl */,
242113
- tenantId: "sso_tenant_id" /* TenantId */,
242114
- oktaDomain: "sso_okta_domain" /* OktaDomain */,
242115
- authEndpoint: "sso_auth_endpoint" /* AuthEndpoint */,
242116
- tokenEndpoint: "sso_token_endpoint" /* TokenEndpoint */,
242117
- userinfoEndpoint: "sso_userinfo_endpoint" /* UserinfoEndpoint */,
242118
- jwksUri: "sso_jwks_uri" /* JwksUri */
242119
- };
242120
- async function updateSSOConfig(authDir, provider, enable) {
242121
- const current = await readAuthConfig(authDir) ?? DEFAULT_AUTH_CONFIG;
242122
- const merged = {
242123
- ...current,
242124
- enableSSOLogin: enable,
242125
- ssoProviderName: enable && provider ? provider : null,
242126
- ...enable && {
242127
- enableGoogleLogin: false,
242128
- enableMicrosoftLogin: false,
242129
- enableFacebookLogin: false,
242130
- enableAppleLogin: false
242131
- }
242132
- };
242133
- await writeAuthConfig(authDir, merged);
242134
- return merged;
242135
- }
242136
- function buildSSOSecrets(provider, options) {
242137
- const schema3 = SSO_PROVIDER_SCHEMAS[provider];
242138
- const secrets = {};
242139
- secrets["sso_name" /* Name */] = options.ssoName ?? provider;
242140
- secrets["sso_client_id" /* ClientId */] = options.clientId;
242141
- secrets["sso_client_secret" /* ClientSecret */] = options.clientSecret;
242142
- for (const [optionKey, secretKey] of Object.entries(OPTION_TO_SECRET_KEY)) {
242143
- const value = options[optionKey];
242144
- if (typeof value === "string" && value.length > 0) {
242145
- secrets[secretKey] = value;
242146
- }
242147
- }
242148
- if (schema3.deriveDefaults) {
242149
- const derived = schema3.deriveDefaults(secrets);
242150
- for (const [key, val] of Object.entries(derived)) {
242151
- if (!secrets[key]) {
242152
- secrets[key] = val;
242153
- }
242154
- }
242155
- }
242156
- for (const [key, val] of Object.entries(schema3.defaults)) {
242157
- if (!secrets[key]) {
242158
- secrets[key] = val;
242159
- }
242160
- }
242161
- const missing = [];
242162
- for (const key of schema3.requiredKeys) {
242163
- if (!secrets[key]) {
242164
- missing.push(key);
242165
- }
242166
- }
242167
- if (provider === KNOWN_SSO_PROVIDERS.custom && !options.ssoName) {
242168
- missing.push("sso_name" /* Name */);
242169
- }
242170
- if (missing.length > 0) {
242171
- throw new InvalidInputError(`Missing required fields for ${provider}: ${missing.join(", ")}`);
242172
- }
242173
- return Object.fromEntries(Object.entries(secrets).filter(([, v]) => v.length > 0));
242174
- }
242175
- async function pushSSOSecrets(secrets) {
242176
- await setSecrets(secrets);
242177
- }
242178
- async function deleteSSOSecrets() {
242179
- await Promise.allSettled(ALL_SSO_SECRET_KEYS.map((key) => deleteSecret(key)));
242180
- }
242181
242001
  // src/core/resources/connector/schema.ts
242182
242002
  var GoogleCalendarConnectorSchema = exports_external.object({
242183
242003
  type: exports_external.literal("googlecalendar"),
@@ -243538,7 +243358,7 @@ import { join as join9 } from "node:path";
243538
243358
  // package.json
243539
243359
  var package_default = {
243540
243360
  name: "base44",
243541
- version: "0.0.50",
243361
+ version: "0.0.51",
243542
243362
  description: "Base44 CLI - Unified interface for managing Base44 applications",
243543
243363
  type: "module",
243544
243364
  bin: {
@@ -243593,6 +243413,7 @@ var package_default = {
243593
243413
  "@types/multer": "^2.0.0",
243594
243414
  "@types/node": "^22.10.5",
243595
243415
  "@vercel/detect-agent": "^1.1.0",
243416
+ outdent: "^0.8.0",
243596
243417
  chalk: "^5.6.2",
243597
243418
  chokidar: "^5.0.0",
243598
243419
  commander: "^12.1.0",
@@ -251215,167 +251036,9 @@ function getSocialLoginCommand() {
251215
251036
  ])).option("--client-id <id>", "custom OAuth client ID (Google only)").option("--client-secret <secret>", "custom OAuth client secret (Google only)").option("--client-secret-stdin", "read client secret from stdin (Google only)").option("--env-file <path>", "read client secret from a .env file (Google only)").action(socialLoginAction);
251216
251037
  }
251217
251038
 
251218
- // src/cli/commands/auth/sso.ts
251219
- import { dirname as dirname11, join as join16, resolve as resolve3 } from "node:path";
251220
- var SSOConfigFileSchema = exports_external.object({
251221
- provider: exports_external.enum(["google", "microsoft", "github", "okta", "custom"]),
251222
- clientId: exports_external.string(),
251223
- clientSecret: exports_external.string(),
251224
- scope: exports_external.string().optional(),
251225
- discoveryUrl: exports_external.string().optional(),
251226
- tenantId: exports_external.string().optional(),
251227
- oktaDomain: exports_external.string().optional(),
251228
- authEndpoint: exports_external.string().optional(),
251229
- tokenEndpoint: exports_external.string().optional(),
251230
- userinfoEndpoint: exports_external.string().optional(),
251231
- jwksUri: exports_external.string().optional(),
251232
- ssoName: exports_external.string().optional()
251233
- });
251234
- async function loadSSOConfigFile(filePath) {
251235
- const resolved = resolve3(filePath);
251236
- const raw2 = await readJsonFile(resolved);
251237
- const result = SSOConfigFileSchema.safeParse(raw2);
251238
- if (!result.success) {
251239
- const issues = result.error.issues.map((i2) => ` ${i2.path.join(".")}: ${i2.message}`).join(`
251240
- `);
251241
- throw new InvalidInputError(`Invalid SSO config file ${filePath}:
251242
- ${issues}`);
251243
- }
251244
- return result.data;
251245
- }
251246
- function mergeFileWithFlags(fileConfig, options) {
251247
- return {
251248
- provider: options.provider ?? fileConfig.provider,
251249
- clientId: options.clientId ?? fileConfig.clientId,
251250
- clientSecret: options.clientSecret ?? fileConfig.clientSecret,
251251
- clientSecretStdin: options.clientSecretStdin,
251252
- envFile: options.envFile,
251253
- scope: options.scope ?? fileConfig.scope,
251254
- discoveryUrl: options.discoveryUrl ?? fileConfig.discoveryUrl,
251255
- tenantId: options.tenantId ?? fileConfig.tenantId,
251256
- oktaDomain: options.oktaDomain ?? fileConfig.oktaDomain,
251257
- authEndpoint: options.authEndpoint ?? fileConfig.authEndpoint,
251258
- tokenEndpoint: options.tokenEndpoint ?? fileConfig.tokenEndpoint,
251259
- userinfoEndpoint: options.userinfoEndpoint ?? fileConfig.userinfoEndpoint,
251260
- jwksUri: options.jwksUri ?? fileConfig.jwksUri,
251261
- ssoName: options.ssoName ?? fileConfig.ssoName
251262
- };
251263
- }
251264
- var providerNames = Object.keys(KNOWN_SSO_PROVIDERS);
251265
- function validateProvider(provider) {
251266
- if (!provider) {
251267
- throw new InvalidInputError("Missing --provider.", {
251268
- hints: [
251269
- {
251270
- message: `Valid providers: ${providerNames.join(", ")}`,
251271
- command: "base44 auth sso enable --provider <provider> --client-id <id> --client-secret <secret>"
251272
- }
251273
- ]
251274
- });
251275
- }
251276
- if (!(provider in KNOWN_SSO_PROVIDERS)) {
251277
- throw new InvalidInputError(`Unknown provider "${provider}". Valid providers: ${providerNames.join(", ")}`);
251278
- }
251279
- return provider;
251280
- }
251281
- async function ssoEnableAction({ isNonInteractive, runTask: runTask2 }, options) {
251282
- let merged = options;
251283
- if (options.file) {
251284
- const fileConfig = await loadSSOConfigFile(options.file);
251285
- merged = mergeFileWithFlags(fileConfig, options);
251286
- }
251287
- const provider = validateProvider(merged.provider);
251288
- if (!merged.clientId) {
251289
- throw new InvalidInputError("Missing --client-id.", {
251290
- hints: [
251291
- {
251292
- message: `Example: base44 auth sso enable --provider ${provider} --client-id <id> --client-secret <secret>`,
251293
- command: `base44 auth sso enable --provider ${provider} --client-id <id> --client-secret <secret>`
251294
- }
251295
- ]
251296
- });
251297
- }
251298
- let clientSecret;
251299
- if (merged.envFile && !merged.clientSecret) {
251300
- const secrets2 = await parseEnvFile(resolve3(merged.envFile));
251301
- const value = secrets2.sso_client_secret;
251302
- if (!value) {
251303
- throw new InvalidInputError(`Key "sso_client_secret" not found in ${merged.envFile}.`);
251304
- }
251305
- clientSecret = value;
251306
- } else {
251307
- clientSecret = await resolveSecret({
251308
- flagValue: merged.clientSecret,
251309
- fromStdin: merged.clientSecretStdin,
251310
- envVar: "sso_client_secret",
251311
- promptMessage: "Enter SSO client secret",
251312
- isNonInteractive,
251313
- name: "client secret",
251314
- hints: [
251315
- {
251316
- message: `Provide via flag: base44 auth sso enable --provider ${provider} --client-id <id> --client-secret <secret>`,
251317
- command: `base44 auth sso enable --provider ${provider} --client-id <id> --client-secret <secret>`
251318
- },
251319
- {
251320
- message: `Provide via stdin: echo <secret> | base44 auth sso enable --provider ${provider} --client-id <id> --client-secret-stdin`
251321
- },
251322
- {
251323
- message: `Provide via env: sso_client_secret=<secret> base44 auth sso enable --provider ${provider} --client-id <id>`
251324
- }
251325
- ]
251326
- });
251327
- }
251328
- const secretOptions = {
251329
- clientId: merged.clientId,
251330
- clientSecret,
251331
- scope: merged.scope,
251332
- discoveryUrl: merged.discoveryUrl,
251333
- tenantId: merged.tenantId,
251334
- oktaDomain: merged.oktaDomain,
251335
- authEndpoint: merged.authEndpoint,
251336
- tokenEndpoint: merged.tokenEndpoint,
251337
- userinfoEndpoint: merged.userinfoEndpoint,
251338
- jwksUri: merged.jwksUri,
251339
- ssoName: merged.ssoName
251340
- };
251341
- const secrets = buildSSOSecrets(provider, secretOptions);
251342
- const { project: project2 } = await readProjectConfig();
251343
- const configDir = dirname11(project2.configPath);
251344
- const authDir = join16(configDir, project2.authDir);
251345
- await runTask2("Updating local auth config", async () => updateSSOConfig(authDir, provider, true));
251346
- await runTask2("Saving SSO credentials", async () => pushSSOSecrets(secrets));
251347
- return {
251348
- outroMessage: `SSO configured with ${provider} in local config. Run \`base44 auth push\` or \`base44 deploy\` to apply.`
251349
- };
251350
- }
251351
- async function ssoDisableAction({
251352
- runTask: runTask2
251353
- }) {
251354
- const { project: project2 } = await readProjectConfig();
251355
- const configDir = dirname11(project2.configPath);
251356
- const authDir = join16(configDir, project2.authDir);
251357
- await runTask2("Updating local auth config", async () => updateSSOConfig(authDir, null, false));
251358
- await runTask2("Removing SSO credentials", async () => deleteSSOSecrets());
251359
- return {
251360
- outroMessage: "SSO disabled in local config and credentials removed. Run `base44 auth push` or `base44 deploy` to apply."
251361
- };
251362
- }
251363
- async function ssoAction(context, action, options) {
251364
- if (action === "disable") {
251365
- return ssoDisableAction(context);
251366
- }
251367
- return ssoEnableAction(context, options);
251368
- }
251369
- function getSSOCommand() {
251370
- return new Base44Command("sso").description("Configure SSO identity provider (google, microsoft, github, okta, custom)").addArgument(new Argument("<action>", "enable or disable SSO").choices([
251371
- "enable",
251372
- "disable"
251373
- ])).option("--provider <provider>", "SSO provider: google, microsoft, github, okta, custom").option("--client-id <id>", "OAuth client ID").option("--client-secret <secret>", "OAuth client secret").option("--client-secret-stdin", "Read client secret from stdin").option("--env-file <path>", "Read client secret from a .env file (key: sso_client_secret)").option("--file <path>", "JSON config file with all SSO settings").option("--scope <scope>", "OAuth scope (defaults per provider)").option("--discovery-url <url>", "OIDC discovery URL").option("--tenant-id <id>", "Microsoft tenant ID (required for microsoft)").option("--okta-domain <domain>", "Okta domain (required for okta)").option("--auth-endpoint <url>", "Authorization endpoint (required for custom)").option("--token-endpoint <url>", "Token endpoint (required for custom)").option("--userinfo-endpoint <url>", "Userinfo endpoint (required for custom)").option("--jwks-uri <url>", "JWKS URI (required for custom)").option("--sso-name <name>", "Provider display name (required for custom)").action(ssoAction);
251374
- }
251375
-
251376
251039
  // src/cli/commands/auth/index.ts
251377
251040
  function getAuthCommand() {
251378
- return new Command("auth").description("Manage app authentication settings").addCommand(getPasswordLoginCommand()).addCommand(getSocialLoginCommand()).addCommand(getSSOCommand()).addCommand(getAuthPullCommand()).addCommand(getAuthPushCommand());
251041
+ return new Command("auth").description("Manage app authentication settings").addCommand(getPasswordLoginCommand()).addCommand(getSocialLoginCommand()).addCommand(getAuthPullCommand()).addCommand(getAuthPushCommand());
251379
251042
  }
251380
251043
 
251381
251044
  // src/cli/commands/auth/login.ts
@@ -251437,14 +251100,14 @@ function getConnectorsListAvailableCommand() {
251437
251100
  }
251438
251101
 
251439
251102
  // src/cli/commands/connectors/pull.ts
251440
- import { dirname as dirname12, join as join17 } from "node:path";
251103
+ import { dirname as dirname11, join as join16 } from "node:path";
251441
251104
  async function pullConnectorsAction({
251442
251105
  log,
251443
251106
  runTask: runTask2
251444
251107
  }) {
251445
251108
  const { project: project2 } = await readProjectConfig();
251446
- const configDir = dirname12(project2.configPath);
251447
- const connectorsDir = join17(configDir, project2.connectorsDir);
251109
+ const configDir = dirname11(project2.configPath);
251110
+ const connectorsDir = join16(configDir, project2.connectorsDir);
251448
251111
  const remoteConnectors = await runTask2("Fetching connectors from Base44", async () => {
251449
251112
  return await pullAllConnectors();
251450
251113
  }, {
@@ -251973,19 +251636,19 @@ var baseOpen = async (options) => {
251973
251636
  }
251974
251637
  const subprocess = childProcess3.spawn(command2, cliArguments, childProcessOptions);
251975
251638
  if (options.wait) {
251976
- return new Promise((resolve4, reject) => {
251639
+ return new Promise((resolve3, reject) => {
251977
251640
  subprocess.once("error", reject);
251978
251641
  subprocess.once("close", (exitCode) => {
251979
251642
  if (!options.allowNonzeroExitCode && exitCode !== 0) {
251980
251643
  reject(new Error(`Exited with code ${exitCode}`));
251981
251644
  return;
251982
251645
  }
251983
- resolve4(subprocess);
251646
+ resolve3(subprocess);
251984
251647
  });
251985
251648
  });
251986
251649
  }
251987
251650
  if (isFallbackAttempt) {
251988
- return new Promise((resolve4, reject) => {
251651
+ return new Promise((resolve3, reject) => {
251989
251652
  subprocess.once("error", reject);
251990
251653
  subprocess.once("spawn", () => {
251991
251654
  subprocess.once("close", (exitCode) => {
@@ -251995,17 +251658,17 @@ var baseOpen = async (options) => {
251995
251658
  return;
251996
251659
  }
251997
251660
  subprocess.unref();
251998
- resolve4(subprocess);
251661
+ resolve3(subprocess);
251999
251662
  });
252000
251663
  });
252001
251664
  });
252002
251665
  }
252003
251666
  subprocess.unref();
252004
- return new Promise((resolve4, reject) => {
251667
+ return new Promise((resolve3, reject) => {
252005
251668
  subprocess.once("error", reject);
252006
251669
  subprocess.once("spawn", () => {
252007
251670
  subprocess.off("error", reject);
252008
- resolve4(subprocess);
251671
+ resolve3(subprocess);
252009
251672
  });
252010
251673
  });
252011
251674
  };
@@ -252499,11 +252162,11 @@ function getListCommand() {
252499
252162
  }
252500
252163
 
252501
252164
  // src/cli/commands/functions/pull.ts
252502
- import { dirname as dirname13, join as join18 } from "node:path";
252165
+ import { dirname as dirname12, join as join17 } from "node:path";
252503
252166
  async function pullFunctionsAction({ log, runTask: runTask2 }, name2) {
252504
252167
  const { project: project2 } = await readProjectConfig();
252505
- const configDir = dirname13(project2.configPath);
252506
- const functionsDir = join18(configDir, project2.functionsDir);
252168
+ const configDir = dirname12(project2.configPath);
252169
+ const functionsDir = join17(configDir, project2.functionsDir);
252507
252170
  const remoteFunctions = await runTask2("Fetching functions from Base44", async () => {
252508
252171
  const { functions } = await listDeployedFunctions();
252509
252172
  return functions;
@@ -252546,7 +252209,7 @@ function getFunctionsCommand() {
252546
252209
  }
252547
252210
 
252548
252211
  // src/cli/commands/project/create.ts
252549
- import { basename as basename3, join as join19, resolve as resolve4 } from "node:path";
252212
+ import { basename as basename3, join as join18, resolve as resolve3 } from "node:path";
252550
252213
  var import_kebabCase = __toESM(require_kebabCase(), 1);
252551
252214
  var DEFAULT_TEMPLATE_ID = "backend-only";
252552
252215
  async function getTemplateById(templateId) {
@@ -252611,7 +252274,7 @@ async function createInteractive(options, ctx) {
252611
252274
  }, ctx);
252612
252275
  }
252613
252276
  async function createNonInteractive(options, ctx) {
252614
- ctx.log.info(`Creating a new project at ${resolve4(options.path)}`);
252277
+ ctx.log.info(`Creating a new project at ${resolve3(options.path)}`);
252615
252278
  const template2 = await getTemplateById(options.template ?? DEFAULT_TEMPLATE_ID);
252616
252279
  return await executeCreate({
252617
252280
  template: template2,
@@ -252632,7 +252295,7 @@ async function executeCreate({
252632
252295
  isInteractive
252633
252296
  }, { log, runTask: runTask2 }) {
252634
252297
  const name2 = rawName.trim();
252635
- const resolvedPath = resolve4(projectPath);
252298
+ const resolvedPath = resolve3(projectPath);
252636
252299
  const { projectId } = await runTask2("Setting up your project...", async () => {
252637
252300
  return await createProjectFiles({
252638
252301
  name: name2,
@@ -252683,7 +252346,7 @@ async function executeCreate({
252683
252346
  updateMessage("Building project...");
252684
252347
  await execa({ cwd: resolvedPath, shell: true })`${buildCommand}`;
252685
252348
  updateMessage("Deploying site...");
252686
- return await deploySite(join19(resolvedPath, outputDirectory));
252349
+ return await deploySite(join18(resolvedPath, outputDirectory));
252687
252350
  }, {
252688
252351
  successMessage: theme.colors.base44Orange("Site deployed successfully"),
252689
252352
  errorMessage: "Failed to deploy site"
@@ -253148,7 +252811,7 @@ function getSecretsListCommand() {
253148
252811
  }
253149
252812
 
253150
252813
  // src/cli/commands/secrets/set.ts
253151
- import { resolve as resolve5 } from "node:path";
252814
+ import { resolve as resolve4 } from "node:path";
253152
252815
  function parseEntries(entries) {
253153
252816
  const secrets = {};
253154
252817
  for (const entry of entries) {
@@ -253179,7 +252842,7 @@ async function setSecretsAction({ log, runTask: runTask2 }, entries, options) {
253179
252842
  validateInput(entries, options);
253180
252843
  let secrets;
253181
252844
  if (options.envFile) {
253182
- secrets = await parseEnvFile(resolve5(options.envFile));
252845
+ secrets = await parseEnvFile(resolve4(options.envFile));
253183
252846
  if (Object.keys(secrets).length === 0) {
253184
252847
  throw new InvalidInputError("The env file contains no valid KEY=VALUE entries.");
253185
252848
  }
@@ -253208,7 +252871,7 @@ function getSecretsCommand() {
253208
252871
  }
253209
252872
 
253210
252873
  // src/cli/commands/site/deploy.ts
253211
- import { resolve as resolve6 } from "node:path";
252874
+ import { resolve as resolve5 } from "node:path";
253212
252875
  async function deployAction2({ isNonInteractive, runTask: runTask2 }, options) {
253213
252876
  if (isNonInteractive && !options.yes) {
253214
252877
  throw new InvalidInputError("--yes is required in non-interactive mode");
@@ -253223,7 +252886,7 @@ async function deployAction2({ isNonInteractive, runTask: runTask2 }, options) {
253223
252886
  ]
253224
252887
  });
253225
252888
  }
253226
- const outputDir = resolve6(project2.root, project2.site.outputDirectory);
252889
+ const outputDir = resolve5(project2.root, project2.site.outputDirectory);
253227
252890
  if (!options.yes) {
253228
252891
  const shouldDeploy = await Re({
253229
252892
  message: `Deploy site from ${project2.site.outputDirectory}?`
@@ -253349,10 +253012,10 @@ function toPascalCase(name2) {
253349
253012
  return name2.split(/[-_\s]+/).map((w8) => w8.charAt(0).toUpperCase() + w8.slice(1)).join("");
253350
253013
  }
253351
253014
  // src/core/types/update-project.ts
253352
- import { join as join22 } from "node:path";
253015
+ import { join as join21 } from "node:path";
253353
253016
  var TYPES_INCLUDE_PATH = `${PROJECT_SUBDIR}/${TYPES_OUTPUT_SUBDIR}/*.d.ts`;
253354
253017
  async function updateProjectConfig(projectRoot) {
253355
- const tsconfigPath = join22(projectRoot, "tsconfig.json");
253018
+ const tsconfigPath = join21(projectRoot, "tsconfig.json");
253356
253019
  if (!await pathExists(tsconfigPath)) {
253357
253020
  return false;
253358
253021
  }
@@ -253400,7 +253063,7 @@ import process21 from "node:process";
253400
253063
  // src/cli/dev/dev-server/main.ts
253401
253064
  var import_cors = __toESM(require_lib4(), 1);
253402
253065
  var import_express6 = __toESM(require_express(), 1);
253403
- import { dirname as dirname18, join as join25 } from "node:path";
253066
+ import { dirname as dirname17, join as join24 } from "node:path";
253404
253067
 
253405
253068
  // ../../node_modules/get-port/index.js
253406
253069
  import net from "node:net";
@@ -253427,14 +253090,14 @@ var getLocalHosts = () => {
253427
253090
  }
253428
253091
  return results;
253429
253092
  };
253430
- var checkAvailablePort = (options8) => new Promise((resolve8, reject) => {
253093
+ var checkAvailablePort = (options8) => new Promise((resolve7, reject) => {
253431
253094
  const server = net.createServer();
253432
253095
  server.unref();
253433
253096
  server.on("error", reject);
253434
253097
  server.listen(options8, () => {
253435
253098
  const { port } = server.address();
253436
253099
  server.close(() => {
253437
- resolve8(port);
253100
+ resolve7(port);
253438
253101
  });
253439
253102
  });
253440
253103
  });
@@ -253632,15 +253295,21 @@ class FunctionManager {
253632
253295
  this.setupProcessHandlers(name2, process21);
253633
253296
  return this.waitForReady(name2, runningFunc);
253634
253297
  }
253635
- reload(functions) {
253636
- this.stopAll();
253298
+ async reload(functions) {
253299
+ await this.stopAll();
253637
253300
  this.functions = new Map(functions.map((f7) => [f7.name, f7]));
253638
253301
  }
253639
- stopAll() {
253640
- for (const [name2, { process: process21 }] of this.running) {
253302
+ async stopAll() {
253303
+ await Promise.all(Array.from(this.running, ([name2, { process: proc2 }]) => {
253641
253304
  this.logger.log(`Stopping function: ${name2}`);
253642
- process21.kill();
253643
- }
253305
+ const exited = new Promise((r5) => proc2.once("exit", () => r5()));
253306
+ if (process.platform === "win32" && proc2.pid) {
253307
+ spawn2("taskkill", ["/pid", String(proc2.pid), "/T", "/F"]);
253308
+ } else {
253309
+ proc2.kill();
253310
+ }
253311
+ return exited;
253312
+ }));
253644
253313
  this.running.clear();
253645
253314
  this.starting.clear();
253646
253315
  }
@@ -253688,7 +253357,7 @@ class FunctionManager {
253688
253357
  });
253689
253358
  }
253690
253359
  waitForReady(name2, runningFunc) {
253691
- return new Promise((resolve8, reject) => {
253360
+ return new Promise((resolve7, reject) => {
253692
253361
  runningFunc.process.on("exit", (code2) => {
253693
253362
  if (!runningFunc.ready) {
253694
253363
  clearTimeout(timeout3);
@@ -253711,7 +253380,7 @@ class FunctionManager {
253711
253380
  runningFunc.ready = true;
253712
253381
  clearTimeout(timeout3);
253713
253382
  runningFunc.process.stdout?.off("data", onData);
253714
- resolve8(runningFunc.port);
253383
+ resolve7(runningFunc.port);
253715
253384
  }
253716
253385
  };
253717
253386
  runningFunc.process.stdout?.on("data", onData);
@@ -254028,6 +253697,9 @@ class Database {
254028
253697
  getCollection(name2) {
254029
253698
  return this.collections.get(this.normalizeName(name2));
254030
253699
  }
253700
+ getSchema(entityName) {
253701
+ return this.schemas.get(this.normalizeName(entityName));
253702
+ }
254031
253703
  getCollectionNames() {
254032
253704
  return Array.from(this.collections.keys()).filter((name2) => {
254033
253705
  return !name2.startsWith(PRIVATE_COLLECTION_PREFIX);
@@ -254255,6 +253927,120 @@ In order to complete registration use this verification code: ${otpCode}
254255
253927
  // src/cli/dev/dev-server/routes/entities/entities-router.ts
254256
253928
  var import_express4 = __toESM(require_express(), 1);
254257
253929
 
253930
+ // src/cli/dev/dev-server/db/rls.ts
253931
+ function getRLSFieldValue(key2, source3) {
253932
+ const DATA_FIELD_PREFIX = "data.";
253933
+ return source3[key2.startsWith(DATA_FIELD_PREFIX) ? key2.slice(DATA_FIELD_PREFIX.length) : key2];
253934
+ }
253935
+ function resolveTemplate(value, user) {
253936
+ return value.replace(/\{\{user\.([\w.]+)\}\}/g, (_match, path18) => {
253937
+ return String(getRLSFieldValue(path18, user) ?? "");
253938
+ });
253939
+ }
253940
+ function evaluateOperator(recordValue, operator) {
253941
+ for (const [op2, opValue] of Object.entries(operator)) {
253942
+ switch (op2) {
253943
+ case "$in":
253944
+ if (!Array.isArray(opValue) || !opValue.includes(recordValue)) {
253945
+ return false;
253946
+ }
253947
+ break;
253948
+ case "$nin":
253949
+ if (!Array.isArray(opValue) || opValue.includes(recordValue)) {
253950
+ return false;
253951
+ }
253952
+ break;
253953
+ case "$ne":
253954
+ if (recordValue === opValue)
253955
+ return false;
253956
+ break;
253957
+ case "$all":
253958
+ if (!Array.isArray(recordValue) || !Array.isArray(opValue)) {
253959
+ return false;
253960
+ }
253961
+ if (!opValue.every((v10) => recordValue.includes(v10))) {
253962
+ return false;
253963
+ }
253964
+ break;
253965
+ default:
253966
+ return false;
253967
+ }
253968
+ }
253969
+ return true;
253970
+ }
253971
+ function evaluateUserCondition(condition, user) {
253972
+ for (const [key2, expected] of Object.entries(condition)) {
253973
+ const userValue = getRLSFieldValue(key2, user);
253974
+ if (typeof expected === "object" && expected !== null) {
253975
+ if (!evaluateOperator(userValue, expected))
253976
+ return false;
253977
+ } else {
253978
+ if (userValue !== expected)
253979
+ return false;
253980
+ }
253981
+ }
253982
+ return true;
253983
+ }
253984
+ function evaluateCondition(condition, record2, user) {
253985
+ for (const [key2, value] of Object.entries(condition)) {
253986
+ if (key2 === "user_condition") {
253987
+ if (!evaluateUserCondition(value, user))
253988
+ return false;
253989
+ continue;
253990
+ }
253991
+ if (key2 === "$or") {
253992
+ const conditions = value;
253993
+ if (!conditions.some((c8) => evaluateCondition(c8, record2, user)))
253994
+ return false;
253995
+ continue;
253996
+ }
253997
+ if (key2 === "$and") {
253998
+ const conditions = value;
253999
+ if (!conditions.every((c8) => evaluateCondition(c8, record2, user)))
254000
+ return false;
254001
+ continue;
254002
+ }
254003
+ if (key2 === "$nor") {
254004
+ const conditions = value;
254005
+ if (conditions.some((c8) => evaluateCondition(c8, record2, user)))
254006
+ return false;
254007
+ continue;
254008
+ }
254009
+ const recordValue = getRLSFieldValue(key2, record2);
254010
+ const resolvedValue = typeof value === "string" ? resolveTemplate(value, user) : value;
254011
+ if (typeof resolvedValue === "object" && resolvedValue !== null) {
254012
+ if (!evaluateOperator(recordValue, resolvedValue))
254013
+ return false;
254014
+ } else {
254015
+ if (recordValue !== resolvedValue)
254016
+ return false;
254017
+ }
254018
+ }
254019
+ return true;
254020
+ }
254021
+ function checkRLS(rule, record2, user) {
254022
+ if (rule === undefined)
254023
+ return true;
254024
+ if (typeof rule === "boolean")
254025
+ return rule;
254026
+ if (!user)
254027
+ return false;
254028
+ return evaluateCondition(rule, record2, user);
254029
+ }
254030
+ function applyFLS(record2, schema10, user, operation) {
254031
+ if (Array.isArray(record2)) {
254032
+ return record2.map((r5) => applyFLS(r5, schema10, user, operation));
254033
+ }
254034
+ const result = {};
254035
+ for (const [key2, value] of Object.entries(record2)) {
254036
+ const rule = schema10.properties[key2]?.rls?.[operation];
254037
+ if (!rule || checkRLS(rule, record2, user)) {
254038
+ result[key2] = value;
254039
+ }
254040
+ }
254041
+ return result;
254042
+ }
254043
+
254258
254044
  // src/cli/dev/dev-server/db/entity-queries.ts
254259
254045
  function parseSort(sort) {
254260
254046
  if (!sort) {
@@ -254312,30 +254098,54 @@ var queryEntity = async (collection, reqQuery) => {
254312
254098
  return cursor3;
254313
254099
  };
254314
254100
 
254101
+ // src/cli/dev/dev-server/routes/entities/current-user.ts
254102
+ var import_jsonwebtoken2 = __toESM(require_jsonwebtoken(), 1);
254103
+ function getSubject(payload) {
254104
+ if (!payload || typeof payload === "string") {
254105
+ return;
254106
+ }
254107
+ return payload.sub;
254108
+ }
254109
+ async function resolveCurrentUser(db2, req) {
254110
+ const auth2 = req.headers.authorization;
254111
+ if (!auth2?.startsWith("Bearer ")) {
254112
+ return { ok: false, reason: "missing" };
254113
+ }
254114
+ try {
254115
+ const decoded = import_jsonwebtoken2.default.decode(auth2.replace("Bearer ", ""), {
254116
+ complete: true
254117
+ });
254118
+ const subject = getSubject(decoded?.payload);
254119
+ if (!subject) {
254120
+ return { ok: false, reason: "invalid" };
254121
+ }
254122
+ const currentUser = await db2.getCollection(USER_COLLECTION)?.findOneAsync({ email: subject });
254123
+ if (!currentUser) {
254124
+ return { ok: false, reason: "not_found" };
254125
+ }
254126
+ return { ok: true, user: currentUser };
254127
+ } catch {
254128
+ return { ok: false, reason: "invalid" };
254129
+ }
254130
+ }
254131
+
254315
254132
  // src/cli/dev/dev-server/routes/entities/entities-user-router.ts
254316
254133
  var import_express3 = __toESM(require_express(), 1);
254317
- var import_jsonwebtoken2 = __toESM(require_jsonwebtoken(), 1);
254318
254134
  function createUserRouter(db2, logger2) {
254319
254135
  const router = import_express3.Router({ mergeParams: true });
254320
254136
  const parseBody = import_express3.json();
254321
254137
  function withAuth(handler) {
254322
254138
  return async (req, res) => {
254323
- const auth2 = req.headers.authorization;
254324
- if (!auth2 || !auth2.startsWith("Bearer ")) {
254139
+ const currentUserResult = await resolveCurrentUser(db2, req);
254140
+ if (!currentUserResult.ok && (currentUserResult.reason === "missing" || currentUserResult.reason === "invalid")) {
254325
254141
  res.status(401).json({ error: "Unauthorized" });
254326
254142
  return;
254327
254143
  }
254328
- try {
254329
- const { payload } = import_jsonwebtoken2.default.decode(auth2.replace("Bearer ", ""), { complete: true }) ?? {};
254330
- const result = await db2.getCollection(USER_COLLECTION)?.findOneAsync({ email: payload?.sub });
254331
- if (!result) {
254332
- res.status(404).json({ error: "Unable to read data for the current user" });
254333
- return;
254334
- }
254335
- await handler(req, res, result);
254336
- } catch {
254337
- res.status(401).json({ error: "Unauthorized" });
254144
+ if (!currentUserResult.ok) {
254145
+ res.status(404).json({ error: "Unable to read data for the current user" });
254146
+ return;
254338
254147
  }
254148
+ await handler(req, res, currentUserResult.user);
254339
254149
  };
254340
254150
  }
254341
254151
  router.get("/:id", withAuth(async (req, res, currentUser) => {
@@ -254435,12 +254245,20 @@ async function createEntityRoutes(db2, logger2, broadcast) {
254435
254245
  const parseBody = import_express4.json();
254436
254246
  function withCollection(handler) {
254437
254247
  return async (req, res) => {
254438
- const collection = db2.getCollection(req.params.entityName);
254248
+ const { entityName } = req.params;
254249
+ const collection = db2.getCollection(entityName);
254439
254250
  if (!collection) {
254440
- res.status(404).json({ error: `Entity "${req.params.entityName}" not found` });
254251
+ res.status(404).json({ error: `Entity "${entityName}" not found` });
254441
254252
  return;
254442
254253
  }
254443
- await handler(req, res, collection);
254254
+ const schema10 = db2.getSchema(entityName);
254255
+ if (!schema10) {
254256
+ res.status(404).json({ error: `Schema for "${entityName}" not found` });
254257
+ return;
254258
+ }
254259
+ const currentUserResult = await resolveCurrentUser(db2, req);
254260
+ const currentUser = currentUserResult.ok ? currentUserResult.user : undefined;
254261
+ await handler(req, res, collection, schema10, currentUser);
254444
254262
  };
254445
254263
  }
254446
254264
  function emit(appId, entityName, type, data) {
@@ -254458,9 +254276,31 @@ async function createEntityRoutes(db2, logger2, broadcast) {
254458
254276
  }
254459
254277
  broadcast(appId, entityName, createData(data));
254460
254278
  }
254279
+ function prepareCreateRecord(entityName, body, schema10, currentUser, now) {
254280
+ const { _id, ...recordBody } = body;
254281
+ const ownerFields = {
254282
+ created_by: currentUser?.email,
254283
+ created_by_id: currentUser?.id
254284
+ };
254285
+ if (!checkRLS(schema10.rls?.create, {
254286
+ ...recordBody,
254287
+ ...ownerFields
254288
+ }, currentUser)) {
254289
+ return;
254290
+ }
254291
+ const filteredBody = applyFLS(db2.prepareRecord(entityName, recordBody), schema10, currentUser, "write");
254292
+ db2.validate(entityName, filteredBody);
254293
+ return {
254294
+ ...filteredBody,
254295
+ id: nanoid3(),
254296
+ ...ownerFields,
254297
+ created_date: now,
254298
+ updated_date: now
254299
+ };
254300
+ }
254461
254301
  const userRouter = createUserRouter(db2, logger2);
254462
254302
  router.use("/User", userRouter);
254463
- router.get("/:entityName/:id", withCollection(async (req, res, collection) => {
254303
+ router.get("/:entityName/:id", withCollection(async (req, res, collection, schema10, currentUser) => {
254464
254304
  const { entityName, id: id2 } = req.params;
254465
254305
  try {
254466
254306
  const doc2 = await collection.findOneAsync({ id: id2 });
@@ -254468,16 +254308,28 @@ async function createEntityRoutes(db2, logger2, broadcast) {
254468
254308
  res.status(404).json({ error: `Record with id "${id2}" not found` });
254469
254309
  return;
254470
254310
  }
254471
- res.json(stripInternalFields(doc2));
254311
+ if (!checkRLS(schema10.rls?.read, doc2, currentUser)) {
254312
+ res.status(404).json({
254313
+ message: `Entity ${entityName} with ID ${id2} not found`
254314
+ });
254315
+ return;
254316
+ }
254317
+ const result = applyFLS(stripInternalFields(doc2), schema10, currentUser, "read");
254318
+ res.json(result);
254472
254319
  } catch (error48) {
254473
254320
  logger2.error(`Error in GET /${entityName}/${id2}:`, error48);
254474
254321
  res.status(500).json({ error: "Internal server error" });
254475
254322
  }
254476
254323
  }));
254477
- router.get("/:entityName", withCollection(async (req, res, collection) => {
254324
+ router.get("/:entityName", withCollection(async (req, res, collection, schema10, currentUser) => {
254478
254325
  const { entityName } = req.params;
254479
254326
  try {
254480
- res.json(stripInternalFields(await queryEntity(collection, req.query)));
254327
+ let results = stripInternalFields(await queryEntity(collection, req.query));
254328
+ if (schema10.rls?.read && schema10.rls.read !== true) {
254329
+ results = results.filter((doc2) => checkRLS(schema10.rls.read, doc2, currentUser));
254330
+ }
254331
+ results = results.map((doc2) => applyFLS(doc2, schema10, currentUser, "read"));
254332
+ res.json(results);
254481
254333
  } catch (error48) {
254482
254334
  if (error48 instanceof InvalidInputError) {
254483
254335
  res.status(400).json({ error: error48.message });
@@ -254487,20 +254339,16 @@ async function createEntityRoutes(db2, logger2, broadcast) {
254487
254339
  }
254488
254340
  }
254489
254341
  }));
254490
- router.post("/:entityName", parseBody, withCollection(async (req, res, collection) => {
254342
+ router.post("/:entityName", parseBody, withCollection(async (req, res, collection, schema10, currentUser) => {
254491
254343
  const { appId, entityName } = req.params;
254492
254344
  try {
254493
254345
  const now = new Date().toISOString();
254494
- const { _id, ...body } = req.body;
254495
- const filteredBody = db2.prepareRecord(entityName, body);
254496
- db2.validate(entityName, filteredBody);
254497
- const record2 = {
254498
- ...filteredBody,
254499
- id: nanoid3(),
254500
- created_date: now,
254501
- updated_date: now
254502
- };
254503
- const inserted = stripInternalFields(await collection.insertAsync(record2));
254346
+ const record2 = prepareCreateRecord(entityName, req.body, schema10, currentUser, now);
254347
+ if (!record2) {
254348
+ res.status(403).json({ error: "Permission denied" });
254349
+ return;
254350
+ }
254351
+ const inserted = applyFLS(stripInternalFields(await collection.insertAsync(record2)), schema10, currentUser, "read");
254504
254352
  emit(appId, entityName, "create", inserted);
254505
254353
  res.status(201).json(inserted);
254506
254354
  } catch (error48) {
@@ -254512,7 +254360,7 @@ async function createEntityRoutes(db2, logger2, broadcast) {
254512
254360
  res.status(500).json({ error: "Internal server error" });
254513
254361
  }
254514
254362
  }));
254515
- router.post("/:entityName/bulk", parseBody, withCollection(async (req, res, collection) => {
254363
+ router.post("/:entityName/bulk", parseBody, withCollection(async (req, res, collection, schema10, currentUser) => {
254516
254364
  const { appId, entityName } = req.params;
254517
254365
  if (!Array.isArray(req.body)) {
254518
254366
  res.status(400).json({ error: "Request body must be an array" });
@@ -254521,17 +254369,15 @@ async function createEntityRoutes(db2, logger2, broadcast) {
254521
254369
  try {
254522
254370
  const now = new Date().toISOString();
254523
254371
  const records = [];
254524
- for (const record2 of req.body) {
254525
- const filteredRecord = db2.prepareRecord(entityName, record2);
254526
- db2.validate(entityName, filteredRecord);
254527
- records.push({
254528
- ...filteredRecord,
254529
- id: nanoid3(),
254530
- created_date: now,
254531
- updated_date: now
254532
- });
254372
+ for (const body of req.body) {
254373
+ const record2 = prepareCreateRecord(entityName, body, schema10, currentUser, now);
254374
+ if (!record2) {
254375
+ res.status(403).json({ error: "Permission denied" });
254376
+ return;
254377
+ }
254378
+ records.push(record2);
254533
254379
  }
254534
- const inserted = stripInternalFields(await collection.insertAsync(records));
254380
+ const inserted = applyFLS(stripInternalFields(await collection.insertAsync(records)), schema10, currentUser, "read");
254535
254381
  emit(appId, entityName, "create", inserted);
254536
254382
  res.status(201).json(inserted);
254537
254383
  } catch (error48) {
@@ -254543,11 +254389,24 @@ async function createEntityRoutes(db2, logger2, broadcast) {
254543
254389
  res.status(500).json({ error: "Internal server error" });
254544
254390
  }
254545
254391
  }));
254546
- router.put("/:entityName/:id", parseBody, withCollection(async (req, res, collection) => {
254392
+ router.put("/:entityName/:id", parseBody, withCollection(async (req, res, collection, schema10, currentUser) => {
254547
254393
  const { appId, entityName, id: id2 } = req.params;
254548
254394
  const { id: _id, created_date: _created_date, ...body } = req.body;
254549
254395
  try {
254550
- const filteredBody = db2.prepareRecord(entityName, body, true);
254396
+ if (schema10.rls?.update !== undefined) {
254397
+ const existing = await collection.findOneAsync({ id: id2 });
254398
+ if (!existing) {
254399
+ res.status(404).json({ error: `Record with id "${id2}" not found` });
254400
+ return;
254401
+ }
254402
+ if (!checkRLS(schema10.rls.update, existing, currentUser)) {
254403
+ res.status(404).json({
254404
+ message: `Entity ${entityName} with ID ${id2} not found`
254405
+ });
254406
+ return;
254407
+ }
254408
+ }
254409
+ const filteredBody = applyFLS(db2.prepareRecord(entityName, body, true), schema10, currentUser, "write");
254551
254410
  db2.validate(entityName, filteredBody, true);
254552
254411
  const updateData = {
254553
254412
  ...filteredBody,
@@ -254558,7 +254417,7 @@ async function createEntityRoutes(db2, logger2, broadcast) {
254558
254417
  res.status(404).json({ error: `Record with id "${id2}" not found` });
254559
254418
  return;
254560
254419
  }
254561
- const updated = stripInternalFields(result.affectedDocuments);
254420
+ const updated = applyFLS(stripInternalFields(result.affectedDocuments), schema10, currentUser, "read");
254562
254421
  emit(appId, entityName, "update", updated);
254563
254422
  res.json(updated);
254564
254423
  } catch (error48) {
@@ -254570,30 +254429,48 @@ async function createEntityRoutes(db2, logger2, broadcast) {
254570
254429
  res.status(500).json({ error: "Internal server error" });
254571
254430
  }
254572
254431
  }));
254573
- router.delete("/:entityName/:id", withCollection(async (req, res, collection) => {
254432
+ router.delete("/:entityName/:id", withCollection(async (req, res, collection, schema10, currentUser) => {
254574
254433
  const { appId, entityName, id: id2 } = req.params;
254575
254434
  try {
254576
254435
  const doc2 = await collection.findOneAsync({ id: id2 });
254577
- const numRemoved = await collection.removeAsync({ id: id2 }, { multi: false });
254578
- if (numRemoved === 0) {
254436
+ if (!doc2) {
254579
254437
  res.status(404).json({ error: `Record with id "${id2}" not found` });
254580
254438
  return;
254581
254439
  }
254582
- if (doc2) {
254583
- emit(appId, entityName, "delete", stripInternalFields(doc2));
254440
+ if (!checkRLS(schema10.rls?.delete, doc2, currentUser)) {
254441
+ res.status(404).json({
254442
+ message: `Entity ${entityName} with ID ${id2} not found`
254443
+ });
254444
+ return;
254584
254445
  }
254446
+ await collection.removeAsync({ id: id2 }, { multi: false });
254447
+ emit(appId, entityName, "delete", stripInternalFields(doc2));
254585
254448
  res.json({ success: true });
254586
254449
  } catch (error48) {
254587
254450
  logger2.error(`Error in DELETE /${entityName}/${id2}:`, error48);
254588
254451
  res.status(500).json({ error: "Internal server error" });
254589
254452
  }
254590
254453
  }));
254591
- router.delete("/:entityName", parseBody, withCollection(async (req, res, collection) => {
254454
+ router.delete("/:entityName", parseBody, withCollection(async (req, res, collection, schema10, currentUser) => {
254592
254455
  const { entityName } = req.params;
254593
254456
  try {
254594
254457
  const query = req.body || {};
254595
- const numRemoved = await collection.removeAsync(query, { multi: true });
254596
- res.json({ success: true, deleted: numRemoved });
254458
+ const rlsDelete = schema10?.rls?.delete;
254459
+ if (rlsDelete !== undefined && rlsDelete !== true) {
254460
+ if (rlsDelete === false) {
254461
+ res.status(403).json({ error: "Permission denied" });
254462
+ return;
254463
+ }
254464
+ const docs = await collection.findAsync(query);
254465
+ const allowedIds = docs.filter((doc2) => checkRLS(rlsDelete, doc2, currentUser)).map((doc2) => doc2.id);
254466
+ const numRemoved = await collection.removeAsync({ id: { $in: allowedIds } }, { multi: true });
254467
+ res.json({ success: true, deleted: numRemoved });
254468
+ } else {
254469
+ const numRemoved = await collection.removeAsync(query, {
254470
+ multi: true
254471
+ });
254472
+ res.json({ success: true, deleted: numRemoved });
254473
+ }
254597
254474
  } catch (error48) {
254598
254475
  logger2.error(`Error in DELETE /${entityName}:`, error48);
254599
254476
  res.status(500).json({ error: "Internal server error" });
@@ -255424,9 +255301,9 @@ class NodeFsHandler {
255424
255301
  if (this.fsw.closed) {
255425
255302
  return;
255426
255303
  }
255427
- const dirname17 = sp2.dirname(file2);
255304
+ const dirname16 = sp2.dirname(file2);
255428
255305
  const basename5 = sp2.basename(file2);
255429
- const parent = this.fsw._getWatchedDir(dirname17);
255306
+ const parent = this.fsw._getWatchedDir(dirname16);
255430
255307
  let prevStats = stats;
255431
255308
  if (parent.has(basename5))
255432
255309
  return;
@@ -255453,7 +255330,7 @@ class NodeFsHandler {
255453
255330
  prevStats = newStats2;
255454
255331
  }
255455
255332
  } catch (error48) {
255456
- this.fsw._remove(dirname17, basename5);
255333
+ this.fsw._remove(dirname16, basename5);
255457
255334
  }
255458
255335
  } else if (parent.has(basename5)) {
255459
255336
  const at13 = newStats.atimeMs;
@@ -255542,7 +255419,7 @@ class NodeFsHandler {
255542
255419
  this._addToNodeFs(path19, initialAdd, wh2, depth + 1);
255543
255420
  }
255544
255421
  }).on(EV.ERROR, this._boundHandleError);
255545
- return new Promise((resolve9, reject) => {
255422
+ return new Promise((resolve8, reject) => {
255546
255423
  if (!stream)
255547
255424
  return reject();
255548
255425
  stream.once(STR_END, () => {
@@ -255551,7 +255428,7 @@ class NodeFsHandler {
255551
255428
  return;
255552
255429
  }
255553
255430
  const wasThrottled = throttler ? throttler.clear() : false;
255554
- resolve9(undefined);
255431
+ resolve8(undefined);
255555
255432
  previous.getChildren().filter((item) => {
255556
255433
  return item !== directory && !current.has(item);
255557
255434
  }).forEach((item) => {
@@ -256393,7 +256270,9 @@ var DEFAULT_PORT = 4400;
256393
256270
  var BASE44_APP_URL = "https://base44.app";
256394
256271
  async function createDevServer(options8) {
256395
256272
  const { port: userPort } = options8;
256396
- const port = userPort ?? await getPorts({ port: DEFAULT_PORT });
256273
+ const port = userPort ?? await getPorts({
256274
+ port: process.env.IS_TEST === "true" ? undefined : DEFAULT_PORT
256275
+ });
256397
256276
  const baseUrl = `http://localhost:${port}`;
256398
256277
  const { functions, entities, project: project2 } = await options8.loadResources();
256399
256278
  const app = import_express6.default();
@@ -256460,7 +256339,7 @@ async function createDevServer(options8) {
256460
256339
  }
256461
256340
  remoteProxy(req, res, next);
256462
256341
  });
256463
- const server = await new Promise((resolve10, reject) => {
256342
+ const server = await new Promise((resolve9, reject) => {
256464
256343
  const s5 = app.listen(port, "127.0.0.1", (err) => {
256465
256344
  if (err) {
256466
256345
  if ("code" in err && err.code === "EADDRINUSE") {
@@ -256469,7 +256348,7 @@ async function createDevServer(options8) {
256469
256348
  reject(err);
256470
256349
  }
256471
256350
  } else {
256472
- resolve10(s5);
256351
+ resolve9(s5);
256473
256352
  }
256474
256353
  });
256475
256354
  });
@@ -256478,15 +256357,15 @@ async function createDevServer(options8) {
256478
256357
  broadcastEntityEvent(io6, appId, entityName, event);
256479
256358
  };
256480
256359
  const base44ConfigWatcher = new WatchBase44({
256481
- functions: join25(dirname18(project2.configPath), project2.functionsDir),
256482
- entities: join25(dirname18(project2.configPath), project2.entitiesDir)
256360
+ functions: join24(dirname17(project2.configPath), project2.functionsDir),
256361
+ entities: join24(dirname17(project2.configPath), project2.entitiesDir)
256483
256362
  }, devLogger);
256484
256363
  base44ConfigWatcher.on("change", async (name2) => {
256485
256364
  try {
256486
256365
  const { functions: functions2, entities: entities2 } = await options8.loadResources();
256487
256366
  if (name2 === "functions") {
256488
256367
  const previousFunctionCount = functionManager.getFunctionNames().length;
256489
- functionManager.reload(functions2);
256368
+ await functionManager.reload(functions2);
256490
256369
  const names = functionManager.getFunctionNames();
256491
256370
  if (names.length > 0) {
256492
256371
  devLogger.log(`Reloaded functions: ${names.sort().join(", ")}`);
@@ -256511,10 +256390,10 @@ async function createDevServer(options8) {
256511
256390
  }
256512
256391
  });
256513
256392
  await base44ConfigWatcher.start();
256514
- const shutdown = () => {
256393
+ const shutdown = async () => {
256515
256394
  base44ConfigWatcher.close();
256516
256395
  io6.close();
256517
- functionManager.stopAll();
256396
+ await functionManager.stopAll();
256518
256397
  server.close();
256519
256398
  };
256520
256399
  process.on("SIGINT", shutdown);
@@ -256586,13 +256465,13 @@ async function runScript(options8) {
256586
256465
  }
256587
256466
  // src/cli/commands/exec.ts
256588
256467
  function readStdin2() {
256589
- return new Promise((resolve10, reject) => {
256468
+ return new Promise((resolve9, reject) => {
256590
256469
  let data = "";
256591
256470
  process.stdin.setEncoding("utf-8");
256592
256471
  process.stdin.on("data", (chunk) => {
256593
256472
  data += chunk;
256594
256473
  });
256595
- process.stdin.on("end", () => resolve10(data));
256474
+ process.stdin.on("end", () => resolve9(data));
256596
256475
  process.stdin.on("error", reject);
256597
256476
  });
256598
256477
  }
@@ -256631,7 +256510,7 @@ Examples:
256631
256510
  }
256632
256511
 
256633
256512
  // src/cli/commands/project/eject.ts
256634
- import { resolve as resolve10 } from "node:path";
256513
+ import { resolve as resolve9 } from "node:path";
256635
256514
  var import_kebabCase2 = __toESM(require_kebabCase(), 1);
256636
256515
  async function eject(ctx, options8) {
256637
256516
  const { log, runTask: runTask2, isNonInteractive } = ctx;
@@ -256687,7 +256566,7 @@ async function eject(ctx, options8) {
256687
256566
  Ne("Operation cancelled.");
256688
256567
  throw new CLIExitError(0);
256689
256568
  }
256690
- const resolvedPath = resolve10(selectedPath);
256569
+ const resolvedPath = resolve9(selectedPath);
256691
256570
  await runTask2("Downloading your project's code...", async (updateMessage) => {
256692
256571
  await createProjectFilesForExistingProject({
256693
256572
  projectId,
@@ -256768,7 +256647,7 @@ var import_detect_agent = __toESM(require_dist5(), 1);
256768
256647
  import { release, type } from "node:os";
256769
256648
 
256770
256649
  // ../../node_modules/posthog-node/dist/extensions/error-tracking/modifiers/module.node.mjs
256771
- import { dirname as dirname19, posix, sep } from "path";
256650
+ import { dirname as dirname18, posix, sep } from "path";
256772
256651
  function createModulerModifier() {
256773
256652
  const getModuleFromFileName = createGetModuleFromFilename();
256774
256653
  return async (frames) => {
@@ -256777,7 +256656,7 @@ function createModulerModifier() {
256777
256656
  return frames;
256778
256657
  };
256779
256658
  }
256780
- function createGetModuleFromFilename(basePath = process.argv[1] ? dirname19(process.argv[1]) : process.cwd(), isWindows5 = sep === "\\") {
256659
+ function createGetModuleFromFilename(basePath = process.argv[1] ? dirname18(process.argv[1]) : process.cwd(), isWindows5 = sep === "\\") {
256781
256660
  const normalizedBase = isWindows5 ? normalizeWindowsPath2(basePath) : basePath;
256782
256661
  return (filename) => {
256783
256662
  if (!filename)
@@ -259055,14 +258934,14 @@ async function addSourceContext(frames) {
259055
258934
  return frames;
259056
258935
  }
259057
258936
  function getContextLinesFromFile(path19, ranges, output) {
259058
- return new Promise((resolve11) => {
258937
+ return new Promise((resolve10) => {
259059
258938
  const stream = createReadStream2(path19);
259060
258939
  const lineReaded = createInterface2({
259061
258940
  input: stream
259062
258941
  });
259063
258942
  function destroyStreamAndResolve() {
259064
258943
  stream.destroy();
259065
- resolve11();
258944
+ resolve10();
259066
258945
  }
259067
258946
  let lineNumber = 0;
259068
258947
  let currentRangeIndex = 0;
@@ -260174,15 +260053,15 @@ class PostHogBackendClient extends PostHogCoreStateless {
260174
260053
  return true;
260175
260054
  if (this.featureFlagsPoller === undefined)
260176
260055
  return false;
260177
- return new Promise((resolve11) => {
260056
+ return new Promise((resolve10) => {
260178
260057
  const timeout3 = setTimeout(() => {
260179
260058
  cleanup();
260180
- resolve11(false);
260059
+ resolve10(false);
260181
260060
  }, timeoutMs);
260182
260061
  const cleanup = this._events.on("localEvaluationFlagsLoaded", (count2) => {
260183
260062
  clearTimeout(timeout3);
260184
260063
  cleanup();
260185
- resolve11(count2 > 0);
260064
+ resolve10(count2 > 0);
260186
260065
  });
260187
260066
  });
260188
260067
  }
@@ -260966,9 +260845,9 @@ function addCommandInfoToErrorReporter(program2, errorReporter) {
260966
260845
  });
260967
260846
  }
260968
260847
  // src/cli/index.ts
260969
- var __dirname4 = dirname20(fileURLToPath6(import.meta.url));
260848
+ var __dirname4 = dirname19(fileURLToPath6(import.meta.url));
260970
260849
  async function runCLI(options8) {
260971
- ensureNpmAssets(join26(__dirname4, "../assets"));
260850
+ ensureNpmAssets(join25(__dirname4, "../assets"));
260972
260851
  const errorReporter = new ErrorReporter;
260973
260852
  errorReporter.registerProcessErrorHandlers();
260974
260853
  const isNonInteractive = !process.stdin.isTTY || !process.stdout.isTTY;
@@ -261005,4 +260884,4 @@ export {
261005
260884
  CLIExitError
261006
260885
  };
261007
260886
 
261008
- //# debugId=3D7486B2A6408CC364756E2164756E21
260887
+ //# debugId=8CB4CFE788FBDEB164756E2164756E21