@base44-preview/cli 0.0.40-pr.388.e82c3e8 → 0.0.41-pr.251.81e7ce8

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
@@ -18062,7 +18062,7 @@ var require_lodash = __commonJS((exports, module) => {
18062
18062
  function nth(array2, n2) {
18063
18063
  return array2 && array2.length ? baseNth(array2, toInteger(n2)) : undefined2;
18064
18064
  }
18065
- var pull = baseRest(pullAll);
18065
+ var pull2 = baseRest(pullAll);
18066
18066
  function pullAll(array2, values2) {
18067
18067
  return array2 && array2.length && values2 && values2.length ? basePullAll(array2, values2) : array2;
18068
18068
  }
@@ -19827,7 +19827,7 @@ __p += '`;
19827
19827
  lodash.pickBy = pickBy;
19828
19828
  lodash.property = property;
19829
19829
  lodash.propertyOf = propertyOf;
19830
- lodash.pull = pull;
19830
+ lodash.pull = pull2;
19831
19831
  lodash.pullAll = pullAll;
19832
19832
  lodash.pullAllBy = pullAllBy;
19833
19833
  lodash.pullAllWith = pullAllWith;
@@ -230612,6 +230612,10 @@ var GoogleBigQueryConnectorSchema = exports_external.object({
230612
230612
  type: exports_external.literal("googlebigquery"),
230613
230613
  scopes: exports_external.array(exports_external.string()).default([])
230614
230614
  });
230615
+ var StripeConnectorSchema = exports_external.object({
230616
+ type: exports_external.literal("stripe"),
230617
+ scopes: exports_external.array(exports_external.string()).default([])
230618
+ });
230615
230619
  var CustomTypeSchema = exports_external.string().min(1).regex(/^[a-z0-9_-]+$/i);
230616
230620
  var GenericConnectorSchema = exports_external.object({
230617
230621
  type: CustomTypeSchema,
@@ -230631,6 +230635,7 @@ var ConnectorResourceSchema = exports_external.union([
230631
230635
  HubspotConnectorSchema,
230632
230636
  LinkedInConnectorSchema,
230633
230637
  TikTokConnectorSchema,
230638
+ StripeConnectorSchema,
230634
230639
  GenericConnectorSchema
230635
230640
  ]);
230636
230641
  var KnownIntegrationTypes = [
@@ -230646,7 +230651,8 @@ var KnownIntegrationTypes = [
230646
230651
  "salesforce",
230647
230652
  "hubspot",
230648
230653
  "linkedin",
230649
- "tiktok"
230654
+ "tiktok",
230655
+ "stripe"
230650
230656
  ];
230651
230657
  var IntegrationTypeSchema = exports_external.union([
230652
230658
  exports_external.enum(KnownIntegrationTypes),
@@ -230699,6 +230705,18 @@ var RemoveConnectorResponseSchema = exports_external.object({
230699
230705
  status: data.status,
230700
230706
  integrationType: data.integration_type
230701
230707
  }));
230708
+ var STRIPE_CONNECTOR_TYPE = "stripe";
230709
+ var InstallStripeResponseSchema = exports_external.object({
230710
+ already_installed: exports_external.boolean(),
230711
+ claim_url: exports_external.string().nullable()
230712
+ });
230713
+ var StripeStatusResponseSchema = exports_external.object({
230714
+ stripe_mode: exports_external.enum(["sandbox", "live"]).nullable(),
230715
+ sandbox_claim_url: exports_external.string().nullable().optional()
230716
+ });
230717
+ var RemoveStripeResponseSchema = exports_external.object({
230718
+ success: exports_external.boolean()
230719
+ });
230702
230720
 
230703
230721
  // src/core/resources/connector/api.ts
230704
230722
  async function listConnectors() {
@@ -230766,6 +230784,54 @@ async function removeConnector(integrationType) {
230766
230784
  }
230767
230785
  return result.data;
230768
230786
  }
230787
+ async function installStripe() {
230788
+ const appClient = getAppClient();
230789
+ let response;
230790
+ try {
230791
+ response = await appClient.post("payments/stripe/install", {
230792
+ timeout: 60000
230793
+ });
230794
+ } catch (error48) {
230795
+ throw await ApiError.fromHttpError(error48, "installing Stripe");
230796
+ }
230797
+ const result = InstallStripeResponseSchema.safeParse(await response.json());
230798
+ if (!result.success) {
230799
+ throw new SchemaValidationError("Invalid response from server", result.error);
230800
+ }
230801
+ return result.data;
230802
+ }
230803
+ async function getStripeStatus() {
230804
+ const appClient = getAppClient();
230805
+ let response;
230806
+ try {
230807
+ response = await appClient.get("payments/stripe/status", {
230808
+ timeout: 60000
230809
+ });
230810
+ } catch (error48) {
230811
+ throw await ApiError.fromHttpError(error48, "checking Stripe integration status");
230812
+ }
230813
+ const result = StripeStatusResponseSchema.safeParse(await response.json());
230814
+ if (!result.success) {
230815
+ throw new SchemaValidationError("Invalid response from server", result.error);
230816
+ }
230817
+ return result.data;
230818
+ }
230819
+ async function removeStripe() {
230820
+ const appClient = getAppClient();
230821
+ let response;
230822
+ try {
230823
+ response = await appClient.delete("payments/stripe", {
230824
+ timeout: 60000
230825
+ });
230826
+ } catch (error48) {
230827
+ throw await ApiError.fromHttpError(error48, "removing Stripe integration");
230828
+ }
230829
+ const result = RemoveStripeResponseSchema.safeParse(await response.json());
230830
+ if (!result.success) {
230831
+ throw new SchemaValidationError("Invalid response from server", result.error);
230832
+ }
230833
+ return result.data;
230834
+ }
230769
230835
  // src/core/resources/connector/config.ts
230770
230836
  import { join as join4 } from "node:path";
230771
230837
  import { isDeepStrictEqual as isDeepStrictEqual2 } from "node:util";
@@ -230814,7 +230880,7 @@ async function readAllConnectors(connectorsDir) {
230814
230880
  async function writeConnectors(connectorsDir, remoteConnectors) {
230815
230881
  const entries = await readConnectorFiles(connectorsDir);
230816
230882
  const typeToEntry = buildTypeToEntryMap(entries);
230817
- const newTypes = new Set(remoteConnectors.map((c) => c.integrationType));
230883
+ const newTypes = new Set(remoteConnectors.map((c) => c.type));
230818
230884
  const deleted = [];
230819
230885
  for (const [type, entry] of typeToEntry) {
230820
230886
  if (!newTypes.has(type)) {
@@ -230824,22 +230890,44 @@ async function writeConnectors(connectorsDir, remoteConnectors) {
230824
230890
  }
230825
230891
  const written = [];
230826
230892
  for (const connector of remoteConnectors) {
230827
- const existing = typeToEntry.get(connector.integrationType);
230828
- const localConnector = {
230829
- type: connector.integrationType,
230830
- scopes: connector.scopes
230831
- };
230832
- if (existing && isDeepStrictEqual2(existing.data, localConnector)) {
230893
+ const existing = typeToEntry.get(connector.type);
230894
+ if (existing && isDeepStrictEqual2(existing.data, connector)) {
230833
230895
  continue;
230834
230896
  }
230835
- const filePath = existing?.filePath ?? join4(connectorsDir, `${connector.integrationType}.${CONFIG_FILE_EXTENSION}`);
230836
- await writeJsonFile(filePath, localConnector);
230837
- written.push(connector.integrationType);
230897
+ const filePath = existing?.filePath ?? join4(connectorsDir, `${connector.type}.${CONFIG_FILE_EXTENSION}`);
230898
+ await writeJsonFile(filePath, connector);
230899
+ written.push(connector.type);
230838
230900
  }
230839
230901
  return { written, deleted };
230840
230902
  }
230903
+ // src/core/resources/connector/pull.ts
230904
+ async function pullAllConnectors() {
230905
+ const [oauthResponse, stripeStatus] = await Promise.all([
230906
+ listConnectors(),
230907
+ getStripeStatus()
230908
+ ]);
230909
+ const connectors = oauthResponse.integrations.map((i) => ({
230910
+ type: i.integrationType,
230911
+ scopes: i.scopes
230912
+ }));
230913
+ if (stripeStatus.stripe_mode !== null) {
230914
+ connectors.push({ type: STRIPE_CONNECTOR_TYPE, scopes: [] });
230915
+ }
230916
+ return connectors;
230917
+ }
230841
230918
  // src/core/resources/connector/push.ts
230842
230919
  async function pushConnectors(connectors) {
230920
+ const stripeConnector = connectors.find((c) => c.type === STRIPE_CONNECTOR_TYPE);
230921
+ const oauthConnectors = connectors.filter((c) => c.type !== STRIPE_CONNECTOR_TYPE);
230922
+ const oauthResults = await syncOAuthConnectors(oauthConnectors);
230923
+ const stripeResult = await syncStripeConnector(stripeConnector);
230924
+ const results = [...oauthResults];
230925
+ if (stripeResult) {
230926
+ results.push(stripeResult);
230927
+ }
230928
+ return { results };
230929
+ }
230930
+ async function syncOAuthConnectors(connectors) {
230843
230931
  const results = [];
230844
230932
  const upstream = await listConnectors();
230845
230933
  const localTypes = new Set(connectors.map((c) => c.type));
@@ -230872,7 +230960,62 @@ async function pushConnectors(connectors) {
230872
230960
  }
230873
230961
  }
230874
230962
  }
230875
- return { results };
230963
+ return results;
230964
+ }
230965
+ async function syncStripeConnector(localStripe) {
230966
+ const remoteStatus = await fetchStripeRemoteStatus();
230967
+ if (remoteStatus === "error") {
230968
+ return localStripe ? stripeError("Failed to check Stripe integration status") : null;
230969
+ }
230970
+ const isRemoteInstalled = remoteStatus.stripe_mode !== null;
230971
+ const needsInstall = localStripe && !isRemoteInstalled;
230972
+ const alreadySynced = localStripe && isRemoteInstalled;
230973
+ const needsRemoval = !localStripe && isRemoteInstalled;
230974
+ if (needsInstall) {
230975
+ return handleStripeInstall();
230976
+ }
230977
+ if (alreadySynced) {
230978
+ return stripeSynced();
230979
+ }
230980
+ if (needsRemoval) {
230981
+ return handleStripeRemoval();
230982
+ }
230983
+ return null;
230984
+ }
230985
+ async function fetchStripeRemoteStatus() {
230986
+ try {
230987
+ return await getStripeStatus();
230988
+ } catch {
230989
+ return "error";
230990
+ }
230991
+ }
230992
+ async function handleStripeInstall() {
230993
+ try {
230994
+ const result = await installStripe();
230995
+ return stripeProvisioned(result.claim_url ?? undefined);
230996
+ } catch (err) {
230997
+ return stripeError(err instanceof Error ? err.message : String(err));
230998
+ }
230999
+ }
231000
+ async function handleStripeRemoval() {
231001
+ try {
231002
+ await removeStripe();
231003
+ return stripeRemoved();
231004
+ } catch (err) {
231005
+ return stripeError(err instanceof Error ? err.message : String(err));
231006
+ }
231007
+ }
231008
+ function stripeSynced() {
231009
+ return { type: STRIPE_CONNECTOR_TYPE, action: "synced" };
231010
+ }
231011
+ function stripeProvisioned(claimUrl) {
231012
+ return { type: STRIPE_CONNECTOR_TYPE, action: "provisioned", claimUrl };
231013
+ }
231014
+ function stripeRemoved() {
231015
+ return { type: STRIPE_CONNECTOR_TYPE, action: "removed" };
231016
+ }
231017
+ function stripeError(error48) {
231018
+ return { type: STRIPE_CONNECTOR_TYPE, action: "error", error: error48 };
230876
231019
  }
230877
231020
  function getConnectorSyncResult(type, response) {
230878
231021
  if (response.error === "different_user") {
@@ -230890,7 +231033,7 @@ function getConnectorSyncResult(type, response) {
230890
231033
  type,
230891
231034
  action: "needs_oauth",
230892
231035
  redirectUrl: response.redirectUrl,
230893
- connectionId: response.connectionId ?? undefined
231036
+ connectionId: response.connectionId ?? ""
230894
231037
  };
230895
231038
  }
230896
231039
  return { type, action: "synced" };
@@ -231453,7 +231596,7 @@ import { join as join7 } from "node:path";
231453
231596
  // package.json
231454
231597
  var package_default = {
231455
231598
  name: "base44",
231456
- version: "0.0.40",
231599
+ version: "0.0.41",
231457
231600
  description: "Base44 CLI - Unified interface for managing Base44 applications",
231458
231601
  type: "module",
231459
231602
  bin: {
@@ -239387,6 +239530,10 @@ function getDashboardUrl(projectId) {
239387
239530
  const id = projectId ?? getAppConfig().id;
239388
239531
  return `${getBase44ApiUrl()}/apps/${id}/editor/workspace/overview`;
239389
239532
  }
239533
+ function getConnectorsUrl(projectId) {
239534
+ const id = projectId ?? getAppConfig().id;
239535
+ return `${getBase44ApiUrl()}/apps/${id}/editor/workspace/app-connections`;
239536
+ }
239390
239537
  // src/cli/commands/agents/pull.ts
239391
239538
  async function pullAgentsAction() {
239392
239539
  const { project: project2 } = await readProjectConfig();
@@ -239491,13 +239638,13 @@ async function pullConnectorsAction() {
239491
239638
  const configDir = dirname8(project2.configPath);
239492
239639
  const connectorsDir = join11(configDir, project2.connectorsDir);
239493
239640
  const remoteConnectors = await runTask("Fetching connectors from Base44", async () => {
239494
- return await listConnectors();
239641
+ return await pullAllConnectors();
239495
239642
  }, {
239496
239643
  successMessage: "Connectors fetched successfully",
239497
239644
  errorMessage: "Failed to fetch connectors"
239498
239645
  });
239499
239646
  const { written, deleted } = await runTask("Syncing connector files", async () => {
239500
- return await writeConnectors(connectorsDir, remoteConnectors.integrations);
239647
+ return await writeConnectors(connectorsDir, remoteConnectors);
239501
239648
  }, {
239502
239649
  successMessage: "Connector files synced successfully",
239503
239650
  errorMessage: "Failed to sync connector files"
@@ -239512,7 +239659,7 @@ async function pullConnectorsAction() {
239512
239659
  R2.info("All connectors are already up to date");
239513
239660
  }
239514
239661
  return {
239515
- outroMessage: `Pulled ${remoteConnectors.integrations.length} connectors to ${connectorsDir}`
239662
+ outroMessage: `Pulled ${remoteConnectors.length} connectors to ${connectorsDir}`
239516
239663
  };
239517
239664
  }
239518
239665
  function getConnectorsPullCommand(context) {
@@ -240131,7 +240278,7 @@ var open_default = open;
240131
240278
  var POLL_INTERVAL_MS = 2000;
240132
240279
  var POLL_TIMEOUT_MS = 2 * 60 * 1000;
240133
240280
  function filterPendingOAuth(results) {
240134
- return results.filter((r) => r.action === "needs_oauth" && !!r.redirectUrl && !!r.connectionId);
240281
+ return results.filter((r) => r.action === "needs_oauth" && !!r.connectionId);
240135
240282
  }
240136
240283
  async function runOAuthFlowWithSkip(connector2) {
240137
240284
  await open_default(connector2.redirectUrl);
@@ -240211,32 +240358,49 @@ async function promptOAuthFlows(pending, options) {
240211
240358
  function printSummary(results, oauthOutcomes) {
240212
240359
  const synced = [];
240213
240360
  const added = [];
240361
+ let provisioned;
240214
240362
  const removed = [];
240215
240363
  const skipped = [];
240216
240364
  const failed = [];
240217
240365
  for (const r of results) {
240218
- const oauthStatus = oauthOutcomes.get(r.type);
240219
- if (r.action === "synced") {
240220
- synced.push(r.type);
240221
- } else if (r.action === "removed") {
240222
- removed.push(r.type);
240223
- } else if (r.action === "error") {
240224
- failed.push({ type: r.type, error: r.error });
240225
- } else if (r.action === "needs_oauth") {
240226
- if (oauthStatus === "ACTIVE") {
240227
- added.push(r.type);
240228
- } else if (oauthStatus === "SKIPPED") {
240229
- skipped.push(r.type);
240230
- } else if (oauthStatus === "PENDING") {
240231
- failed.push({ type: r.type, error: "authorization timed out" });
240232
- } else if (oauthStatus === "FAILED") {
240233
- failed.push({ type: r.type, error: "authorization failed" });
240234
- } else {
240235
- failed.push({ type: r.type, error: "needs authorization" });
240366
+ switch (r.action) {
240367
+ case "provisioned":
240368
+ provisioned = r;
240369
+ break;
240370
+ case "synced":
240371
+ synced.push(r.type);
240372
+ break;
240373
+ case "removed":
240374
+ removed.push(r.type);
240375
+ break;
240376
+ case "error":
240377
+ failed.push({ type: r.type, error: r.error });
240378
+ break;
240379
+ case "needs_oauth": {
240380
+ const oauthStatus = oauthOutcomes.get(r.type);
240381
+ if (oauthStatus === "ACTIVE") {
240382
+ added.push(r.type);
240383
+ } else if (oauthStatus === "SKIPPED") {
240384
+ skipped.push(r.type);
240385
+ } else if (oauthStatus === "PENDING") {
240386
+ failed.push({ type: r.type, error: "authorization timed out" });
240387
+ } else if (oauthStatus === "FAILED") {
240388
+ failed.push({ type: r.type, error: "authorization failed" });
240389
+ } else {
240390
+ failed.push({ type: r.type, error: "needs authorization" });
240391
+ }
240392
+ break;
240236
240393
  }
240237
240394
  }
240238
240395
  }
240239
240396
  R2.info(theme.styles.bold("Summary:"));
240397
+ if (provisioned) {
240398
+ R2.success("Stripe sandbox provisioned");
240399
+ if (provisioned.claimUrl) {
240400
+ R2.info(` Claim your Stripe sandbox: ${theme.colors.links(provisioned.claimUrl)}`);
240401
+ }
240402
+ R2.info(` Connectors dashboard: ${theme.colors.links(getConnectorsUrl())}`);
240403
+ }
240240
240404
  if (synced.length > 0) {
240241
240405
  R2.success(`Synced: ${synced.join(", ")}`);
240242
240406
  }
@@ -240250,7 +240414,7 @@ function printSummary(results, oauthOutcomes) {
240250
240414
  R2.warn(`Skipped: ${skipped.join(", ")}`);
240251
240415
  }
240252
240416
  for (const r of failed) {
240253
- R2.error(`Failed: ${r.type}${r.error ? ` - ${r.error}` : ""}`);
240417
+ R2.error(`Failed: ${r.type} - ${r.error}`);
240254
240418
  }
240255
240419
  }
240256
240420
  async function pushConnectorsAction(isNonInteractive) {
@@ -240284,7 +240448,7 @@ function getConnectorsPushCommand(context) {
240284
240448
 
240285
240449
  // src/cli/commands/connectors/index.ts
240286
240450
  function getConnectorsCommand(context) {
240287
- return new Command("connectors").description("Manage project connectors (OAuth integrations)").addCommand(getConnectorsPullCommand(context)).addCommand(getConnectorsPushCommand(context));
240451
+ return new Command("connectors").description("Manage project connectors").addCommand(getConnectorsPullCommand(context)).addCommand(getConnectorsPushCommand(context));
240288
240452
  }
240289
240453
 
240290
240454
  // src/cli/commands/dashboard/open.ts
@@ -240598,15 +240762,11 @@ ${summaryLines.join(`
240598
240762
  successMessage: theme.colors.base44Orange("Deployment completed"),
240599
240763
  errorMessage: "Deployment failed"
240600
240764
  });
240601
- const needsOAuth = filterPendingOAuth(result.connectorResults ?? []);
240602
- if (needsOAuth.length > 0) {
240603
- const oauthOutcomes = await promptOAuthFlows(needsOAuth, {
240604
- skipPrompt: options.yes || options.isNonInteractive
240605
- });
240606
- const allAuthorized = oauthOutcomes.size > 0 && [...oauthOutcomes.values()].every((s) => s === "ACTIVE");
240607
- if (!allAuthorized) {
240608
- R2.info("Some connectors still require authorization. Run 'base44 connectors push' or open the links above in your browser.");
240609
- }
240765
+ const connectorResults = result.connectorResults ?? [];
240766
+ await handleOAuthConnectors(connectorResults, options);
240767
+ const stripeResult = connectorResults.find((r) => r.action === "provisioned");
240768
+ if (stripeResult) {
240769
+ printStripeResult(stripeResult);
240610
240770
  }
240611
240771
  R2.message(`${theme.styles.header("Dashboard")}: ${theme.colors.links(getDashboardUrl())}`);
240612
240772
  if (result.appUrl) {
@@ -240622,6 +240782,25 @@ function getDeployCommand(context) {
240622
240782
  }), { requireAuth: true }, context);
240623
240783
  });
240624
240784
  }
240785
+ async function handleOAuthConnectors(connectorResults, options) {
240786
+ const needsOAuth = filterPendingOAuth(connectorResults);
240787
+ if (needsOAuth.length === 0)
240788
+ return;
240789
+ const oauthOutcomes = await promptOAuthFlows(needsOAuth, {
240790
+ skipPrompt: options.yes || options.isNonInteractive
240791
+ });
240792
+ const allAuthorized = oauthOutcomes.size > 0 && [...oauthOutcomes.values()].every((s) => s === "ACTIVE");
240793
+ if (!allAuthorized) {
240794
+ R2.info("Some connectors still require authorization. Run 'base44 connectors push' or open the links above in your browser.");
240795
+ }
240796
+ }
240797
+ function printStripeResult(r) {
240798
+ R2.success("Stripe sandbox provisioned");
240799
+ if (r.claimUrl) {
240800
+ R2.info(` Claim your Stripe sandbox: ${theme.colors.links(r.claimUrl)}`);
240801
+ }
240802
+ R2.info(` Connectors dashboard: ${theme.colors.links(getConnectorsUrl())}`);
240803
+ }
240625
240804
 
240626
240805
  // src/cli/commands/project/link.ts
240627
240806
  function validateNonInteractiveFlags2(command) {
@@ -248103,4 +248282,4 @@ export {
248103
248282
  CLIExitError
248104
248283
  };
248105
248284
 
248106
- //# debugId=B1A9A7CE6BA5120664756E2164756E21
248285
+ //# debugId=4DCA97D9C282E08464756E2164756E21