@base44-preview/cli 0.1.32-pr.663.63c4a74 → 0.1.32-pr.663.8c37aaa

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
@@ -39570,9 +39570,9 @@ function tm(e, t, r) {
39570
39570
  return l(["<", r("name"), r("typeArguments"), " ", ...e.map(r, "attributes"), n.selfClosing ? " />" : ">"]);
39571
39571
  let i = n.attributes?.some((u) => V3(u.value) && u.value.value.includes(`
39572
39572
  `)), o = t.singleAttributePerLine && n.attributes.length > 1 ? E : A;
39573
- return l(["<", r("name"), r("typeArguments"), m(e.map(() => [o, r()], "attributes")), ...rm2(n, t, s)], { shouldBreak: i });
39573
+ return l(["<", r("name"), r("typeArguments"), m(e.map(() => [o, r()], "attributes")), ...rm3(n, t, s)], { shouldBreak: i });
39574
39574
  }
39575
- function rm2(e, t, r) {
39575
+ function rm3(e, t, r) {
39576
39576
  return e.selfClosing ? [A, "/>"] : nm(e, t, r) ? [">"] : [f, ">"];
39577
39577
  }
39578
39578
  function nm(e, t, r) {
@@ -111521,7 +111521,7 @@ function N62(e) {
111521
111521
  function nm2(e, t, a) {
111522
111522
  return ie10(t, a, e.typeParameters) || ie10(t, a, e.parameters) || S7(t, e.type);
111523
111523
  }
111524
- function rm3(e, t, a) {
111524
+ function rm4(e, t, a) {
111525
111525
  return ie10(t, a, e.types);
111526
111526
  }
111527
111527
  function im2(e, t, a) {
@@ -114489,7 +114489,7 @@ ${Me.join(`
114489
114489
  return S7(a, t.elementType);
114490
114490
  }, 190: function(t, a, _) {
114491
114491
  return ie10(a, _, t.elements);
114492
- }, 193: rm3, 194: rm3, 195: function(t, a, _) {
114492
+ }, 193: rm4, 194: rm4, 195: function(t, a, _) {
114493
114493
  return S7(a, t.checkType) || S7(a, t.extendsType) || S7(a, t.trueType) || S7(a, t.falseType);
114494
114494
  }, 196: function(t, a, _) {
114495
114495
  return S7(a, t.typeParameter);
@@ -249264,10 +249264,16 @@ var OpenApiSpecSchema = looseObject({
249264
249264
  security: array(SecurityRequirementSchema).optional()
249265
249265
  });
249266
249266
 
249267
+ // src/core/api-spec/text.ts
249268
+ var DOCS_CALLOUT = /<(Info|Note|Tip|Check|Warning)>([\s\S]*?)<\/\1>/g;
249269
+ var RELATIVE_LINK = /\[([^\]]+)\]\(\/[^)]*\)/g;
249270
+ function cleanText(text) {
249271
+ return text.replace(DOCS_CALLOUT, (_, kind, body) => kind === "Warning" ? `Warning: ${body}` : body).replace(RELATIVE_LINK, "$1");
249272
+ }
249273
+
249267
249274
  // src/core/api-spec/contract.ts
249268
249275
  var SCHEMA_REF_PREFIX = "#/components/schemas/";
249269
249276
  var MAX_REF_DEPTH = 4;
249270
- var FRAMEWORK_VALIDATION_ERROR = "Validation Error";
249271
249277
  function inlineRefs(node, schemas, seen = new Set, depth = 0) {
249272
249278
  if (depth > MAX_REF_DEPTH) {
249273
249279
  return node;
@@ -249307,8 +249313,10 @@ function leftoverRefs(node, schemas, found = new Map) {
249307
249313
  for (const [key, value] of Object.entries(node)) {
249308
249314
  if (key === "$ref" && typeof value === "string" && value.startsWith(SCHEMA_REF_PREFIX) && !found.has(value)) {
249309
249315
  const schema = schemas[value.slice(SCHEMA_REF_PREFIX.length)];
249310
- found.set(value, schema);
249311
- leftoverRefs(schema, schemas, found);
249316
+ if (schema !== undefined) {
249317
+ found.set(value, schema);
249318
+ leftoverRefs(schema, schemas, found);
249319
+ }
249312
249320
  } else {
249313
249321
  leftoverRefs(value, schemas, found);
249314
249322
  }
@@ -249323,11 +249331,6 @@ var SCHEMA_DATA_KEYS = new Set([
249323
249331
  "enum",
249324
249332
  "const"
249325
249333
  ]);
249326
- var DOCS_CALLOUT = /<(Info|Note|Tip|Check|Warning)>([\s\S]*?)<\/\1>/g;
249327
- var RELATIVE_LINK = /\[([^\]]+)\]\(\/[^)]*\)/g;
249328
- function cleanText(text) {
249329
- return text.replace(DOCS_CALLOUT, (_, kind, body) => kind === "Warning" ? `Warning: ${body}` : body).replace(RELATIVE_LINK, "$1");
249330
- }
249331
249334
  function slimSchema(node, isPropertyMap = false) {
249332
249335
  if (Array.isArray(node)) {
249333
249336
  return node.map((item) => slimSchema(item));
@@ -249365,14 +249368,13 @@ function getOperationContract(spec, op) {
249365
249368
  return parsed.success ? [[status, parsed.data]] : [];
249366
249369
  });
249367
249370
  const success = responses.filter(([status]) => status.startsWith("2")).sort(([a], [b]) => a.localeCompare(b)).map(([, response]) => bodyOf(response).schema).find(Boolean);
249368
- const errors = responses.filter(([status, response]) => !status.startsWith("2") && response.description !== FRAMEWORK_VALIDATION_ERROR);
249369
249371
  const requestBody = bodyOf(op.operation.requestBody);
249370
249372
  const contract = {
249371
249373
  endpoint: op.endpoint,
249372
249374
  method: op.method,
249373
249375
  path: op.path,
249374
249376
  summary: op.summary,
249375
- description: cleanText(op.description),
249377
+ description: op.description,
249376
249378
  parameters: (op.operation.parameters ?? []).flatMap((parameter) => {
249377
249379
  const parsed = ParameterSchema.safeParse(parameter);
249378
249380
  if (!parsed.success) {
@@ -249393,11 +249395,7 @@ function getOperationContract(spec, op) {
249393
249395
  }),
249394
249396
  ...requestBody.contentType && requestBody.contentType !== "application/json" ? { requestBodyContentType: requestBody.contentType } : {},
249395
249397
  requestBodySchema: inline(requestBody.schema),
249396
- responseSchema: inline(success),
249397
- errors: Object.fromEntries(errors.map(([status, response]) => [
249398
- status,
249399
- cleanText(response.description ?? "")
249400
- ]))
249398
+ responseSchema: inline(success)
249401
249399
  };
249402
249400
  const refs = leftoverRefs(contract, schemas);
249403
249401
  return {
@@ -249422,7 +249420,7 @@ function isReadOnly(operation, spec) {
249422
249420
  function parameterText(operation) {
249423
249421
  return (operation.parameters ?? []).flatMap((parameter) => {
249424
249422
  const parsed = ParameterSchema.safeParse(parameter);
249425
- return parsed.success ? [parsed.data.name, parsed.data.description ?? ""] : [];
249423
+ return parsed.success ? [parsed.data.name, cleanText(parsed.data.description ?? "")] : [];
249426
249424
  }).join(" ");
249427
249425
  }
249428
249426
  function mergeParameters(shared, own) {
@@ -249455,7 +249453,7 @@ function listOperations(spec) {
249455
249453
  method: method.toUpperCase(),
249456
249454
  path,
249457
249455
  summary: operation.summary ?? "",
249458
- description: operation.description ?? "",
249456
+ description: cleanText(operation.description ?? ""),
249459
249457
  parameterText: parameterText(operation),
249460
249458
  readOnly: isReadOnly(operation, spec),
249461
249459
  operation
@@ -249488,6 +249486,7 @@ function matchOperation(operations, method, concretePath) {
249488
249486
  }
249489
249487
  // src/core/api-spec/request.ts
249490
249488
  var MAX_ERROR_BODY_CHARS = 4000;
249489
+ var QUERY_STRING = /\?\S*/g;
249491
249490
  async function readBody(response) {
249492
249491
  try {
249493
249492
  const text = (await response.clone().text()).trim();
@@ -249502,7 +249501,8 @@ async function sendApiRequest(method, path, body) {
249502
249501
  method,
249503
249502
  body,
249504
249503
  headers: body === undefined ? {} : { "Content-Type": "application/json" },
249505
- timeout: false
249504
+ timeout: false,
249505
+ retry: { methods: ["get", "head"] }
249506
249506
  });
249507
249507
  return {
249508
249508
  status: response.status,
@@ -249516,7 +249516,8 @@ async function sendApiRequest(method, path, body) {
249516
249516
  }
249517
249517
  }
249518
249518
  function redactedApiError(apiError, raw, method, path) {
249519
- const message = raw && apiError.statusCode !== undefined ? `Error calling ${method} ${path.split("?", 1)[0]}: HTTP ${apiError.statusCode}` : apiError.message;
249519
+ const reason = apiError.statusCode !== undefined ? `HTTP ${apiError.statusCode}` : (apiError.cause?.message ?? "request failed").replace(QUERY_STRING, "");
249520
+ const message = `Error calling ${method} ${path.split("?", 1)[0]}: ${reason}`;
249520
249521
  return new ApiError(message, {
249521
249522
  statusCode: apiError.statusCode,
249522
249523
  requestUrl: apiError.requestUrl?.split("?", 1)[0],
@@ -249527,7 +249528,7 @@ function redactedApiError(apiError, raw, method, path) {
249527
249528
  });
249528
249529
  }
249529
249530
  // src/core/api-spec/spec.ts
249530
- import { rename, stat as stat3 } from "node:fs/promises";
249531
+ import { rename, rm, stat as stat3 } from "node:fs/promises";
249531
249532
  import { join as join22 } from "node:path";
249532
249533
  var SPEC_CACHE_TTL_MS = 60 * 60 * 1000;
249533
249534
  function getSpecCachePath(apiUrl = getBase44ApiUrl()) {
@@ -249582,8 +249583,14 @@ async function loadSpec(options = {}) {
249582
249583
  const text = await downloadSpec();
249583
249584
  const spec = parseSpec(text);
249584
249585
  const partial = `${path}.${process.pid}.tmp`;
249585
- await writeFile(partial, text);
249586
- await rename(partial, path);
249586
+ try {
249587
+ await writeFile(partial, text);
249588
+ await rename(partial, path);
249589
+ } catch {
249590
+ await rm(partial, { force: true }).catch(() => {
249591
+ return;
249592
+ });
249593
+ }
249587
249594
  return { text, spec };
249588
249595
  }
249589
249596
  // src/cli/commands/api/shared.ts
@@ -249639,10 +249646,13 @@ async function readRequestBody(flag, log) {
249639
249646
  }
249640
249647
  return flag;
249641
249648
  }
249649
+ function withoutQuery(path) {
249650
+ return path.split("?", 1)[0] ?? "";
249651
+ }
249642
249652
  function reportedFetchCommand(method, path, options) {
249643
249653
  return {
249644
249654
  name: "api fetch",
249645
- args: [method, path.split("?", 1)[0] ?? ""],
249655
+ args: [method, withoutQuery(path)],
249646
249656
  options: {
249647
249657
  ...options,
249648
249658
  ...options.body === undefined ? {} : { body: "[not reported]" }
@@ -249673,7 +249683,7 @@ async function findOperation(ctx, method, path, { refresh, flag }) {
249673
249683
  const { spec } = await loadSpecTask(ctx, refresh);
249674
249684
  const op = matchOperation(listOperations(spec), method, path);
249675
249685
  if (!op) {
249676
- throw new InvalidInputError(`No operation in the API spec matches ${method} ${path}.`, {
249686
+ throw new InvalidInputError(`No operation in the API spec matches ${method} ${withoutQuery(path)}.`, {
249677
249687
  hints: [
249678
249688
  {
249679
249689
  message: "The cached spec may predate this route; fetch it again",
@@ -249688,6 +249698,8 @@ async function findOperation(ctx, method, path, { refresh, flag }) {
249688
249698
  }
249689
249699
  return { spec, op };
249690
249700
  }
249701
+ var CONTRACT_HELP = `
249702
+ The contract is JSON; cut it down with e.g. | jq '.parameters, .requestBodySchema'`;
249691
249703
  var TEXT_CONTENT_TYPES = [
249692
249704
  "json",
249693
249705
  "text/",
@@ -249727,9 +249739,13 @@ async function formatResponse({ status, contentType, body }, output, jsonMode) {
249727
249739
  }
249728
249740
  }
249729
249741
  async function fetchAction(ctx, methodArg, path, options, command) {
249742
+ ctx.errorReporter.setContext({
249743
+ command: reportedFetchCommand(methodArg ?? "", path ?? "", { ...options })
249744
+ });
249730
249745
  if (!methodArg || !path) {
249731
249746
  if (options.help) {
249732
- const usage = command.helpInformation();
249747
+ const usage = `${command.helpInformation()}${CONTRACT_HELP}
249748
+ `;
249733
249749
  return { stdout: ctx.jsonMode ? formatJson({ usage }) : usage };
249734
249750
  }
249735
249751
  throw new InvalidInputError("Provide a method and a path, e.g. GET /api/apps.");
@@ -249751,9 +249767,6 @@ async function fetchAction(ctx, methodArg, path, options, command) {
249751
249767
  throw new InvalidInputError(`Refused under --read-only: ${op.method} ${op.path} is not a read-only operation. Nothing was sent.`);
249752
249768
  }
249753
249769
  }
249754
- ctx.errorReporter.setContext({
249755
- command: reportedFetchCommand(method, path, { ...options })
249756
- });
249757
249770
  await ensureAuth(ctx);
249758
249771
  const body = await readRequestBody(options.body, ctx.log);
249759
249772
  const response = await ctx.runTask(`Calling ${method} ${path}`, () => sendApiRequest(method, path, body), {
@@ -249768,7 +249781,7 @@ function getApiFetchCommand() {
249768
249781
  return new Base44Command("fetch", {
249769
249782
  requireAuth: false,
249770
249783
  requireAppContext: false
249771
- }).description("Call a Base44 API operation; add --help after a path for its contract").helpOption(false).argument("[method]", "HTTP method, e.g. GET or POST").argument("[path]", 'Concrete path with any query string, e.g. "/api/apps/<app-id>/workflows/runs?status=failed"').option("--body <json>", "Request body: JSON, @file.json, or @- to read it from stdin").option("--output <file>", "Save the response body to a file").option("--read-only", "Refuse, before sending, any operation the spec does not mark read-only").option("--refresh", REFRESH_OPTION_HELP).option("-h, --help", "With a method and path, print that operation's contract; otherwise this help").action(fetchAction);
249784
+ }).description("Call a Base44 API operation; add --help after a path for its contract").helpOption(false).argument("[method]", "HTTP method, e.g. GET or POST").argument("[path]", 'Concrete path with any query string, e.g. "/api/apps/<app-id>/workflows/runs?status=failed"').option("--body <json>", "Request body: JSON, @file.json, or @- to read it from stdin").option("--output <file>", "Save the response body to a file").option("--read-only", "Refuse, before sending, any operation the spec does not mark read-only").option("--refresh", REFRESH_OPTION_HELP).option("-h, --help", "With a method and path, print that operation's contract; otherwise this help").addHelpText("after", CONTRACT_HELP).action(fetchAction);
249772
249785
  }
249773
249786
 
249774
249787
  // src/cli/commands/api/grep.ts
@@ -262390,7 +262403,7 @@ var bundleAppRequestSchema = objectType({
262390
262403
  var ACTIVATION_MODE = "pull";
262391
262404
 
262392
262405
  // ../functions-compiler/src/deno-bundle.ts
262393
- import { mkdtemp, rm, writeFile as writeFile2 } from "node:fs/promises";
262406
+ import { mkdtemp, rm as rm2, writeFile as writeFile2 } from "node:fs/promises";
262394
262407
  import { tmpdir as tmpdir2 } from "node:os";
262395
262408
  import path21 from "node:path";
262396
262409
 
@@ -262997,7 +263010,7 @@ async function bundleToModule(prepared, nodeModulesDir = "none") {
262997
263010
  warnings: result.warnings.map((w) => w.text)
262998
263011
  };
262999
263012
  } finally {
263000
- await rm(dir, { recursive: true, force: true });
263013
+ await rm2(dir, { recursive: true, force: true });
263001
263014
  }
263002
263015
  }
263003
263016
  function buildFailureErrors(e, dir) {
@@ -273362,4 +273375,4 @@ export {
273362
273375
  runCLI
273363
273376
  };
273364
273377
 
273365
- //# debugId=FFB0D67D7951621A64756E2164756E21
273378
+ //# debugId=A6B266663FAD34EF64756E2164756E21