@drax/media-back 2.11.0 → 3.1.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.
Files changed (66) hide show
  1. package/dist/controllers/FileController.js +38 -0
  2. package/dist/controllers/MediaController.js +42 -1
  3. package/dist/factory/services/FileServiceFactory.js +30 -0
  4. package/dist/index.js +13 -2
  5. package/dist/interfaces/IFile.js +1 -0
  6. package/dist/interfaces/IFileRepository.js +1 -0
  7. package/dist/models/FileModel.js +49 -0
  8. package/dist/permissions/FilePermissions.js +13 -0
  9. package/dist/repository/mongo/FileMongoRepository.js +13 -0
  10. package/dist/repository/sqlite/FileSqliteRepository.js +37 -0
  11. package/dist/routes/FileRoutes.js +20 -0
  12. package/dist/schemas/FileSchema.js +51 -0
  13. package/dist/services/FileService.js +22 -0
  14. package/package.json +4 -4
  15. package/src/controllers/FileController.ts +50 -0
  16. package/src/controllers/MediaController.ts +48 -4
  17. package/src/factory/services/FileServiceFactory.ts +41 -0
  18. package/src/index.ts +30 -3
  19. package/src/interfaces/IFile.ts +67 -0
  20. package/src/interfaces/IFileRepository.ts +11 -0
  21. package/src/models/FileModel.ts +65 -0
  22. package/src/permissions/FilePermissions.ts +17 -0
  23. package/src/repository/mongo/FileMongoRepository.ts +22 -0
  24. package/src/repository/sqlite/FileSqliteRepository.ts +46 -0
  25. package/src/routes/FileRoutes.ts +36 -0
  26. package/src/schemas/FileSchema.ts +55 -0
  27. package/src/services/FileService.ts +36 -0
  28. package/test/modules/media/File/File-endpoints.test.ts +573 -0
  29. package/test/setup/MongoInMemory.ts +56 -0
  30. package/test/setup/TestSetup.ts +347 -0
  31. package/test/setup/data/admin-role.ts +13 -0
  32. package/test/setup/data/basic-user.ts +14 -0
  33. package/test/setup/data/file-role.ts +16 -0
  34. package/test/setup/data/one-tenant.ts +6 -0
  35. package/test/setup/data/restricted-role.ts +11 -0
  36. package/test/setup/data/root-user.ts +14 -0
  37. package/test/setup/data/tenant-one-user.ts +13 -0
  38. package/test/setup/data/tenant-two-user.ts +14 -0
  39. package/test/setup/data/two-tenant.ts +6 -0
  40. package/test/utils/StoreManager.test.ts +1 -1
  41. package/tsconfig.tsbuildinfo +1 -1
  42. package/types/controllers/FileController.d.ts +10 -0
  43. package/types/controllers/FileController.d.ts.map +1 -0
  44. package/types/controllers/MediaController.d.ts.map +1 -1
  45. package/types/factory/services/FileServiceFactory.d.ts +8 -0
  46. package/types/factory/services/FileServiceFactory.d.ts.map +1 -0
  47. package/types/index.d.ts +13 -1
  48. package/types/index.d.ts.map +1 -1
  49. package/types/interfaces/IFile.d.ts +63 -0
  50. package/types/interfaces/IFile.d.ts.map +1 -0
  51. package/types/interfaces/IFileRepository.d.ts +6 -0
  52. package/types/interfaces/IFileRepository.d.ts.map +1 -0
  53. package/types/models/FileModel.d.ts +15 -0
  54. package/types/models/FileModel.d.ts.map +1 -0
  55. package/types/permissions/FilePermissions.d.ts +13 -0
  56. package/types/permissions/FilePermissions.d.ts.map +1 -0
  57. package/types/repository/mongo/FileMongoRepository.d.ts +9 -0
  58. package/types/repository/mongo/FileMongoRepository.d.ts.map +1 -0
  59. package/types/repository/sqlite/FileSqliteRepository.d.ts +18 -0
  60. package/types/repository/sqlite/FileSqliteRepository.d.ts.map +1 -0
  61. package/types/routes/FileRoutes.d.ts +4 -0
  62. package/types/routes/FileRoutes.d.ts.map +1 -0
  63. package/types/schemas/FileSchema.d.ts +65 -0
  64. package/types/schemas/FileSchema.d.ts.map +1 -0
  65. package/types/services/FileService.d.ts +12 -0
  66. package/types/services/FileService.d.ts.map +1 -0
