@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
package/.env ADDED
@@ -0,0 +1,6 @@
1
+ PORT='4001'
2
+ MODE='local'
3
+ LOCAL_PATH ='/home/dtaas/Documents/git/into-cps/DTaaS/files'
4
+ LOG_LEVEL='debug'
5
+ APOLLO_PATH='/lib'
6
+ GRAPHQL_PLAYGROUND='true'
package/DEVELOPER.md CHANGED
@@ -37,16 +37,47 @@ APOLLO_PATH='/lib'
37
37
  GRAPHQL_PLAYGROUND='true'
38
38
  ```
39
39
 
40
- ## :package: :ship: NPM package
40
+ ## Service Endpoint
41
+
42
+ The URL endpoint for this microservice is located at: `localhost:PORT/lib`
43
+
44
+ The [API](./API.md) page shows sample queries and responses.
45
+
46
+ ## :package: :ship: Packages
47
+
48
+ ### Docker images
49
+
50
+ The docker version of lib microservice is packaged with the DTaaS
51
+ application release.
52
+ Please see [publishing](../../docker/README.md) page
53
+ for more information publishing docker images.
54
+
55
+ ### Default NPM Registry
56
+
57
+ The default registry for npm packages is [npmjs](https://registry.npmjs.org).
58
+
59
+ ```bash
60
+ sudo npm install -g @into-cps-association/libms
61
+ ```
62
+
63
+ The steps for publishing the package to npmjs are listed in
64
+ [npm packages](../../docs/developer/npm-packages.md) page.
41
65
 
42
- ### Github Package Registry
66
+ The libms is also published on this registry, usually per release
67
+ of the DTaaS application. The package on npmjs is more stable
68
+ than the package on github npm registry.
69
+
70
+ ### Github NPM Package Registry
43
71
 
44
72
  The Github actions workflow of
45
73
  [lib microservice](../../.github/workflows/lib-ms.yml) publishes the **libms**
46
74
  into
47
75
  [packages](https://github.com/orgs/INTO-CPS-Association/packages?repo_name=DTaaS).
48
76
 
49
- ### Verdaccio - Local Package Registry
77
+ A new libmspackage is published to github packages for each version
78
+ of libms microservice.
79
+
80
+ ### Verdaccio - Local NPM Package Registry
50
81
 
51
82
  Use the instructions in
52
83
  [publish npm package](../../docs/developer/npm-packages.md) for help
@@ -69,9 +100,3 @@ yarn publish #increments version, publishes to registry and adds a git tag
69
100
  ```bash
70
101
  npm unpublish --registry http://localhost:4873/ @into-cps-association/libms@0.2.0
71
102
  ```
72
-
73
- ## Service Endpoint
74
-
75
- The URL endpoint for this microservice is located at: `localhost:PORT/lib`
76
-
77
- The [API](./API.md) page shows sample queries and responses.
package/README.md CHANGED
@@ -8,7 +8,23 @@ It has two features:
8
8
 
9
9
  ## :arrow_down: Install
10
10
 
11
- The package is available in Github
11
+ ### Default NPM Registry
12
+
13
+ The default registry for npm packages is [npmjs](https://registry.npmjs.org).
14
+ Install the package with the following commands
15
+
16
+ ```bash
17
+ sudo npm install -g @into-cps-association/libms
18
+ ```
19
+
20
+ The package on [npmjs](https://registry.npmjs.org) is published
21
+ less frequently than the one on Github NPM Registry. But
22
+ the package on npmjs is more stable version of libms and should
23
+ be used for production purposes.
24
+
25
+ ### Github NPM Registry
26
+
27
+ The package is also available in Github
12
28
  [packages registry](https://github.com/orgs/INTO-CPS-Association/packages).
13
29
 
14
30
  Set the registry and install the package with the following commands
@@ -40,10 +56,10 @@ GRAPHQL_PLAYGROUND='false' or 'true'
40
56
 
41
57
  The `LOCAL_PATH` variable is the absolute filepath to the
42
58
  location of the local directory which will be served to users
43
- by the Library microservice. This
44
- [sample configuration file](./config/.env.default) can be used.
59
+ by the Library microservice.
45
60
 
46
61
  Replace the default values the appropriate values for your setup.
62
+ Please save this config in a file.
47
63
 
48
64
  ## :rocket: Use
49
65
 
@@ -105,14 +121,282 @@ libms -H FILE-PATH
105
121
  libms --http FILE-PATH
106
122
  ```
