@base44-preview/cli 0.0.9-pr.74.8755bae → 0.0.9-pr.75.1247e76

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 +256 -222
  2. package/package.json +1 -1
package/dist/cli/index.js CHANGED
@@ -4956,7 +4956,6 @@ const string$1 = (params) => {
4956
4956
  };
4957
4957
  const integer = /^-?\d+$/;
4958
4958
  const number$1 = /^-?\d+(?:\.\d+)?$/;
4959
- const boolean$1 = /^(?:true|false)$/i;
4960
4959
  const lowercase = /^[^A-Z]*$/;
4961
4960
  const uppercase = /^[^a-z]*$/;
4962
4961
 
@@ -5735,24 +5734,6 @@ const $ZodNumberFormat = /* @__PURE__ */ $constructor("$ZodNumberFormat", (inst,
5735
5734
  $ZodCheckNumberFormat.init(inst, def);
5736
5735
  $ZodNumber.init(inst, def);
5737
5736
  });
5738
- const $ZodBoolean = /* @__PURE__ */ $constructor("$ZodBoolean", (inst, def) => {
5739
- $ZodType.init(inst, def);
5740
- inst._zod.pattern = boolean$1;
5741
- inst._zod.parse = (payload, _ctx) => {
5742
- if (def.coerce) try {
5743
- payload.value = Boolean(payload.value);
5744
- } catch (_$2) {}
5745
- const input = payload.value;
5746
- if (typeof input === "boolean") return payload;
5747
- payload.issues.push({
5748
- expected: "boolean",
5749
- code: "invalid_type",
5750
- input,
5751
- inst
5752
- });
5753
- return payload;
5754
- };
5755
- });
5756
5737
  const $ZodUnknown = /* @__PURE__ */ $constructor("$ZodUnknown", (inst, def) => {
5757
5738
  $ZodType.init(inst, def);
5758
5739
  inst._zod.parse = (payload) => payload;
@@ -6058,61 +6039,6 @@ const $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
6058
6039
  });
6059
6040
  };
6060
6041
  });
