@base44-preview/cli 0.0.32-pr.250.8053fb1 → 0.0.32-pr.251.fd02def

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
@@ -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 pull = baseRest(pullAll);
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 = 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.integrationType));
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.integrationType);
185265
- const localConnector = {
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.integrationType}.${CONFIG_FILE_EXTENSION}`);
185273
- await writeJsonFile(filePath, localConnector);
185274
- written.push(connector.integrationType);
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,62 @@ async function pushConnectors(connectors) {
185309
185397
  }
185310
185398
  }
185311
185399
  }
185312
- return { results };
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
+ return stripeSynced();
185416
+ }
185417
+ if (needsRemoval) {
185418
+ return handleStripeRemoval();
185419
+ }
185420
+ return null;
185421
+ }
185422
+ async function fetchStripeRemoteStatus() {
185423
+ try {
185424
+ return await getStripeStatus();
185425
+ } catch {
185426
+ return "error";
185427
+ }
185428
+ }
185429
+ async function handleStripeInstall() {
185430
+ try {
185431
+ const result = await installStripe();
185432
+ return stripeProvisioned(result.claim_url ?? undefined);
185433
+ } catch (err) {
185434
+ return stripeError(err instanceof Error ? err.message : String(err));
185435
+ }
185436
+ }
185437
+ async function handleStripeRemoval() {
185438
+ try {
185439
+ await removeStripe();
185440
+ return stripeRemoved();
185441
+ } catch (err) {
185442
+ return stripeError(err instanceof Error ? err.message : String(err));
185443
+ }
185444
+ }
185445
+ function stripeSynced() {
185446
+ return { type: STRIPE_CONNECTOR_TYPE, action: "synced" };
185447
+ }
185448
+ function stripeProvisioned(claimUrl) {
185449
+ return { type: STRIPE_CONNECTOR_TYPE, action: "provisioned", claimUrl };
185450
+ }
185451
+ function stripeRemoved() {
185452
+ return { type: STRIPE_CONNECTOR_TYPE, action: "removed" };
185453
+ }
185454
+ function stripeError(error48) {
185455
+ return { type: STRIPE_CONNECTOR_TYPE, action: "error", error: error48 };
185313
185456
  }
185314
185457
  function getConnectorSyncResult(type, response) {
185315
185458
  if (response.error === "different_user") {
@@ -185327,7 +185470,7 @@ function getConnectorSyncResult(type, response) {
185327
185470
  type,
185328
185471
  action: "needs_oauth",
185329
185472
  redirectUrl: response.redirectUrl,
185330
- connectionId: response.connectionId ?? undefined
185473
+ connectionId: response.connectionId ?? ""
185331
185474
  };
185332
185475
  }
185333
185476
  return { type, action: "synced" };
@@ -193636,6 +193779,10 @@ function getDashboardUrl(projectId) {
193636
193779
  const id = projectId ?? getAppConfig().id;
193637
193780
  return `${getBase44ApiUrl()}/apps/${id}/editor/workspace/overview`;
193638
193781
  }
193782
+ function getConnectorsUrl(projectId) {
193783
+ const id = projectId ?? getAppConfig().id;
193784
+ return `${getBase44ApiUrl()}/apps/${id}/editor/workspace/app-connections`;
193785
+ }
193639
193786
  // src/cli/commands/agents/pull.ts
193640
193787
  async function pullAgentsAction() {
193641
193788
  const { project: project2 } = await readProjectConfig();
@@ -193740,13 +193887,13 @@ async function pullConnectorsAction() {
193740
193887
  const configDir = dirname8(project2.configPath);
193741
193888
  const connectorsDir = join10(configDir, project2.connectorsDir);
193742
193889
  const remoteConnectors = await runTask("Fetching connectors from Base44", async () => {
193743
- return await listConnectors();
193890
+ return await pullAllConnectors();
193744
193891
  }, {
193745
193892
  successMessage: "Connectors fetched successfully",
193746
193893
  errorMessage: "Failed to fetch connectors"
193747
193894
  });
193748
193895
  const { written, deleted } = await runTask("Syncing connector files", async () => {
193749
- return await writeConnectors(connectorsDir, remoteConnectors.integrations);
193896
+ return await writeConnectors(connectorsDir, remoteConnectors);
193750
193897
  }, {
193751
193898
  successMessage: "Connector files synced successfully",
193752
193899
  errorMessage: "Failed to sync connector files"
@@ -193761,7 +193908,7 @@ async function pullConnectorsAction() {
193761
193908
  M2.info("All connectors are already up to date");
193762
193909
  }
193763
193910
  return {
193764
- outroMessage: `Pulled ${remoteConnectors.integrations.length} connectors to ${connectorsDir}`
193911
+ outroMessage: `Pulled ${remoteConnectors.length} connectors to ${connectorsDir}`
193765
193912
  };
193766
193913
  }
193767
193914
  function getConnectorsPullCommand(context) {
@@ -194380,7 +194527,7 @@ var open_default = open;
194380
194527
  var POLL_INTERVAL_MS = 2000;
194381
194528
  var POLL_TIMEOUT_MS = 2 * 60 * 1000;
194382
194529
  function filterPendingOAuth(results) {
194383
- return results.filter((r2) => r2.action === "needs_oauth" && !!r2.redirectUrl && !!r2.connectionId);
194530
+ return results.filter((r2) => r2.action === "needs_oauth" && !!r2.connectionId);
194384
194531
  }
194385
194532
  async function runOAuthFlowWithSkip(connector2) {
194386
194533
  await open_default(connector2.redirectUrl);
@@ -194462,32 +194609,49 @@ Opening browser for ${connector2.type}...`);
194462
194609
  function printSummary(results, oauthOutcomes) {
194463
194610
  const synced = [];
194464
194611
  const added = [];
194612
+ const provisioned = [];
194465
194613
  const removed = [];
194466
194614
  const skipped = [];
194467
194615
  const failed = [];
194468
194616
  for (const r2 of results) {
194469
- const oauthStatus = oauthOutcomes.get(r2.type);
194470
- if (r2.action === "synced") {
194471
- synced.push(r2.type);
194472
- } else if (r2.action === "removed") {
194473
- removed.push(r2.type);
194474
- } else if (r2.action === "error") {
194475
- failed.push({ type: r2.type, error: r2.error });
194476
- } else if (r2.action === "needs_oauth") {
194477
- if (oauthStatus === "ACTIVE") {
194478
- added.push(r2.type);
194479
- } else if (oauthStatus === "SKIPPED") {
194480
- skipped.push(r2.type);
194481
- } else if (oauthStatus === "PENDING") {
194482
- failed.push({ type: r2.type, error: "authorization timed out" });
194483
- } else if (oauthStatus === "FAILED") {
194484
- failed.push({ type: r2.type, error: "authorization failed" });
194485
- } else {
194486
- failed.push({ type: r2.type, error: "needs authorization" });
194617
+ switch (r2.action) {
194618
+ case "provisioned":
194619
+ provisioned.push(r2);
194620
+ break;
194621
+ case "synced":
194622
+ synced.push(r2.type);
194623
+ break;
194624
+ case "removed":
194625
+ removed.push(r2.type);
194626
+ break;
194627
+ case "error":
194628
+ failed.push({ type: r2.type, error: r2.error });
194629
+ break;
194630
+ case "needs_oauth": {
194631
+ const oauthStatus = oauthOutcomes.get(r2.type);
194632
+ if (oauthStatus === "ACTIVE") {
194633
+ added.push(r2.type);
194634
+ } else if (oauthStatus === "SKIPPED") {
194635
+ skipped.push(r2.type);
194636
+ } else if (oauthStatus === "PENDING") {
194637
+ failed.push({ type: r2.type, error: "authorization timed out" });
194638
+ } else if (oauthStatus === "FAILED") {
194639
+ failed.push({ type: r2.type, error: "authorization failed" });
194640
+ } else {
194641
+ failed.push({ type: r2.type, error: "needs authorization" });
194642
+ }
194643
+ break;
194487
194644
  }
194488
194645
  }
194489
194646
  }
194490
194647
  M2.info(theme.styles.bold("Summary:"));
194648
+ for (const i2 of provisioned) {
194649
+ M2.success(`Provisioned: ${i2.type}`);
194650
+ if (i2.claimUrl) {
194651
+ M2.info(` Claim your Stripe account: ${theme.colors.links(i2.claimUrl)}`);
194652
+ }
194653
+ M2.info(` Connectors dashboard: ${theme.colors.links(getConnectorsUrl())}`);
194654
+ }
194491
194655
  if (synced.length > 0) {
194492
194656
  M2.success(`Synced: ${synced.join(", ")}`);
194493
194657
  }
@@ -194501,7 +194665,7 @@ function printSummary(results, oauthOutcomes) {
194501
194665
  M2.warn(`Skipped: ${skipped.join(", ")}`);
194502
194666
  }
194503
194667
  for (const r2 of failed) {
194504
- M2.error(`Failed: ${r2.type}${r2.error ? ` - ${r2.error}` : ""}`);
194668
+ M2.error(`Failed: ${r2.type} - ${r2.error}`);
194505
194669
  }
194506
194670
  }
194507
194671
  async function pushConnectorsAction() {
@@ -194535,7 +194699,7 @@ function getConnectorsPushCommand(context) {
194535
194699
 
194536
194700
  // src/cli/commands/connectors/index.ts
194537
194701
  function getConnectorsCommand(context) {
194538
- return new Command("connectors").description("Manage project connectors (OAuth integrations)").addCommand(getConnectorsPullCommand(context)).addCommand(getConnectorsPushCommand(context));
194702
+ return new Command("connectors").description("Manage project connectors").addCommand(getConnectorsPullCommand(context)).addCommand(getConnectorsPushCommand(context));
194539
194703
  }
194540
194704
 
194541
194705
  // src/cli/commands/dashboard/open.ts
@@ -194851,15 +195015,11 @@ ${summaryLines.join(`
194851
195015
  successMessage: theme.colors.base44Orange("Deployment completed"),
194852
195016
  errorMessage: "Deployment failed"
194853
195017
  });
194854
- const needsOAuth = filterPendingOAuth(result.connectorResults ?? []);
194855
- if (needsOAuth.length > 0) {
194856
- const oauthOutcomes = await promptOAuthFlows(needsOAuth, {
194857
- skipPrompt: options.yes || !!process.env.CI
194858
- });
194859
- const allAuthorized = oauthOutcomes.size > 0 && [...oauthOutcomes.values()].every((s) => s === "ACTIVE");
194860
- if (!allAuthorized) {
194861
- M2.info("Some connectors still require authorization. Run 'base44 connectors push' or open the links above in your browser.");
194862
- }
195018
+ const connectorResults = result.connectorResults ?? [];
195019
+ await handleOAuthConnectors(connectorResults, options);
195020
+ const stripeResult = connectorResults.find((r2) => r2.action === "provisioned");
195021
+ if (stripeResult) {
195022
+ printStripeResult(stripeResult);
194863
195023
  }
194864
195024
  M2.message(`${theme.styles.header("Dashboard")}: ${theme.colors.links(getDashboardUrl())}`);
194865
195025
  if (result.appUrl) {
@@ -194872,6 +195032,25 @@ function getDeployCommand(context) {
194872
195032
  await runCommand(() => deployAction(options), { requireAuth: true }, context);
194873
195033
  });
194874
195034
  }
195035
+ async function handleOAuthConnectors(connectorResults, options) {
195036
+ const needsOAuth = filterPendingOAuth(connectorResults);
195037
+ if (needsOAuth.length === 0)
195038
+ return;
195039
+ const oauthOutcomes = await promptOAuthFlows(needsOAuth, {
195040
+ skipPrompt: options.yes || !!process.env.CI
195041
+ });
195042
+ const allAuthorized = oauthOutcomes.size > 0 && [...oauthOutcomes.values()].every((s) => s === "ACTIVE");
195043
+ if (!allAuthorized) {
195044
+ M2.info("Some connectors still require authorization. Run 'base44 connectors push' or open the links above in your browser.");
195045
+ }
195046
+ }
195047
+ function printStripeResult(r2) {
195048
+ M2.success(`Provisioned: Stripe`);
195049
+ if (r2.claimUrl) {
195050
+ M2.info(` Claim your Stripe account: ${theme.colors.links(r2.claimUrl)}`);
195051
+ }
195052
+ M2.info(` Connectors dashboard: ${theme.colors.links(getConnectorsUrl())}`);
195053
+ }
194875
195054
 
194876
195055
  // src/cli/commands/project/link.ts
194877
195056
  function validateNonInteractiveFlags2(command) {
@@ -199760,4 +199939,4 @@ export {
199760
199939
  CLIExitError
199761
199940
  };
199762
199941
 
199763
- //# debugId=06A844C7F693D30164756E2164756E21
199942
+ //# debugId=72EE81BD671BA57A64756E2164756E21