streamby-core 0.9.1 → 0.9.2

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.
@@ -397,8 +397,18 @@ export declare function initProjectModel(connection: mongoose.Connection): mongo
397
397
  }>;
398
398
  allowUpload: boolean;
399
399
  allowSharing: boolean;
400
- image?: string | null | undefined;
400
+ members: mongoose.Types.DocumentArray<{
401
+ userId: mongoose.Types.ObjectId;
402
+ role: "viewer" | "editor" | "admin";
403
+ }, mongoose.Types.Subdocument<mongoose.Types.ObjectId, any, {
404
+ userId: mongoose.Types.ObjectId;
405
+ role: "viewer" | "editor" | "admin";
406
+ }> & {
407
+ userId: mongoose.Types.ObjectId;
408
+ role: "viewer" | "editor" | "admin";
409
+ }>;
401
410
  description?: string | null | undefined;
411
+ image?: string | null | undefined;
402
412
  }, {}, {}, {}, mongoose.Document<unknown, {}, {
403
413
  createdAt: NativeDate;
404
414
  updatedAt: NativeDate;
@@ -797,8 +807,18 @@ export declare function initProjectModel(connection: mongoose.Connection): mongo
797
807
  }>;
798
808
  allowUpload: boolean;
799
809
  allowSharing: boolean;
800
- image?: string | null | undefined;
810
+ members: mongoose.Types.DocumentArray<{
811
+ userId: mongoose.Types.ObjectId;
812
+ role: "viewer" | "editor" | "admin";
813
+ }, mongoose.Types.Subdocument<mongoose.Types.ObjectId, any, {
814
+ userId: mongoose.Types.ObjectId;
815
+ role: "viewer" | "editor" | "admin";
816
+ }> & {
817
+ userId: mongoose.Types.ObjectId;
818
+ role: "viewer" | "editor" | "admin";
819
+ }>;
801
820
  description?: string | null | undefined;
821
+ image?: string | null | undefined;
802
822
  }> & {
803
823
  createdAt: NativeDate;
804
824
  updatedAt: NativeDate;
@@ -1197,8 +1217,18 @@ export declare function initProjectModel(connection: mongoose.Connection): mongo
1197
1217
  }>;
1198
1218
  allowUpload: boolean;
1199
1219
  allowSharing: boolean;
1200
- image?: string | null | undefined;
1220
+ members: mongoose.Types.DocumentArray<{
1221
+ userId: mongoose.Types.ObjectId;
1222
+ role: "viewer" | "editor" | "admin";
1223
+ }, mongoose.Types.Subdocument<mongoose.Types.ObjectId, any, {
1224
+ userId: mongoose.Types.ObjectId;
1225
+ role: "viewer" | "editor" | "admin";
1226
+ }> & {
1227
+ userId: mongoose.Types.ObjectId;
1228
+ role: "viewer" | "editor" | "admin";
1229
+ }>;
1201
1230
  description?: string | null | undefined;
1231
+ image?: string | null | undefined;
1202
1232
  } & {
1203
1233
  _id: mongoose.Types.ObjectId;
1204
1234
  } & {
@@ -1603,8 +1633,18 @@ export declare function initProjectModel(connection: mongoose.Connection): mongo
1603
1633
  }>;
1604
1634
  allowUpload: boolean;
1605
1635
  allowSharing: boolean;
1606
- image?: string | null | undefined;
1636
+ members: mongoose.Types.DocumentArray<{
1637
+ userId: mongoose.Types.ObjectId;
1638
+ role: "viewer" | "editor" | "admin";
1639
+ }, mongoose.Types.Subdocument<mongoose.Types.ObjectId, any, {
1640
+ userId: mongoose.Types.ObjectId;
1641
+ role: "viewer" | "editor" | "admin";
1642
+ }> & {
1643
+ userId: mongoose.Types.ObjectId;
1644
+ role: "viewer" | "editor" | "admin";
1645
+ }>;
1607
1646
  description?: string | null | undefined;
1647
+ image?: string | null | undefined;
1608
1648
  }, mongoose.Document<unknown, {}, mongoose.FlatRecord<{
1609
1649
  createdAt: NativeDate;
1610
1650
  updatedAt: NativeDate;
@@ -2003,8 +2043,18 @@ export declare function initProjectModel(connection: mongoose.Connection): mongo
2003
2043
  }>;
2004
2044
  allowUpload: boolean;
2005
2045
  allowSharing: boolean;
2006
- image?: string | null | undefined;
2046
+ members: mongoose.Types.DocumentArray<{
2047
+ userId: mongoose.Types.ObjectId;
2048
+ role: "viewer" | "editor" | "admin";
2049
+ }, mongoose.Types.Subdocument<mongoose.Types.ObjectId, any, {
2050
+ userId: mongoose.Types.ObjectId;
2051
+ role: "viewer" | "editor" | "admin";
2052
+ }> & {
2053
+ userId: mongoose.Types.ObjectId;
2054
+ role: "viewer" | "editor" | "admin";
2055
+ }>;
2007
2056
  description?: string | null | undefined;
