streamby-core 0.24.11 → 0.24.13

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.
@@ -44,7 +44,7 @@ function exportRouter(config) {
44
44
  let data;
45
45
  if (project.dbType === 'nosql') {
46
46
  const db = connection.client.db();
47
- if (exportMetadata.type === 'raw') {
47
+ if (exportMetadata.type === 'raw' || exportMetadata.type === 'json') {
48
48
  const rawData = await db.collection(exportMetadata.collectionName).findOne({ _id: new mongodb_1.ObjectId(exportId) });
49
49
  data = rawData ? { json: rawData.json, name: rawData.name, method: rawData.method, collectionName: rawData.collectionName, createdAt: rawData.createdAt, updatedAt: rawData.updatedAt, type: exportMetadata.type } : null;
50
50
  }
@@ -57,7 +57,8 @@ function exportRouter(config) {
57
57
  data = { name: exportMetadata.name, createdAt: exportMetadata.createdAt, updatedAt: exportMetadata.updatedAt, type: exportMetadata.type, collectionName: exportMetadata.collectionName };
58
58
  }
59
59
  else {
60
- data = await db.collection(exportMetadata.collectionName).find({ __metadata: { $exists: false } }).toArray();
60
+ const rawData = await db.collection(exportMetadata.collectionName).findOne({ _id: new mongodb_1.ObjectId(exportId) });
61
+ data = rawData ? { json: rawData.json, name: rawData.name, method: rawData.method, collectionName: rawData.collectionName, createdAt: rawData.createdAt, updatedAt: rawData.updatedAt, type: exportMetadata.type } : null;
61
62
  }
62
63
  }
63
64
  else if (project.dbType === 'sql') {
@@ -67,20 +68,11 @@ function exportRouter(config) {
67
68
  return res.status(404).json({ message: 'Export data not found' });
68
69
  }
69
70
  let responseData;
70
- if (Array.isArray(data)) {
71
- responseData = {
72
- content: data,
73
- allowedOrigin: exportMetadata.allowedOrigin,
74
- private: exportMetadata.private,
75
- };
76
- }
77
- else {
78
- responseData = {
79
- ...data,
80
- allowedOrigin: exportMetadata.allowedOrigin,
81
- private: exportMetadata.private,
82
- };
83
- }
71
+ responseData = {
72
+ ...data,
73
+ allowedOrigin: exportMetadata.allowedOrigin,
74
+ private: exportMetadata.private,
75
+ };
84
76
  res.json({
85
77
  data: responseData,
86
78
  message: 'Export data fetched successfully',
@@ -218,7 +210,7 @@ function exportRouter(config) {
218
210
  let data;
219
211
  if (project.dbType === 'nosql') {
220
212
  const db = connection.client.db();
221
- if (exportMetadata.type === 'raw') {
213
+ if (exportMetadata.type === 'raw' || exportMetadata.type === 'json') {
222
214
  const rawData = await db.collection(exportMetadata.collectionName).findOne({ _id: new mongodb_1.ObjectId(exportMetadata.id) });
223
215
  data = rawData ? rawData.json : null;
224
216
  }
@@ -4,8 +4,8 @@ interface CreateExportResult {
4
4
  collectionName: string;
5
5
  message: string;
6
6
  }
7
- export declare function createExport(config: StreamByConfig, projectId: string, exportName: string, collectionName: string, jsonData: any, dbType: DatabaseType, exportType: 'structured' | 'raw' | 'externalApi', isPrivate?: boolean, allowedOrigin?: string[], apiUrl?: string, credentialId?: string, prefix?: string): Promise<CreateExportResult>;
8
- export declare function updateExport(config: StreamByConfig, projectId: string, exportId: string, exportName: string, collectionName: string, jsonData: any, dbType: DatabaseType, exportType: 'structured' | 'raw' | 'externalApi', isPrivate?: boolean, allowedOrigin?: string[], apiUrl?: string, credentialId?: string, prefix?: string): Promise<CreateExportResult>;
7
+ export declare function createExport(config: StreamByConfig, projectId: string, exportName: string, collectionName: string, jsonData: any, dbType: DatabaseType, exportType: 'structured' | 'raw' | 'json' | 'externalApi', isPrivate?: boolean, allowedOrigin?: string[], apiUrl?: string, credentialId?: string, prefix?: string): Promise<CreateExportResult>;
8
+ export declare function updateExport(config: StreamByConfig, projectId: string, exportId: string, exportName: string, collectionName: string, jsonData: any, dbType: DatabaseType, exportType: 'structured' | 'raw' | 'json' | 'externalApi', isPrivate?: boolean, allowedOrigin?: string[], apiUrl?: string, credentialId?: string, prefix?: string): Promise<CreateExportResult>;
9
9
  export declare function deleteExport(config: StreamByConfig, projectId: string, exportId: string, dbType: DatabaseType, collectionName: string): Promise<{
10
10
  message: string;
11
11
  }>;
@@ -87,7 +87,7 @@ export interface Export {
87
87
  projectId: string;
88
88
  createdAt: Date;
89
89
  updatedAt: Date;
90
- type: 'structured' | 'raw' | 'externalApi';
90
+ type: 'structured' | 'raw' | 'json' | 'externalApi';
91
91
  fields?: FieldDefinition[];
92
92
  jsonData?: any;
93
93
  private?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "streamby-core",
3
- "version": "0.24.11",
3
+ "version": "0.24.13",
4
4
  "description": "StreamBy middleware framework for media storage management",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",