base44 0.0.10 → 0.0.12

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.
Files changed (2) hide show
  1. package/dist/cli/index.js +966 -290
  2. package/package.json +3 -2
package/dist/cli/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from "node:module";
3
3
  import { EventEmitter, addAbortListener, on, once, setMaxListeners } from "node:events";
4
- import { ChildProcess, execFile, spawn, spawnSync } from "node:child_process";
4
+ import childProcess, { ChildProcess, execFile, spawn, spawnSync } from "node:child_process";
5
5
  import path, { basename, dirname, join, posix, resolve, win32 } from "node:path";
6
6
  import fs, { appendFileSync, createReadStream, createWriteStream, readFileSync, statSync, writeFileSync } from "node:fs";
7
7
  import y, { execArgv, execPath, hrtime, platform, stdin, stdout } from "node:process";
@@ -15,7 +15,7 @@ import fs$1 from "fs";
15
15
  import path$1, { dirname as dirname$1, parse } from "path";
16
16
  import { finished } from "node:stream/promises";
17
17
  import EE, { EventEmitter as EventEmitter$1 } from "events";
18
- import fsPromises, { access, copyFile, mkdir, readFile, unlink, writeFile } from "node:fs/promises";
18
+ import fs$2, { access, constants as constants$1, copyFile, mkdir, readFile, unlink, writeFile } from "node:fs/promises";
19
19
  import { Buffer as Buffer$1 } from "buffer";
20
20
  import tty from "node:tty";
21
21
  import { randomBytes, randomUUID } from "node:crypto";
@@ -891,9 +891,9 @@ var require_suggestSimilar = /* @__PURE__ */ __commonJSMin(((exports) => {
891
891
  //#region node_modules/commander/lib/command.js
892
892
  var require_command = /* @__PURE__ */ __commonJSMin(((exports) => {
893
893
  const EventEmitter$2 = __require("node:events").EventEmitter;
894
- const childProcess = __require("node:child_process");
894
+ const childProcess$1 = __require("node:child_process");
895
895
  const path$16 = __require("node:path");
896
- const fs$10 = __require("node:fs");
896
+ const fs$11 = __require("node:fs");
897
897
  const process$3 = __require("node:process");
898
898
  const { Argument, humanReadableArgName } = require_argument();
899
899
  const { CommanderError } = require_error$1();
@@ -1741,9 +1741,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
1741
1741
  ];
1742
1742
  function findFile(baseDir, baseName) {
1743
1743
  const localBin = path$16.resolve(baseDir, baseName);
1744
- if (fs$10.existsSync(localBin)) return localBin;
1744
+ if (fs$11.existsSync(localBin)) return localBin;
1745
1745
  if (sourceExt.includes(path$16.extname(baseName))) return void 0;
1746
- const foundExt = sourceExt.find((ext) => fs$10.existsSync(`${localBin}${ext}`));
1746
+ const foundExt = sourceExt.find((ext) => fs$11.existsSync(`${localBin}${ext}`));
1747
1747
  if (foundExt) return `${localBin}${foundExt}`;
1748
1748
  }
1749
1749
  this._checkForMissingMandatoryOptions();
@@ -1753,7 +1753,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1753
1753
  if (this._scriptPath) {
1754
1754
  let resolvedScriptPath;
1755
1755
  try {
1756
- resolvedScriptPath = fs$10.realpathSync(this._scriptPath);
1756
+ resolvedScriptPath = fs$11.realpathSync(this._scriptPath);
1757
1757
  } catch (err) {
1758
1758
  resolvedScriptPath = this._scriptPath;
1759
1759
  }
@@ -1772,12 +1772,12 @@ Expecting one of '${allowedValues.join("', '")}'`);
1772
1772
  if (process$3.platform !== "win32") if (launchWithNode) {
1773
1773
  args.unshift(executableFile);
1774
1774
  args = incrementNodeInspectorPort(process$3.execArgv).concat(args);
1775
- proc$1 = childProcess.spawn(process$3.argv[0], args, { stdio: "inherit" });
1776
- } else proc$1 = childProcess.spawn(executableFile, args, { stdio: "inherit" });
1775
+ proc$1 = childProcess$1.spawn(process$3.argv[0], args, { stdio: "inherit" });
1776
+ } else proc$1 = childProcess$1.spawn(executableFile, args, { stdio: "inherit" });
1777
1777
  else {
1778
1778
  args.unshift(executableFile);
1779
1779
  args = incrementNodeInspectorPort(process$3.execArgv).concat(args);
1780
- proc$1 = childProcess.spawn(process$3.execPath, args, { stdio: "inherit" });
1780
+ proc$1 = childProcess$1.spawn(process$3.execPath, args, { stdio: "inherit" });
1781
1781
  }
1782
1782
  if (!proc$1.killed) [
1783
1783
  "SIGUSR1",
@@ -2767,9 +2767,9 @@ var require_src = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2767
2767
  var require_picocolors = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2768
2768
  let p = process || {}, argv = p.argv || [], env = p.env || {};
2769
2769
  let isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
2770
- let formatter = (open, close, replace$1 = open) => (input) => {
2771
- let string$2 = "" + input, index = string$2.indexOf(close, open.length);
2772
- return ~index ? open + replaceClose(string$2, close, replace$1, index) + close : open + string$2 + close;
2770
+ let formatter = (open$1, close, replace$1 = open$1) => (input) => {
2771
+ let string$2 = "" + input, index = string$2.indexOf(close, open$1.length);
2772
+ return ~index ? open$1 + replaceClose(string$2, close, replace$1, index) + close : open$1 + string$2 + close;
2773
2773
  };
2774
2774
  let replaceClose = (string$2, close, replace$1, index) => {
2775
2775
  let result = "", cursor = 0;
@@ -4547,7 +4547,6 @@ const string$1 = (params) => {
4547
4547
  };
4548
4548
  const integer = /^-?\d+$/;
4549
4549
  const number$1 = /^-?\d+(?:\.\d+)?$/;
4550
- const boolean$1 = /^(?:true|false)$/i;
4551
4550
  const lowercase = /^[^A-Z]*$/;
4552
4551
  const uppercase = /^[^a-z]*$/;
4553
4552
 
@@ -5326,24 +5325,6 @@ const $ZodNumberFormat = /* @__PURE__ */ $constructor("$ZodNumberFormat", (inst,
5326
5325
  $ZodCheckNumberFormat.init(inst, def);
5327
5326
  $ZodNumber.init(inst, def);
5328
5327
  });
5329
- const $ZodBoolean = /* @__PURE__ */ $constructor("$ZodBoolean", (inst, def) => {
5330
- $ZodType.init(inst, def);
5331
- inst._zod.pattern = boolean$1;
5332
- inst._zod.parse = (payload, _ctx) => {
5333
- if (def.coerce) try {
5334
- payload.value = Boolean(payload.value);
5335
- } catch (_$2) {}
5336
- const input = payload.value;
5337
- if (typeof input === "boolean") return payload;
5338
- payload.issues.push({
5339
- expected: "boolean",
5340
- code: "invalid_type",
5341
- input,
5342
- inst
5343
- });
5344
- return payload;
5345
- };
5346
- });
5347
5328
  const $ZodUnknown = /* @__PURE__ */ $constructor("$ZodUnknown", (inst, def) => {
5348
5329
  $ZodType.init(inst, def);
5349
5330
  inst._zod.parse = (payload) => payload;
@@ -5649,61 +5630,6 @@ const $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
5649
5630
  });
5650
5631
  };
5651
5632
  });
5652
- const $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnion", (inst, def) => {
5653
- def.inclusive = false;
5654
- $ZodUnion.init(inst, def);
5655
- const _super = inst._zod.parse;
5656
- defineLazy(inst._zod, "propValues", () => {
5657
- const propValues = {};
5658
- for (const option of def.options) {
5659
- const pv = option._zod.propValues;
5660
- if (!pv || Object.keys(pv).length === 0) throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
5661
- for (const [k$2, v$1] of Object.entries(pv)) {
5662
- if (!propValues[k$2]) propValues[k$2] = /* @__PURE__ */ new Set();
5663
- for (const val of v$1) propValues[k$2].add(val);
5664
- }
5665
- }
5666
- return propValues;
5667
- });
5668
- const disc = cached(() => {
5669
- const opts = def.options;
5670
- const map = /* @__PURE__ */ new Map();
5671
- for (const o$2 of opts) {
5672
- const values = o$2._zod.propValues?.[def.discriminator];
5673
- if (!values || values.size === 0) throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o$2)}"`);
5674
- for (const v$1 of values) {
5675
- if (map.has(v$1)) throw new Error(`Duplicate discriminator value "${String(v$1)}"`);
5676
- map.set(v$1, o$2);
5677
- }
5678
- }
5679
- return map;
5680
- });
5681
- inst._zod.parse = (payload, ctx) => {
5682
- const input = payload.value;
5683
- if (!isObject$2(input)) {
5684
- payload.issues.push({
5685
- code: "invalid_type",
5686
- expected: "object",
5687
- input,
5688
- inst
5689
- });
5690
- return payload;
5691
- }
5692
- const opt = disc.value.get(input?.[def.discriminator]);
5693
- if (opt) return opt._zod.run(payload, ctx);
5694
- if (def.unionFallback) return _super(payload, ctx);
5695
- payload.issues.push({
5696
- code: "invalid_union",
5697
- errors: [],
5698
- note: "No matching discriminator",
5699
- discriminator: def.discriminator,
5700
- input,
5701
- path: [def.discriminator],
5702
- inst
5703
- });
5704
- return payload;
5705
- };
5706
- });
5707
5633
  const $ZodIntersection = /* @__PURE__ */ $constructor("$ZodIntersection", (inst, def) => {
5708
5634
  $ZodType.init(inst, def);
5709
5635
  inst._zod.parse = (payload, ctx) => {
@@ -5803,6 +5729,77 @@ function handleIntersectionResults(result, left, right) {
5803
5729
  result.value = merged.data;
5804
5730
  return result;
5805
5731
  }
5732
+ const $ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
5733
+ $ZodType.init(inst, def);
5734
+ const items = def.items;
5735
+ inst._zod.parse = (payload, ctx) => {
5736
+ const input = payload.value;
5737
+ if (!Array.isArray(input)) {
5738
+ payload.issues.push({
5739
+ input,
5740
+ inst,
5741
+ expected: "tuple",
5742
+ code: "invalid_type"
5743
+ });
5744
+ return payload;
5745
+ }
5746
+ payload.value = [];
5747
+ const proms = [];
5748
+ const reversedIndex = [...items].reverse().findIndex((item) => item._zod.optin !== "optional");
5749
+ const optStart = reversedIndex === -1 ? 0 : items.length - reversedIndex;
5750
+ if (!def.rest) {
5751
+ const tooBig = input.length > items.length;
5752
+ const tooSmall = input.length < optStart - 1;
5753
+ if (tooBig || tooSmall) {
5754
+ payload.issues.push({
5755
+ ...tooBig ? {
5756
+ code: "too_big",
5757
+ maximum: items.length,
5758
+ inclusive: true
5759
+ } : {
5760
+ code: "too_small",
5761
+ minimum: items.length
5762
+ },
5763
+ input,
5764
+ inst,
5765
+ origin: "array"
5766
+ });
5767
+ return payload;
5768
+ }
5769
+ }
5770
+ let i$1 = -1;
5771
+ for (const item of items) {
5772
+ i$1++;
5773
+ if (i$1 >= input.length) {
5774
+ if (i$1 >= optStart) continue;
5775
+ }
5776
+ const result = item._zod.run({
5777
+ value: input[i$1],
5778
+ issues: []
5779
+ }, ctx);
5780
+ if (result instanceof Promise) proms.push(result.then((result$1) => handleTupleResult(result$1, payload, i$1)));
5781
+ else handleTupleResult(result, payload, i$1);
5782
+ }
5783
+ if (def.rest) {
5784
+ const rest = input.slice(items.length);
5785
+ for (const el of rest) {
5786
+ i$1++;
5787
+ const result = def.rest._zod.run({
5788
+ value: el,
5789
+ issues: []
5790
+ }, ctx);
5791
+ if (result instanceof Promise) proms.push(result.then((result$1) => handleTupleResult(result$1, payload, i$1)));
5792
+ else handleTupleResult(result, payload, i$1);
5793
+ }
5794
+ }
5795
+ if (proms.length) return Promise.all(proms).then(() => payload);
5796
+ return payload;
5797
+ };
5798
+ });
5799
+ function handleTupleResult(result, final, index) {
5800
+ if (result.issues.length) final.issues.push(...prefixIssues(index, result.issues));
5801
+ final.value[index] = result.value;
5802
+ }
5806
5803
  const $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
5807
5804
  $ZodType.init(inst, def);
5808
5805
  const values = getEnumValues(def.entries);
@@ -5821,24 +5818,6 @@ const $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
5821
5818
  return payload;
5822
5819
  };
