@into-cps-association/libms 0.4.3 → 0.4.4

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 (59) hide show
  1. package/.env +6 -0
  2. package/DEVELOPER.md +34 -9
  3. package/README.md +294 -10
  4. package/config/.env.default +1 -1
  5. package/dist/src/app.module.d.ts +2 -0
  6. package/dist/src/app.module.js +36 -0
  7. package/dist/src/app.module.js.map +1 -0
  8. package/dist/src/bootstrap.d.ts +7 -0
  9. package/dist/src/bootstrap.js +31 -0
  10. package/dist/src/bootstrap.js.map +1 -0
  11. package/dist/src/cloudcmd/cloudcmd.d.ts +3 -0
  12. package/dist/src/cloudcmd/cloudcmd.js +22 -0
  13. package/dist/src/cloudcmd/cloudcmd.js.map +1 -0
  14. package/dist/src/files/files.module.d.ts +2 -0
  15. package/dist/src/files/files.module.js +21 -0
  16. package/dist/src/files/files.module.js.map +1 -0
  17. package/dist/src/files/interfaces/files.service.interface.d.ts +5 -0
  18. package/dist/src/files/interfaces/files.service.interface.js +3 -0
  19. package/dist/src/files/interfaces/files.service.interface.js.map +1 -0
  20. package/dist/src/files/resolvers/files.resolver.d.ts +8 -0
  21. package/dist/src/files/resolvers/files.resolver.js +49 -0
  22. package/dist/src/files/resolvers/files.resolver.js.map +1 -0
  23. package/dist/src/files/services/files-service.factory.d.ts +9 -0
  24. package/dist/src/files/services/files-service.factory.js +40 -0
  25. package/dist/src/files/services/files-service.factory.js.map +1 -0
  26. package/dist/src/files/services/local-files.service.d.ts +11 -0
  27. package/dist/src/files/services/local-files.service.js +77 -0
  28. package/dist/src/files/services/local-files.service.js.map +1 -0
  29. package/dist/src/main.d.ts +2 -0
  30. package/dist/src/main.js +20 -0
  31. package/dist/src/main.js.map +1 -0
  32. package/dist/src/types.d.ts +43 -0
  33. package/dist/src/types.js +181 -0
  34. package/dist/src/types.js.map +1 -0
  35. package/dist/test/cloudcmd/cloudcmd.spec.d.ts +1 -0
  36. package/dist/test/cloudcmd/cloudcmd.spec.js +35 -0
  37. package/dist/test/cloudcmd/cloudcmd.spec.js.map +1 -0
  38. package/dist/test/e2e/app.e2e.spec.d.ts +1 -0
  39. package/dist/test/e2e/app.e2e.spec.js +53 -0
  40. package/dist/test/e2e/app.e2e.spec.js.map +1 -0
  41. package/dist/test/integration/files.service.integration.spec.d.ts +1 -0
  42. package/dist/test/integration/files.service.integration.spec.js +51 -0
  43. package/dist/test/integration/files.service.integration.spec.js.map +1 -0
  44. package/dist/test/testUtil.d.ts +88 -0
  45. package/dist/test/testUtil.js +173 -0
  46. package/dist/test/testUtil.js.map +1 -0
  47. package/dist/test/unit/files-service.factory.unit.spec.d.ts +1 -0
  48. package/dist/test/unit/files-service.factory.unit.spec.js +32 -0
  49. package/dist/test/unit/files-service.factory.unit.spec.js.map +1 -0
  50. package/dist/test/unit/files.resolver.unit.spec.d.ts +1 -0
  51. package/dist/test/unit/files.resolver.unit.spec.js +56 -0
  52. package/dist/test/unit/files.resolver.unit.spec.js.map +1 -0
  53. package/dist/test/unit/local-files.service.unit.spec.d.ts +1 -0
  54. package/dist/test/unit/local-files.service.unit.spec.js +84 -0
  55. package/dist/test/unit/local-files.service.unit.spec.js.map +1 -0
  56. package/dist/tsconfig.tsbuildinfo +1 -0
  57. package/inside.png +0 -0
  58. package/package.json +1 -1
  59. package/top-level.png +0 -0
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const common_1 = require("@nestjs/common");
16
+ const config_1 = require("@nestjs/config");
17
+ const local_files_service_1 = require("./local-files.service");
18
+ let FilesServiceFactory = class FilesServiceFactory {
19
+ configService;
20
+ localFilesService;
21
+ constructor(configService, localFilesService) {
22
+ this.configService = configService;
23
+ this.localFilesService = localFilesService;
24
+ }
25
+ create() {
26
+ const mode = this.configService.get('MODE');
27
+ if (mode === 'local') {
28
+ return this.localFilesService;
29
+ }
30
+ throw new Error(`Invalid MODE: ${mode}`);
31
+ }
32
+ };
33
+ FilesServiceFactory = __decorate([
34
+ (0, common_1.Injectable)(),
35
+ __param(1, (0, common_1.Inject)(local_files_service_1.default)),
36
+ __metadata("design:paramtypes", [config_1.ConfigService,
37
+ local_files_service_1.default])
38
+ ], FilesServiceFactory);
39
+ exports.default = FilesServiceFactory;
40
+ //# sourceMappingURL=files-service.factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files-service.factory.js","sourceRoot":"","sources":["../../../../src/files/services/files-service.factory.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,2CAAoD;AACpD,2CAA+C;AAE/C,+DAAsD;AAGvC,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAG5B;IAC2B;IAFrC,YACU,aAA4B,EACD,iBAAoC;QAD/D,kBAAa,GAAb,aAAa,CAAe;QACD,sBAAiB,GAAjB,iBAAiB,CAAmB;IACtE,CAAC;IAGJ,MAAM;QACJ,MAAM,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAS,MAAM,CAAC,CAAC;QACpD,IAAI,IAAI,KAAK,OAAO,EAAE,CAAC;YACrB,OAAO,IAAI,CAAC,iBAAiB,CAAC;QAChC,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,iBAAiB,IAAI,EAAE,CAAC,CAAC;IAC3C,CAAC;CACF,CAAA;AAfoB,mBAAmB;IADvC,IAAA,mBAAU,GAAE;IAKR,WAAA,IAAA,eAAM,EAAC,6BAAiB,CAAC,CAAA;qCADH,sBAAa;QACkB,6BAAiB;GAJtD,mBAAmB,CAevC;kBAfoB,mBAAmB"}
@@ -0,0 +1,11 @@
1
+ import { ConfigService } from '@nestjs/config';
2
+ import { Project } from 'src/types';
3
+ import { IFilesService } from '../interfaces/files.service.interface';
4
+ export default class LocalFilesService implements IFilesService {
5
+ private configService;
6
+ constructor(configService: ConfigService);
7
+ listDirectory(path: string): Promise<Project>;
8
+ readFile(path: string): Promise<Project>;
9
+ private static getFileStats;
10
+ private static formatResponse;
11
+ }
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var LocalFilesService_1;
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ const common_1 = require("@nestjs/common");
14
+ const fs = require("fs");
15
+ const path_1 = require("path");
16
+ const config_1 = require("@nestjs/config");
17
+ let LocalFilesService = LocalFilesService_1 = class LocalFilesService {
18
+ configService;
19
+ constructor(configService) {
20
+ this.configService = configService;
21
+ }
22
+ async listDirectory(path) {
23
+ const dataPath = this.configService.get('LOCAL_PATH');
24
+ const fullPath = (0, path_1.join)(dataPath, path);
25
+ const files = await fs.promises.readdir(fullPath);
26
+ const edges = await Promise.all(files.map((file) => LocalFilesService_1.getFileStats(fullPath, file)));
27
+ const tree = {
28
+ trees: {
29
+ edges: edges.filter((edge) => edge.node.type === 'tree'),
30
+ },
31
+ blobs: {
32
+ edges: edges.filter((edge) => edge.node.type === 'blob'),
33
+ },
34
+ };
35
+ return { repository: { tree } };
36
+ }
37
+ async readFile(path) {
38
+ const dataPath = this.configService.get('LOCAL_PATH');
39
+ const fullPath = (0, path_1.join)(dataPath, path);
40
+ try {
41
+ const content = await (await fs.promises.readFile(fullPath, 'utf8')).trim();
42
+ const name = path.split('/').pop();
43
+ return LocalFilesService_1.formatResponse(name, content);
44
+ }
45
+ catch (error) {
46
+ throw new common_1.InternalServerErrorException('Error reading file');
47
+ }
48
+ }
49
+ static async getFileStats(fullPath, file) {
50
+ const stats = await fs.promises.lstat((0, path_1.join)(fullPath, file));
51
+ if (stats.isDirectory()) {
52
+ return { node: { name: file, type: 'tree' } };
53
+ }
54
+ return { node: { name: file, type: 'blob' } };
55
+ }
56
+ static formatResponse(name, content) {
57
+ return {
58
+ repository: {
59
+ blobs: {
60
+ nodes: [
61
+ {
62
+ name,
63
+ rawBlob: content,
64
+ rawTextBlob: content,
65
+ },
66
+ ],
67
+ },
68
+ },
69
+ };
70
+ }
71
+ };
72
+ LocalFilesService = LocalFilesService_1 = __decorate([
73
+ (0, common_1.Injectable)(),
74
+ __metadata("design:paramtypes", [config_1.ConfigService])
75
+ ], LocalFilesService);
76
+ exports.default = LocalFilesService;
77
+ //# sourceMappingURL=local-files.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"local-files.service.js","sourceRoot":"","sources":["../../../../src/files/services/local-files.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA0E;AAC1E,yBAAyB;AACzB,+BAA4B;AAC5B,2CAA+C;AAKhC,IAAM,iBAAiB,yBAAvB,MAAM,iBAAi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true });
4
+ const commander_1 = require("commander");
5
+ const bootstrap_1 = require("./bootstrap");
6
+ const program = new commander_1.Command();
7
+ program
8
+ .description('The lib microservice is a file server. It supports file transfer over GraphQL and HTTP protocols.')
9
+ .option('-c, --config <file>', 'provide the config file (default .env)')
10
+ .option('-H, --http <file>', 'enable the HTTP server with the specified config')
11
+ .helpOption('-h, --help', 'display help for libms')
12
+ .showHelpAfterError();
13
+ program.parse(process.argv);
14
+ const options = program.opts();
15
+ (0, bootstrap_1.default)({
16
+ config: options.config,
17
+ httpServer: options.http,
18
+ runHelp: () => program.help(),
19
+ });
20
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/main.ts"],"names":[],"mappings":";;;AACA,yCAAoC;AACpC,2CAAoC;AAOpC,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,WAAW,CACV,mGAAmG,CACpG;KACA,MAAM,CAAC,qBAAqB,EAAE,wCAAwC,CAAC;KACvE,MAAM,CACL,mBAAmB,EACnB,kDAAkD,CACnD;KACA,UAAU,CAAC,YAAY,EAAE,wBAAwB,CAAC;KAClD,kBAAkB,EAAE,CAAC;AAExB,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAE5B,MAAM,OAAO,GAAmB,OAAO,CAAC,IAAI,EAAE,CAAC;AAE/C,IAAA,mBAAS,EAAC;IACR,MAAM,EAAE,OAAO,CAAC,MAAM;IACtB,UAAU,EAAE,OAAO,CAAC,IAAI;IACxB,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE;CAC9B,CAAC,CAAC"}
@@ -0,0 +1,43 @@
1
+ export declare class Blob {
2
+ name: string;
3
+ type: string;
4
+ }
5
+ export declare class BlobEdge {
6
+ node: Blob;
7
+ }
8
+ export declare class BlobConnection {
9
+ edges: BlobEdge[];
10
+ }
11
+ export declare class TreeEntry {
12
+ name: string;
13
+ type: string;
14
+ }
15
+ export declare class TreeEdge {
16
+ node: TreeEntry;
17
+ }
18
+ export declare class TreeConnection {
19
+ edges: TreeEdge[];
20
+ }
21
+ export declare class Tree {
22
+ blobs: BlobConnection;
23
+ trees: TreeConnection;
24
+ }
25
+ export declare class RepositoryBlob {
26
+ name: string;
27
+ rawBlob: string;
28
+ rawTextBlob: string;
29
+ }
30
+ export declare class RepositoryBlobConnection {
31
+ nodes: RepositoryBlob[];
32
+ }
33
+ export declare class Repository {
34
+ tree?: Tree;
35
+ blobs?: RepositoryBlobConnection;
36
+ }
37
+ export declare class Project {
38
+ repository: Repository;
39
+ }
40
+ export declare class Query {
41
+ listDirectory: Project;
42
+ readFile: Project;
43
+ }
@@ -0,0 +1,181 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.Query = exports.Project = exports.Repository = exports.RepositoryBlobConnection = exports.RepositoryBlob = exports.Tree = exports.TreeConnection = exports.TreeEdge = exports.TreeEntry = exports.BlobConnection = exports.BlobEdge = exports.Blob = void 0;
13
+ const graphql_1 = require("@nestjs/graphql");
14
+ let Blob = class Blob {
15
+ name;
16
+ type;
17
+ };
18
+ exports.Blob = Blob;
19
+ __decorate([
20
+ (0, graphql_1.Field)(),
21
+ __metadata("design:type", String)
22
+ ], Blob.prototype, "name", void 0);
23
+ __decorate([
24
+ (0, graphql_1.Field)(),
25
+ __metadata("design:type", String)
26
+ ], Blob.prototype, "type", void 0);
27
+ exports.Blob = Blob = __decorate([
28
+ (0, graphql_1.ObjectType)()
29
+ ], Blob);
30
+ let BlobEdge = class BlobEdge {
31
+ node;
32
+ };
33
+ exports.BlobEdge = BlobEdge;
34
+ __decorate([
35
+ (0, graphql_1.Field)(() => Blob),
36
+ __metadata("design:type", Blob)
37
+ ], BlobEdge.prototype, "node", void 0);
38
+ exports.BlobEdge = BlobEdge = __decorate([
39
+ (0, graphql_1.ObjectType)()
40
+ ], BlobEdge);
41
+ let BlobConnection = class BlobConnection {
42
+ edges;
43
+ };
44
+ exports.BlobConnection = BlobConnection;
45
+ __decorate([
46
+ (0, graphql_1.Field)(() => [BlobEdge]),
47
+ __metadata("design:type", Array)
48
+ ], BlobConnection.prototype, "edges", void 0);
49
+ exports.BlobConnection = BlobConnection = __decorate([
50
+ (0, graphql_1.ObjectType)()
51
+ ], BlobConnection);
52
+ let TreeEntry = class TreeEntry {
53
+ name;
54
+ type;
55
+ };
56
+ exports.TreeEntry = TreeEntry;
57
+ __decorate([
58
+ (0, graphql_1.Field)(),
59
+ __metadata("design:type", String)
60
+ ], TreeEntry.prototype, "name", void 0);
61
+ __decorate([
62
+ (0, graphql_1.Field)(),
63
+ __metadata("design:type", String)
64
+ ], TreeEntry.prototype, "type", void 0);
65
+ exports.TreeEntry = TreeEntry = __decorate([
66
+ (0, graphql_1.ObjectType)()
67
+ ], TreeEntry);
68
+ let TreeEdge = class TreeEdge {
69
+ node;
70
+ };
71
+ exports.TreeEdge = TreeEdge;
72
+ __decorate([
73
+ (0, graphql_1.Field)(() => TreeEntry),
74
+ __metadata("design:type", TreeEntry)
75
+ ], TreeEdge.prototype, "node", void 0);
76
+ exports.TreeEdge = TreeEdge = __decorate([
77
+ (0, graphql_1.ObjectType)()
78
+ ], TreeEdge);
79
+ let TreeConnection = class TreeConnection {
80
+ edges;
81
+ };
82
+ exports.TreeConnection = TreeConnection;
83
+ __decorate([
84
+ (0, graphql_1.Field)(() => [TreeEdge]),
85
+ __metadata("design:type", Array)
86
+ ], TreeConnection.prototype, "edges", void 0);
87
+ exports.TreeConnection = TreeConnection = __decorate([
88
+ (0, graphql_1.ObjectType)()
89
+ ], TreeConnection);
90
+ let Tree = class Tree {
91
+ blobs;
92
+ trees;
93
+ };
94
+ exports.Tree = Tree;
95
+ __decorate([
96
+ (0, graphql_1.Field)(),
97
+ __metadata("design:type", BlobConnection)
98
+ ], Tree.prototype, "blobs", void 0);
99
+ __decorate([
100
+ (0, graphql_1.Field)(),
101
+ __metadata("design:type", TreeConnection)
102
+ ], Tree.prototype, "trees", void 0);
103
+ exports.Tree = Tree = __decorate([
104
+ (0, graphql_1.ObjectType)()
105
+ ], Tree);
106
+ let RepositoryBlob = class RepositoryBlob {
107
+ name;
108
+ rawBlob;
109
+ rawTextBlob;
110
+ };
111
+ exports.RepositoryBlob = RepositoryBlob;
112
+ __decorate([
113
+ (0, graphql_1.Field)(),
114
+ __metadata("design:type", String)
115
+ ], RepositoryBlob.prototype, "name", void 0);
116
+ __decorate([
117
+ (0, graphql_1.Field)(),
118
+ __metadata("design:type", String)
119
+ ], RepositoryBlob.prototype, "rawBlob", void 0);
120
+ __decorate([
121
+ (0, graphql_1.Field)(),
122
+ __metadata("design:type", String)
123
+ ], RepositoryBlob.prototype, "rawTextBlob", void 0);
124
+ exports.RepositoryBlob = RepositoryBlob = __decorate([
125
+ (0, graphql_1.ObjectType)()
126
+ ], RepositoryBlob);
127
+ let RepositoryBlobConnection = class RepositoryBlobConnection {
128
+ nodes;
129
+ };
130
+ exports.RepositoryBlobConnection = RepositoryBlobConnection;
131
+ __decorate([
132
+ (0, graphql_1.Field)(() => [RepositoryBlob]),
133
+ __metadata("design:type", Array)
134
+ ], RepositoryBlobConnection.prototype, "nodes", void 0);
135
+ exports.RepositoryBlobConnection = RepositoryBlobConnection = __decorate([
136
+ (0, graphql_1.ObjectType)()
137
+ ], RepositoryBlobConnection);
138
+ let Repository = class Repository {
139
+ tree;
140
+ blobs;
141
+ };
142
+ exports.Repository = Repository;
143
+ __decorate([
144
+ (0, graphql_1.Field)(),
145
+ __metadata("design:type", Tree)
146
+ ], Repository.prototype, "tree", void 0);
147
+ __decorate([
148
+ (0, graphql_1.Field)(),
149
+ __metadata("design:type", RepositoryBlobConnection)
150
+ ], Repository.prototype, "blobs", void 0);
151
+ exports.Repository = Repository = __decorate([
152
+ (0, graphql_1.ObjectType)()
153
+ ], Repository);
154
+ let Project = class Project {
155
+ repository;
156
+ };
157
+ exports.Project = Project;
158
+ __decorate([
159
+ (0, graphql_1.Field)(() => Repository),
160
+ __metadata("design:type", Repository)
161
+ ], Project.prototype, "repository", void 0);
162
+ exports.Project = Project = __decorate([
163
+ (0, graphql_1.ObjectType)()
164
+ ], Project);
165
+ let Query = class Query {
166
+ listDirectory;
167
+ readFile;
168
+ };
169
+ exports.Query = Query;
170
+ __decorate([
171
+ (0, graphql_1.Field)(),
172
+ __metadata("design:type", Project)
173
+ ], Query.prototype, "listDirectory", void 0);
174
+ __decorate([
175
+ (0, graphql_1.Field)(),
176
+ __metadata("design:type", Project)
177
+ ], Query.prototype, "readFile", void 0);
178
+ exports.Query = Query = __decorate([
179
+ (0, graphql_1.ObjectType)()
180
+ ], Query);
181
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAAoD;AAG7C,IAAM,IAAI,GAAV,MAAM,IAAI;IAEf,IAAI,CAAS;IAGb,IAAI,CAAS;CACd,CAAA;AANY,oBAAI;AAEf;IADC,IAAA,eAAK,GAAE;;kCACK;AAGb;IADC,IAAA,eAAK,GAAE;;kCACK;eALF,IAAI;IADhB,IAAA,oBAAU,GAAE;GACA,IAAI,CAMhB;AAGM,IAAM,QAAQ,GAAd,MAAM,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AC;AAGvB;IADC,IAAA,eAAK,GAAE;8BACE,OAAO;uCAAC;gBALP,KAAK;IADjB,IAAA,oBAAU,GAAE;GACA,KAAK,CAMjB"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const axios_1 = require("axios");
4
+ const promises_1 = require("fs/promises");
5
+ const dotenv_1 = require("dotenv");
6
+ describe('cloudcmd test for the application', () => {
7
+ beforeAll(async () => {
8
+ (0, dotenv_1.config)();
9
+ await (0, promises_1.writeFile)(`${process.env.LOCAL_PATH}/test.txt`, 'content12345');
10
+ await new Promise((resolve) => setTimeout(resolve, 8000));
11
+ }, 10000);
12
+ afterAll(async () => {
13
+ await (0, promises_1.unlink)(`${process.env.LOCAL_PATH}/test.txt`);
14
+ await (0, promises_1.unlink)(`${process.env.LOCAL_PATH}/uploadTest.txt`);
15
+ }, 10000);
16
+ it('should return the correct directory that is set as root', async () => {
17
+ const response = await axios_1.default.get(`http://localhost:${process.env.PORT}${process.env.APOLLO_PATH}/files/api/v1/fs`, {
18
+ responseType: 'json',
19
+ });
20
+ console.log(response.data);
21
+ expect(response.data.path).toEqual('/');
22
+ expect(response.data.files[0].name).toEqual('common');
23
+ expect(response.data.files[1].name).toEqual('user1');
24
+ expect(response.data.files[2].name).toEqual('user2');
25
+ }, 10000);
26
+ it('should return the content of a file that is uplaoded to cloudcmd ', async () => {
27
+ const response = await axios_1.default.get(`http://localhost:${process.env.PORT}${process.env.APOLLO_PATH}/files/api/v1/fs/test.txt`);
28
+ expect(response.data).toEqual('content12345');
29
+ }, 10000);
30
+ it('should upload a file to cloudcmd', async () => {
31
+ const response = await axios_1.default.put(`http://localhost:${process.env.PORT}${process.env.APOLLO_PATH}/files/api/v1/fs/uploadTest.txt`, 'some content', { responseType: 'text' });
32
+ expect(response.data).toEqual('save: ok("uploadTest.txt")');
33
+ }, 10000);
34
+ });
35
+ //# sourceMappingURL=cloudcmd.sp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I,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACtD,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACrD,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACvD,CAAC,EAAE,KAAK,CAAC,CAAC;IAEV,EAAE,CAAC,mEAAmE,EAAE,KAAK,IAAI,EAAE;QACjF,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,GAAG,CAC9B,oBAAoB,OAAO,CAAC,GAAG,CAAC,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,2BAA2B,CAC1F,CAAC;QAEF,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;IAChD,CAAC,EAAE,KAAK,CAAC,CAAC;IAEV,EAAE,CAAC,kCAAkC,EAAE,KAAK,IAAI,EAAE;QAChD,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,GAAG,CAC9B,oBAAoB,OAAO,CAAC,GAAG,CAAC,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,iCAAiC,EAC/F,cAAc,EACd,EAAE,YAAY,EAAE,MAAM,EAAE,CACzB,CAAC;QAEF,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,4BAA4B,CAAC,CAAC;IAC9D,CAAC,EAAE,KAAK,CAAC,CAAC;AACZ,CAAC,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const testing_1 = require("@nestjs/testing");
4
+ const request = require("supertest");
5
+ const cross_fetch_1 = require("cross-fetch");
6
+ const client_1 = require("@apollo/client");
7
+ const app_module_1 = require("../../src/app.module");
8
+ const testUtil_1 = require("../testUtil");
9
+ const client = new client_1.ApolloClient({
10
+ link: new client_1.HttpLink({
11
+ uri: `http://localhost:${process.env.PORT}${process.env.APOLLO_PATH}`,
12
+ fetch: cross_fetch_1.default,
13
+ }),
14
+ cache: new client_1.InMemoryCache({ addTypename: false }),
15
+ });
16
+ describe('End to End test for the application', () => {
17
+ let app;
18
+ beforeAll(async () => {
19
+ const moduleFixture = await testing_1.Test.createTestingModule({
20
+ imports: [app_module_1.default],
21
+ }).compile();
22
+ app = moduleFixture.createNestApplication();
23
+ await app.init();
24
+ await app.listen(process.env.PORT);
25
+ await new Promise((resolve) => setTimeout(resolve, 4000));
26
+ }, 10000);
27
+ afterAll(async () => {
28
+ await app.close();
29
+ }, 10000);
30
+ async function HTTPQuery(query, expectedResponse) {
31
+ const response = await request(`http://localhost:${process.env.PORT}`)
32
+ .post(process.env.APOLLO_PATH)
33
+ .send({ query });
34
+ expect(response.body).toEqual(expectedResponse);
35
+ }
36
+ async function GraphQLQuery(query, expectedResponse) {
37
+ const { data } = await client.query({ query });
38
+ expect({ data }).toEqual(expectedResponse);
39
+ }
40
+ it('should return the directory contents requested with HTTP POST query', async () => {
41
+ await HTTPQuery(testUtil_1.e2elistDirectory, testUtil_1.expectedListDirectoryResponse);
42
+ }, 10000);
43
+ it('should return the file content requested with HTTP POST query', async () => {
44
+ await HTTPQuery(testUtil_1.e2eReadFile, testUtil_1.expectedFileContentResponse);
45
+ }, 10000);
46
+ it('should return the directory contents requested with GraphQL query', async () => {
47
+ await GraphQLQuery((0, client_1.gql)(testUtil_1.e2elistDirectory), testUtil_1.expectedListDirectoryResponse);
48
+ }, 10000);
49
+ it('should return the file content requested with GraphQL query', async () => {
50
+ await GraphQLQuery((0, client_1.gql)(testUtil_1.e2eReadFile), testUtil_1.expectedFileContentResponse);
51
+ }, 10000);
52
+ });
53
+ //# sourceMappingURL=app.e2e.spec.js.map
@@ -0,0 +1 @@
1
+ {"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ing_1 = require("@nestjs/testing");
4
+ const config_1 = require("@nestjs/config");
5
+ const files_resolver_1 = require("../../src/files/resolvers/files.resolver");
6
+ const files_service_factory_1 = require("../../src/files/services/files-service.factory");
7
+ const local_files_service_1 = require("../../src/files/services/local-files.service");
8
+ const testUtil_1 = require("../testUtil");
9
+ describe('Integration tests for FilesResolver', () => {
10
+ let filesResolver;
11
+ let mockConfigService;
12
+ beforeEach(async () => {
13
+ mockConfigService = new testUtil_1.MockConfigService();
14
+ const module = await testing_1.Test.createTestingModule({
15
+ providers: [
16
+ files_resolver_1.default,
17
+ files_service_factory_1.default,
18
+ local_files_service_1.default,
19
+ { provide: config_1.ConfigService, useClass: testUtil_1.MockConfigService },
20
+ ],
21
+ }).compile();
22
+ filesResolver = module.get(files_resolver_1.default);
23
+ });
24
+ afterEach(() => {
25
+ jest.clearAllMocks();
26
+ });
27
+ const modes = ['local'];
28
+ for (const mode of modes) {
29
+ describe(`when MODE is ${mode}`, () => {
30
+ beforeEach(() => {
31
+ jest.spyOn(mockConfigService, 'get').mockReturnValue(mode);
32
+ });
33
+ it('should be defined', () => {
34
+ expect(filesResolver).toBeDefined();
35
+ });
36
+ describe('listDirectory', () => {
37
+ it('should list files', async () => {
38
+ const files = await filesResolver.listDirectory(testUtil_1.pathToTestDirectory);
39
+ expect(files).toEqual(testUtil_1.testDirectory);
40
+ });
41
+ });
42
+ describe('readFile', () => {
43
+ it('should read file', async () => {
44
+ const content = await filesResolver.readFile(testUtil_1.pathToTestFileContent);
45
+ expect(content).toEqual(testUtil_1.testFileContent);
46
+ });
47
+ });
48
+ });
49
+ }
50
+ });
51
+ //# sourceMappingURL=files.service.integration.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.service.integration.spec.js","sourceRoot":"","sources":["../../../test/integration/files.service.integration.spec.ts"],"names":[],"mappings":";;AAAA,6CAAsD;AACtD,2CAA+C;AAC/C,6EAAqE;AACrE,0FAAiF;AACjF,sFAA6E;AAC7E,0CAMqB;AA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AC,wBAAa,CAAC,CAAC;gBACvC,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;YAEH,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE;gBACxB,EAAE,CAAC,kBAAkB,EAAE,KAAK,IAAI,EAAE;oBAChC,MAAM,OAAO,GAAG,MAAM,aAAa,CAAC,QAAQ,CAAC,gCAAqB,CAAC,CAAC;oBACpE,MAAM,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,0BAAe,CAAC,CAAC;gBAC3C,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC,CAAC"}
@@ -0,0 +1,88 @@
1
+ export declare const readFileActualContent: string[];
2
+ export declare const pathToTestDirectory = "user2";
3
+ export declare const testDirectory: {
4
+ repository: {
5
+ tree: {
6
+ blobs: {
7
+ edges: any[];
8
+ };
9
+ trees: {
10
+ edges: {
11
+ node: {
12
+ name: string;
13
+ type: string;
14
+ };
15
+ }[];
16
+ };
17
+ };
18
+ };
19
+ };
20
+ export declare const testFileName = "README.md";
21
+ export declare const fstestFileContent = "content123";
22
+ export declare const pathToTestFileContent = "user2/tools/README.md";
23
+ export declare const testFileArray: string[];
24
+ export declare const testFileContent: {
25
+ repository: {
26
+ blobs: {
27
+ nodes: {
28
+ name: string;
29
+ rawBlob: string;
30
+ rawTextBlob: string;
31
+ }[];
32
+ };
33
+ };
34
+ };
35
+ export declare function sleep(ms: any): void;
36
+ export declare class MockConfigService {
37
+ get(key: string): string;
38
+ }
39
+ export declare const mockReadFileResponseData: {
40
+ project: {
41
+ __typename: string;
42
+ repository: {
43
+ __typename: string;
44
+ blobs: {
45
+ nodes: {
46
+ __typename: string;
47
+ name: string;
48
+ rawBlob: string;
49
+ rawTextBlob: string;
50
+ }[];
51
+ };
52
+ };
53
+ };
54
+ };
55
+ export declare const expectedListDirectoryResponse: {
56
+ data: {
57
+ listDirectory: {
58
+ repository: {
59
+ tree: {
60
+ trees: {
61
+ edges: {
62
+ node: {
63
+ name: string;
64
+ };
65
+ }[];
66
+ };
67
+ };
68
+ };
69
+ };
70
+ };
71
+ };
72
+ export declare const expectedFileContentResponse: {
73
+ data: {
74
+ readFile: {
75
+ repository: {
76
+ blobs: {
77
+ nodes: {
78
+ name: string;
79
+ rawBlob: string;
80
+ rawTextBlob: string;
81
+ }[];
82
+ };
83
+ };
84
+ };
85
+ };
86
+ };
87
+ export declare const e2elistDirectory = "query {\n listDirectory(path:\"user2\")\n {\n repository{\n tree{\n trees{\n edges{\n node{\n name\n \n }\n }\n }\n }\n }\n }\n}";
88
+ export declare const e2eReadFile = "query {\n readFile(path:\"user2/tools/README.md\") {\n repository {\n blobs {\n nodes {\n name\n rawBlob\n rawTextBlob\n }\n }\n }\n }\n}";