streamby-core 0.26.0 → 0.26.1
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/adapters/database/nosql.d.ts +1 -1
- package/dist/adapters/database/nosql.js +2 -4
- package/dist/adapters/database/sql.d.ts +1 -1
- package/dist/adapters/database/sql.js +2 -3
- package/dist/middleware/routes/export.js +1 -1
- package/dist/services/export.d.ts +1 -1
- package/dist/services/export.js +5 -7
- package/package.json +1 -1
|
@@ -5,7 +5,7 @@ export declare const createNoSQLExportCollection: (connection: MongoClient, proj
|
|
|
5
5
|
collectionName: string;
|
|
6
6
|
exportId: string;
|
|
7
7
|
}>;
|
|
8
|
-
export declare const createNoSQLRawExportCollection: (connection: MongoClient, exportName: string, method: string, nodeSchema?: NodeSchema) => Promise<{
|
|
8
|
+
export declare const createNoSQLRawExportCollection: (connection: MongoClient, projectId: string, exportName: string, method: string, nodeSchema?: NodeSchema) => Promise<{
|
|
9
9
|
collectionName: string;
|
|
10
10
|
exportId: string;
|
|
11
11
|
}>;
|
|
@@ -33,12 +33,10 @@ const createNoSQLExportCollection = async (connection, projectId, exportName, fi
|
|
|
33
33
|
return { collectionName, exportId: collectionName };
|
|
34
34
|
};
|
|
35
35
|
exports.createNoSQLExportCollection = createNoSQLExportCollection;
|
|
36
|
-
const createNoSQLRawExportCollection = async (connection, exportName, method, nodeSchema) => {
|
|
36
|
+
const createNoSQLRawExportCollection = async (connection, projectId, exportName, method, nodeSchema) => {
|
|
37
37
|
const db = connection.db();
|
|
38
|
-
const
|
|
39
|
-
const collectionName = slug;
|
|
38
|
+
const collectionName = projectId;
|
|
40
39
|
const result = await db.collection(collectionName).insertOne({ nodeSchema, name: exportName, method, createdAt: new Date(), updatedAt: new Date() });
|
|
41
|
-
console.log(`✅ Raw collection '${collectionName}' created.`);
|
|
42
40
|
return { collectionName, exportId: result.insertedId.toHexString() };
|
|
43
41
|
};
|
|
44
42
|
exports.createNoSQLRawExportCollection = createNoSQLRawExportCollection;
|
|
@@ -4,7 +4,7 @@ export declare const createSQLExportTable: (connection: Pool, projectId: string,
|
|
|
4
4
|
collectionName: string;
|
|
5
5
|
exportId: string;
|
|
6
6
|
}>;
|
|
7
|
-
export declare const createSQLRawExportTable: (connection: Pool, exportName: string, nodeSchema?: any) => Promise<{
|
|
7
|
+
export declare const createSQLRawExportTable: (connection: Pool, projectId: string, exportName: string, nodeSchema?: any) => Promise<{
|
|
8
8
|
collectionName: string;
|
|
9
9
|
exportId: string;
|
|
10
10
|
}>;
|
|
@@ -27,9 +27,8 @@ const createSQLExportTable = async (connection, projectId, exportName, fields) =
|
|
|
27
27
|
return { collectionName: tableName, exportId: tableName };
|
|
28
28
|
};
|
|
29
29
|
exports.createSQLExportTable = createSQLExportTable;
|
|
30
|
-
const createSQLRawExportTable = async (connection, exportName, nodeSchema) => {
|
|
31
|
-
const
|
|
32
|
-
const tableName = slug;
|
|
30
|
+
const createSQLRawExportTable = async (connection, projectId, exportName, nodeSchema) => {
|
|
31
|
+
const tableName = projectId;
|
|
33
32
|
const exportId = (0, crypto_1.randomUUID)();
|
|
34
33
|
const createTableQuery = `
|
|
35
34
|
CREATE TABLE IF NOT EXISTS "${tableName}" (
|
|
@@ -200,7 +200,7 @@ function exportRouter(config) {
|
|
|
200
200
|
if (!exportMetadata) {
|
|
201
201
|
return res.status(404).json({ message: 'Export not found' });
|
|
202
202
|
}
|
|
203
|
-
const result = await (0, export_1.updateExport)(config, projectId, exportId, description, name,
|
|
203
|
+
const result = await (0, export_1.updateExport)(config, projectId, exportId, description, name, project.dbType, exportType, isPrivate, allowedOrigin, nodeSchema, useConnections, useCredentials);
|
|
204
204
|
res.status(200).json({ data: result, message: result.message });
|
|
205
205
|
}
|
|
206
206
|
catch (err) {
|
|
@@ -4,7 +4,7 @@ interface ExportResult {
|
|
|
4
4
|
message: string;
|
|
5
5
|
}
|
|
6
6
|
export declare function createExport(config: StreamByConfig, projectId: string, description: string, exportName: string, dbType: DatabaseType, exportType: 'json' | 'externalApi', isPrivate?: boolean, allowedOrigin?: string[], nodeSchema?: NodeSchema, useConnections?: boolean, useCredentials?: boolean): Promise<ExportResult>;
|
|
7
|
-
export declare function updateExport(config: StreamByConfig, projectId: string, exportId: string, description: string, exportName: string,
|
|
7
|
+
export declare function updateExport(config: StreamByConfig, projectId: string, exportId: string, description: string, exportName: string, dbType: DatabaseType, exportType: 'json' | 'externalApi', isPrivate?: boolean, allowedOrigin?: string[], nodeSchema?: NodeSchema, useConnections?: boolean, useCredentials?: boolean): Promise<ExportResult>;
|
|
8
8
|
export declare function deleteExport(config: StreamByConfig, projectId: string, exportId: string, dbType: DatabaseType, exportName: string): Promise<{
|
|
9
9
|
message: string;
|
|
10
10
|
}>;
|
package/dist/services/export.js
CHANGED
|
@@ -17,11 +17,11 @@ async function createExport(config, projectId, description, exportName, dbType,
|
|
|
17
17
|
const connection = (0, connectionManager_1.getConnection)(targetDb.id);
|
|
18
18
|
let exportId;
|
|
19
19
|
if (dbType === 'nosql') {
|
|
20
|
-
const result = await (0, nosql_1.createNoSQLRawExportCollection)(connection.client, exportName, 'GET', nodeSchema);
|
|
20
|
+
const result = await (0, nosql_1.createNoSQLRawExportCollection)(connection.client, projectId, exportName, 'GET', nodeSchema);
|
|
21
21
|
exportId = result.exportId;
|
|
22
22
|
}
|
|
23
23
|
else if (dbType === 'sql') {
|
|
24
|
-
const result = await (0, sql_1.createSQLRawExportTable)(connection.client, exportName, nodeSchema);
|
|
24
|
+
const result = await (0, sql_1.createSQLRawExportTable)(connection.client, projectId, exportName, nodeSchema);
|
|
25
25
|
exportId = result.exportId;
|
|
26
26
|
}
|
|
27
27
|
else {
|
|
@@ -31,17 +31,16 @@ async function createExport(config, projectId, description, exportName, dbType,
|
|
|
31
31
|
await NoSQLProject.update({ _id: projectId }, { $push: { exports: { id: new mongodb_1.ObjectId(exportId), name: exportName, type: exportType, method: 'GET', private: isPrivate, allowedOrigin, nodeSchema, useConnections, useCredentials, description } } });
|
|
32
32
|
return { exportId, message: `${exportType} export created successfully` };
|
|
33
33
|
}
|
|
34
|
-
async function updateExport(config, projectId, exportId, description, exportName,
|
|
34
|
+
async function updateExport(config, projectId, exportId, description, exportName, dbType, exportType, isPrivate, allowedOrigin, nodeSchema, useConnections, useCredentials) {
|
|
35
35
|
const targetDb = config.databases?.find(db => db.type === dbType && db.main) ||
|
|
36
36
|
config.databases?.find(db => db.type === dbType);
|
|
37
37
|
if (!targetDb) {
|
|
38
38
|
throw new Error(`Database connection not found for type ${dbType}`);
|
|
39
39
|
}
|
|
40
40
|
const connection = (0, connectionManager_1.getConnection)(targetDb.id);
|
|
41
|
-
const storedSlug = storedExportName.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '');
|
|
42
41
|
if (dbType === 'nosql') {
|
|
43
42
|
const db = connection.client.db();
|
|
44
|
-
await db.collection(
|
|
43
|
+
await db.collection(projectId).updateOne({ _id: new mongodb_1.ObjectId(exportId) }, { $set: { nodeSchema, description, updatedAt: new Date() } });
|
|
45
44
|
}
|
|
46
45
|
else {
|
|
47
46
|
throw new Error('Unsupported database type for update');
|
|
@@ -60,10 +59,9 @@ async function deleteExport(config, projectId, exportId, dbType, exportName) {
|
|
|
60
59
|
throw new Error(`Database connection not found for type ${dbType}`);
|
|
61
60
|
}
|
|
62
61
|
const connection = (0, connectionManager_1.getConnection)(targetDb.id);
|
|
63
|
-
const slug = exportName.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '');
|
|
64
62
|
if (dbType === 'nosql') {
|
|
65
63
|
const db = connection.client.db();
|
|
66
|
-
await db.collection(
|
|
64
|
+
await db.collection(projectId).deleteOne({ _id: new mongodb_1.ObjectId(exportId) });
|
|
67
65
|
}
|
|
68
66
|
else {
|
|
69
67
|
throw new Error('Unsupported database type for delete');
|