5823
5820
  });
5824
- const $ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
5825
- $ZodType.init(inst, def);
5826
- if (def.values.length === 0) throw new Error("Cannot create literal schema with no valid values");
5827
- const values = new Set(def.values);
5828
- inst._zod.values = values;
5829
- inst._zod.pattern = /* @__PURE__ */ new RegExp(`^(${def.values.map((o$2) => typeof o$2 === "string" ? escapeRegex(o$2) : o$2 ? escapeRegex(o$2.toString()) : String(o$2)).join("|")})$`);
5830
- inst._zod.parse = (payload, _ctx) => {
5831
- const input = payload.value;
5832
- if (values.has(input)) return payload;
5833
- payload.issues.push({
5834
- code: "invalid_value",
5835
- values: def.values,
5836
- input,
5837
- inst
5838
- });
5839
- return payload;
5840
- };
5841
- });
5842
5821
  const $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def) => {
5843
5822
  $ZodType.init(inst, def);
5844
5823
  inst._zod.parse = (payload, ctx) => {
@@ -6400,13 +6379,6 @@ function _int(Class, params) {
6400
6379
  });
6401
6380
  }
6402
6381
  /* @__NO_SIDE_EFFECTS__ */
6403
- function _boolean(Class, params) {
6404
- return new Class({
6405
- type: "boolean",
6406
- ...normalizeParams(params)
6407
- });
6408
- }
6409
- /* @__NO_SIDE_EFFECTS__ */
6410
6382
  function _unknown(Class) {
6411
6383
  return new Class({ type: "unknown" });
6412
6384
  }
@@ -6977,9 +6949,6 @@ const numberProcessor = (schema, ctx, _json, _params) => {
6977
6949
  }
6978
6950
  if (typeof multipleOf === "number") json.multipleOf = multipleOf;
6979
6951
  };
6980
- const booleanProcessor = (_schema, _ctx, json, _params) => {
6981
- json.type = "boolean";
6982
- };
6983
6952
  const neverProcessor = (_schema, _ctx, json, _params) => {
6984
6953
  json.not = {};
6985
6954
  };
@@ -6991,27 +6960,6 @@ const enumProcessor = (schema, _ctx, json, _params) => {
6991
6960
  if (values.every((v$1) => typeof v$1 === "string")) json.type = "string";
6992
6961
  json.enum = values;
6993
6962
  };
6994
- const literalProcessor = (schema, ctx, json, _params) => {
6995
- const def = schema._zod.def;
6996
- const vals = [];
6997
- for (const val of def.values) if (val === void 0) {
6998
- if (ctx.unrepresentable === "throw") throw new Error("Literal `undefined` cannot be represented in JSON Schema");
6999
- } else if (typeof val === "bigint") if (ctx.unrepresentable === "throw") throw new Error("BigInt literals cannot be represented in JSON Schema");
7000
- else vals.push(Number(val));
7001
- else vals.push(val);
7002
- if (vals.length === 0) {} else if (vals.length === 1) {
7003
- const val = vals[0];
7004
- json.type = val === null ? "null" : typeof val;
7005
- if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") json.enum = [val];
7006
- else json.const = val;
7007
- } else {
7008
- if (vals.every((v$1) => typeof v$1 === "number")) json.type = "number";
7009
- if (vals.every((v$1) => typeof v$1 === "string")) json.type = "string";
7010
- if (vals.every((v$1) => typeof v$1 === "boolean")) json.type = "boolean";
7011
- if (vals.every((v$1) => v$1 === null)) json.type = "null";
7012
- json.enum = vals;
7013
- }
7014
- };
7015
6963
  const customProcessor = (_schema, ctx, _json, _params) => {
7016
6964
  if (ctx.unrepresentable === "throw") throw new Error("Custom types cannot be represented in JSON Schema");
7017
6965
  };
@@ -7094,6 +7042,44 @@ const intersectionProcessor = (schema, ctx, json, params) => {
7094
7042
  const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
7095
7043
  json.allOf = [...isSimpleIntersection(a$1) ? a$1.allOf : [a$1], ...isSimpleIntersection(b$2) ? b$2.allOf : [b$2]];
7096
7044
  };
7045
+ const tupleProcessor = (schema, ctx, _json, params) => {
7046
+ const json = _json;
7047
+ const def = schema._zod.def;
7048
+ json.type = "array";
7049
+ const prefixPath$1 = ctx.target === "draft-2020-12" ? "prefixItems" : "items";
7050
+ const restPath = ctx.target === "draft-2020-12" ? "items" : ctx.target === "openapi-3.0" ? "items" : "additionalItems";
7051
+ const prefixItems = def.items.map((x$2, i$1) => process$2(x$2, ctx, {
7052
+ ...params,
7053
+ path: [
7054
+ ...params.path,
7055
+ prefixPath$1,
7056
+ i$1
7057
+ ]
7058
+ }));
7059
+ const rest = def.rest ? process$2(def.rest, ctx, {
7060
+ ...params,
7061
+ path: [
7062
+ ...params.path,
7063
+ restPath,
7064
+ ...ctx.target === "openapi-3.0" ? [def.items.length] : []
7065
+ ]
7066
+ }) : null;
7067
+ if (ctx.target === "draft-2020-12") {
7068
+ json.prefixItems = prefixItems;
7069
+ if (rest) json.items = rest;
7070
+ } else if (ctx.target === "openapi-3.0") {
7071
+ json.items = { anyOf: prefixItems };
7072
+ if (rest) json.items.anyOf.push(rest);
7073
+ json.minItems = prefixItems.length;
7074
+ if (!rest) json.maxItems = prefixItems.length;
7075
+ } else {
7076
+ json.items = prefixItems;
7077
+ if (rest) json.additionalItems = rest;
7078
+ }
7079
+ const { minimum, maximum } = schema._zod.bag;
7080
+ if (typeof minimum === "number") json.minItems = minimum;
7081
+ if (typeof maximum === "number") json.maxItems = maximum;
7082
+ };
7097
7083
  const nullableProcessor = (schema, ctx, json, params) => {
7098
7084
  const def = schema._zod.def;
7099
7085
  const inner = process$2(def.innerType, ctx, params);
@@ -7486,14 +7472,6 @@ const ZodNumberFormat = /* @__PURE__ */ $constructor("ZodNumberFormat", (inst, d
7486
7472
  function int(params) {
7487
7473
  return _int(ZodNumberFormat, params);
7488
7474
  }
7489
- const ZodBoolean = /* @__PURE__ */ $constructor("ZodBoolean", (inst, def) => {
7490
- $ZodBoolean.init(inst, def);
7491
- ZodType.init(inst, def);
7492
- inst._zod.processJSONSchema = (ctx, json, params) => booleanProcessor(inst, ctx, json, params);
7493
- });
7494
- function boolean(params) {
7495
- return _boolean(ZodBoolean, params);
7496
- }
7497
7475
  const ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
7498
7476
  $ZodUnknown.init(inst, def);
7499
7477
  ZodType.init(inst, def);
@@ -7592,18 +7570,6 @@ function union(options, params) {
7592
7570
  ...normalizeParams(params)
7593
7571
  });
7594
7572
  }
7595
- const ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("ZodDiscriminatedUnion", (inst, def) => {
7596
- ZodUnion.init(inst, def);
7597
- $ZodDiscriminatedUnion.init(inst, def);
7598
- });
7599
- function discriminatedUnion(discriminator, options, params) {
7600
- return new ZodDiscriminatedUnion({
7601
- type: "union",
7602
- options,
7603
- discriminator,
7604
- ...normalizeParams(params)
7605
- });
7606
- }
7607
7573
  const ZodIntersection = /* @__PURE__ */ $constructor("ZodIntersection", (inst, def) => {
7608
7574
  $ZodIntersection.init(inst, def);
7609
7575
  ZodType.init(inst, def);
@@ -7616,6 +7582,25 @@ function intersection(left, right) {
7616
7582
  right
7617
7583
  });
7618
7584
  }
7585
+ const ZodTuple = /* @__PURE__ */ $constructor("ZodTuple", (inst, def) => {
7586
+ $ZodTuple.init(inst, def);
7587
+ ZodType.init(inst, def);
7588
+ inst._zod.processJSONSchema = (ctx, json, params) => tupleProcessor(inst, ctx, json, params);
7589
+ inst.rest = (rest) => inst.clone({
7590
+ ...inst._zod.def,
7591
+ rest
7592
+ });
7593
+ });
7594
+ function tuple(items, _paramsOrRest, _params) {
7595
+ const hasRest = _paramsOrRest instanceof $ZodType;
7596
+ const params = hasRest ? _params : _paramsOrRest;
7597
+ return new ZodTuple({
7598
+ type: "tuple",
7599
+ items,
7600
+ rest: hasRest ? _paramsOrRest : null,
7601
+ ...normalizeParams(params)
7602
+ });
7603
+ }
7619
7604
  const ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
7620
7605
  $ZodEnum.init(inst, def);
7621
7606
  ZodType.init(inst, def);
@@ -7653,23 +7638,6 @@ function _enum(values, params) {
7653
7638
  ...normalizeParams(params)
7654
7639
  });
7655
7640
  }
7656
- const ZodLiteral = /* @__PURE__ */ $constructor("ZodLiteral", (inst, def) => {
7657
- $ZodLiteral.init(inst, def);
7658
- ZodType.init(inst, def);
7659
- inst._zod.processJSONSchema = (ctx, json, params) => literalProcessor(inst, ctx, json, params);
7660
- inst.values = new Set(def.values);
7661
- Object.defineProperty(inst, "value", { get() {
7662
- if (def.values.length > 1) throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");
7663
- return def.values[0];
7664
- } });
7665
- });
7666
- function literal(value, params) {
7667
- return new ZodLiteral({
7668
- type: "literal",
7669
- values: Array.isArray(value) ? value : [value],
7670
- ...normalizeParams(params)
7671
- });
7672
- }
7673
7641
  const ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