2057
+ image?: string | null | undefined;
2008
2058
  }>> & mongoose.FlatRecord<{
2009
2059
  createdAt: NativeDate;
2010
2060
  updatedAt: NativeDate;
@@ -2403,8 +2453,18 @@ export declare function initProjectModel(connection: mongoose.Connection): mongo
2403
2453
  }>;
2404
2454
  allowUpload: boolean;
2405
2455
  allowSharing: boolean;
2406
- image?: string | null | undefined;
2456
+ members: mongoose.Types.DocumentArray<{
2457
+ userId: mongoose.Types.ObjectId;
2458
+ role: "viewer" | "editor" | "admin";
2459
+ }, mongoose.Types.Subdocument<mongoose.Types.ObjectId, any, {
2460
+ userId: mongoose.Types.ObjectId;
2461
+ role: "viewer" | "editor" | "admin";
2462
+ }> & {
2463
+ userId: mongoose.Types.ObjectId;
2464
+ role: "viewer" | "editor" | "admin";
2465
+ }>;
2407
2466
  description?: string | null | undefined;
2467
+ image?: string | null | undefined;
2408
2468
  }> & {
2409
2469
  _id: mongoose.Types.ObjectId;
2410
2470
  } & {
@@ -13,11 +13,15 @@ function initProjectModel(connection) {
13
13
  }, { _id: false });
14
14
  const projectSchema = new mongoose_1.default.Schema({
15
15
  name: { type: String, required: true },
16
- image: { type: String },
17
16
  description: { type: String },
17
+ image: { type: String },
18
18
  rootFolders: [folderNodeSchema],
19
19
  allowUpload: { type: Boolean, default: true },
20
20
  allowSharing: { type: Boolean, default: false },
21
+ members: [{
22
+ userId: { type: mongoose_1.default.Schema.Types.ObjectId, ref: 'User', required: true },
23
+ role: { type: String, enum: ['viewer', 'editor', 'admin'], default: 'viewer' }
24
+ }]
21
25
  }, {
22
26
  timestamps: true
23
27
  });
@@ -11,6 +11,12 @@ function createMongoProjectProvider(ProjectModel) {
11
11
  },
12
12
  async create(data) {
13
13
  const newProject = await ProjectModel.create({
14
+ members: [
15
+ {
16
+ userId: data.userId,
17
+ role: 'admin',
18
+ }
19
+ ],
14
20
  name: data.name,
15
21
  description: data.description || '',
16
22
  image: data.image || '',
@@ -6,11 +6,15 @@ export declare function createProjectService(req: Request, projectProvider: Proj
6
6
  id: string;
7
7
  name: string;
8
8
  image: string | undefined;
9
- description: string | undefined;
9
+ members: {
10
+ userId: string | undefined;
11
+ role: "viewer" | "editor" | "admin" | undefined;
12
+ }[];
10
13
  settings: {
11
14
  allowUpload?: boolean;
12
15
  allowSharing?: boolean;
13
16
  } | undefined;
17
+ description: string | undefined;
14
18
  rootFolders: import("../types").FolderNode[];
15
19
  };
16
20
  }>;
@@ -2,13 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createProjectService = createProjectService;
4
4
  async function createProjectService(req, projectProvider) {
5
- const { name, description } = req.body;
5
+ const { userId, name, description } = req.body;
6
6
  if (!name) {
7
7
  throw new Error('Project name is required');
8
8
  }
9
9
  const newProject = await projectProvider.create({
10
10
  name,
11
- description: description || ''
11
+ description: description || '',
12
+ userId,
12
13
  });
13
14
  return {
14
15
  success: true,
@@ -16,8 +17,12 @@ async function createProjectService(req, projectProvider) {
16
17
  id: newProject.id,
17
18
  name: newProject.name,
18
19
  image: newProject.image,
19
- description: newProject.description,
20
+ members: [{
21
+ userId: newProject.members?.[0].userId,
22
+ role: newProject.members?.[0].role
23
+ }],
20
24
  settings: newProject.settings,
25
+ description: newProject.description,
21
26
  rootFolders: newProject.rootFolders || [],
22
27
  }
23
28
  };
@@ -15,6 +15,10 @@ export interface ProjectInfo {
15
15
  id: string;
16
16
  name: string;
17
17
  image?: string;
18
+ members?: {
19
+ userId: string;
20
+ role: 'viewer' | 'editor' | 'admin';
21
+ }[];
18
22
  description?: string;
19
23
  rootFolders?: FolderNode[];
20
24
  settings?: {
@@ -50,6 +54,7 @@ export interface ProjectProvider {
50
54
  create(data: {
51
55
  name: string;
52
56
  image?: string;
57
+ userId: string;
53
58
  description?: string;
54
59
  allowUpload?: boolean;
55
60
  allowSharing?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "streamby-core",
3
- "version": "0.9.1",
3
+ "version": "0.9.2",
4
4
  "description": "StreamBy middleware framework for media storage management",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",