6061
- const $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnion", (inst, def) => {
6062
- def.inclusive = false;
6063
- $ZodUnion.init(inst, def);
6064
- const _super = inst._zod.parse;
6065
- defineLazy(inst._zod, "propValues", () => {
6066
- const propValues = {};
6067
- for (const option of def.options) {
6068
- const pv = option._zod.propValues;
6069
- if (!pv || Object.keys(pv).length === 0) throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
6070
- for (const [k$2, v$1] of Object.entries(pv)) {
6071
- if (!propValues[k$2]) propValues[k$2] = /* @__PURE__ */ new Set();
6072
- for (const val of v$1) propValues[k$2].add(val);
6073
- }
6074
- }
6075
- return propValues;
6076
- });
6077
- const disc = cached(() => {
6078
- const opts = def.options;
6079
- const map = /* @__PURE__ */ new Map();
6080
- for (const o$2 of opts) {
6081
- const values = o$2._zod.propValues?.[def.discriminator];
6082
- if (!values || values.size === 0) throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o$2)}"`);
6083
- for (const v$1 of values) {
6084
- if (map.has(v$1)) throw new Error(`Duplicate discriminator value "${String(v$1)}"`);
6085
- map.set(v$1, o$2);
6086
- }
6087
- }
6088
- return map;
6089
- });
6090
- inst._zod.parse = (payload, ctx) => {
6091
- const input = payload.value;
6092
- if (!isObject$2(input)) {
6093
- payload.issues.push({
6094
- code: "invalid_type",
6095
- expected: "object",
6096
- input,
6097
- inst
6098
- });
6099
- return payload;
6100
- }
6101
- const opt = disc.value.get(input?.[def.discriminator]);
6102
- if (opt) return opt._zod.run(payload, ctx);
6103
- if (def.unionFallback) return _super(payload, ctx);
6104
- payload.issues.push({
6105
- code: "invalid_union",
6106
- errors: [],
6107
- note: "No matching discriminator",
6108
- discriminator: def.discriminator,
6109
- input,
6110
- path: [def.discriminator],
6111
- inst
6112
- });
6113
- return payload;
6114
- };
6115
- });
6116
6042
  const $ZodIntersection = /* @__PURE__ */ $constructor("$ZodIntersection", (inst, def) => {
6117
6043
  $ZodType.init(inst, def);
6118
6044
  inst._zod.parse = (payload, ctx) => {
@@ -6212,6 +6138,77 @@ function handleIntersectionResults(result, left, right) {
6212
6138
  result.value = merged.data;
6213
6139
  return result;
6214
6140
  }
6141
+ const $ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
6142
+ $ZodType.init(inst, def);
6143
+ const items = def.items;
6144
+ inst._zod.parse = (payload, ctx) => {
6145
+ const input = payload.value;
6146
+ if (!Array.isArray(input)) {
6147
+ payload.issues.push({
6148
+ input,
6149
+ inst,
6150
+ expected: "tuple",
6151
+ code: "invalid_type"
6152
+ });
6153
+ return payload;
6154
+ }
6155
+ payload.value = [];
6156
+ const proms = [];
6157
+ const reversedIndex = [...items].reverse().findIndex((item) => item._zod.optin !== "optional");
6158
+ const optStart = reversedIndex === -1 ? 0 : items.length - reversedIndex;
6159
+ if (!def.rest) {
6160
+ const tooBig = input.length > items.length;
6161
+ const tooSmall = input.length < optStart - 1;
6162
+ if (tooBig || tooSmall) {
6163
+ payload.issues.push({
6164
+ ...tooBig ? {
6165
+ code: "too_big",
6166
+ maximum: items.length,
6167
+ inclusive: true
6168
+ } : {
6169
+ code: "too_small",
6170
+ minimum: items.length
6171
+ },
6172
+ input,
6173
+ inst,
6174
+ origin: "array"
6175
+ });
6176
+ return payload;
6177
+ }
6178
+ }
6179
+ let i$1 = -1;
6180
+ for (const item of items) {
6181
+ i$1++;
6182
+ if (i$1 >= input.length) {
6183
+ if (i$1 >= optStart) continue;
6184
+ }
6185
+ const result = item._zod.run({
6186
+ value: input[i$1],
6187
+ issues: []
6188
+ }, ctx);
6189
+ if (result instanceof Promise) proms.push(result.then((result$1) => handleTupleResult(result$1, payload, i$1)));
6190
+ else handleTupleResult(result, payload, i$1);
6191
+ }
6192
+ if (def.rest) {
6193
+ const rest = input.slice(items.length);
6194
+ for (const el of rest) {
6195
+ i$1++;
6196
+ const result = def.rest._zod.run({
6197
+ value: el,
6198
+ issues: []
6199
+ }, ctx);
6200
+ if (result instanceof Promise) proms.push(result.then((result$1) => handleTupleResult(result$1, payload, i$1)));
6201
+ else handleTupleResult(result, payload, i$1);
6202
+ }
6203
+ }
6204
+ if (proms.length) return Promise.all(proms).then(() => payload);
6205
+ return payload;
6206
+ };
6207
+ });
6208
+ function handleTupleResult(result, final, index) {
6209
+ if (result.issues.length) final.issues.push(...prefixIssues(index, result.issues));
6210
+ final.value[index] = result.value;
6211
+ }
6215
6212
  const $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
6216
6213
  $ZodType.init(inst, def);
6217
6214
  const values = getEnumValues(def.entries);
@@ -6230,24 +6227,6 @@ const $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
6230
6227
  return payload;
6231
6228
  };
6232
6229
  });