107
123
 
108
- A sample configuration is [available](./config/http.json).
124
+ <details>
125
+ <summary>Please see this sample HTTP config file</summary>
126
+
127
+ ```json
128
+ {
129
+ "name": "DTaaS Fileserver",
130
+ "auth": false,
131
+ "editor": "edward",
132
+ "packer": "zip",
133
+ "diff": true,
134
+ "zip": true,
135
+ "buffer": true,
136
+ "dirStorage": true,
137
+ "online": false,
138
+ "open": false,
139
+ "oneFilePanel": true,
140
+ "keysPanel": false,
141
+ "prefix": "/lib/files",
142
+ "confirmCopy": true,
143
+ "confirmMove": true,
144
+ "showConfig": false,
145
+ "showFileName": true,
146
+ "contact": false,
147
+ "configDialog": false,
148
+ "console": false,
149
+ "terminal": false,
150
+ "vim": false,
151
+ "columns": "name-size-date-owner-mode",
152
+ "export": false,
153
+ "import": false,
154
+ "dropbox": false,
155
+ "dropboxToken": "",
156
+ "log": true
157
+ }
158
+ ```
159
+
160
+ </details>
161
+
162
+ ## Application Programming Interface (API)
163
+
164
+ The lib microservice application provides services at
165
+ two end points:
166
+
167
+ ### HTTP protocol
109
168
 
110
- ### Accessible URLs
169
+ Endpoint: `localhost:PORT/lib/files`
111
170
 
112
- The microservice is available at:
171
+ This option needs to be enabled with `-H config.json` flag.
172
+ If enabled, the 'localhost:PORT/lib/files' becomes available.
173
+ The regular file upload and download options become available.
174
+ Here are sample screenshots.
175
+
176
+ ![top-level](top-level.png)
177
+
178
+ ![inside](inside.png)
179
+
180
+ ### GraphQL protocol
181
+
182
+ Endpoint: `localhost:PORT/lib`
183
+
184
+ <details>
185
+ <summary>GraphQL API details</summary>
186
+ The lib microservice takes two distinct GraphQL queries.
187
+
188
+ #### Directory Listing
189
+
190
+ This query receives directory path and provides list of files
191
+ in that directory. A sample query and response are given here.
192
+
193
+ ``` graphql
194
+ query {
195
+ listDirectory(path: "user1") {
196
+ repository {
197
+ tree {
198
+ blobs {
199
+ edges {
200
+ node {
201
+ name
202
+ type
203
+ }
204
+ }
205
+ }
206
+ trees {
207
+ edges {
208
+ node {
209
+ name
210
+ type
211
+ }
212
+ }
213
+ }
214
+ }
215
+ }
216
+ }
217
+ }
218
+ ```
219
+
220
+ ``` graphql
221
+ {
222
+ "data": {
223
+ "listDirectory": {
224
+ "repository": {
225
+ "tree": {
226
+ "blobs": {
227
+ "edges": []
228
+ },
229
+ "trees": {
230
+ "edges": [
231
+ {
232
+ "node": {
233
+ "name": "common",
234
+ "type": "tree"
235
+ }
236
+ },
237
+ {
238
+ "node": {
239
+ "name": "data",
240
+ "type": "tree"
241
+ }
242
+ },
243
+ {
244
+ "node": {
245
+ "name": "digital twins",
246
+ "type": "tree"
247
+ }
248
+ },
249
+ {
250
+ "node": {
251
+ "name": "functions",
252
+ "type": "tree"
253
+ }
254
+ },
255
+ {
256
+ "node": {
257
+ "name": "models",
258
+ "type": "tree"
259
+ }
260
+ },
261
+ {
262
+ "node": {
263
+ "name": "tools",
264
+ "type": "tree"
265
+ }
266
+ }
267
+ ]
268
+ }
269
+ }
270
+ }
271
+ }
272
+ }
273
+ }
274
+ ```
275
+
276
+ #### Fetch a File
277
+
278
+ This query receives directory path and send the file contents to user in response.
279
+
280
+ To check this query, create a file `files/user2/data/welcome.txt`
281
+ with content of `hello world`.
282
+
283
+ A sample query and response are given here.
284
+
285
+ ```graphql
286
+ query {
287
+ readFile(path: "user2/data/sample.txt") {
288
+ repository {
289
+ blobs {
290
+ nodes {
291
+ name
292
+ rawBlob
293
+ rawTextBlob
294
+ }
295
+ }
296
+ }
297
+ }
298
+ }
299
+ ```
113
300
 
