@base44-preview/cli 0.0.38-pr.380.ba23c83 → 0.0.38-pr.381.74c3c3d

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli/index.js CHANGED
@@ -233911,21 +233911,6 @@ var DeployFunctionsResponseSchema = exports_external.object({
233911
233911
  skipped: exports_external.array(exports_external.string()).optional().nullable(),
233912
233912
  errors: exports_external.array(exports_external.object({ name: exports_external.string(), message: exports_external.string() })).nullable()
233913
233913
  });
233914
- var FunctionAutomationInfoSchema = exports_external.object({
233915
- name: exports_external.string(),
233916
- type: exports_external.string(),
233917
- is_active: exports_external.boolean()
233918
- });
233919
- var FunctionInfoSchema = exports_external.object({
233920
- name: exports_external.string(),
233921
- deployment_id: exports_external.string(),
233922
- entry: exports_external.string(),
233923
- files: exports_external.array(FunctionFileSchema),
233924
- automations: exports_external.array(FunctionAutomationInfoSchema)
233925
- });
233926
- var ListFunctionsResponseSchema = exports_external.object({
233927
- functions: exports_external.array(FunctionInfoSchema)
233928
- });
233929
233914
  var LogLevelSchema = exports_external.enum(["info", "warning", "error", "debug"]);
233930
233915
  var FunctionLogEntrySchema = exports_external.object({
233931
233916
  time: exports_external.string(),
@@ -233963,19 +233948,13 @@ async function deployFunctions(functions) {
233963
233948
  }
233964
233949
  return result.data;
233965
233950
  }
233966
- async function listDeployedFunctions() {
233951
+ async function deleteSingleFunction(name2) {
233967
233952
  const appClient = getAppClient();
233968
- let response;
233969
233953
  try {
233970
- response = await appClient.get("backend-functions", { timeout: 30000 });
233954
+ await appClient.delete(`backend-functions/${encodeURIComponent(name2)}`, { timeout: 60000 });
233971
233955
  } catch (error48) {
233972
- throw await ApiError.fromHttpError(error48, "listing deployed functions");
233973
- }
233974
- const result = ListFunctionsResponseSchema.safeParse(await response.json());
233975
- if (!result.success) {
233976
- throw new SchemaValidationError("Invalid response from server", result.error);
233956
+ throw await ApiError.fromHttpError(error48, `deleting function "${name2}"`);
233977
233957
  }
233978
- return result.data;
233979
233958
  }
233980
233959
  function buildLogsQueryString(filters) {
233981
233960
  const params = new URLSearchParams;
@@ -243122,6 +243101,63 @@ function getEntitiesPushCommand(context) {
243122
243101
  }));
243123
243102
  }
243124
243103
 
243104
+ // src/cli/utils/parseNames.ts
243105
+ function parseNames(args) {
243106
+ return args.flatMap((arg) => arg.split(",")).map((n2) => n2.trim()).filter(Boolean);
243107
+ }
243108
+
243109
+ // src/cli/commands/functions/delete.ts
243110
+ async function deleteFunctionsAction(names) {
243111
+ let deleted = 0;
243112
+ let notFound = 0;
243113
+ let errors4 = 0;
243114
+ let completed = 0;
243115
+ const total = names.length;
243116
+ for (const name2 of names) {
243117
+ R2.step(theme.styles.dim(`[${completed + 1}/${total}] Deleting ${name2}...`));
243118
+ try {
243119
+ await deleteSingleFunction(name2);
243120
+ R2.success(`${name2.padEnd(25)} deleted`);
243121
+ deleted++;
243122
+ } catch (error48) {
243123
+ if (error48 instanceof ApiError && error48.statusCode === 404) {
243124
+ R2.warn(`${name2.padEnd(25)} not found`);
243125
+ notFound++;
243126
+ } else {
243127
+ R2.error(`${name2.padEnd(25)} error: ${error48 instanceof Error ? error48.message : String(error48)}`);
243128
+ errors4++;
243129
+ }
243130
+ }
243131
+ completed++;
243132
+ }
243133
+ if (names.length === 1) {
243134
+ if (deleted)
243135
+ return { outroMessage: `Function "${names[0]}" deleted` };
243136
+ if (notFound)
243137
+ return { outroMessage: `Function "${names[0]}" not found` };
243138
+ return { outroMessage: `Failed to delete "${names[0]}"` };
243139
+ }
243140
+ const parts = [];
243141
+ if (deleted > 0)
243142
+ parts.push(`${deleted}/${total} deleted`);
243143
+ if (notFound > 0)
243144
+ parts.push(`${notFound} not found`);
243145
+ if (errors4 > 0)
243146
+ parts.push(`${errors4} error${errors4 !== 1 ? "s" : ""}`);
243147
+ return { outroMessage: parts.join(", ") };
243148
+ }
243149
+ function getDeleteCommand(context) {
243150
+ return new Command("delete").description("Delete deployed functions").argument("<names...>", "Function names to delete").action(async (rawNames) => {
243151
+ await runCommand(() => {
243152
+ const names = parseNames(rawNames);
243153
+ if (names.length === 0) {
243154
+ throw new InvalidInputError("At least one function name is required");
243155
+ }
243156
+ return deleteFunctionsAction(names);
243157
+ }, { requireAuth: true }, context);
243158
+ });
243159
+ }
243160
+
243125
243161
  // src/cli/commands/functions/deploy.ts
243126
243162
  async function deployFunctionsAction() {
243127
243163
  const { functions } = await readProjectConfig();
@@ -243160,30 +243196,9 @@ function getDeployCommand(context) {
243160
243196
  });
243161
243197
  }
243162
243198
 
243163
- // src/cli/commands/functions/list.ts
243164
- async function listFunctionsAction() {
243165
- const { functions } = await listDeployedFunctions();
243166
- if (functions.length === 0) {
243167
- return { outroMessage: "No functions on remote" };
243168
- }
243169
- for (const fn of functions) {
243170
- const autoCount = fn.automations.length;
243171
- const autoLabel = autoCount > 0 ? theme.styles.dim(` (${autoCount} automation${autoCount > 1 ? "s" : ""})`) : "";
243172
- R2.message(` ${fn.name}${autoLabel}`);
243173
- }
243174
- return {
243175
- outroMessage: `${functions.length} function${functions.length !== 1 ? "s" : ""} on remote`
243176
- };
243177
- }
243178
- function getListCommand(context) {
243179
- return new Command("list").description("List all deployed functions").action(async () => {
243180
- await runCommand(listFunctionsAction, { requireAuth: true }, context);
243181
- });
243182
- }
243183
-
243184
243199
  // src/cli/commands/functions/index.ts
243185
243200
  function getFunctionsCommand(context) {
243186
- return new Command("functions").description("Manage backend functions").addCommand(getDeployCommand(context)).addCommand(getListCommand(context));
243201
+ return new Command("functions").description("Manage backend functions").addCommand(getDeployCommand(context)).addCommand(getDeleteCommand(context));
243187
243202
  }
243188
243203
 
243189
243204
  // src/cli/commands/project/create.ts
@@ -250910,4 +250925,4 @@ export {
250910
250925
  CLIExitError
250911
250926
  };
250912
250927
 
250913
- //# debugId=153E33F56F0F0F1C64756E2164756E21
250928
+ //# debugId=82EE38A292EE010964756E2164756E21