6233
- const $ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
6234
- $ZodType.init(inst, def);
6235
- if (def.values.length === 0) throw new Error("Cannot create literal schema with no valid values");
6236
- const values = new Set(def.values);
6237
- inst._zod.values = values;
6238
- 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("|")})$`);
6239
- inst._zod.parse = (payload, _ctx) => {
6240
- const input = payload.value;
6241
- if (values.has(input)) return payload;
6242
- payload.issues.push({
6243
- code: "invalid_value",
6244
- values: def.values,
6245
- input,
6246
- inst
6247
- });
6248
- return payload;
6249
- };
6250
- });
6251
6230
  const $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def) => {
6252
6231
  $ZodType.init(inst, def);
6253
6232
  inst._zod.parse = (payload, ctx) => {
@@ -6809,13 +6788,6 @@ function _int(Class, params) {
6809
6788
  });
6810
6789
  }
6811
6790
  /* @__NO_SIDE_EFFECTS__ */
6812
- function _boolean(Class, params) {
6813
- return new Class({
6814
- type: "boolean",
6815
- ...normalizeParams(params)
6816
- });
6817
- }
6818
- /* @__NO_SIDE_EFFECTS__ */
6819
6791
  function _unknown(Class) {
6820
6792
  return new Class({ type: "unknown" });
6821
6793
  }
@@ -7386,9 +7358,6 @@ const numberProcessor = (schema, ctx, _json, _params) => {
7386
7358
  }
7387
7359
  if (typeof multipleOf === "number") json.multipleOf = multipleOf;
7388
7360
  };
7389
- const booleanProcessor = (_schema, _ctx, json, _params) => {
7390
- json.type = "boolean";
7391
- };
7392
7361
  const neverProcessor = (_schema, _ctx, json, _params) => {
7393
7362
  json.not = {};
7394
7363
  };
@@ -7400,27 +7369,6 @@ const enumProcessor = (schema, _ctx, json, _params) => {
7400
7369
  if (values.every((v$1) => typeof v$1 === "string")) json.type = "string";
7401
7370
  json.enum = values;
7402
7371
  };
7403
- const literalProcessor = (schema, ctx, json, _params) => {
7404
- const def = schema._zod.def;
7405
- const vals = [];
7406
- for (const val of def.values) if (val === void 0) {
7407
- if (ctx.unrepresentable === "throw") throw new Error("Literal `undefined` cannot be represented in JSON Schema");
7408
- } else if (typeof val === "bigint") if (ctx.unrepresentable === "throw") throw new Error("BigInt literals cannot be represented in JSON Schema");
7409
- else vals.push(Number(val));
7410
- else vals.push(val);
7411
- if (vals.length === 0) {} else if (vals.length === 1) {
7412
- const val = vals[0];
7413
- json.type = val === null ? "null" : typeof val;
7414
- if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") json.enum = [val];
7415
- else json.const = val;
7416
- } else {
7417
- if (vals.every((v$1) => typeof v$1 === "number")) json.type = "number";
7418
- if (vals.every((v$1) => typeof v$1 === "string")) json.type = "string";
7419
- if (vals.every((v$1) => typeof v$1 === "boolean")) json.type = "boolean";
7420
- if (vals.every((v$1) => v$1 === null)) json.type = "null";
7421
- json.enum = vals;
7422
- }
7423
- };
7424
7372
  const customProcessor = (_schema, ctx, _json, _params) => {
7425
7373
  if (ctx.unrepresentable === "throw") throw new Error("Custom types cannot be represented in JSON Schema");
7426
7374
  };
@@ -7503,6 +7451,44 @@ const intersectionProcessor = (schema, ctx, json, params) => {
7503
7451
  const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
7504
7452
  json.allOf = [...isSimpleIntersection(a$1) ? a$1.allOf : [a$1], ...isSimpleIntersection(b$2) ? b$2.allOf : [b$2]];
7505
7453
  };
7454
+ const tupleProcessor = (schema, ctx, _json, params) => {
7455
+ const json = _json;
7456
+ const def = schema._zod.def;
7457
+ json.type = "array";
7458
+ const prefixPath$1 = ctx.target === "draft-2020-12" ? "prefixItems" : "items";
7459
+ const restPath = ctx.target === "draft-2020-12" ? "items" : ctx.target === "openapi-3.0" ? "items" : "additionalItems";
7460
+ const prefixItems = def.items.map((x$2, i$1) => process$2(x$2, ctx, {
7461
+ ...params,
7462
+ path: [
7463
+ ...params.path,
7464
+ prefixPath$1,
7465
+ i$1
7466
+ ]
7467
+ }));
7468
+ const rest = def.rest ? process$2(def.rest, ctx, {
7469
+ ...params,
7470
+ path: [
7471
+ ...params.path,
7472
+ restPath,
7473
+ ...ctx.target === "openapi-3.0" ? [def.items.length] : []
7474
+ ]
7475
+ }) : null;
7476
+ if (ctx.target === "draft-2020-12") {
7477
+ json.prefixItems = prefixItems;
7478
+ if (rest) json.items = rest;
7479
+ } else if (ctx.target === "openapi-3.0") {
7480
+ json.items = { anyOf: prefixItems };
7481
+ if (rest) json.items.anyOf.push(rest);
7482
+ json.minItems = prefixItems.length;
7483
+ if (!rest) json.maxItems = prefixItems.length;
7484
+ } else {
7485
+ json.items = prefixItems;
7486
+ if (rest) json.additionalItems = rest;
7487
+ }
7488
+ const { minimum, maximum } = schema._zod.bag;
7489
+ if (typeof minimum === "number") json.minItems = minimum;
7490
+ if (typeof maximum === "number") json.maxItems = maximum;
7491
+ };
7506
7492
  const nullableProcessor = (schema, ctx, json, params) => {
7507
7493
  const def = schema._zod.def;
7508
7494
  const inner = process$2(def.innerType, ctx, params);
@@ -7895,14 +7881,6 @@ const ZodNumberFormat = /* @__PURE__ */ $constructor("ZodNumberFormat", (inst, d
7895
7881
  function int(params) {
7896
7882
  return _int(ZodNumberFormat, params);
7897
7883
  }
7898
- const ZodBoolean = /* @__PURE__ */ $constructor("ZodBoolean", (inst, def) => {
7899
- $ZodBoolean.init(inst, def);
7900
- ZodType.init(inst, def);
7901
- inst._zod.processJSONSchema = (ctx, json, params) => booleanProcessor(inst, ctx, json, params);
7902
- });
7903
- function boolean(params) {
7904
- return _boolean(ZodBoolean, params);
7905
- }
7906
7884
  const ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
7907
7885
  $ZodUnknown.init(inst, def);
7908
7886
  ZodType.init(inst, def);
@@ -8001,18 +7979,6 @@ function union(options, params) {
8001
7979
  ...normalizeParams(params)
8002
7980
  });
8003
7981
  }
8004
- const ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("ZodDiscriminatedUnion", (inst, def) => {
8005
- ZodUnion.init(inst, def);
8006
- $ZodDiscriminatedUnion.init(inst, def);
8007
- });
8008
- function discriminatedUnion(discriminator, options, params) {
8009
- return new ZodDiscriminatedUnion({
8010
- type: "union",
8011
- options,
8012
- discriminator,
8013
- ...normalizeParams(params)
8014
- });
8015
- }
8016
7982
  const ZodIntersection = /* @__PURE__ */ $constructor("ZodIntersection", (inst, def) => {
8017
7983
  $ZodIntersection.init(inst, def);
8018
7984
  ZodType.init(inst, def);
@@ -8025,6 +7991,25 @@ function intersection(left, right) {
8025
7991
  right
8026
7992
  });
8027
7993
  }
7994
+ const ZodTuple = /* @__PURE__ */ $constructor("ZodTuple", (inst, def) => {
7995
+ $ZodTuple.init(inst, def);
7996
+ ZodType.init(inst, def);
7997
+ inst._zod.processJSONSchema = (ctx, json, params) => tupleProcessor(inst, ctx, json, params);
7998
+ inst.rest = (rest) => inst.clone({
7999
+ ...inst._zod.def,
8000
+ rest
8001
+ });
8002
+ });
8003
+ function tuple(items, _paramsOrRest, _params) {
8004
+ const hasRest = _paramsOrRest instanceof $ZodType;
8005
+ const params = hasRest ? _params : _paramsOrRest;
8006
+ return new ZodTuple({
8007
+ type: "tuple",
8008
+ items,
8009
+ rest: hasRest ? _paramsOrRest : null,
8010
+ ...normalizeParams(params)
8011
+ });
8012
+ }
8028
8013
  const ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
8029
8014
  $ZodEnum.init(inst, def);
8030
8015
  ZodType.init(inst, def);
@@ -8062,23 +8047,6 @@ function _enum(values, params) {
8062
8047
  ...normalizeParams(params)
8063
8048
  });
8064
8049
  }
8065
- const ZodLiteral = /* @__PURE__ */ $constructor("ZodLiteral", (inst, def) => {
8066
- $ZodLiteral.init(inst, def);
8067
- ZodType.init(inst, def);
8068
- inst._zod.processJSONSchema = (ctx, json, params) => literalProcessor(inst, ctx, json, params);
8069
- inst.values = new Set(def.values);
8070
- Object.defineProperty(inst, "value", { get() {
8071
- if (def.values.length > 1) throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");
8072
- return def.values[0];
8073
- } });
8074
- });
8075
- function literal(value, params) {
8076
- return new ZodLiteral({
8077
- type: "literal",
8078
- values: Array.isArray(value) ? value : [value],
8079
- ...normalizeParams(params)
8080
- });
8081
- }
8082
8050
  const ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
8083
8051
  $ZodTransform.init(inst, def);
8084
8052
  ZodType.init(inst, def);
@@ -17126,6 +17094,14 @@ async function readFile$1(filePath) {
17126
17094
  throw new Error(`Failed to read file ${filePath}: ${error instanceof Error ? error.message : "Unknown error"}`);
17127
17095
  }
17128
17096
  }
17097
+ async function readTextFile(filePath) {
17098
+ if (!await pathExists(filePath)) throw new Error(`File not found: ${filePath}`);
17099
+ try {
17100
+ return await readFile(filePath, "utf-8");
17101
+ } catch (error) {
17102
+ throw new Error(`Failed to read file ${filePath}: ${error instanceof Error ? error.message : "Unknown error"}`);
17103
+ }
17104
+ }
17129
17105
  async function readJsonFile(filePath) {
17130
17106
  if (!await pathExists(filePath)) throw new Error(`File not found: ${filePath}`);
17131
17107
  try {
@@ -17198,39 +17174,19 @@ const entityResource = {
17198
17174
 
17199
17175
  //#endregion
17200
17176
  //#region src/core/resources/function/schema.ts
17201
- const HttpTriggerSchema = object({
17202
- id: string().optional(),
17203
- name: string().optional(),
17204
- description: string().optional(),
17205
- type: literal("http"),
17206
- path: string().min(1, "Path cannot be empty")
17207
- });
17208
- const ScheduleTriggerSchema = object({
17209
- id: string().optional(),
17210
- name: string().optional(),
17211
- description: string().optional(),
17212
- type: literal("schedule"),
17213
- scheduleMode: _enum(["recurring", "once"]).optional(),
17214
- cron: string().min(1, "Cron expression cannot be empty"),
17215
- isActive: boolean().optional(),
17216
- timezone: string().optional()
17217
- });
17218
- const EventTriggerSchema = object({
17219
- id: string().optional(),
17220
- name: string().optional(),
17221
- description: string().optional(),
17222
- type: literal("event"),
17223
- entity: string().min(1, "Entity name cannot be empty"),
17224
- event: string().min(1, "Event type cannot be empty")
17225
- });
17226
- const TriggerSchema = discriminatedUnion("type", [
17227
- HttpTriggerSchema,
17228
- ScheduleTriggerSchema,
17229
- EventTriggerSchema
17230
- ]);
17231
17177
  const FunctionConfigSchema = object({
17178
+ name: string().min(1, "Function name cannot be empty").refine((name$1) => !name$1.includes("."), "Function name cannot contain dots"),
17232
17179
  entry: string().min(1, "Entry point cannot be empty"),
17233
- triggers: array(TriggerSchema).optional()
17180
+ triggers: tuple([]).optional()
17181
+ });
17182
+ const FunctionSchema = FunctionConfigSchema.extend({ codePath: string().min(1, "Code path cannot be empty") });
17183
+ const DeployFunctionsResponseSchema = object({
17184
+ deployed: array(string()),
17185
+ deleted: array(string()),
17186
+ errors: array(object({
17187
+ name: string(),
17188
+ message: string()
17189
+ })).nullable()
17234
17190
  });
17235
17191
 
17236
17192
  //#endregion
@@ -17238,7 +17194,19 @@ const FunctionConfigSchema = object({
17238
17194
  async function readFunctionConfig(configPath) {
17239
17195
  const parsed = await readJsonFile(configPath);
17240
17196
  const result = FunctionConfigSchema.safeParse(parsed);
17241
- if (!result.success) throw new Error(`Invalid function configuration in ${configPath}: ${result.error.issues.map((e$1) => e$1.message).join(", ")}`);
17197
+ if (!result.success) throw new Error(`Invalid function configuration in ${configPath}: ${result.error.message}`);
17198
+ return result.data;
17199
+ }
17200
+ async function readFunction(configPath) {
17201
+ const config$2 = await readFunctionConfig(configPath);
17202
+ const codePath = join(dirname(configPath), config$2.entry);
17203
+ if (!await pathExists(codePath)) throw new Error(`Function code file not found: ${codePath} (referenced in ${configPath})`);
17204
+ const functionData = {
17205
+ ...config$2,
17206
+ codePath
17207
+ };
17208
+ const result = FunctionSchema.safeParse(functionData);
17209
+ if (!result.success) throw new Error(`Invalid function in ${configPath}: ${result.error.message}`);
17242
17210
  return result.data;
17243
17211
  }
17244
17212
  async function readAllFunctions(functionsDir) {
@@ -17247,12 +17215,60 @@ async function readAllFunctions(functionsDir) {
17247
17215
  cwd: functionsDir,
17248
17216
  absolute: true
17249
17217
  });
17250
- return await Promise.all(configFiles.map((configPath) => readFunctionConfig(configPath)));
17218
+ const functions = await Promise.all(configFiles.map((configPath) => readFunction(configPath)));
17219
+ const names = /* @__PURE__ */ new Set();
17220
+ for (const fn of functions) {
17221
+ if (names.has(fn.name)) throw new Error(`Duplicate function name "${fn.name}"`);
17222
+ names.add(fn.name);
17223
+ }
17224
+ return functions;
17225
+ }
17226
+
17227
+ //#endregion
17228
+ //#region src/core/resources/function/api.ts
17229
+ function toDeployPayloadItem(fn) {
17230
+ return {
17231
+ name: fn.name,
17232
+ entry: fn.entry,
17233
+ files: [{
17234
+ path: fn.entry,
17235
+ content: fn.code
17236
+ }]
17237
+ };
17238
+ }
17239
+ async function deployFunctions(functions) {
17240
+ const appClient = getAppClient();
17241
+ const payload = { functions: functions.map(toDeployPayloadItem) };
17242
+ const response = await appClient.put("backend-functions/deploy", {
17243
+ json: payload,
17244
+ throwHttpErrors: false
17245
+ });
17246
+ if (!response.ok) {
17247
+ const errorJson = await response.json();
17248
+ throw new Error(`Failed to deploy functions: ${errorJson}`);
17249
+ }
17250
+ return DeployFunctionsResponseSchema.parse(await response.json());
17251
+ }
17252
+
17253
+ //#endregion
17254
+ //#region src/core/resources/function/deploy.ts
17255
+ async function loadFunctionCode(fn) {
17256
+ const code$1 = await readTextFile(fn.codePath);
17257
+ return {
17258
+ ...fn,
17259
+ code: code$1
17260
+ };
17261
+ }
17262
+ async function pushFunctions(functions) {
17263
+ return deployFunctions(await Promise.all(functions.map(loadFunctionCode)));
17251
17264
  }
17252
17265
 
17253
17266
  //#endregion
17254
17267
  //#region src/core/resources/function/resource.ts
17255
- const functionResource = { readAll: readAllFunctions };
17268
+ const functionResource = {
17269
+ readAll: readAllFunctions,
17270
+ push: pushFunctions
17271
+ };
17256
17272
 
17257
17273
  //#endregion
17258
17274
  //#region src/core/project/schema.ts
@@ -26187,21 +26203,10 @@ async function getUserInfo(accessToken) {
26187
26203
  return result.data;
26188
26204
  }
26189
26205
 
26190
- //#endregion
26191
- //#region src/cli/utils/consts.ts
26192
- /**
26193
- * Brand colors used throughout the CLI
26194
- */
26195
- const ORANGE = source_default.hex("#E86B3C");
26196
- const CYAN = source_default.hex("#00D4FF");
26197
- const GOLD = source_default.hex("#FFD700");
26198
- /**
26199
- * Background color for the Base44 intro tag
26200
- */
26201
- const BASE44_BG = source_default.bgHex("#E86B3C");
26202
-
26203
26206
  //#endregion
26204
26207
  //#region src/cli/utils/animate.ts
26208
+ const orange$2 = source_default.hex("#E86B3C");
26209
+ const gold = source_default.hex("#FFD700");
26205
26210
  /**
26206
26211
  * Sleep for a specified number of milliseconds.
26207
26212
  */
@@ -26218,13 +26223,13 @@ async function animateLineReveal(line, duration$2) {
26218
26223
  const progress = step / steps;
26219
26224
  const revealIndex = Math.floor(progress * line.length);
26220
26225
  let output = "";
26221
- for (let i$1 = 0; i$1 < line.length; i$1++) if (i$1 < revealIndex) output += ORANGE(line[i$1]);
26222
- else if (i$1 === revealIndex) output += GOLD(line[i$1]);
26226
+ for (let i$1 = 0; i$1 < line.length; i$1++) if (i$1 < revealIndex) output += orange$2(line[i$1]);
26227
+ else if (i$1 === revealIndex) output += gold(line[i$1]);
26223
26228
  else output += source_default.dim(line[i$1]);
26224
26229
  process.stdout.write(`\r${output}`);
26225
26230
  await sleep(stepDuration);
26226
26231
  }
26227
- process.stdout.write(`\r${ORANGE(line)}\n`);
26232
+ process.stdout.write(`\r${orange$2(line)}\n`);
26228
26233
  }
26229
26234
  /**
26230
26235
  * Quick shimmer pass over the entire banner.
@@ -26241,15 +26246,15 @@ async function shimmerPass(lines, duration$2) {
26241
26246
  let output = "";
26242
26247
  for (let i$1 = 0; i$1 < line.length; i$1++) {
26243
26248
  const dist = Math.abs(i$1 - shimmerPos);
26244
- if (dist < 3) output += dist === 0 ? source_default.white(line[i$1]) : GOLD(line[i$1]);
26245
- else output += ORANGE(line[i$1]);
26249
+ if (dist < 3) output += dist === 0 ? source_default.white(line[i$1]) : gold(line[i$1]);
26250
+ else output += orange$2(line[i$1]);
26246
26251
  }
26247
26252
  console.log(output);
26248
26253
  }
26249
26254
  await sleep(stepDuration);
26250
26255
  }
26251
26256
  process.stdout.write(moveUp);
26252
- for (const line of lines) console.log(ORANGE(line));
26257
+ for (const line of lines) console.log(orange$2(line));
26253
26258
  }
26254
26259
  /**
26255
26260
  * Animate the output with a smooth line-by-line reveal.
@@ -26269,6 +26274,7 @@ async function printAnimatedLines(lines) {
26269
26274
 
26270
26275
  //#endregion
26271
26276
  //#region src/cli/utils/banner.ts
26277
+ const orange$1 = source_default.hex("#E86B3C");
26272
26278
  const BANNER_LINES = [
26273
26279
  "██████╗ █████╗ ███████╗███████╗ ██╗ ██╗██╗ ██╗",
26274
26280
  "██╔══██╗██╔══██╗██╔════╝██╔════╝ ██║ ██║██║ ██║",
@@ -26283,11 +26289,12 @@ const BANNER_LINES = [
26283
26289
  */
26284
26290
  async function printBanner() {
26285
26291
  if (process.stdout.isTTY) await printAnimatedLines(BANNER_LINES);
26286
- else console.log(ORANGE(BANNER_LINES.join("\n")));
26292
+ else console.log(orange$1(BANNER_LINES.join("\n")));
26287
26293
  }
26288
26294
 
26289
26295
  //#endregion
26290
26296
  //#region src/cli/utils/runCommand.ts
26297
+ const base44Color = source_default.bgHex("#E86B3C");
26291
26298
  /**
26292
26299
  * Wraps a command function with the Base44 intro/outro and error handling.
26293
26300
  * All CLI commands should use this utility to ensure consistent branding.
@@ -26331,7 +26338,7 @@ async function runCommand(commandFn, options) {
26331
26338
  if (options?.fullBanner) {
26332
26339
  await printBanner();
26333
26340
  Ie("");
26334
- } else Ie(BASE44_BG(" Base 44 "));
26341
+ } else Ie(base44Color(" Base 44 "));
26335
26342
  await loadProjectEnv();
26336
26343
  try {
26337
26344
  if (options?.requireAuth) {
@@ -31497,6 +31504,30 @@ const entitiesPushCommand = new Command("entities").description("Manage project
31497
31504
  await runCommand(pushEntitiesAction, { requireAuth: true });
31498
31505
  }));
31499
31506
 
31507
+ //#endregion
31508
+ //#region src/cli/commands/functions/deploy.ts
31509
+ async function deployFunctionsAction() {
31510
+ const { functions } = await readProjectConfig();
31511
+ if (functions.length === 0) return { outroMessage: "No functions found. Create functions in the 'functions' directory." };
31512
+ M.info(`Found ${functions.length} ${functions.length === 1 ? "function" : "functions"} to deploy`);
31513
+ const result = await runTask("Deploying functions to Base44", async () => {
31514
+ return await pushFunctions(functions);
31515
+ }, {
31516
+ successMessage: "Functions deployed successfully",
31517
+ errorMessage: "Failed to deploy functions"
31518
+ });
31519
+ if (result.deployed.length > 0) M.success(`Deployed: ${result.deployed.join(", ")}`);
31520
+ if (result.deleted.length > 0) M.warn(`Deleted: ${result.deleted.join(", ")}`);
31521
+ if (result.errors && result.errors.length > 0) {
31522
+ const errorMessages = result.errors.map((e$1) => ` ${e$1.name}: ${e$1.message}`).join("\n");
31523
+ throw new Error(`Function deployment errors:\n${errorMessages}`);
31524
+ }
31525
+ return {};
31526
+ }
31527
+ const functionsDeployCommand = new Command("functions").description("Manage project functions").addCommand(new Command("deploy").description("Deploy local functions to Base44").action(async () => {
31528
+ await runCommand(deployFunctionsAction, { requireAuth: true });
31529
+ }));
31530
+
31500
31531
  //#endregion
31501
31532
  //#region node_modules/is-plain-obj/index.js
31502
31533
  function isPlainObject(value) {
@@ -32121,7 +32152,7 @@ const green = format(32, 39);
32121
32152
  const yellow = format(33, 39);
32122
32153
  const blue = format(34, 39);
32123
32154
  const magenta = format(35, 39);
32124
- const cyan = format(36, 39);
32155
+ const cyan$1 = format(36, 39);
32125
32156
  const white = format(37, 39);
32126
32157
  const gray = format(90, 39);
32127
32158
  const bgBlack = format(40, 49);
@@ -38165,6 +38196,8 @@ var require_lodash = /* @__PURE__ */ __commonJSMin(((exports, module) => {
38165
38196
  //#endregion
38166
38197
  //#region src/cli/commands/project/create.ts
38167
38198
  var import_lodash = /* @__PURE__ */ __toESM(require_lodash(), 1);
38199
+ const orange = source_default.hex("#E86B3C");
38200
+ const cyan = source_default.hex("#00D4FF");
38168
38201
  const DEFAULT_TEMPLATE_ID = "backend-only";
38169
38202
  async function getDefaultTemplate() {
38170
38203
  const template = (await listTemplates()).find((t) => t.id === DEFAULT_TEMPLATE_ID);
@@ -38244,7 +38277,7 @@ async function executeCreate({ template, name: rawName, description, projectPath
38244
38277
  template
38245
38278
  });
38246
38279
  }, {
38247
- successMessage: ORANGE("Project created successfully"),
38280
+ successMessage: orange("Project created successfully"),
38248
38281
  errorMessage: "Failed to create project"
38249
38282
  });
38250
38283
  await loadProjectEnv(resolvedPath);
@@ -38259,7 +38292,7 @@ async function executeCreate({ template, name: rawName, description, projectPath
38259
38292
  if (shouldPushEntities) await runTask(`Pushing ${entities.length} entities to Base44...`, async () => {
38260
38293
  await pushEntities(entities);
38261
38294
  }, {
38262
- successMessage: ORANGE("Entities pushed successfully"),
38295
+ successMessage: orange("Entities pushed successfully"),
38263
38296
  errorMessage: "Failed to push entities"
38264
38297
  });
38265
38298
  }
@@ -38284,16 +38317,16 @@ async function executeCreate({ template, name: rawName, description, projectPath
38284
38317
  updateMessage("Deploying site...");
38285
38318
  return await deploySite(join(resolvedPath, outputDirectory));
38286
38319
  }, {
38287
- successMessage: ORANGE("Site deployed successfully"),
38320
+ successMessage: orange("Site deployed successfully"),
38288
38321
  errorMessage: "Failed to deploy site"
38289
38322
  });
38290
38323
  finalAppUrl = appUrl;
38291
38324
  }
38292
38325
  }
38293
38326
  const dashboardUrl = `${getBase44ApiUrl()}/apps/${projectId}/editor/preview`;
38294
- M.message(`${source_default.dim("Project")}: ${ORANGE(name$1)}`);
38295
- M.message(`${source_default.dim("Dashboard")}: ${CYAN(dashboardUrl)}`);
38296
- if (finalAppUrl) M.message(`${source_default.dim("Site")}: ${CYAN(finalAppUrl)}`);
38327
+ M.message(`${source_default.dim("Project")}: ${orange(name$1)}`);
38328
+ M.message(`${source_default.dim("Dashboard")}: ${cyan(dashboardUrl)}`);
38329
+ if (finalAppUrl) M.message(`${source_default.dim("Site")}: ${cyan(finalAppUrl)}`);
38297
38330
  return { outroMessage: "Your project is set and ready to use" };
38298
38331
  }
38299
38332
  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) => {
@@ -38334,6 +38367,7 @@ program.addCommand(whoamiCommand);
38334
38367
  program.addCommand(logoutCommand);
38335
38368
  program.addCommand(createCommand);
38336
38369
  program.addCommand(entitiesPushCommand);
38370
+ program.addCommand(functionsDeployCommand);
38337
38371
  program.addCommand(siteDeployCommand);
38338
38372
  program.parse();
38339
38373
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base44-preview/cli",
3
- "version": "0.0.9-pr.74.8755bae",
3
+ "version": "0.0.9-pr.75.1247e76",
4
4
  "description": "Base44 CLI - Unified interface for managing Base44 applications",
5
5
  "type": "module",
6
6
  "main": "./dist/cli/index.js",