7674
7642
  $ZodTransform.init(inst, def);
7675
7643
  ZodType.init(inst, def);
@@ -8802,7 +8770,7 @@ var require_package$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8802
8770
  //#endregion
8803
8771
  //#region node_modules/dotenv/lib/main.js
8804
8772
  var require_main = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8805
- const fs$9 = __require("fs");
8773
+ const fs$10 = __require("fs");
8806
8774
  const path$15 = __require("path");
8807
8775
  const os$3 = __require("os");
8808
8776
  const crypto = __require("crypto");
@@ -8939,10 +8907,10 @@ var require_main = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8939
8907
  function _vaultPath(options) {
8940
8908
  let possibleVaultPath = null;
8941
8909
  if (options && options.path && options.path.length > 0) if (Array.isArray(options.path)) {
8942
- for (const filepath of options.path) if (fs$9.existsSync(filepath)) possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
8910
+ for (const filepath of options.path) if (fs$10.existsSync(filepath)) possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
8943
8911
  } else possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
8944
8912
  else possibleVaultPath = path$15.resolve(process.cwd(), ".env.vault");
8945
- if (fs$9.existsSync(possibleVaultPath)) return possibleVaultPath;
8913
+ if (fs$10.existsSync(possibleVaultPath)) return possibleVaultPath;
8946
8914
  return null;
8947
8915
  }
