@base44-preview/cli 0.1.32-pr.663.7602773 → 0.1.32-pr.663.d01623b
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 +316 -70
- package/dist/cli/index.js.map +19 -18
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -249106,12 +249106,7 @@ var BOOST = { path: 8, summary: 5, description: 2, parameters: 0.5 };
|
|
|
249106
249106
|
var MIN_RELATIVE_SCORE = 0.2;
|
|
249107
249107
|
var TOKEN_SEPARATOR = /[\n\r\p{Z}\p{P}\p{S}]+/u;
|
|
249108
249108
|
function toOperationSummary(op) {
|
|
249109
|
-
return {
|
|
249110
|
-
method: op.method,
|
|
249111
|
-
path: op.path,
|
|
249112
|
-
summary: op.summary,
|
|
249113
|
-
readOnly: op.readOnly
|
|
249114
|
-
};
|
|
249109
|
+
return { endpoint: op.endpoint, summary: op.summary };
|
|
249115
249110
|
}
|
|
249116
249111
|
function buildSearchIndex(operations) {
|
|
249117
249112
|
const index = new MiniSearch({
|
|
@@ -249145,6 +249140,7 @@ function searchOperations(operations, query, options = {}) {
|
|
|
249145
249140
|
// src/core/api-spec/catalog.ts
|
|
249146
249141
|
var INLINE_AREA_MAX = 2;
|
|
249147
249142
|
var AREA_SAMPLE_MAX = 3;
|
|
249143
|
+
var AREA_OPERATIONS_MAX = 200;
|
|
249148
249144
|
var byCodePoint = (a, b) => a < b ? -1 : a > b ? 1 : 0;
|
|
249149
249145
|
function areaOf(path) {
|
|
249150
249146
|
const parts = path.split("/").filter(Boolean);
|
|
@@ -249166,24 +249162,39 @@ function groupByArea(operations) {
|
|
|
249166
249162
|
}
|
|
249167
249163
|
return new Map([...areas].sort(([a], [b]) => byCodePoint(a, b)));
|
|
249168
249164
|
}
|
|
249165
|
+
function readsFirst(ops) {
|
|
249166
|
+
const isRead = (op) => op.method === "GET" ? 0 : 1;
|
|
249167
|
+
return [...ops].sort((a, b) => isRead(a) - isRead(b));
|
|
249168
|
+
}
|
|
249169
249169
|
function catalogIndex(operations) {
|
|
249170
249170
|
const areas = [...groupByArea(operations)].map(([area, ops]) => ops.length <= INLINE_AREA_MAX ? { area, operations: ops.map(toOperationSummary) } : {
|
|
249171
249171
|
area,
|
|
249172
249172
|
operationCount: ops.length,
|
|
249173
|
-
sample: ops.slice(0, AREA_SAMPLE_MAX).map((op) => op.summary)
|
|
249173
|
+
sample: readsFirst(ops).slice(0, AREA_SAMPLE_MAX).map((op) => op.summary)
|
|
249174
249174
|
});
|
|
249175
249175
|
return { areas, total: operations.length };
|
|
249176
249176
|
}
|
|
249177
|
+
function areaListing(area, operations, max = AREA_OPERATIONS_MAX) {
|
|
249178
|
+
return {
|
|
249179
|
+
area,
|
|
249180
|
+
operations: operations.slice(0, max).map(toOperationSummary),
|
|
249181
|
+
total: operations.length,
|
|
249182
|
+
truncated: operations.length > max
|
|
249183
|
+
};
|
|
249184
|
+
}
|
|
249177
249185
|
// src/core/api-spec/grep.ts
|
|
249178
249186
|
var CONTEXT_CHARS = 40;
|
|
249179
249187
|
var MAX_SNIPPETS = 3;
|
|
249180
249188
|
var MAX_SNIPPET_CHARS = 200;
|
|
249189
|
+
function unescapeJson(snippet) {
|
|
249190
|
+
return snippet.replace(/\\[nrt]/g, " ").replace(/\\"/g, '"');
|
|
249191
|
+
}
|
|
249181
249192
|
function snippets(text, pattern) {
|
|
249182
249193
|
const found = [];
|
|
249183
249194
|
for (const match of text.matchAll(pattern)) {
|
|
249184
249195
|
const start = Math.max(0, match.index - CONTEXT_CHARS);
|
|
249185
249196
|
const end = match.index + match[0].length + CONTEXT_CHARS;
|
|
249186
|
-
found.push(text.slice(start, Math.min(end, start + MAX_SNIPPET_CHARS)));
|
|
249197
|
+
found.push(unescapeJson(text.slice(start, Math.min(end, start + MAX_SNIPPET_CHARS))));
|
|
249187
249198
|
if (found.length === MAX_SNIPPETS || match[0].length === 0) {
|
|
249188
249199
|
break;
|
|
249189
249200
|
}
|
|
@@ -249193,14 +249204,15 @@ function snippets(text, pattern) {
|
|
|
249193
249204
|
function grepSpec(spec, operations, pattern, options = {}) {
|
|
249194
249205
|
const regex = new RegExp(pattern, options.ignoreCase ? "gi" : "g");
|
|
249195
249206
|
const hits = [];
|
|
249196
|
-
const
|
|
249197
|
-
for (const op of operations.filter(
|
|
249198
|
-
const
|
|
249207
|
+
const selected = (op) => (options.area === undefined || areaOf(op.path) === options.area) && (!options.readOnly || op.readOnly);
|
|
249208
|
+
for (const op of operations.filter(selected)) {
|
|
249209
|
+
const { summary, description, parameters, requestBody, responses } = op.operation;
|
|
249210
|
+
const matches = snippets(`${op.endpoint} ${JSON.stringify({ summary, description, parameters, requestBody, responses })}`, regex);
|
|
249199
249211
|
if (matches.length > 0) {
|
|
249200
249212
|
hits.push({ ...toOperationSummary(op), matches });
|
|
249201
249213
|
}
|
|
249202
249214
|
}
|
|
249203
|
-
const schemas = options.area === undefined ? spec.components?.schemas : {};
|
|
249215
|
+
const schemas = options.area === undefined && !options.readOnly ? spec.components?.schemas : {};
|
|
249204
249216
|
for (const [schema, definition] of Object.entries(schemas ?? {})) {
|
|
249205
249217
|
const matches = snippets(JSON.stringify(definition), regex);
|
|
249206
249218
|
if (matches.length > 0) {
|
|
@@ -249225,7 +249237,16 @@ var ParameterSchema = looseObject({
|
|
|
249225
249237
|
in: string2(),
|
|
249226
249238
|
required: boolean2().optional(),
|
|
249227
249239
|
description: string2().optional(),
|
|
249228
|
-
schema: unknown().optional()
|
|
249240
|
+
schema: unknown().optional(),
|
|
249241
|
+
example: unknown().optional()
|
|
249242
|
+
});
|
|
249243
|
+
var MediaTypesSchema = record(string2(), looseObject({ schema: unknown().optional() }));
|
|
249244
|
+
var RequestBodySchema = looseObject({
|
|
249245
|
+
content: MediaTypesSchema.optional()
|
|
249246
|
+
});
|
|
249247
|
+
var ResponseObjectSchema = looseObject({
|
|
249248
|
+
description: string2().optional(),
|
|
249249
|
+
content: MediaTypesSchema.optional()
|
|
249229
249250
|
});
|
|
249230
249251
|
var SecurityRequirementSchema = record(string2(), array(string2()));
|
|
249231
249252
|
var OperationSchema = looseObject({
|
|
@@ -249268,6 +249289,7 @@ function listOperations(spec) {
|
|
|
249268
249289
|
}
|
|
249269
249290
|
return [
|
|
249270
249291
|
{
|
|
249292
|
+
endpoint: `${method.toUpperCase()} ${path}`,
|
|
249271
249293
|
method: method.toUpperCase(),
|
|
249272
249294
|
path,
|
|
249273
249295
|
summary: operation.summary ?? "",
|
|
@@ -249310,46 +249332,73 @@ function matchOperation(operations, method, concretePath) {
|
|
|
249310
249332
|
});
|
|
249311
249333
|
return candidates.sort((a, b) => compareSpecificity(specificity(pathSegments(a.path)), specificity(pathSegments(b.path))))[0];
|
|
249312
249334
|
}
|
|
249313
|
-
|
|
249314
|
-
|
|
249315
|
-
|
|
249316
|
-
|
|
249317
|
-
|
|
249318
|
-
return;
|
|
249335
|
+
var SCHEMA_REF_PREFIX = "#/components/schemas/";
|
|
249336
|
+
var MAX_REF_DEPTH = 4;
|
|
249337
|
+
var FRAMEWORK_VALIDATION_ERROR = "Validation Error";
|
|
249338
|
+
function inlineRefs(node, schemas, seen = new Set, depth = 0) {
|
|
249339
|
+
if (depth > MAX_REF_DEPTH) {
|
|
249340
|
+
return node;
|
|
249319
249341
|
}
|
|
249320
|
-
if (
|
|
249321
|
-
return;
|
|
249342
|
+
if (Array.isArray(node)) {
|
|
249343
|
+
return node.map((item) => inlineRefs(item, schemas, seen, depth));
|
|
249322
249344
|
}
|
|
249323
|
-
|
|
249324
|
-
|
|
249325
|
-
|
|
249326
|
-
|
|
249327
|
-
|
|
249328
|
-
|
|
249329
|
-
|
|
249345
|
+
if (node === null || typeof node !== "object") {
|
|
249346
|
+
return node;
|
|
249347
|
+
}
|
|
249348
|
+
const { $ref, ...siblings } = node;
|
|
249349
|
+
if (typeof $ref === "string" && $ref.startsWith(SCHEMA_REF_PREFIX)) {
|
|
249350
|
+
const name = $ref.slice(SCHEMA_REF_PREFIX.length);
|
|
249351
|
+
if (seen.has(name) || !(name in schemas)) {
|
|
249352
|
+
return node;
|
|
249330
249353
|
}
|
|
249354
|
+
const resolved = inlineRefs(schemas[name], schemas, new Set([...seen, name]), depth + 1);
|
|
249355
|
+
return resolved !== null && typeof resolved === "object" ? { ...resolved, ...siblings } : resolved;
|
|
249331
249356
|
}
|
|
249357
|
+
return Object.fromEntries(Object.entries(node).map(([key, value]) => [
|
|
249358
|
+
key,
|
|
249359
|
+
inlineRefs(value, schemas, seen, depth)
|
|
249360
|
+
]));
|
|
249332
249361
|
}
|
|
249333
|
-
function
|
|
249334
|
-
|
|
249335
|
-
|
|
249336
|
-
}
|
|
249337
|
-
return ref.slice(2).split("/").map((part) => part.replace(/~1/g, "/").replace(/~0/g, "~")).reduce((node, part) => node !== null && typeof node === "object" ? node[part] : undefined, spec);
|
|
249362
|
+
function jsonSchemaOf(value) {
|
|
249363
|
+
const parsed = RequestBodySchema.safeParse(value);
|
|
249364
|
+
return parsed.success ? parsed.data.content?.["application/json"]?.schema : undefined;
|
|
249338
249365
|
}
|
|
249339
249366
|
function getOperationContract(spec, op) {
|
|
249340
|
-
const
|
|
249341
|
-
const
|
|
249342
|
-
|
|
249367
|
+
const schemas = spec.components?.schemas ?? {};
|
|
249368
|
+
const inline = (node) => node === undefined ? null : inlineRefs(node, schemas);
|
|
249369
|
+
const responses = Object.entries(op.operation.responses ?? {}).flatMap(([status, response]) => {
|
|
249370
|
+
const parsed = ResponseObjectSchema.safeParse(response);
|
|
249371
|
+
return parsed.success ? [[status, parsed.data]] : [];
|
|
249372
|
+
});
|
|
249373
|
+
const success = responses.filter(([status]) => status.startsWith("2")).sort(([a], [b]) => a.localeCompare(b)).map(([, response]) => jsonSchemaOf(response)).find(Boolean);
|
|
249374
|
+
const errors = responses.filter(([status, response]) => !status.startsWith("2") && response.description !== FRAMEWORK_VALIDATION_ERROR);
|
|
249343
249375
|
return {
|
|
249376
|
+
endpoint: op.endpoint,
|
|
249344
249377
|
method: op.method,
|
|
249345
249378
|
path: op.path,
|
|
249346
249379
|
summary: op.summary,
|
|
249347
249380
|
description: op.description,
|
|
249348
|
-
|
|
249349
|
-
|
|
249350
|
-
|
|
249351
|
-
|
|
249352
|
-
|
|
249381
|
+
parameters: (op.operation.parameters ?? []).flatMap((parameter) => {
|
|
249382
|
+
const parsed = ParameterSchema.safeParse(parameter);
|
|
249383
|
+
if (!parsed.success) {
|
|
249384
|
+
return [];
|
|
249385
|
+
}
|
|
249386
|
+
const { name, in: location2, required, schema, description } = parsed.data;
|
|
249387
|
+
const inSchema = schema !== null && typeof schema === "object" && "description" in schema;
|
|
249388
|
+
return [
|
|
249389
|
+
{
|
|
249390
|
+
name,
|
|
249391
|
+
in: location2,
|
|
249392
|
+
required: required ?? false,
|
|
249393
|
+
schema: inline(schema ?? {}),
|
|
249394
|
+
...description && !inSchema ? { description } : {},
|
|
249395
|
+
..."example" in parsed.data ? { example: parsed.data.example } : {}
|
|
249396
|
+
}
|
|
249397
|
+
];
|
|
249398
|
+
}),
|
|
249399
|
+
requestBodySchema: inline(jsonSchemaOf(op.operation.requestBody)),
|
|
249400
|
+
responseSchema: inline(success),
|
|
249401
|
+
errors: Object.fromEntries(errors.map(([status, response]) => [status, response.description ?? ""]))
|
|
249353
249402
|
};
|
|
249354
249403
|
}
|
|
249355
249404
|
// src/core/api-spec/request.ts
|
|
@@ -249360,7 +249409,11 @@ async function sendApiRequest(method, path, body) {
|
|
|
249360
249409
|
body,
|
|
249361
249410
|
headers: body === undefined ? {} : { "Content-Type": "application/json" }
|
|
249362
249411
|
});
|
|
249363
|
-
return
|
|
249412
|
+
return {
|
|
249413
|
+
status: response.status,
|
|
249414
|
+
contentType: response.headers.get("content-type") ?? "",
|
|
249415
|
+
body: new Uint8Array(await response.arrayBuffer())
|
|
249416
|
+
};
|
|
249364
249417
|
} catch (error) {
|
|
249365
249418
|
throw await ApiError.fromHttpError(error, `calling ${method} ${path}`);
|
|
249366
249419
|
}
|
|
@@ -249421,18 +249474,6 @@ function formatJson(value) {
|
|
|
249421
249474
|
return `${JSON.stringify(value, null, process.stdout.isTTY ? 2 : undefined)}
|
|
249422
249475
|
`;
|
|
249423
249476
|
}
|
|
249424
|
-
function formatResponseBody(text) {
|
|
249425
|
-
if (!text) {
|
|
249426
|
-
return "";
|
|
249427
|
-
}
|
|
249428
|
-
try {
|
|
249429
|
-
return formatJson(JSON.parse(text));
|
|
249430
|
-
} catch {
|
|
249431
|
-
return text.endsWith(`
|
|
249432
|
-
`) ? text : `${text}
|
|
249433
|
-
`;
|
|
249434
|
-
}
|
|
249435
|
-
}
|
|
249436
249477
|
function parseLimit(value) {
|
|
249437
249478
|
if (value === undefined) {
|
|
249438
249479
|
return;
|
|
@@ -249443,6 +249484,7 @@ function parseLimit(value) {
|
|
|
249443
249484
|
}
|
|
249444
249485
|
return n;
|
|
249445
249486
|
}
|
|
249487
|
+
var READ_ONLY_FILTER_HELP = "Only read-only operations";
|
|
249446
249488
|
var REFRESH_OPTION_HELP = "Fetch the API spec again instead of using the cached copy (kept 1 hour)";
|
|
249447
249489
|
function loadSpecTask({ runTask }, refresh) {
|
|
249448
249490
|
return runTask("Loading the API spec", () => loadSpec({ refresh }), {
|
|
@@ -249480,24 +249522,19 @@ async function readRequestBody(method, flag) {
|
|
|
249480
249522
|
// src/cli/commands/api/catalog.ts
|
|
249481
249523
|
async function catalogAction(ctx, area, options) {
|
|
249482
249524
|
const { spec } = await loadSpecTask(ctx, options.refresh);
|
|
249483
|
-
const operations = listOperations(spec);
|
|
249525
|
+
const operations = listOperations(spec).filter((op) => !options.readOnly || op.readOnly);
|
|
249484
249526
|
if (area === undefined) {
|
|
249485
249527
|
return { stdout: formatJson(catalogIndex(operations)) };
|
|
249486
249528
|
}
|
|
249487
|
-
const inArea = operationsInArea(operations, area);
|
|
249488
249529
|
return {
|
|
249489
|
-
stdout: formatJson(
|
|
249490
|
-
area,
|
|
249491
|
-
operations: inArea.map(toOperationSummary),
|
|
249492
|
-
total: inArea.length
|
|
249493
|
-
})
|
|
249530
|
+
stdout: formatJson(areaListing(area, operationsInArea(operations, area)))
|
|
249494
249531
|
};
|
|
249495
249532
|
}
|
|
249496
249533
|
function getApiCatalogCommand() {
|
|
249497
249534
|
return new Base44Command("catalog", {
|
|
249498
249535
|
requireAuth: false,
|
|
249499
249536
|
requireAppContext: false
|
|
249500
|
-
}).description("List the API's areas, or every operation in one area
|
|
249537
|
+
}).description("List the API's areas, or every operation in one area").argument("[area]", 'An area from the list, e.g. "workflows"').option("--read-only", READ_ONLY_FILTER_HELP).option("--refresh", REFRESH_OPTION_HELP).action(catalogAction);
|
|
249501
249538
|
}
|
|
249502
249539
|
|
|
249503
249540
|
// src/cli/commands/api/fetch.ts
|
|
@@ -249516,6 +249553,36 @@ async function findOperation(ctx, method, path, refresh) {
|
|
|
249516
249553
|
}
|
|
249517
249554
|
return { spec, op };
|
|
249518
249555
|
}
|
|
249556
|
+
var TEXT_CONTENT_TYPES = [
|
|
249557
|
+
"json",
|
|
249558
|
+
"text/",
|
|
249559
|
+
"xml",
|
|
249560
|
+
"javascript",
|
|
249561
|
+
"x-www-form-urlencoded"
|
|
249562
|
+
];
|
|
249563
|
+
function isText(contentType) {
|
|
249564
|
+
return !contentType || TEXT_CONTENT_TYPES.some((hint) => contentType.toLowerCase().includes(hint));
|
|
249565
|
+
}
|
|
249566
|
+
async function formatResponse({ status, contentType, body }, output) {
|
|
249567
|
+
if (output !== undefined) {
|
|
249568
|
+
await writeFile(output, body);
|
|
249569
|
+
return formatJson({ status, contentType, bytes: body.length, output });
|
|
249570
|
+
}
|
|
249571
|
+
if (body.length === 0) {
|
|
249572
|
+
return formatJson({ status });
|
|
249573
|
+
}
|
|
249574
|
+
if (!isText(contentType)) {
|
|
249575
|
+
throw new InvalidInputError(`The response is binary (${contentType}, ${body.length} bytes), so it was not printed. The request was sent; add --output <file> to save the response.`);
|
|
249576
|
+
}
|
|
249577
|
+
const text = new TextDecoder().decode(body);
|
|
249578
|
+
try {
|
|
249579
|
+
return formatJson(JSON.parse(text));
|
|
249580
|
+
} catch {
|
|
249581
|
+
return text.endsWith(`
|
|
249582
|
+
`) ? text : `${text}
|
|
249583
|
+
`;
|
|
249584
|
+
}
|
|
249585
|
+
}
|
|
249519
249586
|
async function fetchAction(ctx, methodArg, path, options, command) {
|
|
249520
249587
|
if (!methodArg || !path) {
|
|
249521
249588
|
if (options.help) {
|
|
@@ -249536,14 +249603,17 @@ async function fetchAction(ctx, methodArg, path, options, command) {
|
|
|
249536
249603
|
}
|
|
249537
249604
|
await ensureAuth(ctx);
|
|
249538
249605
|
const body = await readRequestBody(method, options.body);
|
|
249539
|
-
const
|
|
249540
|
-
|
|
249606
|
+
const response = await ctx.runTask(`Calling ${method} ${path}`, () => sendApiRequest(method, path, body), {
|
|
249607
|
+
successMessage: `Called ${method} ${path}`,
|
|
249608
|
+
errorMessage: "Request failed"
|
|
249609
|
+
});
|
|
249610
|
+
return { stdout: await formatResponse(response, options.output) };
|
|
249541
249611
|
}
|
|
249542
249612
|
function getApiFetchCommand() {
|
|
249543
249613
|
return new Base44Command("fetch", {
|
|
249544
249614
|
requireAuth: false,
|
|
249545
249615
|
requireAppContext: false
|
|
249546
|
-
}).description("Call a Base44 API operation, like curl; 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 @- for stdin (piped stdin is read too)").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);
|
|
249616
|
+
}).description("Call a Base44 API operation, like curl; 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 @- for stdin (piped stdin is read too)").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);
|
|
249547
249617
|
}
|
|
249548
249618
|
|
|
249549
249619
|
// src/cli/commands/api/grep.ts
|
|
@@ -249565,7 +249635,8 @@ async function grepAction(ctx, pattern, options) {
|
|
|
249565
249635
|
const hits = grepSpec(spec, operations, pattern, {
|
|
249566
249636
|
area: options.area,
|
|
249567
249637
|
ignoreCase: options.ignoreCase,
|
|
249568
|
-
limit
|
|
249638
|
+
limit,
|
|
249639
|
+
readOnly: options.readOnly
|
|
249569
249640
|
});
|
|
249570
249641
|
return { stdout: formatJson(hits) };
|
|
249571
249642
|
}
|
|
@@ -249573,7 +249644,7 @@ function getApiGrepCommand() {
|
|
|
249573
249644
|
return new Base44Command("grep", {
|
|
249574
249645
|
requireAuth: false,
|
|
249575
249646
|
requireAppContext: false
|
|
249576
|
-
}).description("Search the raw API spec with a regular expression, for when search misses").argument("<pattern>", 'Regular expression, e.g. "runs.*status"').option("--area <area>", "Search only one area's operations (see base44 api catalog)").option("-i, --ignore-case", "Case-insensitive match").option("--limit <n>", "Most operations or schemas to return (default 20)").option("--refresh", REFRESH_OPTION_HELP).action(grepAction);
|
|
249647
|
+
}).description("Search the raw API spec with a regular expression, for when search misses").argument("<pattern>", 'Regular expression, e.g. "runs.*status"').option("--area <area>", "Search only one area's operations (see base44 api catalog)").option("-i, --ignore-case", "Case-insensitive match").option("--limit <n>", "Most operations or schemas to return (default 20)").option("--read-only", READ_ONLY_FILTER_HELP).option("--refresh", REFRESH_OPTION_HELP).action(grepAction);
|
|
249577
249648
|
}
|
|
249578
249649
|
|
|
249579
249650
|
// src/cli/commands/api/search.ts
|
|
@@ -249590,7 +249661,7 @@ function getApiSearchCommand() {
|
|
|
249590
249661
|
return new Base44Command("search", {
|
|
249591
249662
|
requireAuth: false,
|
|
249592
249663
|
requireAppContext: false
|
|
249593
|
-
}).description("Search every Base44 API operation by what it does").argument("<text...>", 'What you are looking for, e.g. "failed workflow runs"').option("--limit <n>", "Most results to return (default 5)").option("--read-only",
|
|
249664
|
+
}).description("Search every Base44 API operation by what it does").argument("<text...>", 'What you are looking for, e.g. "failed workflow runs"').option("--limit <n>", "Most results to return (default 5)").option("--read-only", READ_ONLY_FILTER_HELP).option("--refresh", REFRESH_OPTION_HELP).action(searchAction);
|
|
249594
249665
|
}
|
|
249595
249666
|
|
|
249596
249667
|
// src/cli/commands/api/index.ts
|
|
@@ -254959,6 +255030,12 @@ var deno2 = Object.freeze({
|
|
|
254959
255030
|
});
|
|
254960
255031
|
globalThis.Deno = deno2;
|
|
254961
255032
|
globalThis.Buffer = Buffer2;
|
|
255033
|
+
try {
|
|
255034
|
+
new AsyncLocalStorage().enterWith(void 0);
|
|
255035
|
+
} catch {
|
|
255036
|
+
AsyncLocalStorage.prototype.enterWith = () => {
|
|
255037
|
+
};
|
|
255038
|
+
}
|
|
254962
255039
|
function getRegisteredHandler() {
|
|
254963
255040
|
return registeredHandler;
|
|
254964
255041
|
}
|
|
@@ -257924,7 +258001,7 @@ var TELEMETRY_PATCH = [
|
|
|
257924
258001
|
var TELEMETRY_STORE_FIELDS = "reqId: crypto.randomUUID(), respondedAt: null, inflight: new Map(), inflightTotal: 0, hadRejection: false, hadNonOk: false, logBudget: 5";
|
|
257925
258002
|
|
|
257926
258003
|
// ../functions-compiler/src/version.ts
|
|
257927
|
-
var COMPILER_VERSION = "0.1.
|
|
258004
|
+
var COMPILER_VERSION = "0.1.8";
|
|
257928
258005
|
|
|
257929
258006
|
// ../functions-compiler/src/worker-entry.ts
|
|
257930
258007
|
function denoShimSource() {
|
|
@@ -262548,6 +262625,174 @@ function runtimeVirtualPlugin() {
|
|
|
262548
262625
|
};
|
|
262549
262626
|
}
|
|
262550
262627
|
|
|
262628
|
+
// ../functions-compiler/src/esbuild/ws-native-virtual.ts
|
|
262629
|
+
var NAMESPACE4 = "base44-ws-native";
|
|
262630
|
+
var WS_SPECIFIER = /^(npm:)?ws(@[^/]+)?$/;
|
|
262631
|
+
var ADAPTER = `"use strict";
|
|
262632
|
+
const toBuffer = (value) => (globalThis.Buffer ? globalThis.Buffer.from(value) : value);
|
|
262633
|
+
const READY_STATES = ["CONNECTING", "OPEN", "CLOSING", "CLOSED"];
|
|
262634
|
+
const later = (fn, ...args) => queueMicrotask(() => fn(...args));
|
|
262635
|
+
const upgradeHeaders = (options) => {
|
|
262636
|
+
const headers = new Headers(options?.headers);
|
|
262637
|
+
for (const name of headers.keys()) if (name !== "user-agent") return headers;
|
|
262638
|
+
return null;
|
|
262639
|
+
};
|
|
262640
|
+
class WebSocket {
|
|
262641
|
+
static CONNECTING = 0;
|
|
262642
|
+
static OPEN = 1;
|
|
262643
|
+
static CLOSING = 2;
|
|
262644
|
+
static CLOSED = 3;
|
|
262645
|
+
#socket = null;
|
|
262646
|
+
#state = 0;
|
|
262647
|
+
#url;
|
|
262648
|
+
#closeRequested = null;
|
|
262649
|
+
#terminated = false;
|
|
262650
|
+
#listeners = new Map();
|
|
262651
|
+
constructor(address, protocols, options) {
|
|
262652
|
+
if (protocols && typeof protocols === "object" && !Array.isArray(protocols)) {
|
|
262653
|
+
options = protocols;
|
|
262654
|
+
protocols = undefined;
|
|
262655
|
+
}
|
|
262656
|
+
this.#url = String(address);
|
|
262657
|
+
const headers = upgradeHeaders(options);
|
|
262658
|
+
if (headers) {
|
|
262659
|
+
this.#upgrade(headers, protocols);
|
|
262660
|
+
} else {
|
|
262661
|
+
this.#attach(new globalThis.WebSocket(this.#url, protocols));
|
|
262662
|
+
}
|
|
262663
|
+
}
|
|
262664
|
+
get readyState() {
|
|
262665
|
+
if (this.#terminated) return 3;
|
|
262666
|
+
return this.#socket ? this.#socket.readyState : this.#state;
|
|
262667
|
+
}
|
|
262668
|
+
get url() { return this.#url; }
|
|
262669
|
+
get protocol() { return this.#socket ? this.#socket.protocol ?? "" : ""; }
|
|
262670
|
+
on(name, listener) { return this.#add(name, listener, false); }
|
|
262671
|
+
addListener(name, listener) { return this.#add(name, listener, false); }
|
|
262672
|
+
once(name, listener) { return this.#add(name, listener, true); }
|
|
262673
|
+
off(name, listener) { return this.removeListener(name, listener); }
|
|
262674
|
+
removeListener(name, listener) {
|
|
262675
|
+
const listeners = this.#listeners.get(name);
|
|
262676
|
+
if (listeners) this.#listeners.set(name, listeners.filter((entry) => entry.listener !== listener));
|
|
262677
|
+
return this;
|
|
262678
|
+
}
|
|
262679
|
+
removeAllListeners(name) {
|
|
262680
|
+
if (name === undefined) this.#listeners.clear();
|
|
262681
|
+
else this.#listeners.delete(name);
|
|
262682
|
+
return this;
|
|
262683
|
+
}
|
|
262684
|
+
emit(name, ...args) {
|
|
262685
|
+
const listeners = this.#listeners.get(name) ?? [];
|
|
262686
|
+
this.#listeners.set(name, listeners.filter((entry) => !entry.once));
|
|
262687
|
+
for (const entry of listeners) entry.listener.apply(this, args);
|
|
262688
|
+
return listeners.length > 0;
|
|
262689
|
+
}
|
|
262690
|
+
send(data, options, callback) {
|
|
262691
|
+
const done = typeof options === "function" ? options : callback;
|
|
262692
|
+
try {
|
|
262693
|
+
if (!this.#socket) {
|
|
262694
|
+
throw new Error("WebSocket is not open: readyState " + this.#state + " (" + READY_STATES[this.#state] + ")");
|
|
262695
|
+
}
|
|
262696
|
+
this.#socket.send(data);
|
|
262697
|
+
done?.();
|
|
262698
|
+
} catch (error) {
|
|
262699
|
+
if (!done) throw error;
|
|
262700
|
+
done(error);
|
|
262701
|
+
}
|
|
262702
|
+
}
|
|
262703
|
+
close(code, reason) {
|
|
262704
|
+
if (this.#socket) this.#socket.close(code, reason);
|
|
262705
|
+
else if (this.#state === 0) {
|
|
262706
|
+
// Upgrade still in flight: close as soon as it lands.
|
|
262707
|
+
this.#closeRequested = [code, reason];
|
|
262708
|
+
this.#state = 2;
|
|
262709
|
+
}
|
|
262710
|
+
}
|
|
262711
|
+
// \`ws\` tears the connection down at once. workerd has no abrupt close, so the
|
|
262712
|
+
// socket is closed normally and "close" is reported now, not on the reply.
|
|
262713
|
+
terminate() {
|
|
262714
|
+
if (this.#terminated || this.readyState === 3) return;
|
|
262715
|
+
this.#terminated = true;
|
|
262716
|
+
if (this.#socket) {
|
|
262717
|
+
try { this.#socket.close(); } catch {}
|
|
262718
|
+
} else {
|
|
262719
|
+
// Upgrade still in flight: close it on arrival, without an "open".
|
|
262720
|
+
this.#closeRequested = [];
|
|
262721
|
+
this.#state = 3;
|
|
262722
|
+
}
|
|
262723
|
+
later(() => this.emit("close", 1006, toBuffer("")));
|
|
262724
|
+
}
|
|
262725
|
+
#attach(socket) {
|
|
262726
|
+
this.#socket = socket;
|
|
262727
|
+
try { socket.binaryType = "arraybuffer"; } catch {}
|
|
262728
|
+
socket.addEventListener("open", () => this.emit("open"));
|
|
262729
|
+
socket.addEventListener("message", (event) => {
|
|
262730
|
+
const isBinary = typeof event.data !== "string";
|
|
262731
|
+
this.emit("message", toBuffer(isBinary ? new Uint8Array(event.data) : event.data), isBinary);
|
|
262732
|
+
});
|
|
262733
|
+
socket.addEventListener("error", (event) => this.emit("error", event.error ?? new Error(event.message || "WebSocket error")));
|
|
262734
|
+
socket.addEventListener("close", (event) => {
|
|
262735
|
+
if (!this.#terminated) this.emit("close", event.code, toBuffer(event.reason ?? ""));
|
|
262736
|
+
});
|
|
262737
|
+
}
|
|
262738
|
+
#upgrade(headers, protocols) {
|
|
262739
|
+
headers.set("Upgrade", "websocket");
|
|
262740
|
+
if (protocols) headers.set("Sec-WebSocket-Protocol", [].concat(protocols).join(", "));
|
|
262741
|
+
const httpUrl = this.#url.replace(/^ws(s?):/i, "http$1:");
|
|
262742
|
+
const fail = (error) => {
|
|
262743
|
+
this.#state = 3;
|
|
262744
|
+
if (this.#terminated) return;
|
|
262745
|
+
this.emit("error", error);
|
|
262746
|
+
this.emit("close", 1006, toBuffer(""));
|
|
262747
|
+
};
|
|
262748
|
+
// Two-argument then(): an exception from an "open" listener must not be
|
|
262749
|
+
// reported as a failed upgrade.
|
|
262750
|
+
fetch(httpUrl, { headers }).then((response) => {
|
|
262751
|
+
const socket = response.webSocket;
|
|
262752
|
+
if (!socket) {
|
|
262753
|
+
response.body?.cancel();
|
|
262754
|
+
return fail(new Error("Unexpected server response: " + response.status));
|
|
262755
|
+
}
|
|
262756
|
+
socket.accept();
|
|
262757
|
+
this.#attach(socket);
|
|
262758
|
+
if (this.#closeRequested) return socket.close(...this.#closeRequested);
|
|
262759
|
+
// accept() opens the socket without dispatching an "open" event.
|
|
262760
|
+
this.emit("open");
|
|
262761
|
+
}, fail);
|
|
262762
|
+
}
|
|
262763
|
+
#add(name, listener, once) {
|
|
262764
|
+
const listeners = this.#listeners.get(name) ?? [];
|
|
262765
|
+
listeners.push({ listener, once });
|
|
262766
|
+
this.#listeners.set(name, listeners);
|
|
262767
|
+
return this;
|
|
262768
|
+
}
|
|
262769
|
+
}
|
|
262770
|
+
class WebSocketServer {
|
|
262771
|
+
constructor() {
|
|
262772
|
+
throw new Error("ws WebSocketServer is not available in Base44 functions: a function can open WebSocket connections but cannot listen for them.");
|
|
262773
|
+
}
|
|
262774
|
+
}
|
|
262775
|
+
module.exports = WebSocket;
|
|
262776
|
+
module.exports.WebSocket = WebSocket;
|
|
262777
|
+
module.exports.WebSocketServer = WebSocketServer;
|
|
262778
|
+
module.exports.default = WebSocket;
|
|
262779
|
+
`;
|
|
262780
|
+
function wsNativeVirtualPlugin() {
|
|
262781
|
+
return {
|
|
262782
|
+
name: "base44-ws-native",
|
|
262783
|
+
setup(build) {
|
|
262784
|
+
build.onResolve({ filter: WS_SPECIFIER }, () => ({
|
|
262785
|
+
path: "ws",
|
|
262786
|
+
namespace: NAMESPACE4
|
|
262787
|
+
}));
|
|
262788
|
+
build.onLoad({ filter: /.*/, namespace: NAMESPACE4 }, () => ({
|
|
262789
|
+
contents: ADAPTER,
|
|
262790
|
+
loader: "js"
|
|
262791
|
+
}));
|
|
262792
|
+
}
|
|
262793
|
+
};
|
|
262794
|
+
}
|
|
262795
|
+
|
|
262551
262796
|
// ../functions-compiler/src/deno-bundle.ts
|
|
262552
262797
|
async function bundleToModule(prepared, nodeModulesDir = "none") {
|
|
262553
262798
|
const dir = await mkdtemp(path21.join(tmpdir2(), "b44-bundle-"));
|
|
@@ -262571,6 +262816,7 @@ async function bundleToModule(prepared, nodeModulesDir = "none") {
|
|
|
262571
262816
|
sourcemap: false,
|
|
262572
262817
|
logLevel: "silent",
|
|
262573
262818
|
plugins: [
|
|
262819
|
+
wsNativeVirtualPlugin(),
|
|
262574
262820
|
nodeBuiltinRequirePlugin(),
|
|
262575
262821
|
userFilesPlugin(prepared.files, prepared.entry),
|
|
262576
262822
|
privateDataSourcesVirtualPlugin(),
|
|
@@ -272960,4 +273206,4 @@ export {
|
|
|
272960
273206
|
runCLI
|
|
272961
273207
|
};
|
|
272962
273208
|
|
|
272963
|
-
//# debugId=
|
|
273209
|
+
//# debugId=874A12DB9A1B72DD64756E2164756E21
|