114
- **GraphQL protocol**: 'localhost:PORT/lib'
115
- **HTTP protocol**: 'localhost:PORT/lib/files'
301
+ ```graphql
302
+ {
303
+ "data": {
304
+ "readFile": {
305
+ "repository": {
306
+ "blobs": {
307
+ "nodes": [
308
+ {
309
+ "name": "sample.txt",
310
+ "rawBlob": "hello world",
311
+ "rawTextBlob": "hello world"
312
+ }
313
+ ]
314
+ }
315
+ }
316
+ }
317
+ }
318
+ }
319
+ ```
320
+
321
+ ### Direct HTTP API Calls in lieu of GraphQL API Calls
322
+
323
+ The lib microservice also supports making API calls using HTTP POST requests.
324
+ Simply send a POST request to the URL endpoint with the GraphQL query in
325
+ the request body. Make sure to set the Content-Type header to
326
+ "application/json".
327
+
328
+ The easiest way to perform HTTP requests is to use
329
+ [HTTPie](https://github.com/httpie/desktop/releases)
330
+ desktop application.
331
+ You can download the Ubuntu AppImage and run it. Select the following options:
332
+
333
+ ```txt
334
+ Method: POST
335
+ URL: localhost:4001
336
+ Body: <<copy the json code from examples below>>
337
+ Content Type: text/json
338
+ ```
339
+
340
+ Here are examples of the HTTP requests and responses for the HTTP API calls.
341
+
342
+ #### Directory listing
343
+
344
+ <!-- markdownlint-disable MD013 -->
345
+
346
+ ```http
347
+ POST /lib HTTP/1.1
348
+ Host: localhost:4001
349
+ Content-Type: application/json
350
+ Content-Length: 388
351
+
352
+ {
353
+ "query":"query {\n listDirectory(path: \"user1\") {\n repository {\n tree {\n blobs {\n edges {\n node {\n name\n type\n }\n }\n }\n trees {\n edges {\n node {\n name\n type\n }\n }\n }\n }\n }\n }\n}"
354
+ }
355
+ ```
356
+
357
+ This HTTP POST request will generate the following HTTP response message.
358
+
359
+ ```http
360
+ HTTP/1.1 200 OK
361
+ Access-Control-Allow-Origin: *
362
+ Connection: close
363
+ Content-Length: 306
364
+ Content-Type: application/json; charset=utf-8
365
+ Date: Tue, 26 Sep 2023 20:26:49 GMT
366
+ X-Powered-By: Express
367
+
368
+ {"data":{"listDirectory":{"repository":{"tree":{"blobs":{"edges":[]},"trees":{"edges":[{"node":{"name":"data","type":"tree"}},{"node":{"name":"digital twins","type":"tree"}},{"node":{"name":"functions","type":"tree"}},{"node":{"name":"models","type":"tree"}},{"node":{"name":"tools","type":"tree"}}]}}}}}}
369
+ ```
370
+
371
+ #### Fetch a file
372
+
373
+ This query receives directory path and send the file contents to user in response.
374
+
375
+ To check this query, create a file `files/user2/data/welcome.txt`
376
+ with content of `hello world`.
377
+
378
+ ```http
379
+ POST /lib HTTP/1.1
380
+ Host: localhost:4001
381
+ Content-Type: application/json
382
+ Content-Length: 217
383
+
384
+ {
385
+ "query":"query {\n readFile(path: \"user2/data/welcome.txt\") {\n repository {\n blobs {\n nodes {\n name\n rawBlob\n rawTextBlob\n }\n }\n }\n }\n}"
386
+ }
387
+ ```
388
+
389
+ ```http
390
+ HTTP/1.1 200 OK
391
+ Access-Control-Allow-Origin: *
392
+ Connection: close
393
+ Content-Length: 134
394
+ Content-Type: application/json; charset=utf-8
395
+ Date: Wed, 27 Sep 2023 09:17:18 GMT
396
+ X-Powered-By: Express
397
+
398
+ {"data":{"readFile":{"repository":{"blobs":{"nodes":[{"name":"welcome.txt","rawBlob":"hello world","rawTextBlob":"hello world"}]}}}}}
399
+ ```
116
400
 
117
- <!-- markdownlint-disable-next-line MD013 -->
118
- The [API](https://into-cps-association.github.io/DTaaS/development/user/servers/lib/LIB-MS.html) page shows sample queries and responses.
401
+ <!-- markdownlint-enable MD013 -->
402
+ </details>
@@ -1,6 +1,6 @@
1
1
  PORT='4001'
2
2
  MODE='local'
3
- LOCAL_PATH ='/Users/<Username>/DTaaS/files'
3
+ LOCAL_PATH ='/dtaas/libms/files'
4
4
  LOG_LEVEL='debug'
5
5
  APOLLO_PATH='/lib'
6
6
  GRAPHQL_PLAYGROUND='true'
@@ -0,0 +1,2 @@
1
+ export default class AppModule {
2
+ }
@@ -0,0 +1,36 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ const config_1 = require("@nestjs/config");
10
+ const common_1 = require("@nestjs/common");
11
+ const graphql_1 = require("@nestjs/graphql");
12
+ const apollo_1 = require("@nestjs/apollo");
13
+ const path_1 = require("path");
14
+ const files_module_1 = require("./files/files.module");
15
+ let AppModule = class AppModule {
16
+ };
17
+ AppModule = __decorate([
18
+ (0, common_1.Module)({
19
+ imports: [
20
+ config_1.ConfigModule.forRoot({
21
+ isGlobal: true,
22
+ }),
23
+ graphql_1.GraphQLModule.forRootAsync({
24
+ driver: apollo_1.ApolloDriver,
25
+ useFactory: (configService) => ({
26
+ autoSchemaFile: (0, path_1.join)(process.cwd(), 'src/schema.gql'),
27
+ path: configService.get('APOLLO_PATH'),
28
+ }),
29
+ inject: [config_1.ConfigService],
30
+ }),
31
+ files_module_1.default,
32
+ ],
33
+ })
34
+ ], AppModule);
35
+ exports.default = AppModule;
36
+ //# sourceMappingURL=app.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.module.js","sourceRoot":"","sources":["../../src/app.module.ts"],"names":[],"mappings":";;;;;;;;AAAA,2CAA6D;AAC7D,2CAAwC;AACxC,6CAAgD;AAChD,2CAA8C;AAC9C,+BAA4B;AAC5B,uDAA+C;AAkBhC,IAAM,SAAS,GAAf,MAAM,SAAS;CAAG,CAAA;AAAZ,SAAS;IAhB7B,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,qBAAY,CAAC,OAAO,CAAC;gBACnB,QAAQ,EAAE,IAAI;aACf,CAAC;YACF,uBAAa,CAAC,YAAY,CAAC;gBACzB,MAAM,EAAE,qBAAY;gBACpB,UAAU,EAAE,CAAC,aAA4B,EAAE,EAAE,CAAC,CAAC;oBAC7C,cAAc,EAAE,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,gBAAgB,CAAC;oBACrD,IAAI,EAAE,aAAa,CAAC,GAAG,CAAS,aAAa,CAAC;iBAC/C,CAAC;gBACF,MAAM,EAAE,CAAC,sBAAa,CAAC;aACxB,CAAC;YACF,sBAAW;SACZ;KACF,CAAC;GACmB,SAAS,CAAG;kBAAZ,SAAS"}
@@ -0,0 +1,7 @@
1
+ type BootstrapOptions = {
2
+ config?: string;
3
+ httpServer?: string;
4
+ runHelp?: CallableFunction;
5
+ };
6
+ export default function bootstrap(options?: BootstrapOptions): Promise<void>;
7
+ export {};
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@nestjs/core");
4
+ const config_1 = require("@nestjs/config");
5
+ const dotenv = require("dotenv");
6
+ const app_module_1 = require("./app.module");
7
+ const cloudcmd_1 = require("./cloudcmd/cloudcmd");
8
+ async function bootstrap(options) {
9
+ const configFile = dotenv.config({
10
+ path: options?.config ?? '.env',
11
+ override: true,
12
+ });
13
+ if (configFile.error) {
14
+ console.error(configFile.error);
15
+ if (options.runHelp) {
16
+ options.runHelp();
17
+ }
18
+ else {
19
+ process.exit(1);
20
+ }
21
+ }
22
+ const app = await core_1.NestFactory.create(app_module_1.default);
23
+ const configService = app.get(config_1.ConfigService);
24
+ const port = configService.get('PORT');
25
+ if (options.httpServer) {
26
+ (0, cloudcmd_1.default)(app, options.httpServer, configService.get('LOCAL_PATH'));
27
+ }
28
+ await app.listen(port);
29
+ }
30
+ exports.default = bootstrap;
31
+ //# sourceMappingURL=bootstrap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../../src/bootstrap.ts"],"names":[],"mappings":";;AAAA,uCAA2C;AAC3C,2CAA+C;AAC/C,iCAAiC;AACjC,6CAAqC;AACrC,kDAA2C;AAQ5B,KAAK,UAAU,SAAS,CAAC,OAA0B;IAChE,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC;QAC/B,IAAI,EAAE,OAAO,EAAE,MAAM,IAAI,MAAM;QAC/B,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC;IACH,IAAI,UAAU,CAAC,KAAK,EAAE,CAAC;QAErB,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAChC,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YACpB,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;IAED,MAAM,GAAG,GAAG,MAAM,kBAAW,CAAC,MAAM,CAAC,oBAAS,CAAC,CAAC;IAChD,MAAM,aAAa,GAAG,GAAG,CAAC,GAAG,CAAC,sBAAa,CAAC,CAAC;IAC7C,MAAM,IAAI,GAAG,aAAa,CAAC,GAAG,CAAS,MAAM,CAAC,CAAC;IAE/C,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;QACvB,IAAA,kBAAQ,EAAC,GAAG,EAAE,OAAO,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,CAAS,YAAY,CAAC,CAAC,CAAC;IAC7E,CAAC;IAED,MAAM,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC;AAxBD,4BAwBC"}
@@ -0,0 +1,3 @@
1
+ import { INestApplication } from '@nestjs/common';
2
+ declare const runCloudCMD: (app: INestApplication, optionsPath: string, filesPath: string) => void;
3
+ export default runCloudCMD;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const socket_io_1 = require("socket.io");
4
+ const cloudcmd = require("cloudcmd");
5
+ const path_1 = require("path");
6
+ const runCloudCMD = (app, optionsPath, filesPath) => {
7
+ const { createConfigManager } = cloudcmd;
8
+ const configManager = createConfigManager({
9
+ configPath: (0, path_1.join)(process.cwd(), optionsPath),
10
+ });
11
+ configManager('root', filesPath);
12
+ const server = app.getHttpServer();
13
+ const socket = new socket_io_1.Server(server, {
14
+ path: `${configManager('prefix')}/socket.io`,
15
+ });
16
+ app.use(configManager('prefix'), cloudcmd({
17
+ configManager,
18
+ socket,
19
+ }));
20
+ };
21
+ exports.default = runCloudCMD;
22
+ //# sourceMappingURL=cloudcmd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cloudcmd.js","sourceRoot":"","sources":["../../../src/cloudcmd/cloudcmd.ts"],"names":[],"mappings":";;AACA,yCAAmC;AACnC,qCAAqC;AACrC,+BAA4B;AAE5B,MAAM,WAAW,GAAG,CAClB,GAAqB,EACrB,WAAmB,EACnB,SAAiB,EACjB,EAAE;IACF,MAAM,EAAE,mBAAmB,EAAE,GAAG,QAAQ,CAAC;IACzC,MAAM,aAAa,GAAG,mBAAmB,CAAC;QACxC,UAAU,EAAE,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,WAAW,CAAC;KAC7C,CAAC,CAAC;IAEH,aAAa,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAEjC,MAAM,MAAM,GAAG,GAAG,CAAC,aAAa,EAAE,CAAC;IAEnC,MAAM,MAAM,GAAG,IAAI,kBAAM,CAAC,MAAM,EAAE;QAChC,IAAI,EAAE,GAAG,aAAa,CAAC,QAAQ,CAAC,YAAY;KAC7C,CAAC,CAAC;IACH,GAAG,CAAC,GAAG,CACL,aAAa,CAAC,QAAQ,CAAC,EACvB,QAAQ,CAAC;QACP,aAAa;QACb,MAAM;KACP,CAAC,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,WAAW,CAAC"}
@@ -0,0 +1,2 @@
1
+ export default class FilesModule {
2
+ }
@@ -0,0 +1,21 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ const common_1 = require("@nestjs/common");
10
+ const files_resolver_1 = require("./resolvers/files.resolver");
11
+ const files_service_factory_1 = require("./services/files-service.factory");
12
+ const local_files_service_1 = require("./services/local-files.service");
13
+ let FilesModule = class FilesModule {
14
+ };
15
+ FilesModule = __decorate([
16
+ (0, common_1.Module)({
17
+ providers: [files_resolver_1.default, local_files_service_1.default, files_service_factory_1.default],
18
+ })
19
+ ], FilesModule);
20
+ exports.default = FilesModule;
21
+ //# sourceMappingURL=files.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.module.js","sourceRoot":"","sources":["../../../src/files/files.module.ts"],"names":[],"mappings":";;;;;;;;AAAA,2CAAwC;AACxC,+DAAuD;AACvD,4EAAmE;AACnE,wEAA+D;AAKhD,IAAM,WAAW,GAAjB,MAAM,WAAW;CAAG,CAAA;AAAd,WAAW;IAH/B,IAAA,eAAM,EAAC;QACN,SAAS,EAAE,CAAC,wBAAa,EAAE,6BAAiB,EAAE,+BAAmB,CAAC;KACnE,CAAC;GACmB,WAAW,CAAG;kBAAd,WAAW"}
@@ -0,0 +1,5 @@
1
+ import { Project } from 'src/types';
2
+ export interface IFilesService {
3
+ listDirectory(path: string): Promise<Project>;
4
+ readFile(path: string): Promise<Project>;
5
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=files.service.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.service.interface.js","sourceRoot":"","sources":["../../../../src/files/interfaces/files.service.interface.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ import FilesServiceFactory from '../services/files-service.factory';
2
+ import { Project } from '../../types';
3
+ export default class FilesResolver {
4
+ private readonly filesService;
5
+ constructor(filesServiceFactory: FilesServiceFactory);
6
+ listDirectory(path: string): Promise<Project>;
7
+ readFile(path: string): Promise<Project>;
8
+ }
@@ -0,0 +1,49 @@
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 graphql_1 = require("@nestjs/graphql");
16
+ const files_service_factory_1 = require("../services/files-service.factory");
17
+ const types_1 = require("../../types");
18
+ let FilesResolver = class FilesResolver {
19
+ filesService;
20
+ constructor(filesServiceFactory) {
21
+ this.filesService = filesServiceFactory.create();
22
+ }
23
+ async listDirectory(path) {
24
+ return this.filesService.listDirectory(path);
25
+ }
26
+ async readFile(path) {
27
+ return this.filesService.readFile(path);
28
+ }
29
+ };
30
+ __decorate([
31
+ (0, graphql_1.Query)(() => types_1.Project),
32
+ __param(0, (0, graphql_1.Args)('path')),
33
+ __metadata("design:type", Function),
34
+ __metadata("design:paramtypes", [String]),
35
+ __metadata("design:returntype", Promise)
36
+ ], FilesResolver.prototype, "listDirectory", null);
37
+ __decorate([
38
+ (0, graphql_1.Query)(() => types_1.Project),
39
+ __param(0, (0, graphql_1.Args)('path')),
40
+ __metadata("design:type", Function),
41
+ __metadata("design:paramtypes", [String]),
42
+ __metadata("design:returntype", Promise)
43
+ ], FilesResolver.prototype, "readFile", null);
44
+ FilesResolver = __decorate([
45
+ (0, graphql_1.Resolver)(),
46
+ __metadata("design:paramtypes", [files_service_factory_1.default])
47
+ ], FilesResolver);
48
+ exports.default = FilesResolver;
49
+ //# sourceMappingURL=files.resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.resolver.js","sourceRoot":"","sources":["../../../../src/files/resolvers/files.resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,6CAAwD;AAExD,6EAAoE;AACpE,uCAAsC;AAGvB,IAAM,aAAa,GAAnB,MAAM,aAAa;IACf,YAAY,CAAgB;IAE7C,YAAY,mBAAwC;QAClD,IAAI,CAAC,YAAY,GAAG,mBAAmB,CAAC,MAAM,EAAE,CAAC;IACnD,CAAC;IAGK,AAAN,KAAK,CAAC,aAAa,CAAe,IAAY;QAC5C,OAAO,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAC/C,CAAC;IAGK,AAAN,KAAK,CAAC,QAAQ,CAAe,IAAY;QACvC,OAAO,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;CACF,CAAA;AARO;IADL,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,eAAO,CAAC;IACA,WAAA,IAAA,cAAI,EAAC,MAAM,CAAC,CAAA;;;;kDAEhC;AAGK;IADL,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,eAAO,CAAC;IACL,WAAA,IAAA,cAAI,EAAC,MAAM,CAAC,CAAA;;;;6CAE3B;AAfkB,aAAa;IADjC,IAAA,kBAAQ,GAAE;qCAIwB,+BAAmB;GAHjC,aAAa,CAgBjC;kBAhBoB,aAAa"}
@@ -0,0 +1,9 @@
1
+ import { ConfigService } from '@nestjs/config';
2
+ import { IFilesService } from '../interfaces/files.service.interface';
3
+ import LocalFilesService from './local-files.service';
4
+ export default class FilesServiceFactory {
5
+ private configService;
6
+ private localFilesService;
7
+ constructor(configService: ConfigService, localFilesService: LocalFilesService);
8
+ create(): IFilesService;
9
+ }