@@ -0,0 +1,10 @@
1
+ import { AbstractFastifyController, CustomRequest } from "@drax/crud-back";
2
+ import type { IFile, IFileBase } from "../interfaces/IFile";
3
+ declare class FileController extends AbstractFastifyController<IFile, IFileBase, IFileBase> {
4
+ constructor();
5
+ preUpdate(request: CustomRequest, payload: any): Promise<IFileBase>;
6
+ postDelete(request: CustomRequest, item: IFile): Promise<IFile>;
7
+ }
8
+ export default FileController;
9
+ export { FileController };
10
+ //# sourceMappingURL=FileController.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileController.d.ts","sourceRoot":"","sources":["../../src/controllers/FileController.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,yBAAyB,EAAE,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAEzE,OAAO,KAAK,EAAC,KAAK,EAAE,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAG1D,cAAM,cAAe,SAAQ,yBAAyB,CAAC,KAAK,EAAE,SAAS,EAAE,SAAS,CAAC;;IAgBzE,SAAS,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAC,GAAG,GAAE,OAAO,CAAC,SAAS,CAAC;IAcjE,UAAU,CAAC,OAAO,EAAE,aAAa,EAAE,IAAI,EAAC,KAAK;CAQtD;AAED,eAAe,cAAc,CAAC;AAC9B,OAAO,EACH,cAAc,EACjB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"MediaController.d.ts","sourceRoot":"","sources":["../../src/controllers/MediaController.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,gBAAgB,EAMnB,MAAM,mBAAmB,CAAC;AAO3B,cAAM,eAAgB,SAAQ,gBAAgB;;IAM1C,WAAW,CAAC,GAAG,EAAE,MAAM;IAQjB,UAAU,CAAC,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG;;;;;;;IAqCnC,YAAY,CAAC,OAAO,KAAA,EAAE,KAAK,KAAA;CAsCpC;AAED,eAAe,eAAe,CAAA;AAC9B,OAAO,EAAC,eAAe,EAAC,CAAA"}
1
+ {"version":3,"file":"MediaController.d.ts","sourceRoot":"","sources":["../../src/controllers/MediaController.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,gBAAgB,EAInB,MAAM,mBAAmB,CAAC;AAQ3B,cAAM,eAAgB,SAAQ,gBAAgB;;IAM1C,WAAW,CAAC,GAAG,EAAE,MAAM;IAQjB,UAAU,CAAC,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG;;;;;;;IA0EnC,YAAY,CAAC,OAAO,KAAA,EAAE,KAAK,KAAA;CA8CpC;AAED,eAAe,eAAe,CAAA;AAC9B,OAAO,EAAC,eAAe,EAAC,CAAA"}
@@ -0,0 +1,8 @@
1
+ import { FileService } from '../../services/FileService.js';
2
+ declare class FileServiceFactory {
3
+ private static service;
4
+ static get instance(): FileService;
5
+ }
6
+ export default FileServiceFactory;
7
+ export { FileServiceFactory };
8
+ //# sourceMappingURL=FileServiceFactory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileServiceFactory.d.ts","sourceRoot":"","sources":["../../../src/factory/services/FileServiceFactory.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,WAAW,EAAC,MAAM,+BAA+B,CAAA;AAIzD,cAAM,kBAAkB;IACpB,OAAO,CAAC,MAAM,CAAC,OAAO,CAAc;IAEpC,WAAkB,QAAQ,IAAI,WAAW,CAsBxC;CACJ;AAED,eAAe,kBAAkB,CAAA;AACjC,OAAO,EACH,kBAAkB,EACrB,CAAA"}
package/types/index.d.ts CHANGED
@@ -1,4 +1,16 @@
1
1
  import { MediaRoutes } from "./routes/MediaRoutes.js";
2
2
  import { MediaPermissions } from "./permissions/MediaPermissions.js";
3
- export { MediaRoutes, MediaPermissions, };
3
+ import { FileRoutes } from "./routes/FileRoutes.js";
4
+ import { FilePermissions } from "./permissions/FilePermissions.js";
5
+ import FileSchema from "./schemas/FileSchema.js";
6
+ import FileModel from "./models/FileModel.js";
7
+ import FileMongoRepository from "./repository/mongo/FileMongoRepository.js";
8
+ import FileSqliteRepository from "./repository/sqlite/FileSqliteRepository.js";
9
+ import FileService from "./services/FileService.js";
10
+ import FileServiceFactory from "./factory/services/FileServiceFactory.js";
11
+ import FileController from "./controllers/FileController.js";
12
+ import type { IFile, IFileBase } from "./interfaces/IFile";
13
+ import type { IFileRepository } from "./interfaces/IFileRepository";
14
+ export type { IFile, IFileBase, IFileRepository };
15
+ export { MediaRoutes, FileRoutes, MediaPermissions, FilePermissions, FileSchema, FileModel, FileMongoRepository, FileSqliteRepository, FileService, FileServiceFactory, FileController };
4
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAC,gBAAgB,EAAC,MAAM,mCAAmC,CAAC;AAEnE,OAAO,EAEH,WAAW,EAGX,gBAAgB,GACnB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,UAAU,MAAM,yBAAyB,CAAC;AACjD,OAAO,SAAS,MAAM,uBAAuB,CAAC;AAC9C,OAAO,mBAAmB,MAAM,2CAA2C,CAAC;AAC5E,OAAO,oBAAoB,MAAM,6CAA6C,CAAC;AAC/E,OAAO,WAAW,MAAM,2BAA2B,CAAC;AACpD,OAAO,kBAAkB,MAAM,0CAA0C,CAAC;AAC1E,OAAO,cAAc,MAAM,iCAAiC,CAAC;AAC7D,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEpE,YAAY,EACR,KAAK,EACL,SAAS,EACT,eAAe,EAClB,CAAA;AAED,OAAO,EAEH,WAAW,EACX,UAAU,EAGV,gBAAgB,EAChB,eAAe,EAGf,UAAU,EACV,SAAS,EACT,mBAAmB,EACnB,oBAAoB,EACpB,WAAW,EACX,kBAAkB,EAClB,cAAc,EACjB,CAAA"}
@@ -0,0 +1,63 @@
1
+ interface IFileBase {
2
+ filename: string;
3
+ relativePath: string;
4
+ absolutePath: string;
5
+ url: string;
6
+ description?: string;
7
+ tags?: Array<string>;
8
+ mimetype: string;
9
+ encoding: string;
10
+ extension: string;
11
+ size: number;
12
+ type: string;
13
+ lastAccess: Date;
14
+ createdBy?: {
15
+ id?: string;
16
+ username?: string;
17
+ };
18
+ updatedBy?: {
19
+ id?: string;
20
+ username?: string;
21
+ };
22
+ createdFor?: string;
23
+ ttlSeconds: number;
24
+ expiresAt?: Date;
25
+ isPublic?: boolean;
26
+ hits?: number;
27
+ createdAt?: Date;
28
+ updatedAt?: Date;
29
+ tenant?: any;
30
+ }
31
+ interface IFile {
32
+ _id: string;
33
+ filename: string;
34
+ relativePath: string;
35
+ absolutePath: string;
36
+ url: string;
37
+ description?: string;
38
+ tags?: Array<string>;
39
+ mimetype: string;
40
+ encoding: string;
41
+ extension: string;
42
+ size: number;
43
+ type: string;
44
+ lastAccess: Date;
45
+ createdBy?: {
46
+ id?: string;
47
+ username?: string;
48
+ };
49
+ updatedBy?: {
50
+ id?: string;
51
+ username?: string;
52
+ };
53
+ createdFor?: string;
54
+ ttlSeconds: number;
55
+ expiresAt?: Date;
56
+ isPublic?: boolean;
57
+ hits?: number;
58
+ createdAt?: Date;
59
+ updatedAt?: Date;
60
+ tenant?: any;
61
+ }
62
+ export type { IFileBase, IFile };
63
+ //# sourceMappingURL=IFile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IFile.d.ts","sourceRoot":"","sources":["../../src/interfaces/IFile.ts"],"names":[],"mappings":"AAAA,UAAU,SAAS;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,YAAY,EAAE,MAAM,CAAA;IACpB,YAAY,EAAE,MAAM,CAAA;IACpB,GAAG,EAAE,MAAM,CAAA;IACX,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,IAAI,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;IACpB,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,IAAI,CAAA;IAChB,SAAS,CAAC,EAAE;QACR,EAAE,CAAC,EAAE,MAAM,CAAA;QACX,QAAQ,CAAC,EAAE,MAAM,CAAA;KACpB,CAAA;IACD,SAAS,CAAC,EAAE;QACR,EAAE,CAAC,EAAE,MAAM,CAAA;QACX,QAAQ,CAAC,EAAE,MAAM,CAAA;KACpB,CAAA;IACD,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,IAAI,CAAA;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,IAAI,CAAA;IAChB,SAAS,CAAC,EAAE,IAAI,CAAA;IAChB,MAAM,CAAC,EAAE,GAAG,CAAA;CACf;AAED,UAAU,KAAK;IACX,GAAG,EAAE,MAAM,CAAA;IACX,QAAQ,EAAE,MAAM,CAAA;IAChB,YAAY,EAAE,MAAM,CAAA;IACpB,YAAY,EAAE,MAAM,CAAA;IACpB,GAAG,EAAE,MAAM,CAAA;IACX,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,IAAI,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;IACpB,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,IAAI,CAAA;IAChB,SAAS,CAAC,EAAE;QACR,EAAE,CAAC,EAAE,MAAM,CAAA;QACX,QAAQ,CAAC,EAAE,MAAM,CAAA;KACpB,CAAA;IACD,SAAS,CAAC,EAAE;QACR,EAAE,CAAC,EAAE,MAAM,CAAA;QACX,QAAQ,CAAC,EAAE,MAAM,CAAA;KACpB,CAAA;IACD,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,IAAI,CAAA;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,IAAI,CAAA;IAChB,SAAS,CAAC,EAAE,IAAI,CAAA;IAChB,MAAM,CAAC,EAAE,GAAG,CAAA;CACf;AAED,YAAY,EACR,SAAS,EACT,KAAK,EACR,CAAA"}
@@ -0,0 +1,6 @@
1
+ import type { IFile, IFileBase } from './IFile';
2
+ import { IDraxCrudRepository } from "@drax/crud-share";
3
+ interface IFileRepository extends IDraxCrudRepository<IFile, IFileBase, IFileBase> {
4
+ }
5
+ export { IFileRepository };
6
+ //# sourceMappingURL=IFileRepository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IFileRepository.d.ts","sourceRoot":"","sources":["../../src/interfaces/IFileRepository.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,KAAK,EAAE,SAAS,EAAC,MAAM,SAAS,CAAA;AAC7C,OAAO,EAAC,mBAAmB,EAAC,MAAM,kBAAkB,CAAC;AAErD,UAAU,eAAgB,SAAQ,mBAAmB,CAAC,KAAK,EAAE,SAAS,EAAE,SAAS,CAAC;CAEjF;AAED,OAAO,EAAC,eAAe,EAAC,CAAA"}
@@ -0,0 +1,15 @@
1
+ import { mongoose } from '@drax/common-back';
2
+ import type { IFile } from '../interfaces/IFile';
3
+ declare const FileSchema: mongoose.Schema<IFile, mongoose.Model<IFile, any, any, any, mongoose.Document<unknown, any, IFile, any, {}> & IFile & Required<{
4
+ _id: string;
5
+ }> & {
6
+ __v: number;
7
+ }, any>, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, IFile, mongoose.Document<unknown, {}, mongoose.FlatRecord<IFile>, {}, mongoose.DefaultSchemaOptions> & mongoose.FlatRecord<IFile> & Required<{
8
+ _id: string;
9
+ }> & {
10
+ __v: number;
11
+ }>;
12
+ declare const FileModel: mongoose.PaginateModel<IFile, {}, {}>;
13
+ export { FileSchema, FileModel };
14
+ export default FileModel;
15
+ //# sourceMappingURL=FileModel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileModel.d.ts","sourceRoot":"","sources":["../../src/models/FileModel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AAI3C,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,qBAAqB,CAAA;AAE9C,QAAA,MAAM,UAAU;;;;;;;;EA2BM,CAAC;AAwBvB,QAAA,MAAM,SAAS,uCAAuF,CAAC;AAEvG,OAAO,EACH,UAAU,EACV,SAAS,EACZ,CAAA;AAED,eAAe,SAAS,CAAA"}
@@ -0,0 +1,13 @@
1
+ declare enum FilePermissions {
2
+ Create = "file:create",
3
+ Update = "file:update",
4
+ Delete = "file:delete",
5
+ View = "file:view",
6
+ ViewAll = "file:viewAll",
7
+ UpdateAll = "file:updateAll",
8
+ DeleteAll = "file:deleteAll",
9
+ Manage = "file:manage"
10
+ }
11
+ export { FilePermissions };
12
+ export default FilePermissions;
13
+ //# sourceMappingURL=FilePermissions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FilePermissions.d.ts","sourceRoot":"","sources":["../../src/permissions/FilePermissions.ts"],"names":[],"mappings":"AACA,aAAK,eAAe;IAEhB,MAAM,gBAAgB;IACtB,MAAM,gBAAgB;IACtB,MAAM,gBAAgB;IACtB,IAAI,cAAc;IAClB,OAAO,iBAAiB;IACxB,SAAS,mBAAmB;IAC5B,SAAS,mBAAmB;IAC5B,MAAM,gBAAgB;CAEzB;AAED,OAAO,EAAE,eAAe,EAAE,CAAC;AAC3B,eAAe,eAAe,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { AbstractMongoRepository } from "@drax/crud-back";
2
+ import type { IFileRepository } from '../../interfaces/IFileRepository';
3
+ import type { IFile, IFileBase } from "../../interfaces/IFile";
4
+ declare class FileMongoRepository extends AbstractMongoRepository<IFile, IFileBase, IFileBase> implements IFileRepository {
5
+ constructor();
6
+ }
7
+ export default FileMongoRepository;
8
+ export { FileMongoRepository };
9
+ //# sourceMappingURL=FileMongoRepository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileMongoRepository.d.ts","sourceRoot":"","sources":["../../../src/repository/mongo/FileMongoRepository.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,uBAAuB,EAAC,MAAM,iBAAiB,CAAC;AAExD,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,kCAAkC,CAAA;AACrE,OAAO,KAAK,EAAC,KAAK,EAAE,SAAS,EAAC,MAAM,wBAAwB,CAAC;AAG7D,cAAM,mBAAoB,SAAQ,uBAAuB,CAAC,KAAK,EAAE,SAAS,EAAE,SAAS,CAAE,YAAW,eAAe;;CAUhH;AAED,eAAe,mBAAmB,CAAA;AAClC,OAAO,EAAC,mBAAmB,EAAC,CAAA"}
@@ -0,0 +1,18 @@
1
+ import { AbstractSqliteRepository } from "@drax/crud-back";
2
+ import type { IFileRepository } from '../../interfaces/IFileRepository';
3
+ import type { IFile, IFileBase } from "../../interfaces/IFile";
4
+ import { SqliteTableField } from "@drax/common-back";
5
+ declare class FileSqliteRepository extends AbstractSqliteRepository<IFile, IFileBase, IFileBase> implements IFileRepository {
6
+ protected db: any;
7
+ protected tableName: string;
8
+ protected dataBaseFile: string;
9
+ protected searchFields: string[];
10
+ protected booleanFields: string[];
11
+ protected identifier: string;
12
+ protected populateFields: any[];
13
+ protected verbose: boolean;
14
+ protected tableFields: SqliteTableField[];
15
+ }
16
+ export default FileSqliteRepository;
17
+ export { FileSqliteRepository };
18
+ //# sourceMappingURL=FileSqliteRepository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileSqliteRepository.d.ts","sourceRoot":"","sources":["../../../src/repository/sqlite/FileSqliteRepository.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,wBAAwB,EAAC,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,kCAAkC,CAAA;AACrE,OAAO,KAAK,EAAC,KAAK,EAAE,SAAS,EAAC,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAC,gBAAgB,EAAC,MAAM,mBAAmB,CAAC;AAEnD,cAAM,oBAAqB,SAAQ,wBAAwB,CAAC,KAAK,EAAE,SAAS,EAAE,SAAS,CAAE,YAAW,eAAe;IAE/G,SAAS,CAAC,EAAE,EAAE,GAAG,CAAC;IAClB,SAAS,CAAC,SAAS,EAAE,MAAM,CAAU;IACrC,SAAS,CAAC,YAAY,EAAE,MAAM,CAAC;IAC/B,SAAS,CAAC,YAAY,EAAE,MAAM,EAAE,CAA+G;IAC/I,SAAS,CAAC,aAAa,EAAE,MAAM,EAAE,CAAgB;IACjD,SAAS,CAAC,UAAU,EAAE,MAAM,CAAS;IACrC,SAAS,CAAC,cAAc,QAEvB;IACD,SAAS,CAAC,OAAO,EAAE,OAAO,CAAS;IACnC,SAAS,CAAC,WAAW,EAAE,gBAAgB,EAAE,CAsBxC;CAEJ;AAED,eAAe,oBAAoB,CAAA;AACnC,OAAO,EAAC,oBAAoB,EAAC,CAAA"}
@@ -0,0 +1,4 @@
1
+ declare function FileRoutes(fastify: any, options: any): Promise<void>;
2
+ export default FileRoutes;
3
+ export { FileRoutes };
4
+ //# sourceMappingURL=FileRoutes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileRoutes.d.ts","sourceRoot":"","sources":["../../src/routes/FileRoutes.ts"],"names":[],"mappings":"AAKA,iBAAe,UAAU,CAAC,OAAO,KAAA,EAAE,OAAO,KAAA,iBA2BzC;AAED,eAAe,UAAU,CAAC;AAC1B,OAAO,EAAC,UAAU,EAAC,CAAA"}
@@ -0,0 +1,65 @@
1
+ import { z } from 'zod';
2
+ declare const FileBaseSchema: z.ZodObject<{
3
+ filename: z.ZodString;
4
+ relativePath: z.ZodString;
5
+ absolutePath: z.ZodString;
6
+ url: z.ZodString;
7
+ description: z.ZodOptional<z.ZodNullable<z.ZodDefault<z.ZodString>>>;
8
+ tags: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
9
+ mimetype: z.ZodOptional<z.ZodNullable<z.ZodString>>;
10
+ encoding: z.ZodOptional<z.ZodNullable<z.ZodString>>;
11
+ extension: z.ZodOptional<z.ZodNullable<z.ZodString>>;
12
+ size: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
13
+ type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
14
+ lastAccess: z.ZodOptional<z.ZodNullable<z.ZodCoercedDate<unknown>>>;
15
+ createdFor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
16
+ ttlSeconds: z.ZodOptional<z.ZodNullable<z.ZodDefault<z.ZodNumber>>>;
17
+ expiresAt: z.ZodOptional<z.ZodNullable<z.ZodCoercedDate<unknown>>>;
18
+ isPublic: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
19
+ hits: z.ZodDefault<z.ZodNumber>;
20
+ createdBy: z.ZodOptional<z.ZodNullable<z.ZodObject<{
21
+ id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
22
+ username: z.ZodOptional<z.ZodNullable<z.ZodString>>;
23
+ }, z.core.$strip>>>;
24
+ updatedBy: z.ZodOptional<z.ZodNullable<z.ZodObject<{
25
+ id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
26
+ username: z.ZodOptional<z.ZodNullable<z.ZodString>>;
27
+ }, z.core.$strip>>>;
28
+ tenant: z.ZodOptional<z.ZodNullable<z.ZodCoercedString<unknown>>>;
29
+ }, z.core.$strip>;
30
+ declare const FileSchema: z.ZodObject<{
31
+ type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
32
+ filename: z.ZodString;
33
+ relativePath: z.ZodString;
34
+ url: z.ZodString;
35
+ description: z.ZodOptional<z.ZodNullable<z.ZodDefault<z.ZodString>>>;
36
+ tags: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
37
+ mimetype: z.ZodOptional<z.ZodNullable<z.ZodString>>;
38
+ encoding: z.ZodOptional<z.ZodNullable<z.ZodString>>;
39
+ extension: z.ZodOptional<z.ZodNullable<z.ZodString>>;
40
+ size: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
41
+ lastAccess: z.ZodOptional<z.ZodNullable<z.ZodCoercedDate<unknown>>>;
42
+ createdFor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
43
+ ttlSeconds: z.ZodOptional<z.ZodNullable<z.ZodDefault<z.ZodNumber>>>;
44
+ isPublic: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
45
+ hits: z.ZodDefault<z.ZodNumber>;
46
+ _id: z.ZodCoercedString<unknown>;
47
+ createdAt: z.ZodCoercedDate<unknown>;
48
+ updatedAt: z.ZodCoercedDate<unknown>;
49
+ expiresAt: z.ZodOptional<z.ZodNullable<z.ZodCoercedDate<unknown>>>;
50
+ createdBy: z.ZodOptional<z.ZodNullable<z.ZodObject<{
51
+ id: z.ZodOptional<z.ZodNullable<z.ZodCoercedString<unknown>>>;
52
+ username: z.ZodOptional<z.ZodNullable<z.ZodString>>;
53
+ }, z.core.$strip>>>;
54
+ updatedBy: z.ZodOptional<z.ZodNullable<z.ZodObject<{
55
+ id: z.ZodOptional<z.ZodNullable<z.ZodCoercedString<unknown>>>;
56
+ username: z.ZodOptional<z.ZodNullable<z.ZodString>>;
57
+ }, z.core.$strip>>>;
58
+ tenant: z.ZodOptional<z.ZodNullable<z.ZodObject<{
59
+ _id: z.ZodCoercedString<unknown>;
60
+ name: z.ZodString;
61
+ }, z.core.$strip>>>;
62
+ }, z.core.$strip>;
63
+ export default FileSchema;
64
+ export { FileSchema, FileBaseSchema };
65
+ //# sourceMappingURL=FileSchema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileSchema.d.ts","sourceRoot":"","sources":["../../src/schemas/FileSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAGtB,QAAA,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA2BlB,CAAC;AAEH,QAAA,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAmBV,CAAA;AAEN,eAAe,UAAU,CAAC;AAC1B,OAAO,EAAC,UAAU,EAAE,cAAc,EAAC,CAAA"}
@@ -0,0 +1,12 @@
1
+ import type { IFileRepository } from "../interfaces/IFileRepository.js";
2
+ import type { IFileBase, IFile } from "../interfaces/IFile.js";
3
+ import { AbstractService } from "@drax/crud-back";
4
+ import type { ZodObject, ZodRawShape } from "zod";
5
+ declare class FileService extends AbstractService<IFile, IFileBase, IFileBase> {
6
+ constructor(FileRepository: IFileRepository, baseSchema?: ZodObject<ZodRawShape>, fullSchema?: ZodObject<ZodRawShape>);
7
+ registerUploadedFile(data: IFileBase): Promise<IFile>;
8
+ registerDownloadHit(relativePath: string): Promise<IFile | null>;
9
+ }
10
+ export default FileService;
11
+ export { FileService };
12
+ //# sourceMappingURL=FileService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileService.d.ts","sourceRoot":"","sources":["../../src/services/FileService.ts"],"names":[],"mappings":"AACA,OAAO,KAAI,EAAC,eAAe,EAAC,MAAM,kCAAkC,CAAC;AACrE,OAAO,KAAK,EAAC,SAAS,EAAE,KAAK,EAAC,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAC,eAAe,EAAC,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,EAAC,SAAS,EAAE,WAAW,EAAC,MAAM,KAAK,CAAC;AAEhD,cAAM,WAAY,SAAQ,eAAe,CAAC,KAAK,EAAE,SAAS,EAAE,SAAS,CAAC;gBAGtD,cAAc,EAAE,eAAe,EAAE,UAAU,CAAC,EAAE,SAAS,CAAC,WAAW,CAAC,EAAE,UAAU,CAAC,EAAE,SAAS,CAAC,WAAW,CAAC;IAO/G,oBAAoB,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,KAAK,CAAC;IAIrD,mBAAmB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;CAYzE;AAED,eAAe,WAAW,CAAA;AAC1B,OAAO,EAAC,WAAW,EAAC,CAAA"}