@base44-preview/cli 0.0.30-pr.214.2479e76 → 0.0.30-pr.214.4036a54
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 +48 -27
- package/dist/cli/index.js.map +5 -5
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -153967,6 +153967,7 @@ async function removeConnector(integrationType) {
|
|
|
153967
153967
|
}
|
|
153968
153968
|
// src/core/resources/connector/config.ts
|
|
153969
153969
|
import { join as join3 } from "node:path";
|
|
153970
|
+
import { isDeepStrictEqual } from "node:util";
|
|
153970
153971
|
async function readConnectorFile(connectorPath) {
|
|
153971
153972
|
const parsed = await readJsonFile(connectorPath);
|
|
153972
153973
|
const result = ConnectorResourceSchema.safeParse(parsed);
|
|
@@ -153975,7 +153976,7 @@ async function readConnectorFile(connectorPath) {
|
|
|
153975
153976
|
}
|
|
153976
153977
|
return result.data;
|
|
153977
153978
|
}
|
|
153978
|
-
async function
|
|
153979
|
+
async function readConnectorFiles(connectorsDir) {
|
|
153979
153980
|
if (!await pathExists(connectorsDir)) {
|
|
153980
153981
|
return [];
|
|
153981
153982
|
}
|
|
@@ -153983,45 +153984,65 @@ async function readAllConnectors(connectorsDir) {
|
|
|
153983
153984
|
cwd: connectorsDir,
|
|
153984
153985
|
absolute: true
|
|
153985
153986
|
});
|
|
153986
|
-
|
|
153987
|
+
return await Promise.all(files.map(async (filePath) => ({
|
|
153988
|
+
data: await readConnectorFile(filePath),
|
|
153989
|
+
filePath
|
|
153990
|
+
})));
|
|
153991
|
+
}
|
|
153992
|
+
async function readAllConnectors(connectorsDir) {
|
|
153993
|
+
const entries = await readConnectorFiles(connectorsDir);
|
|
153987
153994
|
const types = new Set;
|
|
153988
|
-
for (const
|
|
153989
|
-
if (types.has(
|
|
153990
|
-
throw new InvalidInputError(`Duplicate connector type "${
|
|
153995
|
+
for (const { data } of entries) {
|
|
153996
|
+
if (types.has(data.type)) {
|
|
153997
|
+
throw new InvalidInputError(`Duplicate connector type "${data.type}"`, {
|
|
153991
153998
|
hints: [
|
|
153992
153999
|
{
|
|
153993
|
-
message: `Remove duplicate connectors with type "${
|
|
154000
|
+
message: `Remove duplicate connectors with type "${data.type}" - only one connector per type is allowed`
|
|
153994
154001
|
}
|
|
153995
154002
|
]
|
|
153996
154003
|
});
|
|
153997
154004
|
}
|
|
153998
|
-
types.add(
|
|
154005
|
+
types.add(data.type);
|
|
153999
154006
|
}
|
|
154000
|
-
return
|
|
154007
|
+
return entries.map((e2) => e2.data);
|
|
154001
154008
|
}
|
|
154002
154009
|
async function writeConnectors(connectorsDir, remoteConnectors) {
|
|
154003
|
-
const
|
|
154010
|
+
const entries = await readConnectorFiles(connectorsDir);
|
|
154011
|
+
const typeToEntry = new Map;
|
|
154012
|
+
for (const entry of entries) {
|
|
154013
|
+
if (typeToEntry.has(entry.data.type)) {
|
|
154014
|
+
throw new InvalidInputError(`Duplicate connector type "${entry.data.type}"`, {
|
|
154015
|
+
hints: [
|
|
154016
|
+
{
|
|
154017
|
+
message: `Remove duplicate connectors with type "${entry.data.type}" - only one connector per type is allowed`
|
|
154018
|
+
}
|
|
154019
|
+
]
|
|
154020
|
+
});
|
|
154021
|
+
}
|
|
154022
|
+
typeToEntry.set(entry.data.type, entry);
|
|
154023
|
+
}
|
|
154004
154024
|
const newTypes = new Set(remoteConnectors.map((c) => c.integration_type));
|
|
154005
|
-
const
|
|
154006
|
-
for (const
|
|
154007
|
-
|
|
154008
|
-
|
|
154009
|
-
|
|
154010
|
-
});
|
|
154011
|
-
for (const filePath of files) {
|
|
154012
|
-
await deleteFile(filePath);
|
|
154025
|
+
const deleted = [];
|
|
154026
|
+
for (const [type, entry] of typeToEntry) {
|
|
154027
|
+
if (!newTypes.has(type)) {
|
|
154028
|
+
await deleteFile(entry.filePath);
|
|
154029
|
+
deleted.push(type);
|
|
154013
154030
|
}
|
|
154014
154031
|
}
|
|
154032
|
+
const written = [];
|
|
154015
154033
|
for (const connector of remoteConnectors) {
|
|
154016
|
-
const
|
|
154034
|
+
const existing = typeToEntry.get(connector.integration_type);
|
|
154017
154035
|
const localConnector = {
|
|
154018
154036
|
type: connector.integration_type,
|
|
154019
154037
|
scopes: connector.scopes
|
|
154020
154038
|
};
|
|
154039
|
+
if (existing && isDeepStrictEqual(existing.data, localConnector)) {
|
|
154040
|
+
continue;
|
|
154041
|
+
}
|
|
154042
|
+
const filePath = existing?.filePath ?? join3(connectorsDir, `${connector.integration_type}.${CONFIG_FILE_EXTENSION}`);
|
|
154021
154043
|
await writeJsonFile(filePath, localConnector);
|
|
154044
|
+
written.push(connector.integration_type);
|
|
154022
154045
|
}
|
|
154023
|
-
const written = remoteConnectors.map((c) => c.integration_type);
|
|
154024
|
-
const deleted = toDelete.map((c) => c.type);
|
|
154025
154046
|
return { written, deleted };
|
|
154026
154047
|
}
|
|
154027
154048
|
// node_modules/open/index.js
|
|
@@ -169928,14 +169949,11 @@ async function pullConnectorsAction() {
|
|
|
169928
169949
|
successMessage: "Connectors fetched successfully",
|
|
169929
169950
|
errorMessage: "Failed to fetch connectors"
|
|
169930
169951
|
});
|
|
169931
|
-
|
|
169932
|
-
return { outroMessage: "No connectors found on Base44" };
|
|
169933
|
-
}
|
|
169934
|
-
const { written, deleted } = await runTask("Writing connector files", async () => {
|
|
169952
|
+
const { written, deleted } = await runTask("Syncing connector files", async () => {
|
|
169935
169953
|
return await writeConnectors(connectorsDir, remoteConnectors.integrations);
|
|
169936
169954
|
}, {
|
|
169937
|
-
successMessage: "Connector files
|
|
169938
|
-
errorMessage: "Failed to
|
|
169955
|
+
successMessage: "Connector files synced successfully",
|
|
169956
|
+
errorMessage: "Failed to sync connector files"
|
|
169939
169957
|
});
|
|
169940
169958
|
if (written.length > 0) {
|
|
169941
169959
|
M2.success(`Written: ${written.join(", ")}`);
|
|
@@ -169943,6 +169961,9 @@ async function pullConnectorsAction() {
|
|
|
169943
169961
|
if (deleted.length > 0) {
|
|
169944
169962
|
M2.warn(`Deleted: ${deleted.join(", ")}`);
|
|
169945
169963
|
}
|
|
169964
|
+
if (written.length === 0 && deleted.length === 0) {
|
|
169965
|
+
M2.info("All connectors are already up to date");
|
|
169966
|
+
}
|
|
169946
169967
|
return {
|
|
169947
169968
|
outroMessage: `Pulled ${remoteConnectors.integrations.length} connectors to ${connectorsDir}`
|
|
169948
169969
|
};
|
|
@@ -174998,4 +175019,4 @@ export {
|
|
|
174998
175019
|
CLIExitError
|
|
174999
175020
|
};
|
|
175000
175021
|
|
|
175001
|
-
//# debugId=
|
|
175022
|
+
//# debugId=1B3CE6CF267E3DC164756E2164756E21
|