streamby-core 0.16.3 → 0.18.0
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.
|
@@ -152,15 +152,16 @@ function createStreamByRouter(config) {
|
|
|
152
152
|
router.get('/projects', async (req, res) => {
|
|
153
153
|
try {
|
|
154
154
|
const auth = await config.authProvider(req);
|
|
155
|
+
const archived = req.query.archived ? String(req.query.archived).toLowerCase() === 'true' : undefined;
|
|
155
156
|
const projects = [];
|
|
156
157
|
if (projectProviders.nosql) {
|
|
157
|
-
projects.push(...await projectProviders.nosql.list(auth.userId));
|
|
158
|
+
projects.push(...await projectProviders.nosql.list(auth.userId, archived));
|
|
158
159
|
}
|
|
159
160
|
if (projectProviders.sql) {
|
|
160
|
-
projects.push(...await projectProviders.sql.list(auth.userId));
|
|
161
|
+
projects.push(...await projectProviders.sql.list(auth.userId, archived));
|
|
161
162
|
}
|
|
162
163
|
if (projectProviders.default) {
|
|
163
|
-
projects.push(...await projectProviders.default.list(auth.userId));
|
|
164
|
+
projects.push(...await projectProviders.default.list(auth.userId, archived));
|
|
164
165
|
}
|
|
165
166
|
res.json({ projects });
|
|
166
167
|
}
|
|
@@ -276,8 +277,18 @@ function createStreamByRouter(config) {
|
|
|
276
277
|
if (!project || !isProjectMember(project, auth.userId)) {
|
|
277
278
|
return res.status(403).json({ error: 'Unauthorized project access' });
|
|
278
279
|
}
|
|
279
|
-
|
|
280
|
-
|
|
280
|
+
await projectProvider.archive(projectId, auth.userId);
|
|
281
|
+
const projects = [];
|
|
282
|
+
if (projectProviders.nosql) {
|
|
283
|
+
projects.push(...await projectProviders.nosql.list(auth.userId));
|
|
284
|
+
}
|
|
285
|
+
if (projectProviders.sql) {
|
|
286
|
+
projects.push(...await projectProviders.sql.list(auth.userId));
|
|
287
|
+
}
|
|
288
|
+
if (projectProviders.default) {
|
|
289
|
+
projects.push(...await projectProviders.default.list(auth.userId));
|
|
290
|
+
}
|
|
291
|
+
res.status(200).json({ success: true, projects });
|
|
281
292
|
}
|
|
282
293
|
catch (err) {
|
|
283
294
|
res.status(500).json({ error: 'Failed to archive project', details: err.message });
|
|
@@ -295,8 +306,18 @@ function createStreamByRouter(config) {
|
|
|
295
306
|
if (!project || !isProjectMember(project, auth.userId)) {
|
|
296
307
|
return res.status(403).json({ error: 'Unauthorized project access' });
|
|
297
308
|
}
|
|
298
|
-
|
|
299
|
-
|
|
309
|
+
await projectProvider.unarchive(projectId, auth.userId);
|
|
310
|
+
const projects = [];
|
|
311
|
+
if (projectProviders.nosql) {
|
|
312
|
+
projects.push(...await projectProviders.nosql.list(auth.userId));
|
|
313
|
+
}
|
|
314
|
+
if (projectProviders.sql) {
|
|
315
|
+
projects.push(...await projectProviders.sql.list(auth.userId));
|
|
316
|
+
}
|
|
317
|
+
if (projectProviders.default) {
|
|
318
|
+
projects.push(...await projectProviders.default.list(auth.userId));
|
|
319
|
+
}
|
|
320
|
+
res.status(200).json({ success: true, projects });
|
|
300
321
|
}
|
|
301
322
|
catch (err) {
|
|
302
323
|
res.status(500).json({ error: 'Failed to unarchive project', details: err.message });
|
|
@@ -38,10 +38,16 @@ function createMongooseProjectProvider(ProjectModel, ExportModel, adapter) {
|
|
|
38
38
|
throw new Error('Project not found');
|
|
39
39
|
return formatProject(updated);
|
|
40
40
|
},
|
|
41
|
-
async list(userId) {
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
async list(userId, archived) {
|
|
42
|
+
const query = {};
|
|
43
|
+
if (userId) {
|
|
44
|
+
const elemMatch = { userId };
|
|
45
|
+
if (typeof archived === 'boolean') {
|
|
46
|
+
elemMatch.archived = archived;
|
|
47
|
+
}
|
|
48
|
+
query['members'] = { $elemMatch: elemMatch };
|
|
49
|
+
}
|
|
50
|
+
const all = await ProjectModel.find(query);
|
|
45
51
|
return all.map(doc => formatProjectList(doc, userId));
|
|
46
52
|
},
|
|
47
53
|
async delete(projectId) {
|
|
@@ -58,9 +58,18 @@ function createPrismaProjectProvider(prisma, adapter) {
|
|
|
58
58
|
throw new Error('Project not found');
|
|
59
59
|
return formatProject(updated);
|
|
60
60
|
},
|
|
61
|
-
async list(userId) {
|
|
61
|
+
async list(userId, archived) {
|
|
62
|
+
const whereClause = {};
|
|
63
|
+
if (userId) {
|
|
64
|
+
whereClause.members = {
|
|
65
|
+
some: {
|
|
66
|
+
userId,
|
|
67
|
+
...(typeof archived === 'boolean' && { archived }),
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
}
|
|
62
71
|
const all = await prisma.project.findMany({
|
|
63
|
-
where:
|
|
72
|
+
where: whereClause,
|
|
64
73
|
include: {
|
|
65
74
|
members: true,
|
|
66
75
|
},
|
package/dist/services/auth.js
CHANGED
package/dist/types/index.d.ts
CHANGED
|
@@ -107,7 +107,7 @@ export interface ProjectProvider {
|
|
|
107
107
|
success: boolean;
|
|
108
108
|
projects: ProjectListInfo[];
|
|
109
109
|
}>;
|
|
110
|
-
list(userId?: string): Promise<ProjectListInfo[]>;
|
|
110
|
+
list(userId?: string, archived?: boolean): Promise<ProjectListInfo[]>;
|
|
111
111
|
getById(projectId: string, populateMembers?: boolean): Promise<ProjectInfo | null>;
|
|
112
112
|
delete(projectId: string): Promise<{
|
|
113
113
|
success: boolean;
|