@base44-preview/cli 0.1.32-pr.663.60cadbf → 0.1.32-pr.663.63c4a74

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
@@ -249234,7 +249234,7 @@ var ParameterSchema = looseObject({
249234
249234
  example: unknown().optional()
249235
249235
  });
249236
249236
  var MediaTypesSchema = record(string2(), looseObject({ schema: unknown().optional() }));
249237
- var RequestBodySchema = looseObject({
249237
+ var MediaContentSchema = looseObject({
249238
249238
  content: MediaTypesSchema.optional()
249239
249239
  });
249240
249240
  var ResponseObjectSchema = looseObject({
@@ -249264,88 +249264,7 @@ var OpenApiSpecSchema = looseObject({
249264
249264
  security: array(SecurityRequirementSchema).optional()
249265
249265
  });
249266
249266
 
249267
- // src/core/api-spec/operations.ts
249268
- var PERSONAL_ACCESS_TOKEN_SCHEME = "PersonalAccessTokenAuth";
249269
- var READ_ONLY_SCOPE = "read_only";
249270
- function isReadOnly(operation, spec) {
249271
- const security = operation.security ?? spec.security ?? [];
249272
- return security.some((requirement) => requirement[PERSONAL_ACCESS_TOKEN_SCHEME]?.includes(READ_ONLY_SCOPE));
249273
- }
249274
- function parameterText(operation) {
249275
- return (operation.parameters ?? []).flatMap((parameter) => {
249276
- const parsed = ParameterSchema.safeParse(parameter);
249277
- return parsed.success ? [parsed.data.name, parsed.data.description ?? ""] : [];
249278
- }).join(" ");
249279
- }
249280
- function mergeParameters(shared, own) {
249281
- if (!shared?.length) {
249282
- return own;
249283
- }
249284
- const key = (parameter) => {
249285
- const parsed = ParameterSchema.safeParse(parameter);
249286
- return parsed.success ? `${parsed.data.in}:${parsed.data.name}` : undefined;
249287
- };
249288
- const ownKeys = new Set((own ?? []).map(key));
249289
- return [
249290
- ...shared.filter((parameter) => !ownKeys.has(key(parameter))),
249291
- ...own ?? []
249292
- ];
249293
- }
249294
- function listOperations(spec) {
249295
- return Object.entries(spec.paths).flatMap(([path, item]) => HTTP_METHODS.flatMap((method) => {
249296
- const declared = item[method];
249297
- if (!declared) {
249298
- return [];
249299
- }
249300
- const operation = {
249301
- ...declared,
249302
- parameters: mergeParameters(item.parameters, declared.parameters)
249303
- };
249304
- return [
249305
- {
249306
- endpoint: `${method.toUpperCase()} ${path}`,
249307
- method: method.toUpperCase(),
249308
- path,
249309
- summary: operation.summary ?? "",
249310
- description: operation.description ?? "",
249311
- parameterText: parameterText(operation),
249312
- readOnly: isReadOnly(operation, spec),
249313
- operation
249314
- }
249315
- ];
249316
- }));
249317
- }
249318
- function pathSegments(path) {
249319
- const pathname = path.split(/[?#]/, 1)[0] ?? "";
249320
- return pathname.split("/").filter(Boolean);
249321
- }
249322
- function segmentPattern(segment) {
249323
- const source = segment.split(/(\{[^}]+\})/).map((part) => part.startsWith("{") ? "[^/]+" : part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("");
249324
- return new RegExp(`^${source}$`);
249325
- }
249326
- function specificity(templateSegments) {
249327
- return templateSegments.map((segment) => segment.includes("{") ? 0 : 1);
249328
- }
249329
- function compareSpecificity(a, b) {
249330
- for (let i = 0;i < a.length; i++) {
249331
- if (a[i] !== b[i]) {
249332
- return (b[i] ?? 0) - (a[i] ?? 0);
249333
- }
249334
- }
249335
- return 0;
249336
- }
249337
- function matchOperation(operations, method, concretePath) {
249338
- const upperMethod = method.toUpperCase();
249339
- const segments = pathSegments(concretePath);
249340
- const candidates = operations.filter((op) => {
249341
- if (op.method !== upperMethod) {
249342
- return false;
249343
- }
249344
- const template = pathSegments(op.path);
249345
- return template.length === segments.length && template.every((part, i) => segmentPattern(part).test(segments[i] ?? ""));
249346
- });
249347
- return candidates.sort((a, b) => compareSpecificity(specificity(pathSegments(a.path)), specificity(pathSegments(b.path))))[0];
249348
- }
249267
+ // src/core/api-spec/contract.ts
249349
249268
  var SCHEMA_REF_PREFIX = "#/components/schemas/";
249350
249269
  var MAX_REF_DEPTH = 4;
249351
249270
  var FRAMEWORK_VALIDATION_ERROR = "Validation Error";
@@ -249373,12 +249292,8 @@ function inlineRefs(node, schemas, seen = new Set, depth = 0) {
249373
249292
  inlineRefs(value, schemas, seen, depth)
249374
249293
  ]));
249375
249294
  }
249376
- function jsonSchemaOf(value) {
249377
- const parsed = RequestBodySchema.safeParse(value);
249378
- return parsed.success ? parsed.data.content?.["application/json"]?.schema : undefined;
249379
- }
249380
- function requestBodyOf(value) {
249381
- const parsed = RequestBodySchema.safeParse(value);
249295
+ function bodyOf(value) {
249296
+ const parsed = MediaContentSchema.safeParse(value);
249382
249297
  const content = parsed.success ? parsed.data.content ?? {} : {};
249383
249298
  const contentType = "application/json" in content ? "application/json" : Object.keys(content)[0];
249384
249299
  return contentType ? { contentType, schema: content[contentType]?.schema } : {};
@@ -249449,9 +249364,9 @@ function getOperationContract(spec, op) {
249449
249364
  const parsed = ResponseObjectSchema.safeParse(response);
249450
249365
  return parsed.success ? [[status, parsed.data]] : [];
249451
249366
  });
249452
- const success = responses.filter(([status]) => status.startsWith("2")).sort(([a], [b]) => a.localeCompare(b)).map(([, response]) => jsonSchemaOf(response)).find(Boolean);
249367
+ const success = responses.filter(([status]) => status.startsWith("2")).sort(([a], [b]) => a.localeCompare(b)).map(([, response]) => bodyOf(response).schema).find(Boolean);
249453
249368
  const errors = responses.filter(([status, response]) => !status.startsWith("2") && response.description !== FRAMEWORK_VALIDATION_ERROR);
249454
- const requestBody = requestBodyOf(op.operation.requestBody);
249369
+ const requestBody = bodyOf(op.operation.requestBody);
249455
249370
  const contract = {
249456
249371
  endpoint: op.endpoint,
249457
249372
  method: op.method,
@@ -249492,12 +249407,85 @@ function getOperationContract(spec, op) {
249492
249407
  } : {}
249493
249408
  };
249494
249409
  }
249495
-
249496
249410
  // src/core/api-spec/grep.ts
249497
249411
  function grepOperations(spec, operations, pattern, options = {}) {
249498
249412
  const regex = new RegExp(pattern, options.ignoreCase ? "i" : "");
249499
249413
  return operations.filter((op) => regex.test(JSON.stringify(getOperationContract(spec, op)))).slice(0, options.limit ?? 20).map(toOperationSummary);
249500
249414
  }
249415
+ // src/core/api-spec/operations.ts
249416
+ var PERSONAL_ACCESS_TOKEN_SCHEME = "PersonalAccessTokenAuth";
249417
+ var READ_ONLY_SCOPE = "read_only";
249418
+ function isReadOnly(operation, spec) {
249419
+ const security = operation.security ?? spec.security ?? [];
249420
+ return security.some((requirement) => requirement[PERSONAL_ACCESS_TOKEN_SCHEME]?.includes(READ_ONLY_SCOPE));
249421
+ }
249422
+ function parameterText(operation) {
249423
+ return (operation.parameters ?? []).flatMap((parameter) => {
249424
+ const parsed = ParameterSchema.safeParse(parameter);
249425
+ return parsed.success ? [parsed.data.name, parsed.data.description ?? ""] : [];
249426
+ }).join(" ");
249427
+ }
249428
+ function mergeParameters(shared, own) {
249429
+ if (!shared?.length) {
249430
+ return own;
249431
+ }
249432
+ const key = (parameter) => {
249433
+ const parsed = ParameterSchema.safeParse(parameter);
249434
+ return parsed.success ? `${parsed.data.in}:${parsed.data.name}` : undefined;
249435
+ };
249436
+ const ownKeys = new Set((own ?? []).map(key));
249437
+ return [
249438
+ ...shared.filter((parameter) => !ownKeys.has(key(parameter))),
249439
+ ...own ?? []
249440
+ ];
249441
+ }
249442
+ function listOperations(spec) {
249443
+ return Object.entries(spec.paths).flatMap(([path, item]) => HTTP_METHODS.flatMap((method) => {
249444
+ const declared = item[method];
249445
+ if (!declared) {
249446
+ return [];
249447
+ }
249448
+ const operation = {
249449
+ ...declared,
249450
+ parameters: mergeParameters(item.parameters, declared.parameters)
249451
+ };
249452
+ return [
249453
+ {
249454
+ endpoint: `${method.toUpperCase()} ${path}`,
249455
+ method: method.toUpperCase(),
249456
+ path,
249457
+ summary: operation.summary ?? "",
249458
+ description: operation.description ?? "",
249459
+ parameterText: parameterText(operation),
249460
+ readOnly: isReadOnly(operation, spec),
249461
+ operation
249462
+ }
249463
+ ];
249464
+ }));
249465
+ }
249466
+ function pathSegments(path) {
249467
+ const pathname = path.split(/[?#]/, 1)[0] ?? "";
249468
+ return pathname.split("/").filter(Boolean);
249469
+ }
249470
+ function segmentPattern(segment) {
249471
+ const source = segment.split(/(\{[^}]+\})/).map((part) => part.startsWith("{") ? "[^/]+" : part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("");
249472
+ return new RegExp(`^${source}$`);
249473
+ }
249474
+ function literalSegments(path) {
249475
+ return pathSegments(path).map((segment) => segment.includes("{") ? "0" : "1").join("");
249476
+ }
249477
+ function matchOperation(operations, method, concretePath) {
249478
+ const upperMethod = method.toUpperCase();
249479
+ const segments = pathSegments(concretePath);
249480
+ const candidates = operations.filter((op) => {
249481
+ if (op.method !== upperMethod) {
249482
+ return false;
249483
+ }
249484
+ const template = pathSegments(op.path);
249485
+ return template.length === segments.length && template.every((part, i) => segmentPattern(part).test(segments[i] ?? ""));
249486
+ });
249487
+ return candidates.sort((a, b) => literalSegments(b.path).localeCompare(literalSegments(a.path)))[0];
249488
+ }
249501
249489
  // src/core/api-spec/request.ts
249502
249490
  var MAX_ERROR_BODY_CHARS = 4000;
249503
249491
  async function readBody(response) {
@@ -249524,17 +249512,20 @@ async function sendApiRequest(method, path, body) {
249524
249512
  } catch (error) {
249525
249513
  const apiError = await ApiError.fromHttpError(error, `calling ${method} ${path}`);
249526
249514
  const raw = error instanceof HTTPError ? await readBody(error.response) : undefined;
249527
- const message = raw && apiError.statusCode !== undefined ? `Error calling ${method} ${path}: HTTP ${apiError.statusCode}` : apiError.message;
249528
- throw new ApiError(message, {
249529
- statusCode: apiError.statusCode,
249530
- requestUrl: apiError.requestUrl,
249531
- requestMethod: apiError.requestMethod,
249532
- requestId: apiError.requestId,
249533
- hints: apiError.hints,
249534
- details: raw ? [`Response body: ${raw}`] : apiError.details
249535
- });
249515
+ throw redactedApiError(apiError, raw, method, path);
249536
249516
  }
249537
249517
  }
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;
249520
+ return new ApiError(message, {
249521
+ statusCode: apiError.statusCode,
249522
+ requestUrl: apiError.requestUrl?.split("?", 1)[0],
249523
+ requestMethod: apiError.requestMethod,
249524
+ requestId: apiError.requestId,
249525
+ hints: apiError.hints,
249526
+ details: raw ? [`Response body: ${raw}`] : apiError.details
249527
+ });
249528
+ }
249538
249529
  // src/core/api-spec/spec.ts
249539
249530
  import { rename, stat as stat3 } from "node:fs/promises";
249540
249531
  import { join as join22 } from "node:path";
@@ -249648,6 +249639,16 @@ async function readRequestBody(flag, log) {
249648
249639
  }
249649
249640
  return flag;
249650
249641
  }
249642
+ function reportedFetchCommand(method, path, options) {
249643
+ return {
249644
+ name: "api fetch",
249645
+ args: [method, path.split("?", 1)[0] ?? ""],
249646
+ options: {
249647
+ ...options,
249648
+ ...options.body === undefined ? {} : { body: "[not reported]" }
249649
+ }
249650
+ };
249651
+ }
249651
249652
 
249652
249653
  // src/cli/commands/api/catalog.ts
249653
249654
  async function catalogAction(ctx, area, options) {
@@ -249751,11 +249752,7 @@ async function fetchAction(ctx, methodArg, path, options, command) {
249751
249752
  }
249752
249753
  }
249753
249754
  ctx.errorReporter.setContext({
249754
- command: {
249755
- name: "api fetch",
249756
- args: [method, path.split("?", 1)[0] ?? ""],
249757
- options: { ...options, body: options.body && "[not reported]" }
249758
- }
249755
+ command: reportedFetchCommand(method, path, { ...options })
249759
249756
  });
249760
249757
  await ensureAuth(ctx);
249761
249758
  const body = await readRequestBody(options.body, ctx.log);
@@ -273365,4 +273362,4 @@ export {
273365
273362
  runCLI
273366
273363
  };
273367
273364
 
273368
- //# debugId=34B2FE9173AAC44664756E2164756E21
273365
+ //# debugId=FFB0D67D7951621A64756E2164756E21