8948
8916
  function _resolveHome(envPath) {
@@ -8976,7 +8944,7 @@ var require_main = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8976
8944
  let lastError;
8977
8945
  const parsedAll = {};
8978
8946
  for (const path$17 of optionPaths) try {
8979
- const parsed = DotenvModule.parse(fs$9.readFileSync(path$17, { encoding }));
8947
+ const parsed = DotenvModule.parse(fs$10.readFileSync(path$17, { encoding }));
8980
8948
  DotenvModule.populate(parsedAll, parsed, options);
8981
8949
  } catch (e$1) {
8982
8950
  if (debug) _debug(`Failed to load ${path$17} ${e$1.message}`);
@@ -9446,9 +9414,9 @@ var require_is_glob = /* @__PURE__ */ __commonJSMin(((exports, module) => {
9446
9414
  }
9447
9415
  }
9448
9416
  if (str[index] === "\\") {
9449
- var open = str[index + 1];
9417
+ var open$1 = str[index + 1];
9450
9418
  index += 2;
9451
- var close = chars[open];
9419
+ var close = chars[open$1];
9452
9420
  if (close) {
9453
9421
  var n$1 = str.indexOf(close, index);
9454
9422
  if (n$1 !== -1) index = n$1 + 1;
@@ -9464,9 +9432,9 @@ var require_is_glob = /* @__PURE__ */ __commonJSMin(((exports, module) => {
9464
9432
  while (index < str.length) {
9465
9433
  if (/[*?{}()[\]]/.test(str[index])) return true;
9466
9434
  if (str[index] === "\\") {
9467
- var open = str[index + 1];
9435
+ var open$1 = str[index + 1];
9468
9436
  index += 2;
9469
- var close = chars[open];
9437
+ var close = chars[open$1];
9470
9438
  if (close) {
9471
9439
  var n$1 = str.indexOf(close, index);
9472
9440
  if (n$1 !== -1) index = n$1 + 1;
@@ -10318,7 +10286,7 @@ var require_parse$3 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
10318
10286
  * Quotes: '|"|`
10319
10287
  */
10320
10288
  if (value === CHAR_DOUBLE_QUOTE || value === CHAR_SINGLE_QUOTE || value === CHAR_BACKTICK) {
10321
- const open = value;
10289
+ const open$1 = value;
10322
10290
  let next;
10323
10291
  if (options.keepQuotes !== true) value = "";
10324
10292
  while (index < length && (next = advance())) {
@@ -10326,7 +10294,7 @@ var require_parse$3 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
10326
10294
  value += next + advance();
10327
10295
  continue;
10328
10296
  }
10329
- if (next === open) {
10297
+ if (next === open$1) {
10330
10298
  if (options.keepQuotes === true) value += next;
10331
10299
  break;
10332
10300
  }
@@ -10388,8 +10356,8 @@ var require_parse$3 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
10388
10356
  if (value === CHAR_COMMA && depth > 0) {
10389
10357
  if (block.ranges > 0) {
10390
10358
  block.ranges = 0;
10391
- const open = block.nodes.shift();
10392
- block.nodes = [open, {
10359
+ const open$1 = block.nodes.shift();
10360
+ block.nodes = [open$1, {
10393
10361
  type: "text",
10394
10362
  value: stringify(block)
10395
10363
  }];
@@ -11494,15 +11462,15 @@ var require_parse$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
11494
11462
  */
11495
11463
  if (value === "{" && opts.nobrace !== true) {
11496
11464
  increment$1("braces");
11497
- const open = {
11465
+ const open$1 = {
11498
11466
  type: "brace",
11499
11467
  value,
11500
11468
  output: "(",
11501
11469
  outputIndex: state.output.length,
11502
11470
  tokensIndex: state.tokens.length
11503
11471
  };
11504
- braces.push(open);
11505
- push$1(open);
11472
+ braces.push(open$1);
11473
+ push$1(open$1);
11506
11474
  continue;
11507
11475
  }
11508
11476
  if (value === "}") {
@@ -13142,12 +13110,12 @@ var require_sync$5 = /* @__PURE__ */ __commonJSMin(((exports) => {
13142
13110
  var require_fs$2 = /* @__PURE__ */ __commonJSMin(((exports) => {
13143
13111
  Object.defineProperty(exports, "__esModule", { value: true });
13144
13112
  exports.createFileSystemAdapter = exports.FILE_SYSTEM_ADAPTER = void 0;
13145
- const fs$8 = __require("fs");
13113
+ const fs$9 = __require("fs");
13146
13114
  exports.FILE_SYSTEM_ADAPTER = {
13147
- lstat: fs$8.lstat,
13148
- stat: fs$8.stat,
13149
- lstatSync: fs$8.lstatSync,
13150
- statSync: fs$8.statSync
13115
+ lstat: fs$9.lstat,
13116
+ stat: fs$9.stat,
13117
+ lstatSync: fs$9.lstatSync,
13118
+ statSync: fs$9.statSync
13151
13119
  };
13152
13120
  function createFileSystemAdapter(fsMethods) {
13153
13121
  if (fsMethods === void 0) return exports.FILE_SYSTEM_ADAPTER;
@@ -13480,14 +13448,14 @@ var require_sync$4 = /* @__PURE__ */ __commonJSMin(((exports) => {
13480
13448
  var require_fs = /* @__PURE__ */ __commonJSMin(((exports) => {
13481
13449
  Object.defineProperty(exports, "__esModule", { value: true });
13482
13450
  exports.createFileSystemAdapter = exports.FILE_SYSTEM_ADAPTER = void 0;
13483
- const fs$7 = __require("fs");
13451
+ const fs$8 = __require("fs");
13484
13452
  exports.FILE_SYSTEM_ADAPTER = {
13485
- lstat: fs$7.lstat,
13486
- stat: fs$7.stat,
13487
- lstatSync: fs$7.lstatSync,
13488
- statSync: fs$7.statSync,
13489
- readdir: fs$7.readdir,
13490
- readdirSync: fs$7.readdirSync
13453
+ lstat: fs$8.lstat,
13454
+ stat: fs$8.stat,
13455
+ lstatSync: fs$8.lstatSync,
13456
+ statSync: fs$8.statSync,
13457
+ readdir: fs$8.readdir,
13458
+ readdirSync: fs$8.readdirSync
13491
13459
  };
13492
13460
  function createFileSystemAdapter(fsMethods) {
13493
13461
  if (fsMethods === void 0) return exports.FILE_SYSTEM_ADAPTER;
@@ -14709,7 +14677,7 @@ var require_sync = /* @__PURE__ */ __commonJSMin(((exports) => {
14709
14677
  var require_settings = /* @__PURE__ */ __commonJSMin(((exports) => {
14710
14678
  Object.defineProperty(exports, "__esModule", { value: true });
14711
14679
  exports.DEFAULT_FILE_SYSTEM_ADAPTER = void 0;
14712
- const fs$6 = __require("fs");
14680
+ const fs$7 = __require("fs");
14713
14681
  const os$1 = __require("os");
14714
14682
  /**
14715
14683
  * The `os.cpus` method can return zero. We expect the number of cores to be greater than zero.
@@ -14717,12 +14685,12 @@ var require_settings = /* @__PURE__ */ __commonJSMin(((exports) => {
14717
14685
  */
14718
14686
  const CPU_COUNT = Math.max(os$1.cpus().length, 1);
14719
14687
  exports.DEFAULT_FILE_SYSTEM_ADAPTER = {
14720
- lstat: fs$6.lstat,
14721
- lstatSync: fs$6.lstatSync,
14722
- stat: fs$6.stat,
14723
- statSync: fs$6.statSync,
14724
- readdir: fs$6.readdir,
14725
- readdirSync: fs$6.readdirSync
14688
+ lstat: fs$7.lstat,
14689
+ lstatSync: fs$7.lstatSync,
14690
+ stat: fs$7.stat,
14691
+ statSync: fs$7.statSync,
14692
+ readdir: fs$7.readdir,
14693
+ readdirSync: fs$7.readdirSync
14726
14694
  };
14727
14695
  var Settings = class {
14728
14696
  constructor(_options = {}) {
@@ -15301,7 +15269,7 @@ const ignoreFilesGlobOptions = {
15301
15269
  dot: true
15302
15270
  };
15303
15271
  const GITIGNORE_FILES_PATTERN = "**/.gitignore";
15304
- const getReadFileMethod = (fsImplementation) => bindFsMethod(fsImplementation?.promises, "readFile") ?? bindFsMethod(fsPromises, "readFile") ?? promisifyFsMethod(fsImplementation, "readFile");
15272
+ const getReadFileMethod = (fsImplementation) => bindFsMethod(fsImplementation?.promises, "readFile") ?? bindFsMethod(fs$2, "readFile") ?? promisifyFsMethod(fsImplementation, "readFile");
15305
15273
  const getReadFileSyncMethod = (fsImplementation) => bindFsMethod(fsImplementation, "readFileSync") ?? bindFsMethod(fs, "readFileSync");
15306
15274
  const shouldSkipIgnoreFileError = (error, suppressErrors) => {
15307
15275
  if (!error) return Boolean(suppressErrors);
@@ -16717,6 +16685,14 @@ async function readFile$1(filePath) {
16717
16685
  throw new Error(`Failed to read file ${filePath}: ${error instanceof Error ? error.message : "Unknown error"}`);
16718
16686
  }
16719
16687
  }
16688
+ async function readTextFile(filePath) {
16689
+ if (!await pathExists(filePath)) throw new Error(`File not found: ${filePath}`);
16690
+ try {
16691
+ return await readFile(filePath, "utf-8");
16692
+ } catch (error) {
16693
+ throw new Error(`Failed to read file ${filePath}: ${error instanceof Error ? error.message : "Unknown error"}`);
16694
+ }
16695
+ }
16720
16696
  async function readJsonFile(filePath) {
16721
16697
  if (!await pathExists(filePath)) throw new Error(`File not found: ${filePath}`);
16722
16698
  try {
@@ -16789,39 +16765,19 @@ const entityResource = {
16789
16765
 
16790
16766
  //#endregion
16791
16767
  //#region src/core/resources/function/schema.ts
16792
- const HttpTriggerSchema = object({
16793
- id: string().optional(),
16794
- name: string().optional(),
16795
- description: string().optional(),
16796
- type: literal("http"),
16797
- path: string().min(1, "Path cannot be empty")
16798
- });
16799
- const ScheduleTriggerSchema = object({
16800
- id: string().optional(),
16801
- name: string().optional(),
16802
- description: string().optional(),
16803
- type: literal("schedule"),
16804
- scheduleMode: _enum(["recurring", "once"]).optional(),
16805
- cron: string().min(1, "Cron expression cannot be empty"),
16806
- isActive: boolean().optional(),
16807
- timezone: string().optional()
16808
- });
16809
- const EventTriggerSchema = object({
16810
- id: string().optional(),
16811
- name: string().optional(),
16812
- description: string().optional(),
16813
- type: literal("event"),
16814
- entity: string().min(1, "Entity name cannot be empty"),
16815
- event: string().min(1, "Event type cannot be empty")
16816
- });
16817
- const TriggerSchema = discriminatedUnion("type", [
16818
- HttpTriggerSchema,
16819
- ScheduleTriggerSchema,
16820
- EventTriggerSchema
16821
- ]);
16822
16768
  const FunctionConfigSchema = object({
16769
+ name: string().min(1, "Function name cannot be empty").refine((name$1) => !name$1.includes("."), "Function name cannot contain dots"),
16823
16770
  entry: string().min(1, "Entry point cannot be empty"),
16824
- triggers: array(TriggerSchema).optional()
16771
+ triggers: tuple([]).optional()
16772
+ });
16773
+ const FunctionSchema = FunctionConfigSchema.extend({ codePath: string().min(1, "Code path cannot be empty") });
16774
+ const DeployFunctionsResponseSchema = object({
16775
+ deployed: array(string()),
16776
+ deleted: array(string()),
16777
+ errors: array(object({
16778
+ name: string(),
16779
+ message: string()
16780
+ })).nullable()
16825
16781
  });
16826
16782
 
16827
16783
  //#endregion
@@ -16829,7 +16785,19 @@ const FunctionConfigSchema = object({
16829
16785
  async function readFunctionConfig(configPath) {
16830
16786
  const parsed = await readJsonFile(configPath);
16831
16787
  const result = FunctionConfigSchema.safeParse(parsed);
16832
- if (!result.success) throw new Error(`Invalid function configuration in ${configPath}: ${result.error.issues.map((e$1) => e$1.message).join(", ")}`);
16788
+ if (!result.success) throw new Error(`Invalid function configuration in ${configPath}: ${result.error.message}`);
16789
+ return result.data;
16790
+ }
16791
+ async function readFunction(configPath) {
16792
+ const config$2 = await readFunctionConfig(configPath);
16793
+ const codePath = join(dirname(configPath), config$2.entry);
16794
+ if (!await pathExists(codePath)) throw new Error(`Function code file not found: ${codePath} (referenced in ${configPath})`);
16795
+ const functionData = {
16796
+ ...config$2,
16797
+ codePath
16798
+ };
16799
+ const result = FunctionSchema.safeParse(functionData);
16800
+ if (!result.success) throw new Error(`Invalid function in ${configPath}: ${result.error.message}`);
16833
16801
  return result.data;
16834
16802
  }
16835
16803
  async function readAllFunctions(functionsDir) {
@@ -16838,12 +16806,56 @@ async function readAllFunctions(functionsDir) {
16838
16806
  cwd: functionsDir,
16839
16807
  absolute: true
16840
16808
  });
16841
- return await Promise.all(configFiles.map((configPath) => readFunctionConfig(configPath)));
16809
+ const functions = await Promise.all(configFiles.map((configPath) => readFunction(configPath)));
16810
+ const names = /* @__PURE__ */ new Set();
16811
+ for (const fn of functions) {
16812
+ if (names.has(fn.name)) throw new Error(`Duplicate function name "${fn.name}"`);
16813
+ names.add(fn.name);
16814
+ }
16815
+ return functions;
16816
+ }
16817
+
16818
+ //#endregion
16819
+ //#region src/core/resources/function/api.ts
16820
+ function toDeployPayloadItem(fn) {
16821
+ return {
16822
+ name: fn.name,
16823
+ entry: fn.entry,
16824
+ files: [{
16825
+ path: fn.entry,
16826
+ content: fn.code
16827
+ }]
16828
+ };
16829
+ }
16830
+ async function deployFunctions(functions) {
16831
+ const appClient = getAppClient();
16832
+ const payload = { functions: functions.map(toDeployPayloadItem) };
16833
+ const response = await appClient.put("backend-functions", {
16834
+ json: payload,
16835
+ timeout: 12e4
16836
+ });
16837
+ return DeployFunctionsResponseSchema.parse(await response.json());
16838
+ }
16839
+
16840
+ //#endregion
16841
+ //#region src/core/resources/function/deploy.ts
16842
+ async function loadFunctionCode(fn) {
16843
+ const code$1 = await readTextFile(fn.codePath);
16844
+ return {
16845
+ ...fn,
16846
+ code: code$1
16847
+ };
16848
+ }
16849
+ async function pushFunctions(functions) {
16850
+ return deployFunctions(await Promise.all(functions.map(loadFunctionCode)));
16842
16851
  }
16843
16852
 
16844
16853
  //#endregion
16845
16854
  //#region src/core/resources/function/resource.ts
16846
- const functionResource = { readAll: readAllFunctions };
16855
+ const functionResource = {
16856
+ readAll: readAllFunctions,
16857
+ push: pushFunctions
16858
+ };
16847
16859
 
16848
16860
  //#endregion
16849
16861
  //#region src/core/project/schema.ts
@@ -17195,7 +17207,7 @@ var require_ejs = /* @__PURE__ */ __commonJSMin(((exports) => {
17195
17207
  * @module ejs
17196
17208
  * @public
17197
17209
  */
17198
- var fs$5 = __require("fs");
17210
+ var fs$6 = __require("fs");
17199
17211
  var path$5 = __require("path");
17200
17212
  var utils = require_utils();
17201
17213
  var scopeOptionWarned = false;
@@ -17237,7 +17249,7 @@ var require_ejs = /* @__PURE__ */ __commonJSMin(((exports) => {
17237
17249
  *
17238
17250
  * @type {fileLoader}
17239
17251
  */
17240
- exports.fileLoader = fs$5.readFileSync;
17252
+ exports.fileLoader = fs$6.readFileSync;
17241
17253
  /**
17242
17254
  * Name of the object containing the locals.
17243
17255
  *
@@ -17284,7 +17296,7 @@ var require_ejs = /* @__PURE__ */ __commonJSMin(((exports) => {
17284
17296
  var filePath;
17285
17297
  if (paths.some(function(v$1) {
17286
17298
  filePath = exports.resolveInclude(name$1, v$1, true);
17287
- return fs$5.existsSync(filePath);
17299
+ return fs$6.existsSync(filePath);
17288
17300
  })) return filePath;
17289
17301
  }
17290
17302
  /**
@@ -17306,7 +17318,7 @@ var require_ejs = /* @__PURE__ */ __commonJSMin(((exports) => {
17306
17318
  } else {
17307
17319
  if (options.filename) {
17308
17320
  filePath = exports.resolveInclude(path$17, options.filename);
17309
- if (fs$5.existsSync(filePath)) includePath = filePath;
17321
+ if (fs$6.existsSync(filePath)) includePath = filePath;
17310
17322
  }
17311
17323
  if (!includePath && Array.isArray(views)) includePath = resolvePaths(path$17, views);
17312
17324
  if (!includePath && typeof options.includer !== "function") throw new Error("Could not find the include file \"" + options.escapeFunction(path$17) + "\"");
@@ -17579,9 +17591,9 @@ var require_ejs = /* @__PURE__ */ __commonJSMin(((exports) => {
17579
17591
  createRegex: function() {
17580
17592
  var str = _REGEX_STRING;
17581
17593
  var delim = utils.escapeRegExpChars(this.opts.delimiter);
17582
- var open = utils.escapeRegExpChars(this.opts.openDelimiter);
17594
+ var open$1 = utils.escapeRegExpChars(this.opts.openDelimiter);
17583
17595
  var close = utils.escapeRegExpChars(this.opts.closeDelimiter);
17584
- str = str.replace(/%/g, delim).replace(/</g, open).replace(/>/g, close);
17596
+ str = str.replace(/%/g, delim).replace(/</g, open$1).replace(/>/g, close);
17585
17597
  return new RegExp(str);
17586
17598
  },
17587
17599
  compile: function() {
@@ -25520,9 +25532,30 @@ async function createProjectFiles(options) {
25520
25532
  };
25521
25533
  }
25522
25534
 
25535
+ //#endregion
25536
+ //#region src/core/project/env.ts
25537
+ const ENV_LOCAL_TEMPLATE = `# Base44 Project Environment Variables
25538
+ # This file contains environment-specific configuration for your Base44 project.
25539
+ # Do not commit this file to version control if it contains sensitive data.
25540
+
25541
+ # Your Base44 Application ID
25542
+ BASE44_CLIENT_ID={{projectId}}
25543
+ `;
25544
+ function generateEnvLocalContent(projectId) {
25545
+ return ENV_LOCAL_TEMPLATE.replace("{{projectId}}", projectId);
25546
+ }
25547
+ async function writeEnvLocal(projectRoot, projectId) {
25548
+ const envPath = getProjectEnvPath(projectRoot);
25549
+ await writeFile$1(envPath, generateEnvLocalContent(projectId));
25550
+ return envPath;
25551
+ }
25552
+ async function envLocalExists(projectRoot) {
25553
+ return pathExists(getProjectEnvPath(projectRoot));
25554
+ }
25555
+
25523
25556
  //#endregion
25524
25557
  //#region src/core/config.ts
25525
- const __dirname = dirname(fileURLToPath(import.meta.url));
25558
+ const __dirname$1 = dirname(fileURLToPath(import.meta.url));
25526
25559
  function getBase44GlobalDir() {
25527
25560
  return join(homedir(), ".base44");
25528
25561
  }
@@ -25530,11 +25563,14 @@ function getAuthFilePath() {
25530
25563
  return join(getBase44GlobalDir(), "auth", "auth.json");
25531
25564
  }
25532
25565
  function getTemplatesDir() {
25533
- return join(__dirname, "templates");
25566
+ return join(__dirname$1, "templates");
25534
25567
  }
25535
25568
  function getTemplatesIndexPath() {
25536
25569
  return join(getTemplatesDir(), "templates.json");
25537
25570
  }
25571
+ function getProjectEnvPath(projectRoot) {
25572
+ return join(projectRoot, PROJECT_SUBDIR, ".env.local");
25573
+ }
25538
25574
  /**
25539
25575
  * Load .env.local from the project root if it exists.
25540
25576
  * Values won't override existing process.env variables.
@@ -25543,7 +25579,7 @@ async function loadProjectEnv(projectRoot) {
25543
25579
  const found = projectRoot ? { root: projectRoot } : await findProjectRoot();
25544
25580
  if (!found) return;
25545
25581
  (0, import_main.config)({
25546
- path: join(found.root, PROJECT_SUBDIR, ".env.local"),
25582
+ path: getProjectEnvPath(found.root),
25547
25583
  override: false,
25548
25584
  quiet: true
25549
25585
  });
@@ -26143,18 +26179,18 @@ const proto = Object.defineProperties(() => {}, {
26143
26179
  }
26144
26180
  }
26145
26181
  });
26146
- const createStyler = (open, close, parent) => {
26182
+ const createStyler = (open$1, close, parent) => {
26147
26183
  let openAll;
26148
26184
  let closeAll;
26149
26185
  if (parent === void 0) {
26150
- openAll = open;
26186
+ openAll = open$1;
26151
26187
  closeAll = close;
26152
26188
  } else {
26153
- openAll = parent.openAll + open;
26189
+ openAll = parent.openAll + open$1;
26154
26190
  closeAll = close + parent.closeAll;
26155
26191
  }
26156
26192
  return {
26157
- open,
26193
+ open: open$1,
26158
26194
  close,
26159
26195
  openAll,
26160
26196
  closeAll,
@@ -27780,7 +27816,7 @@ const makeCommand = (syncFile, asyncFile, syncNoFile, asyncNoFile, validate$1) =
27780
27816
  /* c8 ignore start */
27781
27817
  const realZlibConstants = realZlib.constants || { ZLIB_VERNUM: 4736 };
27782
27818
  /* c8 ignore stop */
27783
- const constants$1 = Object.freeze(Object.assign(Object.create(null), {
27819
+ const constants$2 = Object.freeze(Object.assign(Object.create(null), {
27784
27820
  Z_NO_FLUSH: 0,
27785
27821
  Z_PARTIAL_FLUSH: 1,
27786
27822
  Z_SYNC_FLUSH: 2,
@@ -28042,9 +28078,9 @@ var Zlib = class extends ZlibBase {
28042
28078
  #strategy;
28043
28079
  constructor(opts, mode) {
28044
28080
  opts = opts || {};
28045
- opts.flush = opts.flush || constants$1.Z_NO_FLUSH;
28046
- opts.finishFlush = opts.finishFlush || constants$1.Z_FINISH;
28047
- opts.fullFlushFlag = constants$1.Z_FULL_FLUSH;
28081
+ opts.flush = opts.flush || constants$2.Z_NO_FLUSH;
28082
+ opts.finishFlush = opts.finishFlush || constants$2.Z_FINISH;
28083
+ opts.fullFlushFlag = constants$2.Z_FULL_FLUSH;
28048
28084
  super(opts, mode);
28049
28085
  this.#level = opts.level;
28050
28086
  this.#strategy = opts.strategy;
@@ -28056,7 +28092,7 @@ var Zlib = class extends ZlibBase {
28056
28092
  if (!this.handle.params) throw new Error("not supported in this implementation");
28057
28093
  /* c8 ignore stop */
28058
28094
  if (this.#level !== level || this.#strategy !== strategy) {
28059
- this.flush(constants$1.Z_SYNC_FLUSH);
28095
+ this.flush(constants$2.Z_SYNC_FLUSH);
28060
28096
  assert(this.handle, "zlib binding closed");
28061
28097
  const origFlush = this.handle.flush;
28062
28098
  this.handle.flush = (flushFlag, cb) => {
@@ -28103,9 +28139,9 @@ var Unzip = class extends Zlib {
28103
28139
  var Brotli = class extends ZlibBase {
28104
28140
  constructor(opts, mode) {
28105
28141
  opts = opts || {};
28106
- opts.flush = opts.flush || constants$1.BROTLI_OPERATION_PROCESS;
28107
- opts.finishFlush = opts.finishFlush || constants$1.BROTLI_OPERATION_FINISH;
28108
- opts.fullFlushFlag = constants$1.BROTLI_OPERATION_FLUSH;
28142
+ opts.flush = opts.flush || constants$2.BROTLI_OPERATION_PROCESS;
28143
+ opts.finishFlush = opts.finishFlush || constants$2.BROTLI_OPERATION_FINISH;
28144
+ opts.fullFlushFlag = constants$2.BROTLI_OPERATION_FLUSH;
28109
28145
  super(opts, mode);
28110
28146
  }
28111
28147
  };
@@ -28122,9 +28158,9 @@ var BrotliDecompress = class extends Brotli {
28122
28158
  var Zstd = class extends ZlibBase {
28123
28159
  constructor(opts, mode) {
28124
28160
  opts = opts || {};
28125
- opts.flush = opts.flush || constants$1.ZSTD_e_continue;
28126
- opts.finishFlush = opts.finishFlush || constants$1.ZSTD_e_end;
28127
- opts.fullFlushFlag = constants$1.ZSTD_e_flush;
28161
+ opts.flush = opts.flush || constants$2.ZSTD_e_continue;
28162
+ opts.finishFlush = opts.finishFlush || constants$2.ZSTD_e_end;
28163
+ opts.fullFlushFlag = constants$2.ZSTD_e_flush;
28128
28164
  super(opts, mode);
28129
28165
  }
28130
28166
  };
@@ -28510,8 +28546,8 @@ const parseKVLine = (set, line) => {
28510
28546
 
28511
28547
  //#endregion
28512
28548
  //#region node_modules/tar/dist/esm/normalize-windows-path.js
28513
- const platform$1 = process.env.TESTING_TAR_FAKE_PLATFORM || process.platform;
28514
- const normalizeWindowsPath = platform$1 !== "win32" ? (p$1) => p$1 : (p$1) => p$1 && p$1.replace(/\\/g, "/");
28549
+ const platform$2 = process.env.TESTING_TAR_FAKE_PLATFORM || process.platform;
28550
+ const normalizeWindowsPath = platform$2 !== "win32" ? (p$1) => p$1 : (p$1) => p$1 && p$1.replace(/\\/g, "/");
28515
28551
 
28516
28552
  //#endregion
28517
28553
  //#region node_modules/tar/dist/esm/read-entry.js
@@ -30475,7 +30511,7 @@ const mkdir$1 = (dir, opt, cb) => {
30475
30511
  else cb();
30476
30512
  };
30477
30513
  if (dir === cwd) return checkCwd(dir, done);
30478
- if (preserve) return fsPromises.mkdir(dir, {
30514
+ if (preserve) return fs$2.mkdir(dir, {
30479
30515
  mode,
30480
30516
  recursive: true
30481
30517
  }).then((made) => done(null, made ?? void 0), done);
@@ -31108,8 +31144,8 @@ var Unpack = class extends Parser {
31108
31144
  case "GNUDumpDir": return this[DIRECTORY](entry, done);
31109
31145
  }
31110
31146
  }
31111
- [LINK](entry, linkpath, link, done) {
31112
- fs[link](linkpath, String(entry.absolute), (er) => {
31147
+ [LINK](entry, linkpath, link$1, done) {
31148
+ fs[link$1](linkpath, String(entry.absolute), (er) => {
31113
31149
  if (er) this[ONERROR](er, entry);
31114
31150
  else {
31115
31151
  this[UNPEND]();
@@ -31256,8 +31292,8 @@ var UnpackSync = class extends Unpack {
31256
31292
  return er;
31257
31293
  }
31258
31294
  }
31259
- [LINK](entry, linkpath, link, done) {
31260
- const ls = `${link}Sync`;
31295
+ [LINK](entry, linkpath, link$1, done) {
31296
+ const ls = `${link$1}Sync`;
31261
31297
  try {
31262
31298
  fs[ls](linkpath, String(entry.absolute));
31263
31299
  done();
@@ -31503,6 +31539,30 @@ const entitiesPushCommand = new Command("entities").description("Manage project
31503
31539
  await runCommand(pushEntitiesAction, { requireAuth: true });
31504
31540
  }));
31505
31541
 
31542
+ //#endregion
31543
+ //#region src/cli/commands/functions/deploy.ts
31544
+ async function deployFunctionsAction() {
31545
+ const { functions } = await readProjectConfig();
31546
+ if (functions.length === 0) return { outroMessage: "No functions found. Create functions in the 'functions' directory." };
31547
+ M.info(`Found ${functions.length} ${functions.length === 1 ? "function" : "functions"} to deploy`);
31548
+ const result = await runTask("Deploying functions to Base44", async () => {
31549
+ return await pushFunctions(functions);
31550
+ }, {
31551
+ successMessage: "Functions deployed successfully",
31552
+ errorMessage: "Failed to deploy functions"
31553
+ });
31554
+ if (result.deployed.length > 0) M.success(`Deployed: ${result.deployed.join(", ")}`);
31555
+ if (result.deleted.length > 0) M.warn(`Deleted: ${result.deleted.join(", ")}`);
31556
+ if (result.errors && result.errors.length > 0) {
31557
+ const errorMessages = result.errors.map((e$1) => `'${e$1.name}' function: ${e$1.message}`).join("\n");
31558
+ throw new Error(`Function deployment errors:\n${errorMessages}`);
31559
+ }
31560
+ return {};
31561
+ }
31562
+ const functionsDeployCommand = new Command("functions").description("Manage project functions").addCommand(new Command("deploy").description("Deploy local functions to Base44").action(async () => {
31563
+ await runCommand(deployFunctionsAction, { requireAuth: true });
31564
+ }));
31565
+
31506
31566
  //#endregion
31507
31567
  //#region node_modules/is-plain-obj/index.js
31508
31568
  function isPlainObject(value) {
@@ -32092,9 +32152,9 @@ const replacements = Object.entries(specialMainSymbols);
32092
32152
  //#endregion
32093
32153
  //#region node_modules/yoctocolors/base.js
32094
32154
  const hasColors = tty?.WriteStream?.prototype?.hasColors?.() ?? false;
32095
- const format = (open, close) => {
32155
+ const format = (open$1, close) => {
32096
32156
  if (!hasColors) return (input) => input;
32097
- const openCode = `\u001B[${open}m`;
32157
+ const openCode = `\u001B[${open$1}m`;
32098
32158
  const closeCode = `\u001B[${close}m`;
32099
32159
  return (input) => {
32100
32160
  const string$2 = input + "";
@@ -32295,7 +32355,7 @@ const handleCommand = (filePath, rawArguments, rawOptions) => {
32295
32355
  var require_windows = /* @__PURE__ */ __commonJSMin(((exports, module) => {
32296
32356
  module.exports = isexe;
32297
32357
  isexe.sync = sync;
32298
- var fs$4 = __require("fs");
32358
+ var fs$5 = __require("fs");
32299
32359
  function checkPathExt(path$17, options) {
32300
32360
  var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
32301
32361
  if (!pathext) return true;
@@ -32312,12 +32372,12 @@ var require_windows = /* @__PURE__ */ __commonJSMin(((exports, module) => {
32312
32372
  return checkPathExt(path$17, options);
32313
32373
  }
32314
32374
  function isexe(path$17, options, cb) {
32315
- fs$4.stat(path$17, function(er, stat) {
32375
+ fs$5.stat(path$17, function(er, stat) {
32316
32376
  cb(er, er ? false : checkStat(stat, path$17, options));
32317
32377
  });
32318
32378
  }
32319
32379
  function sync(path$17, options) {
32320
- return checkStat(fs$4.statSync(path$17), path$17, options);
32380
+ return checkStat(fs$5.statSync(path$17), path$17, options);
32321
32381
  }
32322
32382
  }));
32323
32383
 
@@ -32326,14 +32386,14 @@ var require_windows = /* @__PURE__ */ __commonJSMin(((exports, module) => {
32326
32386
  var require_mode = /* @__PURE__ */ __commonJSMin(((exports, module) => {
32327
32387
  module.exports = isexe;
32328
32388
  isexe.sync = sync;
32329
- var fs$3 = __require("fs");
32389
+ var fs$4 = __require("fs");
32330
32390
  function isexe(path$17, options, cb) {
32331
- fs$3.stat(path$17, function(er, stat) {
32391
+ fs$4.stat(path$17, function(er, stat) {
32332
32392
  cb(er, er ? false : checkStat(stat, options));
32333
32393
  });
32334
32394
  }
32335
32395
  function sync(path$17, options) {
32336
- return checkStat(fs$3.statSync(path$17), options);
32396
+ return checkStat(fs$4.statSync(path$17), options);
32337
32397
  }
32338
32398
  function checkStat(stat, options) {
32339
32399
  return stat.isFile() && checkMode(stat, options);
@@ -32556,16 +32616,16 @@ var require_shebang_command = /* @__PURE__ */ __commonJSMin(((exports, module) =
32556
32616
  //#endregion
32557
32617
  //#region node_modules/cross-spawn/lib/util/readShebang.js
32558
32618
  var require_readShebang = /* @__PURE__ */ __commonJSMin(((exports, module) => {
32559
- const fs$2 = __require("fs");
32619
+ const fs$3 = __require("fs");
32560
32620
  const shebangCommand = require_shebang_command();
32561
32621
  function readShebang(command) {
32562
32622
  const size = 150;
32563
32623
  const buffer = Buffer.alloc(size);
32564
32624
  let fd;
32565
32625
  try {
32566
- fd = fs$2.openSync(command, "r");
32567
- fs$2.readSync(fd, buffer, 0, size, 0);
32568
- fs$2.closeSync(fd);
32626
+ fd = fs$3.openSync(command, "r");
32627
+ fs$3.readSync(fd, buffer, 0, size, 0);
32628
+ fs$3.closeSync(fd);
32569
32629
  } catch (e$1) {}
32570
32630
  return shebangCommand(buffer.toString());
32571
32631
  }
@@ -32703,8 +32763,8 @@ var require_cross_spawn = /* @__PURE__ */ __commonJSMin(((exports, module) => {
32703
32763
  //#region node_modules/npm-run-path/node_modules/path-key/index.js
32704
32764
  var import_cross_spawn = /* @__PURE__ */ __toESM(require_cross_spawn(), 1);
32705
32765
  function pathKey(options = {}) {
32706
- const { env: env$1 = process.env, platform: platform$2 = process.platform } = options;
32707
- if (platform$2 !== "win32") return "PATH";
32766
+ const { env: env$1 = process.env, platform: platform$3 = process.platform } = options;
32767
+ if (platform$3 !== "win32") return "PATH";
32708
32768
  return Object.keys(env$1).reverse().find((key) => key.toUpperCase() === "PATH") || "Path";
32709
32769
  }
32710
32770
 
@@ -38177,7 +38237,7 @@ async function getDefaultTemplate() {
38177
38237
  if (!template) throw new Error(`Default template "${DEFAULT_TEMPLATE_ID}" not found`);
38178
38238
  return template;
38179
38239
  }
38180
- function validateNonInteractiveFlags(command) {
38240
+ function validateNonInteractiveFlags$1(command) {
38181
38241
  const { name: name$1, path: path$17 } = command.opts();
38182
38242
  const providedCount = [name$1, path$17].filter(Boolean).length;
38183
38243
  if (providedCount > 0 && providedCount < 2) command.error("Non-interactive mode requires all flags: --name, --path");
@@ -38302,10 +38362,622 @@ async function executeCreate({ template, name: rawName, description, projectPath
38302
38362
  if (finalAppUrl) M.message(`${theme.styles.header("Site")}: ${theme.colors.links(finalAppUrl)}`);
38303
38363
  return { outroMessage: "Your project is set up and ready to use" };
38304
38364
  }
38305
- const createCommand = new Command("create").description("Create a new Base44 project").option("-n, --name <name>", "Project name").option("-d, --description <description>", "Project description").option("-p, --path <path>", "Path where to create the project").option("--deploy", "Build and deploy the site").hook("preAction", validateNonInteractiveFlags).action(async (options) => {
38365
+ const createCommand = new Command("create").description("Create a new Base44 project").option("-n, --name <name>", "Project name").option("-d, --description <description>", "Project description").option("-p, --path <path>", "Path where to create the project").option("--deploy", "Build and deploy the site").hook("preAction", validateNonInteractiveFlags$1).action(async (options) => {
38306
38366
  await chooseCreate(options);
38307
38367
  });
38308
38368
 
38369
+ //#endregion
38370
+ //#region node_modules/is-docker/index.js
38371
+ let isDockerCached;
38372
+ function hasDockerEnv() {
38373
+ try {
38374
+ fs.statSync("/.dockerenv");
38375
+ return true;
38376
+ } catch {
38377
+ return false;
38378
+ }
38379
+ }
38380
+ function hasDockerCGroup() {
38381
+ try {
38382
+ return fs.readFileSync("/proc/self/cgroup", "utf8").includes("docker");
38383
+ } catch {
38384
+ return false;
38385
+ }
38386
+ }
38387
+ function isDocker() {
38388
+ if (isDockerCached === void 0) isDockerCached = hasDockerEnv() || hasDockerCGroup();
38389
+ return isDockerCached;
38390
+ }
38391
+
38392
+ //#endregion
38393
+ //#region node_modules/is-inside-container/index.js
38394
+ let cachedResult;
38395
+ const hasContainerEnv = () => {
38396
+ try {
38397
+ fs.statSync("/run/.containerenv");
38398
+ return true;
38399
+ } catch {
38400
+ return false;
38401
+ }
38402
+ };
38403
+ function isInsideContainer() {
38404
+ if (cachedResult === void 0) cachedResult = hasContainerEnv() || isDocker();
38405
+ return cachedResult;
38406
+ }
38407
+
38408
+ //#endregion
38409
+ //#region node_modules/is-wsl/index.js
38410
+ const isWsl = () => {
38411
+ if (y.platform !== "linux") return false;
38412
+ if (os.release().toLowerCase().includes("microsoft")) {
38413
+ if (isInsideContainer()) return false;
38414
+ return true;
38415
+ }
38416
+ try {
38417
+ return fs.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft") ? !isInsideContainer() : false;
38418
+ } catch {
38419
+ return false;
38420
+ }
38421
+ };
38422
+ var is_wsl_default = y.env.__IS_WSL_TEST__ ? isWsl : isWsl();
38423
+
38424
+ //#endregion
38425
+ //#region node_modules/powershell-utils/index.js
38426
+ const execFile$2 = promisify(childProcess.execFile);
38427
+ const powerShellPath$1 = () => `${y.env.SYSTEMROOT || y.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
38428
+ const executePowerShell = async (command, options = {}) => {
38429
+ const { powerShellPath: psPath, ...execFileOptions } = options;
38430
+ const encodedCommand = executePowerShell.encodeCommand(command);
38431
+ return execFile$2(psPath ?? powerShellPath$1(), [...executePowerShell.argumentsPrefix, encodedCommand], {
38432
+ encoding: "utf8",
38433
+ ...execFileOptions
38434
+ });
38435
+ };
38436
+ executePowerShell.argumentsPrefix = [
38437
+ "-NoProfile",
38438
+ "-NonInteractive",
38439
+ "-ExecutionPolicy",
38440
+ "Bypass",
38441
+ "-EncodedCommand"
38442
+ ];
38443
+ executePowerShell.encodeCommand = (command) => Buffer$2.from(command, "utf16le").toString("base64");
38444
+ executePowerShell.escapeArgument = (value) => `'${String(value).replaceAll("'", "''")}'`;
38445
+
38446
+ //#endregion
38447
+ //#region node_modules/wsl-utils/utilities.js
38448
+ function parseMountPointFromConfig(content) {
38449
+ for (const line of content.split("\n")) {
38450
+ if (/^\s*#/.test(line)) continue;
38451
+ const match = /^\s*root\s*=\s*(?<mountPoint>"[^"]*"|'[^']*'|[^#]*)/.exec(line);
38452
+ if (!match) continue;
38453
+ return match.groups.mountPoint.trim().replaceAll(/^["']|["']$/g, "");
38454
+ }
38455
+ }
38456
+
38457
+ //#endregion
38458
+ //#region node_modules/wsl-utils/index.js
38459
+ const execFile$1 = promisify(childProcess.execFile);
38460
+ const wslDrivesMountPoint = (() => {
38461
+ const defaultMountPoint = "/mnt/";
38462
+ let mountPoint;
38463
+ return async function() {
38464
+ if (mountPoint) return mountPoint;
38465
+ const configFilePath = "/etc/wsl.conf";
38466
+ let isConfigFileExists = false;
38467
+ try {
38468
+ await fs$2.access(configFilePath, constants$1.F_OK);
38469
+ isConfigFileExists = true;
38470
+ } catch {}
38471
+ if (!isConfigFileExists) return defaultMountPoint;
38472
+ const parsedMountPoint = parseMountPointFromConfig(await fs$2.readFile(configFilePath, { encoding: "utf8" }));
38473
+ if (parsedMountPoint === void 0) return defaultMountPoint;
38474
+ mountPoint = parsedMountPoint;
38475
+ mountPoint = mountPoint.endsWith("/") ? mountPoint : `${mountPoint}/`;
38476
+ return mountPoint;
38477
+ };
38478
+ })();
38479
+ const powerShellPathFromWsl = async () => {
38480
+ return `${await wslDrivesMountPoint()}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`;
38481
+ };
38482
+ const powerShellPath = is_wsl_default ? powerShellPathFromWsl : powerShellPath$1;
38483
+ let canAccessPowerShellPromise;
38484
+ const canAccessPowerShell = async () => {
38485
+ canAccessPowerShellPromise ??= (async () => {
38486
+ try {
38487
+ const psPath = await powerShellPath();
38488
+ await fs$2.access(psPath, constants$1.X_OK);
38489
+ return true;
38490
+ } catch {
38491
+ return false;
38492
+ }
38493
+ })();
38494
+ return canAccessPowerShellPromise;
38495
+ };
38496
+ const wslDefaultBrowser = async () => {
38497
+ const psPath = await powerShellPath();
38498
+ const { stdout: stdout$1 } = await executePowerShell(String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`, { powerShellPath: psPath });
38499
+ return stdout$1.trim();
38500
+ };
38501
+ const convertWslPathToWindows = async (path$17) => {
38502
+ if (/^[a-z]+:\/\//i.test(path$17)) return path$17;
38503
+ try {
38504
+ const { stdout: stdout$1 } = await execFile$1("wslpath", ["-aw", path$17], { encoding: "utf8" });
38505
+ return stdout$1.trim();
38506
+ } catch {
38507
+ return path$17;
38508
+ }
38509
+ };
38510
+
38511
+ //#endregion
38512
+ //#region node_modules/define-lazy-prop/index.js
38513
+ function defineLazyProperty(object$1, propertyName, valueGetter) {
38514
+ const define$1 = (value) => Object.defineProperty(object$1, propertyName, {
38515
+ value,
38516
+ enumerable: true,
38517
+ writable: true
38518
+ });
38519
+ Object.defineProperty(object$1, propertyName, {
38520
+ configurable: true,
38521
+ enumerable: true,
38522
+ get() {
38523
+ const result = valueGetter();
38524
+ define$1(result);
38525
+ return result;
38526
+ },
38527
+ set(value) {
38528
+ define$1(value);
38529
+ }
38530
+ });
38531
+ return object$1;
38532
+ }
38533
+
38534
+ //#endregion
38535
+ //#region node_modules/default-browser-id/index.js
38536
+ const execFileAsync$3 = promisify(execFile);
38537
+ async function defaultBrowserId() {
38538
+ if (y.platform !== "darwin") throw new Error("macOS only");
38539
+ const { stdout: stdout$1 } = await execFileAsync$3("defaults", [
38540
+ "read",
38541
+ "com.apple.LaunchServices/com.apple.launchservices.secure",
38542
+ "LSHandlers"
38543
+ ]);
38544
+ const browserId = /LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(stdout$1)?.groups.id ?? "com.apple.Safari";
38545
+ if (browserId === "com.apple.safari") return "com.apple.Safari";
38546
+ return browserId;
38547
+ }
38548
+
38549
+ //#endregion
38550
+ //#region node_modules/run-applescript/index.js
38551
+ const execFileAsync$2 = promisify(execFile);
38552
+ async function runAppleScript(script, { humanReadableOutput = true, signal } = {}) {
38553
+ if (y.platform !== "darwin") throw new Error("macOS only");
38554
+ const outputArguments = humanReadableOutput ? [] : ["-ss"];
38555
+ const execOptions = {};
38556
+ if (signal) execOptions.signal = signal;
38557
+ const { stdout: stdout$1 } = await execFileAsync$2("osascript", [
38558
+ "-e",
38559
+ script,
38560
+ outputArguments
38561
+ ], execOptions);
38562
+ return stdout$1.trim();
38563
+ }
38564
+
38565
+ //#endregion
38566
+ //#region node_modules/bundle-name/index.js
38567
+ async function bundleName(bundleId) {
38568
+ return runAppleScript(`tell application "Finder" to set app_path to application file id "${bundleId}" as string\ntell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`);
38569
+ }
38570
+
38571
+ //#endregion
38572
+ //#region node_modules/default-browser/windows.js
38573
+ const execFileAsync$1 = promisify(execFile);
38574
+ const windowsBrowserProgIds = {
38575
+ MSEdgeHTM: {
38576
+ name: "Edge",
38577
+ id: "com.microsoft.edge"
38578
+ },
38579
+ MSEdgeBHTML: {
38580
+ name: "Edge Beta",
38581
+ id: "com.microsoft.edge.beta"
38582
+ },
38583
+ MSEdgeDHTML: {
38584
+ name: "Edge Dev",
38585
+ id: "com.microsoft.edge.dev"
38586
+ },
38587
+ AppXq0fevzme2pys62n3e0fbqa7peapykr8v: {
38588
+ name: "Edge",
38589
+ id: "com.microsoft.edge.old"
38590
+ },
38591
+ ChromeHTML: {
38592
+ name: "Chrome",
38593
+ id: "com.google.chrome"
38594
+ },
38595
+ ChromeBHTML: {
38596
+ name: "Chrome Beta",
38597
+ id: "com.google.chrome.beta"
38598
+ },
38599
+ ChromeDHTML: {
38600
+ name: "Chrome Dev",
38601
+ id: "com.google.chrome.dev"
38602
+ },
38603
+ ChromiumHTM: {
38604
+ name: "Chromium",
38605
+ id: "org.chromium.Chromium"
38606
+ },
38607
+ BraveHTML: {
38608
+ name: "Brave",
38609
+ id: "com.brave.Browser"
38610
+ },
38611
+ BraveBHTML: {
38612
+ name: "Brave Beta",
38613
+ id: "com.brave.Browser.beta"
38614
+ },
38615
+ BraveDHTML: {
38616
+ name: "Brave Dev",
38617
+ id: "com.brave.Browser.dev"
38618
+ },
38619
+ BraveSSHTM: {
38620
+ name: "Brave Nightly",
38621
+ id: "com.brave.Browser.nightly"
38622
+ },
38623
+ FirefoxURL: {
38624
+ name: "Firefox",
38625
+ id: "org.mozilla.firefox"
38626
+ },
38627
+ OperaStable: {
38628
+ name: "Opera",
38629
+ id: "com.operasoftware.Opera"
38630
+ },
38631
+ VivaldiHTM: {
38632
+ name: "Vivaldi",
38633
+ id: "com.vivaldi.Vivaldi"
38634
+ },
38635
+ "IE.HTTP": {
38636
+ name: "Internet Explorer",
38637
+ id: "com.microsoft.ie"
38638
+ }
38639
+ };
38640
+ const _windowsBrowserProgIdMap = new Map(Object.entries(windowsBrowserProgIds));
38641
+ var UnknownBrowserError = class extends Error {};
38642
+ async function defaultBrowser$1(_execFileAsync = execFileAsync$1) {
38643
+ const { stdout: stdout$1 } = await _execFileAsync("reg", [
38644
+ "QUERY",
38645
+ " HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice",
38646
+ "/v",
38647
+ "ProgId"
38648
+ ]);
38649
+ const match = /ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(stdout$1);
38650
+ if (!match) throw new UnknownBrowserError(`Cannot find Windows browser in stdout: ${JSON.stringify(stdout$1)}`);
38651
+ const { id } = match.groups;
38652
+ const browser = windowsBrowserProgIds[id];
38653
+ if (!browser) throw new UnknownBrowserError(`Unknown browser ID: ${id}`);
38654
+ return browser;
38655
+ }
38656
+
38657
+ //#endregion
38658
+ //#region node_modules/default-browser/index.js
38659
+ const execFileAsync = promisify(execFile);
38660
+ const titleize = (string$2) => string$2.toLowerCase().replaceAll(/(?:^|\s|-)\S/g, (x$2) => x$2.toUpperCase());
38661
+ async function defaultBrowser() {
38662
+ if (y.platform === "darwin") {
38663
+ const id = await defaultBrowserId();
38664
+ return {
38665
+ name: await bundleName(id),
38666
+ id
38667
+ };
38668
+ }
38669
+ if (y.platform === "linux") {
38670
+ const { stdout: stdout$1 } = await execFileAsync("xdg-mime", [
38671
+ "query",
38672
+ "default",
38673
+ "x-scheme-handler/http"
38674
+ ]);
38675
+ const id = stdout$1.trim();
38676
+ return {
38677
+ name: titleize(id.replace(/.desktop$/, "").replace("-", " ")),
38678
+ id
38679
+ };
38680
+ }
38681
+ if (y.platform === "win32") return defaultBrowser$1();
38682
+ throw new Error("Only macOS, Linux, and Windows are supported");
38683
+ }
38684
+
38685
+ //#endregion
38686
+ //#region node_modules/is-in-ssh/index.js
38687
+ const isInSsh = Boolean(y.env.SSH_CONNECTION || y.env.SSH_CLIENT || y.env.SSH_TTY);
38688
+ var is_in_ssh_default = isInSsh;
38689
+
38690
+ //#endregion
38691
+ //#region node_modules/open/index.js
38692
+ const fallbackAttemptSymbol = Symbol("fallbackAttempt");
38693
+ const __dirname = import.meta.url ? path.dirname(fileURLToPath(import.meta.url)) : "";
38694
+ const localXdgOpenPath = path.join(__dirname, "xdg-open");
38695
+ const { platform: platform$1, arch } = y;
38696
+ const tryEachApp = async (apps$1, opener) => {
38697
+ if (apps$1.length === 0) return;
38698
+ const errors = [];
38699
+ for (const app of apps$1) try {
38700
+ return await opener(app);
38701
+ } catch (error) {
38702
+ errors.push(error);
38703
+ }
38704
+ throw new AggregateError(errors, "Failed to open in all supported apps");
38705
+ };
38706
+ const baseOpen = async (options) => {
38707
+ options = {
38708
+ wait: false,
38709
+ background: false,
38710
+ newInstance: false,
38711
+ allowNonzeroExitCode: false,
38712
+ ...options
38713
+ };
38714
+ const isFallbackAttempt = options[fallbackAttemptSymbol] === true;
38715
+ delete options[fallbackAttemptSymbol];
38716
+ if (Array.isArray(options.app)) return tryEachApp(options.app, (singleApp) => baseOpen({
38717
+ ...options,
38718
+ app: singleApp,
38719
+ [fallbackAttemptSymbol]: true
38720
+ }));
38721
+ let { name: app, arguments: appArguments = [] } = options.app ?? {};
38722
+ appArguments = [...appArguments];
38723
+ if (Array.isArray(app)) return tryEachApp(app, (appName) => baseOpen({
38724
+ ...options,
38725
+ app: {
38726
+ name: appName,
38727
+ arguments: appArguments
38728
+ },
38729
+ [fallbackAttemptSymbol]: true
38730
+ }));
38731
+ if (app === "browser" || app === "browserPrivate") {
38732
+ const ids = {
38733
+ "com.google.chrome": "chrome",
38734
+ "google-chrome.desktop": "chrome",
38735
+ "com.brave.browser": "brave",
38736
+ "org.mozilla.firefox": "firefox",
38737
+ "firefox.desktop": "firefox",
38738
+ "com.microsoft.msedge": "edge",
38739
+ "com.microsoft.edge": "edge",
38740
+ "com.microsoft.edgemac": "edge",
38741
+ "microsoft-edge.desktop": "edge",
38742
+ "com.apple.safari": "safari"
38743
+ };
38744
+ const flags = {
38745
+ chrome: "--incognito",
38746
+ brave: "--incognito",
38747
+ firefox: "--private-window",
38748
+ edge: "--inPrivate"
38749
+ };
38750
+ let browser;
38751
+ if (is_wsl_default) {
38752
+ const progId = await wslDefaultBrowser();
38753
+ browser = _windowsBrowserProgIdMap.get(progId) ?? {};
38754
+ } else browser = await defaultBrowser();
38755
+ if (browser.id in ids) {
38756
+ const browserName = ids[browser.id.toLowerCase()];
38757
+ if (app === "browserPrivate") {
38758
+ if (browserName === "safari") throw new Error("Safari doesn't support opening in private mode via command line");
38759
+ appArguments.push(flags[browserName]);
38760
+ }
38761
+ return baseOpen({
38762
+ ...options,
38763
+ app: {
38764
+ name: apps[browserName],
38765
+ arguments: appArguments
38766
+ }
38767
+ });
38768
+ }
38769
+ throw new Error(`${browser.name} is not supported as a default browser`);
38770
+ }
38771
+ let command;
38772
+ const cliArguments = [];
38773
+ const childProcessOptions = {};
38774
+ let shouldUseWindowsInWsl = false;
38775
+ if (is_wsl_default && !isInsideContainer() && !is_in_ssh_default && !app) shouldUseWindowsInWsl = await canAccessPowerShell();
38776
+ if (platform$1 === "darwin") {
38777
+ command = "open";
38778
+ if (options.wait) cliArguments.push("--wait-apps");
38779
+ if (options.background) cliArguments.push("--background");
38780
+ if (options.newInstance) cliArguments.push("--new");
38781
+ if (app) cliArguments.push("-a", app);
38782
+ } else if (platform$1 === "win32" || shouldUseWindowsInWsl) {
38783
+ command = await powerShellPath();
38784
+ cliArguments.push(...executePowerShell.argumentsPrefix);
38785
+ if (!is_wsl_default) childProcessOptions.windowsVerbatimArguments = true;
38786
+ if (is_wsl_default && options.target) options.target = await convertWslPathToWindows(options.target);
38787
+ const encodedArguments = ["$ProgressPreference = 'SilentlyContinue';", "Start"];
38788
+ if (options.wait) encodedArguments.push("-Wait");
38789
+ if (app) {
38790
+ encodedArguments.push(executePowerShell.escapeArgument(app));
38791
+ if (options.target) appArguments.push(options.target);
38792
+ } else if (options.target) encodedArguments.push(executePowerShell.escapeArgument(options.target));
38793
+ if (appArguments.length > 0) {
38794
+ appArguments = appArguments.map((argument) => executePowerShell.escapeArgument(argument));
38795
+ encodedArguments.push("-ArgumentList", appArguments.join(","));
38796
+ }
38797
+ options.target = executePowerShell.encodeCommand(encodedArguments.join(" "));
38798
+ if (!options.wait) childProcessOptions.stdio = "ignore";
38799
+ } else {
38800
+ if (app) command = app;
38801
+ else {
38802
+ const isBundled = !__dirname || __dirname === "/";
38803
+ let exeLocalXdgOpen = false;
38804
+ try {
38805
+ await fs$2.access(localXdgOpenPath, constants$1.X_OK);
38806
+ exeLocalXdgOpen = true;
38807
+ } catch {}
38808
+ command = y.versions.electron ?? (platform$1 === "android" || isBundled || !exeLocalXdgOpen) ? "xdg-open" : localXdgOpenPath;
38809
+ }
38810
+ if (appArguments.length > 0) cliArguments.push(...appArguments);
38811
+ if (!options.wait) {
38812
+ childProcessOptions.stdio = "ignore";
38813
+ childProcessOptions.detached = true;
38814
+ }
38815
+ }
38816
+ if (platform$1 === "darwin" && appArguments.length > 0) cliArguments.push("--args", ...appArguments);
38817
+ if (options.target) cliArguments.push(options.target);
38818
+ const subprocess = childProcess.spawn(command, cliArguments, childProcessOptions);
38819
+ if (options.wait) return new Promise((resolve$1, reject) => {
38820
+ subprocess.once("error", reject);
38821
+ subprocess.once("close", (exitCode) => {
38822
+ if (!options.allowNonzeroExitCode && exitCode !== 0) {
38823
+ reject(/* @__PURE__ */ new Error(`Exited with code ${exitCode}`));
38824
+ return;
38825
+ }
38826
+ resolve$1(subprocess);
38827
+ });
38828
+ });
38829
+ if (isFallbackAttempt) return new Promise((resolve$1, reject) => {
38830
+ subprocess.once("error", reject);
38831
+ subprocess.once("spawn", () => {
38832
+ subprocess.once("close", (exitCode) => {
38833
+ subprocess.off("error", reject);
38834
+ if (exitCode !== 0) {
38835
+ reject(/* @__PURE__ */ new Error(`Exited with code ${exitCode}`));
38836
+ return;
38837
+ }
38838
+ subprocess.unref();
38839
+ resolve$1(subprocess);
38840
+ });
38841
+ });
38842
+ });
38843
+ subprocess.unref();
38844
+ return new Promise((resolve$1, reject) => {
38845
+ subprocess.once("error", reject);
38846
+ subprocess.once("spawn", () => {
38847
+ subprocess.off("error", reject);
38848
+ resolve$1(subprocess);
38849
+ });
38850
+ });
38851
+ };
38852
+ const open = (target, options) => {
38853
+ if (typeof target !== "string") throw new TypeError("Expected a `target`");
38854
+ return baseOpen({
38855
+ ...options,
38856
+ target
38857
+ });
38858
+ };
38859
+ function detectArchBinary(binary) {
38860
+ if (typeof binary === "string" || Array.isArray(binary)) return binary;
38861
+ const { [arch]: archBinary } = binary;
38862
+ if (!archBinary) throw new Error(`${arch} is not supported`);
38863
+ return archBinary;
38864
+ }
38865
+ function detectPlatformBinary({ [platform$1]: platformBinary }, { wsl } = {}) {
38866
+ if (wsl && is_wsl_default) return detectArchBinary(wsl);
38867
+ if (!platformBinary) throw new Error(`${platform$1} is not supported`);
38868
+ return detectArchBinary(platformBinary);
38869
+ }
38870
+ const apps = {
38871
+ browser: "browser",
38872
+ browserPrivate: "browserPrivate"
38873
+ };
38874
+ defineLazyProperty(apps, "chrome", () => detectPlatformBinary({
38875
+ darwin: "google chrome",
38876
+ win32: "chrome",
38877
+ linux: [
38878
+ "google-chrome",
38879
+ "google-chrome-stable",
38880
+ "chromium",
38881
+ "chromium-browser"
38882
+ ]
38883
+ }, { wsl: {
38884
+ ia32: "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",
38885
+ x64: ["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe", "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]
38886
+ } }));
38887
+ defineLazyProperty(apps, "brave", () => detectPlatformBinary({
38888
+ darwin: "brave browser",
38889
+ win32: "brave",
38890
+ linux: ["brave-browser", "brave"]
38891
+ }, { wsl: {
38892
+ ia32: "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",
38893
+ x64: ["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe", "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]
38894
+ } }));
38895
+ defineLazyProperty(apps, "firefox", () => detectPlatformBinary({
38896
+ darwin: "firefox",
38897
+ win32: String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,
38898
+ linux: "firefox"
38899
+ }, { wsl: "/mnt/c/Program Files/Mozilla Firefox/firefox.exe" }));
38900
+ defineLazyProperty(apps, "edge", () => detectPlatformBinary({
38901
+ darwin: "microsoft edge",
38902
+ win32: "msedge",
38903
+ linux: ["microsoft-edge", "microsoft-edge-dev"]
38904
+ }, { wsl: "/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe" }));
38905
+ defineLazyProperty(apps, "safari", () => detectPlatformBinary({ darwin: "Safari" }));
38906
+ var open_default = open;
38907
+
38908
+ //#endregion
38909
+ //#region src/cli/commands/project/dashboard.ts
38910
+ async function openDashboard() {
38911
+ await loadProjectEnv();
38912
+ const projectId = getBase44ClientId();
38913
+ if (!projectId) throw new Error("App not configured. BASE44_CLIENT_ID environment variable is required. Set it in your .env.local file.");
38914
+ const dashboardUrl = `${getBase44ApiUrl()}/apps/${projectId}/editor/workspace/overview`;
38915
+ await open_default(dashboardUrl);
38916
+ return { outroMessage: `Dashboard opened at ${dashboardUrl}` };
38917
+ }
38918
+ const dashboardCommand = new Command("dashboard").description("Open the app dashboard in your browser").action(async () => {
38919
+ await runCommand(openDashboard, { requireAuth: true });
38920
+ });
38921
+
38922
+ //#endregion
38923
+ //#region src/cli/commands/project/link.ts
38924
+ function validateNonInteractiveFlags(command) {
38925
+ const { create: create$1, name: name$1 } = command.opts();
38926
+ if (create$1 && !name$1) command.error("--name is required when using --create");
38927
+ }
38928
+ async function promptForProjectDetails() {
38929
+ const actionOptions = [{
38930
+ value: "create",
38931
+ label: "Create a new project",
38932
+ hint: "Create a new Base44 project and link it"
38933
+ }];
38934
+ const result = await Ce({
38935
+ action: () => ve({
38936
+ message: "How would you like to link this project?",
38937
+ options: actionOptions
38938
+ }),
38939
+ name: () => {
38940
+ return he({
38941
+ message: "What is the name of your project?",
38942
+ placeholder: "my-app",
38943
+ validate: (value) => {
38944
+ if (!value || value.trim().length === 0) return "Project name is required";
38945
+ }
38946
+ });
38947
+ },
38948
+ description: () => he({
38949
+ message: "Description (optional)",
38950
+ placeholder: "A brief description of your project"
38951
+ })
38952
+ }, { onCancel: onPromptCancel });
38953
+ return {
38954
+ name: result.name.trim(),
38955
+ description: result.description ? result.description.trim() : void 0
38956
+ };
38957
+ }
38958
+ async function link(options) {
38959
+ const projectRoot = await findProjectRoot();
38960
+ if (!projectRoot) throw new Error("No Base44 project found. Run this command from a project directory with a config.jsonc file.");
38961
+ if (await envLocalExists(projectRoot.root)) throw new Error("Project is already linked. A .env.local file with BASE44_CLIENT_ID already exists.");
38962
+ const { name: name$1, description } = options.create ? {
38963
+ name: options.name.trim(),
38964
+ description: options.description?.trim()
38965
+ } : await promptForProjectDetails();
38966
+ const { projectId } = await runTask("Creating project on Base44...", async () => {
38967
+ return await createProject(name$1, description);
38968
+ }, {
38969
+ successMessage: "Project created successfully",
38970
+ errorMessage: "Failed to create project"
38971
+ });
38972
+ await writeEnvLocal(projectRoot.root, projectId);
38973
+ const dashboardUrl = `${getBase44ApiUrl()}/apps/${projectId}/editor/workspace/overview`;
38974
+ M.message(`${theme.styles.header("Dashboard")}: ${theme.colors.links(dashboardUrl)}`);
38975
+ return { outroMessage: "Project linked" };
38976
+ }
38977
+ const linkCommand = new Command("link").description("Link a local project to a Base44 project").option("-c, --create", "Create a new project (skip selection prompt)").option("-n, --name <name>", "Project name (required when --create is used)").option("-d, --description <description>", "Project description").hook("preAction", validateNonInteractiveFlags).action(async (options) => {
38978
+ await runCommand(() => link(options), { requireAuth: true });
38979
+ });
38980
+
38309
38981
  //#endregion
38310
38982
  //#region src/cli/commands/site/deploy.ts
38311
38983
  async function deployAction(options) {
@@ -38329,17 +39001,21 @@ const siteDeployCommand = new Command("site").description("Manage site deploymen
38329
39001
 
38330
39002
  //#endregion
38331
39003
  //#region package.json
38332
- var version = "0.0.10";
39004
+ var version = "0.0.12";
38333
39005
 
38334
39006
  //#endregion
38335
39007
  //#region src/cli/index.ts
38336
39008
  const program = new Command();
38337
39009
  program.name("base44").description("Base44 CLI - Unified interface for managing Base44 applications").version(version);
39010
+ program.configureHelp({ sortSubcommands: true });
38338
39011
  program.addCommand(loginCommand);
38339
39012
  program.addCommand(whoamiCommand);
38340
39013
  program.addCommand(logoutCommand);
38341
39014
  program.addCommand(createCommand);
39015
+ program.addCommand(dashboardCommand);
39016
+ program.addCommand(linkCommand);
38342
39017
  program.addCommand(entitiesPushCommand);
39018
+ program.addCommand(functionsDeployCommand);
38343
39019
  program.addCommand(siteDeployCommand);
38344
39020
  program.parse();
38345
39021