@base44-preview/cli 0.0.32-pr.249.fc3089a → 0.0.32-pr.251.2056a80
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 +243 -331
- package/dist/cli/index.js.map +17 -19
- package/package.json +1 -2
- package/dist/deno-runtime/main.js +0 -31
- package/dist/deno-runtime/main.js.map +0 -10
package/dist/cli/index.js
CHANGED
|
@@ -17468,7 +17468,7 @@ var require_lodash2 = __commonJS((exports, module) => {
|
|
|
17468
17468
|
function nth(array2, n2) {
|
|
17469
17469
|
return array2 && array2.length ? baseNth(array2, toInteger(n2)) : undefined2;
|
|
17470
17470
|
}
|
|
17471
|
-
var
|
|
17471
|
+
var pull2 = baseRest(pullAll);
|
|
17472
17472
|
function pullAll(array2, values2) {
|
|
17473
17473
|
return array2 && array2.length && values2 && values2.length ? basePullAll(array2, values2) : array2;
|
|
17474
17474
|
}
|
|
@@ -19233,7 +19233,7 @@ __p += '`;
|
|
|
19233
19233
|
lodash.pickBy = pickBy;
|
|
19234
19234
|
lodash.property = property;
|
|
19235
19235
|
lodash.propertyOf = propertyOf;
|
|
19236
|
-
lodash.pull =
|
|
19236
|
+
lodash.pull = pull2;
|
|
19237
19237
|
lodash.pullAll = pullAll;
|
|
19238
19238
|
lodash.pullAllBy = pullAllBy;
|
|
19239
19239
|
lodash.pullAllWith = pullAllWith;
|
|
@@ -185051,6 +185051,10 @@ var TikTokConnectorSchema = exports_external.object({
|
|
|
185051
185051
|
type: exports_external.literal("tiktok"),
|
|
185052
185052
|
scopes: exports_external.array(exports_external.string()).default([])
|
|
185053
185053
|
});
|
|
185054
|
+
var StripeConnectorSchema = exports_external.object({
|
|
185055
|
+
type: exports_external.literal("stripe"),
|
|
185056
|
+
scopes: exports_external.array(exports_external.string()).default([])
|
|
185057
|
+
});
|
|
185054
185058
|
var CustomTypeSchema = exports_external.string().min(1).regex(/^[a-z0-9_-]+$/i);
|
|
185055
185059
|
var GenericConnectorSchema = exports_external.object({
|
|
185056
185060
|
type: CustomTypeSchema,
|
|
@@ -185069,6 +185073,7 @@ var ConnectorResourceSchema = exports_external.union([
|
|
|
185069
185073
|
HubspotConnectorSchema,
|
|
185070
185074
|
LinkedInConnectorSchema,
|
|
185071
185075
|
TikTokConnectorSchema,
|
|
185076
|
+
StripeConnectorSchema,
|
|
185072
185077
|
GenericConnectorSchema
|
|
185073
185078
|
]);
|
|
185074
185079
|
var KnownIntegrationTypes = [
|
|
@@ -185083,7 +185088,8 @@ var KnownIntegrationTypes = [
|
|
|
185083
185088
|
"salesforce",
|
|
185084
185089
|
"hubspot",
|
|
185085
185090
|
"linkedin",
|
|
185086
|
-
"tiktok"
|
|
185091
|
+
"tiktok",
|
|
185092
|
+
"stripe"
|
|
185087
185093
|
];
|
|
185088
185094
|
var IntegrationTypeSchema = exports_external.union([
|
|
185089
185095
|
exports_external.enum(KnownIntegrationTypes),
|
|
@@ -185136,6 +185142,18 @@ var RemoveConnectorResponseSchema = exports_external.object({
|
|
|
185136
185142
|
status: data.status,
|
|
185137
185143
|
integrationType: data.integration_type
|
|
185138
185144
|
}));
|
|
185145
|
+
var STRIPE_CONNECTOR_TYPE = "stripe";
|
|
185146
|
+
var InstallStripeResponseSchema = exports_external.object({
|
|
185147
|
+
already_installed: exports_external.boolean(),
|
|
185148
|
+
claim_url: exports_external.string().nullable()
|
|
185149
|
+
});
|
|
185150
|
+
var StripeStatusResponseSchema = exports_external.object({
|
|
185151
|
+
stripe_mode: exports_external.enum(["sandbox", "live"]).nullable(),
|
|
185152
|
+
sandbox_claim_url: exports_external.string().nullable().optional()
|
|
185153
|
+
});
|
|
185154
|
+
var RemoveStripeResponseSchema = exports_external.object({
|
|
185155
|
+
success: exports_external.boolean()
|
|
185156
|
+
});
|
|
185139
185157
|
|
|
185140
185158
|
// src/core/resources/connector/api.ts
|
|
185141
185159
|
async function listConnectors() {
|
|
@@ -185203,6 +185221,54 @@ async function removeConnector(integrationType) {
|
|
|
185203
185221
|
}
|
|
185204
185222
|
return result.data;
|
|
185205
185223
|
}
|
|
185224
|
+
async function installStripe() {
|
|
185225
|
+
const appClient = getAppClient();
|
|
185226
|
+
let response;
|
|
185227
|
+
try {
|
|
185228
|
+
response = await appClient.post("payments/stripe/install", {
|
|
185229
|
+
timeout: 60000
|
|
185230
|
+
});
|
|
185231
|
+
} catch (error48) {
|
|
185232
|
+
throw await ApiError.fromHttpError(error48, "installing Stripe");
|
|
185233
|
+
}
|
|
185234
|
+
const result = InstallStripeResponseSchema.safeParse(await response.json());
|
|
185235
|
+
if (!result.success) {
|
|
185236
|
+
throw new SchemaValidationError("Invalid response from server", result.error);
|
|
185237
|
+
}
|
|
185238
|
+
return result.data;
|
|
185239
|
+
}
|
|
185240
|
+
async function getStripeStatus() {
|
|
185241
|
+
const appClient = getAppClient();
|
|
185242
|
+
let response;
|
|
185243
|
+
try {
|
|
185244
|
+
response = await appClient.get("payments/stripe/status", {
|
|
185245
|
+
timeout: 60000
|
|
185246
|
+
});
|
|
185247
|
+
} catch (error48) {
|
|
185248
|
+
throw await ApiError.fromHttpError(error48, "checking Stripe integration status");
|
|
185249
|
+
}
|
|
185250
|
+
const result = StripeStatusResponseSchema.safeParse(await response.json());
|
|
185251
|
+
if (!result.success) {
|
|
185252
|
+
throw new SchemaValidationError("Invalid response from server", result.error);
|
|
185253
|
+
}
|
|
185254
|
+
return result.data;
|
|
185255
|
+
}
|
|
185256
|
+
async function removeStripe() {
|
|
185257
|
+
const appClient = getAppClient();
|
|
185258
|
+
let response;
|
|
185259
|
+
try {
|
|
185260
|
+
response = await appClient.delete("payments/stripe", {
|
|
185261
|
+
timeout: 60000
|
|
185262
|
+
});
|
|
185263
|
+
} catch (error48) {
|
|
185264
|
+
throw await ApiError.fromHttpError(error48, "removing Stripe integration");
|
|
185265
|
+
}
|
|
185266
|
+
const result = RemoveStripeResponseSchema.safeParse(await response.json());
|
|
185267
|
+
if (!result.success) {
|
|
185268
|
+
throw new SchemaValidationError("Invalid response from server", result.error);
|
|
185269
|
+
}
|
|
185270
|
+
return result.data;
|
|
185271
|
+
}
|
|
185206
185272
|
// src/core/resources/connector/config.ts
|
|
185207
185273
|
import { join as join4 } from "node:path";
|
|
185208
185274
|
import { isDeepStrictEqual } from "node:util";
|
|
@@ -185251,7 +185317,7 @@ async function readAllConnectors(connectorsDir) {
|
|
|
185251
185317
|
async function writeConnectors(connectorsDir, remoteConnectors) {
|
|
185252
185318
|
const entries = await readConnectorFiles(connectorsDir);
|
|
185253
185319
|
const typeToEntry = buildTypeToEntryMap(entries);
|
|
185254
|
-
const newTypes = new Set(remoteConnectors.map((c) => c.
|
|
185320
|
+
const newTypes = new Set(remoteConnectors.map((c) => c.type));
|
|
185255
185321
|
const deleted = [];
|
|
185256
185322
|
for (const [type, entry] of typeToEntry) {
|
|
185257
185323
|
if (!newTypes.has(type)) {
|
|
@@ -185261,22 +185327,44 @@ async function writeConnectors(connectorsDir, remoteConnectors) {
|
|
|
185261
185327
|
}
|
|
185262
185328
|
const written = [];
|
|
185263
185329
|
for (const connector of remoteConnectors) {
|
|
185264
|
-
const existing = typeToEntry.get(connector.
|
|
185265
|
-
|
|
185266
|
-
type: connector.integrationType,
|
|
185267
|
-
scopes: connector.scopes
|
|
185268
|
-
};
|
|
185269
|
-
if (existing && isDeepStrictEqual(existing.data, localConnector)) {
|
|
185330
|
+
const existing = typeToEntry.get(connector.type);
|
|
185331
|
+
if (existing && isDeepStrictEqual(existing.data, connector)) {
|
|
185270
185332
|
continue;
|
|
185271
185333
|
}
|
|
185272
|
-
const filePath = existing?.filePath ?? join4(connectorsDir, `${connector.
|
|
185273
|
-
await writeJsonFile(filePath,
|
|
185274
|
-
written.push(connector.
|
|
185334
|
+
const filePath = existing?.filePath ?? join4(connectorsDir, `${connector.type}.${CONFIG_FILE_EXTENSION}`);
|
|
185335
|
+
await writeJsonFile(filePath, connector);
|
|
185336
|
+
written.push(connector.type);
|
|
185275
185337
|
}
|
|
185276
185338
|
return { written, deleted };
|
|
185277
185339
|
}
|
|
185340
|
+
// src/core/resources/connector/pull.ts
|
|
185341
|
+
async function pullAllConnectors() {
|
|
185342
|
+
const [oauthResponse, stripeStatus] = await Promise.all([
|
|
185343
|
+
listConnectors(),
|
|
185344
|
+
getStripeStatus()
|
|
185345
|
+
]);
|
|
185346
|
+
const connectors = oauthResponse.integrations.map((i) => ({
|
|
185347
|
+
type: i.integrationType,
|
|
185348
|
+
scopes: i.scopes
|
|
185349
|
+
}));
|
|
185350
|
+
if (stripeStatus.stripe_mode !== null) {
|
|
185351
|
+
connectors.push({ type: STRIPE_CONNECTOR_TYPE, scopes: [] });
|
|
185352
|
+
}
|
|
185353
|
+
return connectors;
|
|
185354
|
+
}
|
|
185278
185355
|
// src/core/resources/connector/push.ts
|
|
185279
185356
|
async function pushConnectors(connectors) {
|
|
185357
|
+
const stripeConnector = connectors.find((c) => c.type === STRIPE_CONNECTOR_TYPE);
|
|
185358
|
+
const oauthConnectors = connectors.filter((c) => c.type !== STRIPE_CONNECTOR_TYPE);
|
|
185359
|
+
const oauthResults = await syncOAuthConnectors(oauthConnectors);
|
|
185360
|
+
const stripeResult = await syncStripeConnector(stripeConnector);
|
|
185361
|
+
const results = [...oauthResults];
|
|
185362
|
+
if (stripeResult) {
|
|
185363
|
+
results.push(stripeResult);
|
|
185364
|
+
}
|
|
185365
|
+
return { results };
|
|
185366
|
+
}
|
|
185367
|
+
async function syncOAuthConnectors(connectors) {
|
|
185280
185368
|
const results = [];
|
|
185281
185369
|
const upstream = await listConnectors();
|
|
185282
185370
|
const localTypes = new Set(connectors.map((c) => c.type));
|
|
@@ -185309,7 +185397,69 @@ async function pushConnectors(connectors) {
|
|
|
185309
185397
|
}
|
|
185310
185398
|
}
|
|
185311
185399
|
}
|
|
185312
|
-
return
|
|
185400
|
+
return results;
|
|
185401
|
+
}
|
|
185402
|
+
async function syncStripeConnector(localStripe) {
|
|
185403
|
+
const remoteStatus = await fetchStripeRemoteStatus();
|
|
185404
|
+
if (remoteStatus === "error") {
|
|
185405
|
+
return localStripe ? stripeError("Failed to check Stripe integration status") : null;
|
|
185406
|
+
}
|
|
185407
|
+
const isRemoteInstalled = remoteStatus.stripe_mode !== null;
|
|
185408
|
+
const needsInstall = localStripe && !isRemoteInstalled;
|
|
185409
|
+
const alreadySynced = localStripe && isRemoteInstalled;
|
|
185410
|
+
const needsRemoval = !localStripe && isRemoteInstalled;
|
|
185411
|
+
if (needsInstall) {
|
|
185412
|
+
return handleStripeInstall();
|
|
185413
|
+
}
|
|
185414
|
+
if (alreadySynced) {
|
|
185415
|
+
const mode = remoteStatus.stripe_mode;
|
|
185416
|
+
const hasUnclaimedSandbox = mode === "sandbox" && remoteStatus.sandbox_claim_url;
|
|
185417
|
+
return hasUnclaimedSandbox ? stripeProvisioned(mode, remoteStatus.sandbox_claim_url ?? undefined) : stripeSynced();
|
|
185418
|
+
}
|
|
185419
|
+
if (needsRemoval) {
|
|
185420
|
+
return handleStripeRemoval();
|
|
185421
|
+
}
|
|
185422
|
+
return null;
|
|
185423
|
+
}
|
|
185424
|
+
async function fetchStripeRemoteStatus() {
|
|
185425
|
+
try {
|
|
185426
|
+
const status = await getStripeStatus();
|
|
185427
|
+
if (!status)
|
|
185428
|
+
return "error";
|
|
185429
|
+
return status;
|
|
185430
|
+
} catch {
|
|
185431
|
+
return "error";
|
|
185432
|
+
}
|
|
185433
|
+
}
|
|
185434
|
+
async function handleStripeInstall() {
|
|
185435
|
+
try {
|
|
185436
|
+
const result = await installStripe();
|
|
185437
|
+
const status = await fetchStripeRemoteStatus();
|
|
185438
|
+
const mode = status !== "error" && status.stripe_mode ? status.stripe_mode : "sandbox";
|
|
185439
|
+
return stripeProvisioned(mode, result.claim_url ?? undefined);
|
|
185440
|
+
} catch (err) {
|
|
185441
|
+
return stripeError(err instanceof Error ? err.message : String(err));
|
|
185442
|
+
}
|
|
185443
|
+
}
|
|
185444
|
+
async function handleStripeRemoval() {
|
|
185445
|
+
try {
|
|
185446
|
+
await removeStripe();
|
|
185447
|
+
return stripeRemoved();
|
|
185448
|
+
} catch (err) {
|
|
185449
|
+
return stripeError(err instanceof Error ? err.message : String(err));
|
|
185450
|
+
}
|
|
185451
|
+
}
|
|
185452
|
+
function stripeSynced() {
|
|
185453
|
+
return { type: STRIPE_CONNECTOR_TYPE, action: "synced" };
|
|
185454
|
+
}
|
|
185455
|
+
function stripeProvisioned(mode, claimUrl) {
|
|
185456
|
+
return { type: STRIPE_CONNECTOR_TYPE, action: "provisioned", mode, claimUrl };
|
|
185457
|
+
}
|
|
185458
|
+
function stripeRemoved() {
|
|
185459
|
+
return { type: STRIPE_CONNECTOR_TYPE, action: "removed" };
|
|
185460
|
+
}
|
|
185461
|
+
function stripeError(error48) {
|
|
185462
|
+
return { type: STRIPE_CONNECTOR_TYPE, action: "error", error: error48 };
|
|
185313
185463
|
}
|
|
185314
185464
|
function getConnectorSyncResult(type, response) {
|
|
185315
185465
|
if (response.error === "different_user") {
|
|
@@ -185327,7 +185477,7 @@ function getConnectorSyncResult(type, response) {
|
|
|
185327
185477
|
type,
|
|
185328
185478
|
action: "needs_oauth",
|
|
185329
185479
|
redirectUrl: response.redirectUrl,
|
|
185330
|
-
connectionId: response.connectionId ??
|
|
185480
|
+
connectionId: response.connectionId ?? ""
|
|
185331
185481
|
};
|
|
185332
185482
|
}
|
|
185333
185483
|
return { type, action: "synced" };
|
|
@@ -186024,7 +186174,7 @@ async function handleUnauthorized(request, _options, response) {
|
|
|
186024
186174
|
return;
|
|
186025
186175
|
}
|
|
186026
186176
|
retriedRequests.add(request);
|
|
186027
|
-
return distribution_default(request, {
|
|
186177
|
+
return distribution_default(request.clone(), {
|
|
186028
186178
|
headers: { Authorization: `Bearer ${newAccessToken}` }
|
|
186029
186179
|
});
|
|
186030
186180
|
}
|
|
@@ -193486,7 +193636,6 @@ var package_default = {
|
|
|
193486
193636
|
"@types/bun": "^1.2.15",
|
|
193487
193637
|
"@types/common-tags": "^1.8.4",
|
|
193488
193638
|
"@types/cors": "^2.8.19",
|
|
193489
|
-
"@types/deno": "^2.5.0",
|
|
193490
193639
|
"@types/ejs": "^3.1.5",
|
|
193491
193640
|
"@types/express": "^5.0.6",
|
|
193492
193641
|
"@types/json-schema": "^7.0.15",
|
|
@@ -193637,6 +193786,10 @@ function getDashboardUrl(projectId) {
|
|
|
193637
193786
|
const id = projectId ?? getAppConfig().id;
|
|
193638
193787
|
return `${getBase44ApiUrl()}/apps/${id}/editor/workspace/overview`;
|
|
193639
193788
|
}
|
|
193789
|
+
function getConnectorsUrl(projectId) {
|
|
193790
|
+
const id = projectId ?? getAppConfig().id;
|
|
193791
|
+
return `${getBase44ApiUrl()}/apps/${id}/editor/workspace/app-connections`;
|
|
193792
|
+
}
|
|
193640
193793
|
// src/cli/commands/agents/pull.ts
|
|
193641
193794
|
async function pullAgentsAction() {
|
|
193642
193795
|
const { project: project2 } = await readProjectConfig();
|
|
@@ -193741,13 +193894,13 @@ async function pullConnectorsAction() {
|
|
|
193741
193894
|
const configDir = dirname8(project2.configPath);
|
|
193742
193895
|
const connectorsDir = join10(configDir, project2.connectorsDir);
|
|
193743
193896
|
const remoteConnectors = await runTask("Fetching connectors from Base44", async () => {
|
|
193744
|
-
return await
|
|
193897
|
+
return await pullAllConnectors();
|
|
193745
193898
|
}, {
|
|
193746
193899
|
successMessage: "Connectors fetched successfully",
|
|
193747
193900
|
errorMessage: "Failed to fetch connectors"
|
|
193748
193901
|
});
|
|
193749
193902
|
const { written, deleted } = await runTask("Syncing connector files", async () => {
|
|
193750
|
-
return await writeConnectors(connectorsDir, remoteConnectors
|
|
193903
|
+
return await writeConnectors(connectorsDir, remoteConnectors);
|
|
193751
193904
|
}, {
|
|
193752
193905
|
successMessage: "Connector files synced successfully",
|
|
193753
193906
|
errorMessage: "Failed to sync connector files"
|
|
@@ -193762,7 +193915,7 @@ async function pullConnectorsAction() {
|
|
|
193762
193915
|
M2.info("All connectors are already up to date");
|
|
193763
193916
|
}
|
|
193764
193917
|
return {
|
|
193765
|
-
outroMessage: `Pulled ${remoteConnectors.
|
|
193918
|
+
outroMessage: `Pulled ${remoteConnectors.length} connectors to ${connectorsDir}`
|
|
193766
193919
|
};
|
|
193767
193920
|
}
|
|
193768
193921
|
function getConnectorsPullCommand(context) {
|
|
@@ -194381,7 +194534,7 @@ var open_default = open;
|
|
|
194381
194534
|
var POLL_INTERVAL_MS = 2000;
|
|
194382
194535
|
var POLL_TIMEOUT_MS = 2 * 60 * 1000;
|
|
194383
194536
|
function filterPendingOAuth(results) {
|
|
194384
|
-
return results.filter((r2) => r2.action === "needs_oauth"
|
|
194537
|
+
return results.filter((r2) => r2.action === "needs_oauth");
|
|
194385
194538
|
}
|
|
194386
194539
|
async function runOAuthFlowWithSkip(connector2) {
|
|
194387
194540
|
await open_default(connector2.redirectUrl);
|
|
@@ -194463,32 +194616,49 @@ Opening browser for ${connector2.type}...`);
|
|
|
194463
194616
|
function printSummary(results, oauthOutcomes) {
|
|
194464
194617
|
const synced = [];
|
|
194465
194618
|
const added = [];
|
|
194619
|
+
const provisioned = [];
|
|
194466
194620
|
const removed = [];
|
|
194467
194621
|
const skipped = [];
|
|
194468
194622
|
const failed = [];
|
|
194469
194623
|
for (const r2 of results) {
|
|
194470
|
-
|
|
194471
|
-
|
|
194472
|
-
|
|
194473
|
-
|
|
194474
|
-
|
|
194475
|
-
|
|
194476
|
-
|
|
194477
|
-
|
|
194478
|
-
|
|
194479
|
-
|
|
194480
|
-
|
|
194481
|
-
|
|
194482
|
-
|
|
194483
|
-
|
|
194484
|
-
|
|
194485
|
-
|
|
194486
|
-
|
|
194487
|
-
|
|
194624
|
+
switch (r2.action) {
|
|
194625
|
+
case "provisioned":
|
|
194626
|
+
provisioned.push(r2);
|
|
194627
|
+
break;
|
|
194628
|
+
case "synced":
|
|
194629
|
+
synced.push(r2.type);
|
|
194630
|
+
break;
|
|
194631
|
+
case "removed":
|
|
194632
|
+
removed.push(r2.type);
|
|
194633
|
+
break;
|
|
194634
|
+
case "error":
|
|
194635
|
+
failed.push({ type: r2.type, error: r2.error });
|
|
194636
|
+
break;
|
|
194637
|
+
case "needs_oauth": {
|
|
194638
|
+
const oauthStatus = oauthOutcomes.get(r2.type);
|
|
194639
|
+
if (oauthStatus === "ACTIVE") {
|
|
194640
|
+
added.push(r2.type);
|
|
194641
|
+
} else if (oauthStatus === "SKIPPED") {
|
|
194642
|
+
skipped.push(r2.type);
|
|
194643
|
+
} else if (oauthStatus === "PENDING") {
|
|
194644
|
+
failed.push({ type: r2.type, error: "authorization timed out" });
|
|
194645
|
+
} else if (oauthStatus === "FAILED") {
|
|
194646
|
+
failed.push({ type: r2.type, error: "authorization failed" });
|
|
194647
|
+
} else {
|
|
194648
|
+
failed.push({ type: r2.type, error: "needs authorization" });
|
|
194649
|
+
}
|
|
194650
|
+
break;
|
|
194488
194651
|
}
|
|
194489
194652
|
}
|
|
194490
194653
|
}
|
|
194491
194654
|
M2.info(theme.styles.bold("Summary:"));
|
|
194655
|
+
for (const i2 of provisioned) {
|
|
194656
|
+
M2.success(`Provisioned: ${i2.type} (${i2.mode})`);
|
|
194657
|
+
if (i2.claimUrl) {
|
|
194658
|
+
M2.info(` Claim your Stripe account: ${theme.colors.links(i2.claimUrl)}`);
|
|
194659
|
+
}
|
|
194660
|
+
M2.info(` Connectors dashboard: ${theme.colors.links(getConnectorsUrl())}`);
|
|
194661
|
+
}
|
|
194492
194662
|
if (synced.length > 0) {
|
|
194493
194663
|
M2.success(`Synced: ${synced.join(", ")}`);
|
|
194494
194664
|
}
|
|
@@ -194502,7 +194672,7 @@ function printSummary(results, oauthOutcomes) {
|
|
|
194502
194672
|
M2.warn(`Skipped: ${skipped.join(", ")}`);
|
|
194503
194673
|
}
|
|
194504
194674
|
for (const r2 of failed) {
|
|
194505
|
-
M2.error(`Failed: ${r2.type}
|
|
194675
|
+
M2.error(`Failed: ${r2.type} - ${r2.error}`);
|
|
194506
194676
|
}
|
|
194507
194677
|
}
|
|
194508
194678
|
async function pushConnectorsAction() {
|
|
@@ -194536,7 +194706,7 @@ function getConnectorsPushCommand(context) {
|
|
|
194536
194706
|
|
|
194537
194707
|
// src/cli/commands/connectors/index.ts
|
|
194538
194708
|
function getConnectorsCommand(context) {
|
|
194539
|
-
return new Command("connectors").description("Manage project connectors
|
|
194709
|
+
return new Command("connectors").description("Manage project connectors").addCommand(getConnectorsPullCommand(context)).addCommand(getConnectorsPushCommand(context));
|
|
194540
194710
|
}
|
|
194541
194711
|
|
|
194542
194712
|
// src/cli/commands/dashboard/open.ts
|
|
@@ -194852,15 +195022,11 @@ ${summaryLines.join(`
|
|
|
194852
195022
|
successMessage: theme.colors.base44Orange("Deployment completed"),
|
|
194853
195023
|
errorMessage: "Deployment failed"
|
|
194854
195024
|
});
|
|
194855
|
-
const
|
|
194856
|
-
|
|
194857
|
-
|
|
194858
|
-
|
|
194859
|
-
|
|
194860
|
-
const allAuthorized = oauthOutcomes.size > 0 && [...oauthOutcomes.values()].every((s) => s === "ACTIVE");
|
|
194861
|
-
if (!allAuthorized) {
|
|
194862
|
-
M2.info("Some connectors still require authorization. Run 'base44 connectors push' or open the links above in your browser.");
|
|
194863
|
-
}
|
|
195025
|
+
const connectorResults = result.connectorResults ?? [];
|
|
195026
|
+
await handleOAuthConnectors(connectorResults, options);
|
|
195027
|
+
const stripeResult = connectorResults.find((r2) => r2.action === "provisioned");
|
|
195028
|
+
if (stripeResult) {
|
|
195029
|
+
printStripeResult(stripeResult);
|
|
194864
195030
|
}
|
|
194865
195031
|
M2.message(`${theme.styles.header("Dashboard")}: ${theme.colors.links(getDashboardUrl())}`);
|
|
194866
195032
|
if (result.appUrl) {
|
|
@@ -194873,6 +195039,25 @@ function getDeployCommand(context) {
|
|
|
194873
195039
|
await runCommand(() => deployAction(options), { requireAuth: true }, context);
|
|
194874
195040
|
});
|
|
194875
195041
|
}
|
|
195042
|
+
async function handleOAuthConnectors(connectorResults, options) {
|
|
195043
|
+
const needsOAuth = filterPendingOAuth(connectorResults);
|
|
195044
|
+
if (needsOAuth.length === 0)
|
|
195045
|
+
return;
|
|
195046
|
+
const oauthOutcomes = await promptOAuthFlows(needsOAuth, {
|
|
195047
|
+
skipPrompt: options.yes || !!process.env.CI
|
|
195048
|
+
});
|
|
195049
|
+
const allAuthorized = oauthOutcomes.size > 0 && [...oauthOutcomes.values()].every((s) => s === "ACTIVE");
|
|
195050
|
+
if (!allAuthorized) {
|
|
195051
|
+
M2.info("Some connectors still require authorization. Run 'base44 connectors push' or open the links above in your browser.");
|
|
195052
|
+
}
|
|
195053
|
+
}
|
|
195054
|
+
function printStripeResult(r2) {
|
|
195055
|
+
M2.success(`Provisioned: Stripe (${r2.mode})`);
|
|
195056
|
+
if (r2.claimUrl) {
|
|
195057
|
+
M2.info(` Claim your Stripe account: ${theme.colors.links(r2.claimUrl)}`);
|
|
195058
|
+
}
|
|
195059
|
+
M2.info(` Connectors dashboard: ${theme.colors.links(getConnectorsUrl())}`);
|
|
195060
|
+
}
|
|
194876
195061
|
|
|
194877
195062
|
// src/cli/commands/project/link.ts
|
|
194878
195063
|
function validateNonInteractiveFlags2(command) {
|
|
@@ -195206,62 +195391,9 @@ function getTypesCommand(context) {
|
|
|
195206
195391
|
return new Command("types").description("Manage TypeScript type generation").addCommand(getTypesGenerateCommand(context));
|
|
195207
195392
|
}
|
|
195208
195393
|
|
|
195209
|
-
// src/cli/dev/createDevLogger.ts
|
|
195210
|
-
var dateTimeFormat = new Intl.DateTimeFormat([], {
|
|
195211
|
-
hour: "2-digit",
|
|
195212
|
-
minute: "2-digit",
|
|
195213
|
-
second: "2-digit",
|
|
195214
|
-
hour12: false
|
|
195215
|
-
});
|
|
195216
|
-
var colorByType = {
|
|
195217
|
-
error: source_default.red,
|
|
195218
|
-
warn: source_default.yellow,
|
|
195219
|
-
log: (text) => text
|
|
195220
|
-
};
|
|
195221
|
-
function createDevLogger(isPrefixed = true) {
|
|
195222
|
-
const print = (type, msg) => {
|
|
195223
|
-
const colorize = colorByType[type];
|
|
195224
|
-
switch (type) {
|
|
195225
|
-
case "error":
|
|
195226
|
-
console.error(colorize(msg));
|
|
195227
|
-
break;
|
|
195228
|
-
case "warn":
|
|
195229
|
-
console.warn(colorize(msg));
|
|
195230
|
-
break;
|
|
195231
|
-
default:
|
|
195232
|
-
console.log(msg);
|
|
195233
|
-
}
|
|
195234
|
-
};
|
|
195235
|
-
const prefixedLog = (type, msg) => {
|
|
195236
|
-
const timestamp = dateTimeFormat.format(new Date);
|
|
195237
|
-
const colorize = colorByType[type];
|
|
195238
|
-
console.log(`${source_default.gray(timestamp)} ${colorize(msg)}`);
|
|
195239
|
-
};
|
|
195240
|
-
return isPrefixed ? {
|
|
195241
|
-
log: (msg) => prefixedLog("log", msg),
|
|
195242
|
-
error: (msg, err) => {
|
|
195243
|
-
prefixedLog("error", msg);
|
|
195244
|
-
if (err) {
|
|
195245
|
-
prefixedLog("error", String(err));
|
|
195246
|
-
}
|
|
195247
|
-
},
|
|
195248
|
-
warn: (msg) => prefixedLog("warn", msg)
|
|
195249
|
-
} : {
|
|
195250
|
-
log: (msg) => print("log", msg),
|
|
195251
|
-
error: (msg, err) => {
|
|
195252
|
-
print("error", msg);
|
|
195253
|
-
if (err) {
|
|
195254
|
-
print("error", String(err));
|
|
195255
|
-
}
|
|
195256
|
-
},
|
|
195257
|
-
warn: (msg) => print("warn", msg)
|
|
195258
|
-
};
|
|
195259
|
-
}
|
|
195260
|
-
|
|
195261
195394
|
// src/cli/dev/dev-server/main.ts
|
|
195262
195395
|
var import_cors = __toESM(require_lib4(), 1);
|
|
195263
|
-
var
|
|
195264
|
-
import { dirname as dirname12, join as join16 } from "node:path";
|
|
195396
|
+
var import_express = __toESM(require_express(), 1);
|
|
195265
195397
|
|
|
195266
195398
|
// node_modules/get-port/index.js
|
|
195267
195399
|
import net from "node:net";
|
|
@@ -195379,220 +195511,11 @@ async function getPorts(options8) {
|
|
|
195379
195511
|
|
|
195380
195512
|
// src/cli/dev/dev-server/main.ts
|
|
195381
195513
|
var import_http_proxy_middleware = __toESM(require_dist2(), 1);
|
|
195382
|
-
|
|
195383
|
-
// src/cli/dev/dev-server/function-manager.ts
|
|
195384
|
-
import { spawn as spawn2 } from "node:child_process";
|
|
195385
|
-
import { dirname as dirname11, join as join15 } from "node:path";
|
|
195386
|
-
import { fileURLToPath as fileURLToPath7 } from "node:url";
|
|
195387
|
-
var __dirname5 = dirname11(fileURLToPath7(import.meta.url));
|
|
195388
|
-
var WRAPPER_PATH = join15(__dirname5, "../deno-runtime/main.js");
|
|
195389
|
-
var READY_TIMEOUT = 30000;
|
|
195390
|
-
|
|
195391
|
-
class FunctionManager {
|
|
195392
|
-
functions;
|
|
195393
|
-
running = new Map;
|
|
195394
|
-
logger;
|
|
195395
|
-
constructor(functions, logger) {
|
|
195396
|
-
this.functions = new Map(functions.map((f7) => [f7.name, f7]));
|
|
195397
|
-
this.logger = logger;
|
|
195398
|
-
}
|
|
195399
|
-
getFunction(name2) {
|
|
195400
|
-
return this.functions.get(name2);
|
|
195401
|
-
}
|
|
195402
|
-
async ensureRunning(name2) {
|
|
195403
|
-
const existing = this.running.get(name2);
|
|
195404
|
-
if (existing?.ready) {
|
|
195405
|
-
return existing.port;
|
|
195406
|
-
}
|
|
195407
|
-
const backendFunction = this.functions.get(name2);
|
|
195408
|
-
if (!backendFunction) {
|
|
195409
|
-
throw new Error(`Function "${name2}" not found`);
|
|
195410
|
-
}
|
|
195411
|
-
if (existing && !existing.ready) {
|
|
195412
|
-
return this.waitForReady(name2, existing);
|
|
195413
|
-
}
|
|
195414
|
-
const port = await this.allocatePort();
|
|
195415
|
-
const process21 = this.spawnFunction(backendFunction, port);
|
|
195416
|
-
const runningFunc = {
|
|
195417
|
-
process: process21,
|
|
195418
|
-
port,
|
|
195419
|
-
ready: false
|
|
195420
|
-
};
|
|
195421
|
-
this.running.set(name2, runningFunc);
|
|
195422
|
-
this.setupProcessHandlers(name2, process21);
|
|
195423
|
-
return this.waitForReady(name2, runningFunc);
|
|
195424
|
-
}
|
|
195425
|
-
getPort(name2) {
|
|
195426
|
-
const running = this.running.get(name2);
|
|
195427
|
-
return running?.ready ? running.port : undefined;
|
|
195428
|
-
}
|
|
195429
|
-
stopAll() {
|
|
195430
|
-
for (const [name2, { process: process21 }] of this.running) {
|
|
195431
|
-
this.logger.log(`[dev-server] Stopping function: ${name2}`);
|
|
195432
|
-
process21.kill();
|
|
195433
|
-
}
|
|
195434
|
-
this.running.clear();
|
|
195435
|
-
}
|
|
195436
|
-
stop(name2) {
|
|
195437
|
-
const running = this.running.get(name2);
|
|
195438
|
-
if (running) {
|
|
195439
|
-
this.logger.log(`Stopping function: ${name2}`);
|
|
195440
|
-
running.process.kill();
|
|
195441
|
-
this.running.delete(name2);
|
|
195442
|
-
}
|
|
195443
|
-
}
|
|
195444
|
-
async allocatePort() {
|
|
195445
|
-
const usedPorts = Array.from(this.running.values()).map((r5) => r5.port);
|
|
195446
|
-
return getPorts({ exclude: usedPorts });
|
|
195447
|
-
}
|
|
195448
|
-
spawnFunction(func, port) {
|
|
195449
|
-
this.logger.log(`[dev-server] Spawning function "${func.name}" on port ${port}`);
|
|
195450
|
-
const process21 = spawn2("deno", ["run", "--allow-all", WRAPPER_PATH], {
|
|
195451
|
-
env: {
|
|
195452
|
-
...globalThis.process.env,
|
|
195453
|
-
FUNCTION_PATH: func.entryPath,
|
|
195454
|
-
FUNCTION_PORT: String(port),
|
|
195455
|
-
FUNCTION_NAME: func.name
|
|
195456
|
-
},
|
|
195457
|
-
stdio: ["pipe", "pipe", "pipe"]
|
|
195458
|
-
});
|
|
195459
|
-
return process21;
|
|
195460
|
-
}
|
|
195461
|
-
setupProcessHandlers(name2, process21) {
|
|
195462
|
-
process21.stdout?.on("data", (data) => {
|
|
195463
|
-
const lines = data.toString().trim().split(`
|
|
195464
|
-
`);
|
|
195465
|
-
for (const line3 of lines) {
|
|
195466
|
-
this.logger.log(line3);
|
|
195467
|
-
}
|
|
195468
|
-
});
|
|
195469
|
-
process21.stderr?.on("data", (data) => {
|
|
195470
|
-
const lines = data.toString().trim().split(`
|
|
195471
|
-
`);
|
|
195472
|
-
for (const line3 of lines) {
|
|
195473
|
-
this.logger.error(line3);
|
|
195474
|
-
}
|
|
195475
|
-
});
|
|
195476
|
-
process21.on("exit", (code2) => {
|
|
195477
|
-
this.logger.log(`[dev-server] Function "${name2}" exited with code ${code2}`);
|
|
195478
|
-
this.running.delete(name2);
|
|
195479
|
-
});
|
|
195480
|
-
process21.on("error", (error48) => {
|
|
195481
|
-
this.logger.error(`[dev-server] Function "${name2}" error:`, error48);
|
|
195482
|
-
this.running.delete(name2);
|
|
195483
|
-
});
|
|
195484
|
-
}
|
|
195485
|
-
waitForReady(name2, runningFunc) {
|
|
195486
|
-
return new Promise((resolve5, reject) => {
|
|
195487
|
-
const timeout3 = setTimeout(() => {
|
|
195488
|
-
reject(new Error(`Function "${name2}" failed to start within timeout`));
|
|
195489
|
-
}, READY_TIMEOUT);
|
|
195490
|
-
const onData = (data) => {
|
|
195491
|
-
const output = data.toString();
|
|
195492
|
-
if (output.includes("Listening on")) {
|
|
195493
|
-
runningFunc.ready = true;
|
|
195494
|
-
clearTimeout(timeout3);
|
|
195495
|
-
runningFunc.process.stdout?.off("data", onData);
|
|
195496
|
-
resolve5(runningFunc.port);
|
|
195497
|
-
}
|
|
195498
|
-
};
|
|
195499
|
-
runningFunc.process.stdout?.on("data", onData);
|
|
195500
|
-
runningFunc.process.on("exit", (code2) => {
|
|
195501
|
-
if (!runningFunc.ready) {
|
|
195502
|
-
clearTimeout(timeout3);
|
|
195503
|
-
reject(new Error(`Function "${name2}" exited with code ${code2}`));
|
|
195504
|
-
}
|
|
195505
|
-
});
|
|
195506
|
-
});
|
|
195507
|
-
}
|
|
195508
|
-
}
|
|
195509
|
-
|
|
195510
|
-
// src/cli/dev/dev-server/routes/functions.ts
|
|
195511
|
-
var import_express = __toESM(require_express(), 1);
|
|
195512
|
-
import { request as httpRequest } from "node:http";
|
|
195513
|
-
function createFunctionRoutes(manager, logger) {
|
|
195514
|
-
const router = import_express.Router({ mergeParams: true });
|
|
195515
|
-
router.all("/:functionName", async (req, res) => {
|
|
195516
|
-
const { functionName } = req.params;
|
|
195517
|
-
try {
|
|
195518
|
-
const func = manager.getFunction(functionName);
|
|
195519
|
-
if (!func) {
|
|
195520
|
-
res.status(404).json({
|
|
195521
|
-
error: `Function "${functionName}" not found`
|
|
195522
|
-
});
|
|
195523
|
-
return;
|
|
195524
|
-
}
|
|
195525
|
-
const port = await manager.ensureRunning(functionName);
|
|
195526
|
-
await proxyRequest(req, res, port, logger);
|
|
195527
|
-
} catch (error48) {
|
|
195528
|
-
logger.error(`Function error:`, error48);
|
|
195529
|
-
const message = error48 instanceof Error ? error48.message : String(error48);
|
|
195530
|
-
res.status(500).json({ error: message });
|
|
195531
|
-
}
|
|
195532
|
-
});
|
|
195533
|
-
return router;
|
|
195534
|
-
}
|
|
195535
|
-
function proxyRequest(req, res, port, logger) {
|
|
195536
|
-
return new Promise((resolve5, reject) => {
|
|
195537
|
-
const headers = {
|
|
195538
|
-
...req.headers
|
|
195539
|
-
};
|
|
195540
|
-
delete headers.host;
|
|
195541
|
-
if (headers["x-app-id"]) {
|
|
195542
|
-
headers["Base44-App-Id"] = headers["x-app-id"];
|
|
195543
|
-
}
|
|
195544
|
-
headers["Base44-Api-Url"] = `${req.protocol}://${req.get("host")}`;
|
|
195545
|
-
const options8 = {
|
|
195546
|
-
hostname: "localhost",
|
|
195547
|
-
port,
|
|
195548
|
-
path: req.url,
|
|
195549
|
-
method: req.method,
|
|
195550
|
-
headers
|
|
195551
|
-
};
|
|
195552
|
-
const proxyReq = httpRequest(options8, (proxyRes) => {
|
|
195553
|
-
res.status(proxyRes.statusCode || 200);
|
|
195554
|
-
for (const [key2, value] of Object.entries(proxyRes.headers)) {
|
|
195555
|
-
if (value !== undefined) {
|
|
195556
|
-
res.setHeader(key2, value);
|
|
195557
|
-
}
|
|
195558
|
-
}
|
|
195559
|
-
proxyRes.pipe(res);
|
|
195560
|
-
proxyRes.on("end", () => {
|
|
195561
|
-
resolve5();
|
|
195562
|
-
});
|
|
195563
|
-
proxyRes.on("error", (error48) => {
|
|
195564
|
-
reject(error48);
|
|
195565
|
-
});
|
|
195566
|
-
});
|
|
195567
|
-
proxyReq.on("error", (error48) => {
|
|
195568
|
-
logger.error(`Function proxy error:`, error48);
|
|
195569
|
-
if (!res.headersSent) {
|
|
195570
|
-
res.status(502).json({
|
|
195571
|
-
error: "Failed to proxy request to function",
|
|
195572
|
-
details: error48.message
|
|
195573
|
-
});
|
|
195574
|
-
}
|
|
195575
|
-
resolve5();
|
|
195576
|
-
});
|
|
195577
|
-
if (req.body && Object.keys(req.body).length > 0) {
|
|
195578
|
-
const bodyString = JSON.stringify(req.body);
|
|
195579
|
-
proxyReq.setHeader("Content-Type", "application/json");
|
|
195580
|
-
proxyReq.setHeader("Content-Length", Buffer.byteLength(bodyString));
|
|
195581
|
-
proxyReq.write(bodyString);
|
|
195582
|
-
}
|
|
195583
|
-
proxyReq.end();
|
|
195584
|
-
});
|
|
195585
|
-
}
|
|
195586
|
-
|
|
195587
|
-
// src/cli/dev/dev-server/main.ts
|
|
195588
195514
|
var DEFAULT_PORT = 4400;
|
|
195589
195515
|
var BASE44_APP_URL = "https://base44.app";
|
|
195590
|
-
async function createDevServer(options8) {
|
|
195591
|
-
const
|
|
195592
|
-
const
|
|
195593
|
-
const { project: project2 } = await readProjectConfig();
|
|
195594
|
-
const configDir = dirname12(project2.configPath);
|
|
195595
|
-
const app = import_express2.default();
|
|
195516
|
+
async function createDevServer(options8 = {}) {
|
|
195517
|
+
const port = options8.port ?? await getPorts({ port: DEFAULT_PORT });
|
|
195518
|
+
const app = import_express.default();
|
|
195596
195519
|
const remoteProxy = import_http_proxy_middleware.createProxyMiddleware({
|
|
195597
195520
|
target: BASE44_APP_URL,
|
|
195598
195521
|
changeOrigin: true
|
|
@@ -195609,17 +195532,9 @@ async function createDevServer(options8) {
|
|
|
195609
195532
|
}
|
|
195610
195533
|
next();
|
|
195611
195534
|
});
|
|
195612
|
-
const [functions] = await Promise.all([
|
|
195613
|
-
functionResource.readAll(join16(configDir, project2.functionsDir))
|
|
195614
|
-
]);
|
|
195615
|
-
const functionManager = new FunctionManager(functions, logger);
|
|
195616
|
-
logger.log(`Loaded functions: ${functions.map((f7) => f7.name).join(", ") || "(none)"}`);
|
|
195617
|
-
const functionRoutes = createFunctionRoutes(functionManager, logger);
|
|
195618
|
-
app.use("/api/apps/:appId/functions", functionRoutes);
|
|
195619
195535
|
app.use((req, res, next) => {
|
|
195620
195536
|
return remoteProxy(req, res, next);
|
|
195621
195537
|
});
|
|
195622
|
-
app.use(import_express2.default.json());
|
|
195623
195538
|
return new Promise((resolve5, reject) => {
|
|
195624
195539
|
const server = app.listen(port, "127.0.0.1", (err) => {
|
|
195625
195540
|
if (err) {
|
|
@@ -195641,10 +195556,7 @@ async function createDevServer(options8) {
|
|
|
195641
195556
|
// src/cli/commands/dev.ts
|
|
195642
195557
|
async function devAction(options8) {
|
|
195643
195558
|
const port = options8.port ? Number(options8.port) : undefined;
|
|
195644
|
-
const { port: resolvedPort } = await createDevServer({
|
|
195645
|
-
port,
|
|
195646
|
-
logger: createDevLogger()
|
|
195647
|
-
});
|
|
195559
|
+
const { port: resolvedPort } = await createDevServer({ port });
|
|
195648
195560
|
return {
|
|
195649
195561
|
outroMessage: `Dev server is available at ${theme.colors.links(`http://localhost:${resolvedPort}`)}`
|
|
195650
195562
|
};
|
|
@@ -195806,7 +195718,7 @@ function nanoid3(size = 21) {
|
|
|
195806
195718
|
}
|
|
195807
195719
|
|
|
195808
195720
|
// node_modules/posthog-node/dist/extensions/error-tracking/modifiers/module.node.mjs
|
|
195809
|
-
import { dirname as
|
|
195721
|
+
import { dirname as dirname11, posix, sep } from "path";
|
|
195810
195722
|
function createModulerModifier() {
|
|
195811
195723
|
const getModuleFromFileName = createGetModuleFromFilename();
|
|
195812
195724
|
return async (frames) => {
|
|
@@ -195815,7 +195727,7 @@ function createModulerModifier() {
|
|
|
195815
195727
|
return frames;
|
|
195816
195728
|
};
|
|
195817
195729
|
}
|
|
195818
|
-
function createGetModuleFromFilename(basePath = process.argv[1] ?
|
|
195730
|
+
function createGetModuleFromFilename(basePath = process.argv[1] ? dirname11(process.argv[1]) : process.cwd(), isWindows4 = sep === "\\") {
|
|
195819
195731
|
const normalizedBase = isWindows4 ? normalizeWindowsPath2(basePath) : basePath;
|
|
195820
195732
|
return (filename) => {
|
|
195821
195733
|
if (!filename)
|
|
@@ -200034,4 +199946,4 @@ export {
|
|
|
200034
199946
|
CLIExitError
|
|
200035
199947
|
};
|
|
200036
199948
|
|
|
200037
|
-
//# debugId=
|
|
199949
|
+
//# debugId=52C00CE37DAE994264756E2164756E21
|