@into-cps-association/libms 0.3.1 → 0.4.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.
- package/.env +0 -3
- package/DEVELOPER.md +24 -7
- package/README.md +42 -43
- package/config/.env.default +6 -0
- package/config/http.json +30 -0
- package/dist/src/bootstrap.d.ts +1 -0
- package/dist/src/bootstrap.js +4 -0
- package/dist/src/bootstrap.js.map +1 -1
- package/dist/src/cloudcmd/cloudcmd.d.ts +3 -0
- package/dist/src/cloudcmd/cloudcmd.js +22 -0
- package/dist/src/cloudcmd/cloudcmd.js.map +1 -0
- package/dist/src/files/files.module.js +1 -7
- package/dist/src/files/files.module.js.map +1 -1
- package/dist/src/files/services/files-service.factory.d.ts +1 -3
- package/dist/src/files/services/files-service.factory.js +2 -10
- package/dist/src/files/services/files-service.factory.js.map +1 -1
- package/dist/src/files/services/local-files.service.js +2 -2
- package/dist/src/main.js +8 -8
- package/dist/src/main.js.map +1 -1
- package/dist/test/cloudcmd/cloudcmd.spec.js +35 -0
- package/dist/test/cloudcmd/cloudcmd.spec.js.map +1 -0
- package/dist/test/e2e/app.e2e.spec.js +27 -10
- package/dist/test/e2e/app.e2e.spec.js.map +1 -1
- package/dist/test/integration/files.service.integration.spec.js +1 -3
- package/dist/test/integration/files.service.integration.spec.js.map +1 -1
- package/dist/test/testUtil.js +1 -10
- package/dist/test/testUtil.js.map +1 -1
- package/dist/test/unit/files-service.factory.unit.spec.js +0 -8
- package/dist/test/unit/files-service.factory.unit.spec.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +37 -27
- package/pm2.config.js +10 -0
- package/src/bootstrap.ts +8 -0
- package/src/cloudcmd/cloudcmd.ts +32 -0
- package/src/files/files.module.ts +1 -7
- package/src/files/services/files-service.factory.ts +0 -5
- package/src/files/services/local-files.service.ts +2 -2
- package/src/main.ts +12 -7
- package/test/cloudcmd/cloudcmd.spec.ts +52 -0
- package/test/coverage/clover.xml +14 -19
- package/test/coverage/coverage-final.json +1 -1
- package/test/coverage/lcov-report/base.css +261 -123
- package/test/coverage/lcov-report/index.html +13 -13
- package/test/coverage/lcov-report/prettify.css +101 -1
- package/test/coverage/lcov-report/testUtil.ts.html +8 -35
- package/test/coverage/lcov.info +10 -19
- package/test/e2e/app.e2e.spec.ts +42 -42
- package/test/integration/files.service.integration.spec.ts +1 -3
- package/test/testUtil.ts +1 -10
- package/test/unit/files-service.factory.unit.spec.ts +0 -9
- package/tsconfig.json +1 -1
- package/dist/src/files/queries.d.ts +0 -2
- package/dist/src/files/queries.js +0 -47
- package/dist/src/files/queries.js.map +0 -1
- package/dist/src/files/services/gitlab-files.service.d.ts +0 -12
- package/dist/src/files/services/gitlab-files.service.js +0 -65
- package/dist/src/files/services/gitlab-files.service.js.map +0 -1
- package/dist/test/unit/gitlab-files.service.unit.spec.js +0 -37
- package/dist/test/unit/gitlab-files.service.unit.spec.js.map +0 -1
- package/src/files/queries.ts +0 -42
- package/src/files/services/gitlab-files.service.ts +0 -65
- package/test/starttraefik.bash +0 -11
- package/test/stoptraefik.bash +0 -9
- package/test/unit/gitlab-files.service.unit.spec.ts +0 -46
- /package/dist/test/{unit/gitlab-files.service.unit.spec.d.ts → cloudcmd/cloudcmd.spec.d.ts} +0 -0
package/.env
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
PORT='4001'
|
|
2
2
|
MODE='local'
|
|
3
3
|
LOCAL_PATH ='/home/prasad/git/prasadtalasila/DTaaS/files'
|
|
4
|
-
GITLAB_GROUP ='dtaas'
|
|
5
|
-
GITLAB_URL='https://gitlab.foo.com/api/graphql'
|
|
6
|
-
TOKEN='glpat-xFagGa33EW7bWpsM5q-Z'
|
|
7
4
|
LOG_LEVEL='debug'
|
|
8
5
|
APOLLO_PATH='/lib'
|
|
9
6
|
GRAPHQL_PLAYGROUND='true'
|
package/DEVELOPER.md
CHANGED
|
@@ -10,32 +10,49 @@ file. Please see [README](./README.md) for this information.
|
|
|
10
10
|
```bash
|
|
11
11
|
yarn install # Install dependencies for the microservice
|
|
12
12
|
yarn syntax # Analyze code for errors and style issues
|
|
13
|
+
yarn format #format .ts[x] and .js[x] files with prettier
|
|
13
14
|
yarn graph # Generate dependency graphs in the code
|
|
14
15
|
yarn build # Compile ES6 to ES5 and copy JS files to build/ directory
|
|
15
|
-
yarn test:unit # Run
|
|
16
|
-
yarn test:e2e # Run end-to-end tests
|
|
16
|
+
yarn test:unit # Run unit tests
|
|
17
17
|
yarn test:int # Run integration tests
|
|
18
|
-
yarn test:
|
|
18
|
+
yarn test:e2e # Run end-to-end tests
|
|
19
|
+
yarn test:http # Run tests for HTTP file service provided by cloudcmd
|
|
20
|
+
yarn test:all # Run all tests except http tests
|
|
19
21
|
yarn start -h # List of all the CLI commands
|
|
20
22
|
yarn start # Start the application
|
|
23
|
+
yarn start:pm2 # Start the application with process manager 2
|
|
24
|
+
yarn stop:pm2 # Stop the application managed by process manager 2
|
|
21
25
|
yarn clean # Deletes "build", "coverage", "dist" and other temp files
|
|
22
26
|
```
|
|
23
27
|
|
|
28
|
+
**NOTE:** The integration, end-to-end and http tests require a valid
|
|
29
|
+
`.env` file. Here is a sample file.
|
|
30
|
+
|
|
31
|
+
```ini
|
|
32
|
+
PORT='4001'
|
|
33
|
+
MODE='local'
|
|
34
|
+
LOCAL_PATH ='/Users/<Username>/DTaaS/files'
|
|
35
|
+
LOG_LEVEL='debug'
|
|
36
|
+
APOLLO_PATH='/lib'
|
|
37
|
+
GRAPHQL_PLAYGROUND='true'
|
|
38
|
+
```
|
|
39
|
+
|
|
24
40
|
## :package: :ship: NPM package
|
|
25
41
|
|
|
26
42
|
### Github Package Registry
|
|
27
43
|
|
|
28
44
|
The Github actions workflow of
|
|
29
|
-
[lib microservice](../../.github/workflows/lib-ms.yml) publishes the
|
|
30
|
-
into
|
|
45
|
+
[lib microservice](../../.github/workflows/lib-ms.yml) publishes the **libms**
|
|
46
|
+
into
|
|
47
|
+
[packages](https://github.com/orgs/INTO-CPS-Association/packages?repo_name=DTaaS).
|
|
31
48
|
|
|
32
49
|
### Verdaccio - Local Package Registry
|
|
33
50
|
|
|
34
51
|
Use the instructions in
|
|
35
52
|
[publish npm package](../../docs/developer/npm-packages.md) for help
|
|
36
|
-
with publishing
|
|
53
|
+
with publishing **libms npm package** in local computer.
|
|
37
54
|
|
|
38
|
-
Application of the advice given on that page for
|
|
55
|
+
Application of the advice given on that page for **libms** will require
|
|
39
56
|
running the following commands.
|
|
40
57
|
|
|
41
58
|
### Publish
|
package/README.md
CHANGED
|
@@ -1,28 +1,10 @@
|
|
|
1
1
|
# Overview
|
|
2
2
|
|
|
3
3
|
The **lib microservice** is a simplified file manager providing graphQL API.
|
|
4
|
-
It has
|
|
4
|
+
It has two features:
|
|
5
5
|
|
|
6
6
|
* provide a listing of directory contents.
|
|
7
7
|
* transfer a file to user.
|
|
8
|
-
* Source files can either come from local file system or from a gitlab instance.
|
|
9
|
-
|
|
10
|
-
## Gitlab setup
|
|
11
|
-
|
|
12
|
-
For this microserivce to be functional,
|
|
13
|
-
a certain directory or gitlab project structure is expected.
|
|
14
|
-
The microservice expects that the gitlab consisting of one group, dtaas (by convention),
|
|
15
|
-
and within that group, all of the projects be located,
|
|
16
|
-
**user1**, **user2**, ... , as well as a **commons** projects.
|
|
17
|
-
Each project corresponds to files of one user.
|
|
18
|
-
A sample file structure can be seen in [gitlab dtaas group](https://gitlab.com/dtaas).
|
|
19
|
-
You can visit the gitlab documentation on
|
|
20
|
-
[groups](https://docs.gitlab.com/ee/user/group/)
|
|
21
|
-
for help on the management of gitlab groups.
|
|
22
|
-
|
|
23
|
-
You can clone the git repositories from
|
|
24
|
-
the [gitlab dtaas](https://gitlab.com/dtaas) group
|
|
25
|
-
to get a sample file system structure for the lib microservice.
|
|
26
8
|
|
|
27
9
|
## :arrow_down: Install
|
|
28
10
|
|
|
@@ -51,9 +33,6 @@ The template configuration file is:
|
|
|
51
33
|
PORT='4001'
|
|
52
34
|
MODE='local' or 'gitlab'
|
|
53
35
|
LOCAL_PATH ='/Users/<Username>/DTaaS/files'
|
|
54
|
-
GITLAB_GROUP ='dtaas'
|
|
55
|
-
GITLAB_URL='https://gitlab.com/api/graphql'
|
|
56
|
-
TOKEN='123-sample-token'
|
|
57
36
|
LOG_LEVEL='debug'
|
|
58
37
|
APOLLO_PATH='/lib' or ''
|
|
59
38
|
GRAPHQL_PLAYGROUND='false' or 'true'
|
|
@@ -61,34 +40,34 @@ GRAPHQL_PLAYGROUND='false' or 'true'
|
|
|
61
40
|
|
|
62
41
|
The `LOCAL_PATH` variable is the absolute filepath to the
|
|
63
42
|
location of the local directory which will be served to users
|
|
64
|
-
by the Library microservice.
|
|
65
|
-
|
|
66
|
-
The `GITLAB_URL`, `GITLAB_GROUP` and `TOKEN` are only relevant for `gitlab` mode.
|
|
67
|
-
The `TOKEN` should be set to your GitLab Group access API token.
|
|
68
|
-
For more information on how to create and use your access token,
|
|
69
|
-
[gitlab page](https://docs.gitlab.com/ee/user/group/settings/group_access_tokens.html).
|
|
70
|
-
|
|
71
|
-
Once you've generated a token, copy it and replace
|
|
72
|
-
the value of `TOKEN` with your token for the gitlab group,
|
|
43
|
+
by the Library microservice. This
|
|
44
|
+
[sample configuration file](./config/.env.default) can be used.
|
|
73
45
|
|
|
74
46
|
Replace the default values the appropriate values for your setup.
|
|
75
47
|
|
|
76
|
-
**NOTE**:
|
|
77
|
-
|
|
78
|
-
1. When \__MODE=local_, only _LOCAL_PATH_ is used.
|
|
79
|
-
Other environment variables are unused.
|
|
80
|
-
1. When _MODE=gitlab_, _GITLAB_URL, TOKEN_,
|
|
81
|
-
and _GITLAB_GROUP_ are used; _LOCAL_PATH_ is unused.
|
|
82
|
-
|
|
83
48
|
## :rocket: Use
|
|
84
49
|
|
|
85
50
|
Display help.
|
|
86
51
|
|
|
87
52
|
```bash
|
|
88
|
-
libms -h
|
|
53
|
+
$libms -h
|
|
54
|
+
Usage: libms [options]
|
|
55
|
+
|
|
56
|
+
The lib microservice is a file server. It supports file transfer
|
|
57
|
+
over GraphQL and HTTP protocols.
|
|
58
|
+
|
|
59
|
+
Options:
|
|
60
|
+
-c, --config <file> provide the config file (default .env)
|
|
61
|
+
-H, --http <file> enable the HTTP server with the specified config
|
|
62
|
+
-h, --help display help for libms
|
|
89
63
|
```
|
|
90
64
|
|
|
91
|
-
|
|
65
|
+
Both the options are not mandatory.
|
|
66
|
+
|
|
67
|
+
### Configuration file
|
|
68
|
+
|
|
69
|
+
The config is saved `.env` file by convention. If `-c` is not specified
|
|
70
|
+
The **libms** looks for
|
|
92
71
|
`.env` file in the working directory from which it is run.
|
|
93
72
|
If you want to run **libms** without explicitly specifying the configuration
|
|
94
73
|
file, run
|
|
@@ -105,15 +84,35 @@ libms --config FILE-PATH
|
|
|
105
84
|
```
|
|
106
85
|
|
|
107
86
|
If the environment file is named something other than `.env`,
|
|
108
|
-
for example as
|
|
87
|
+
for example as `config/.env.default`, you can run
|
|
109
88
|
|
|
110
89
|
```sh
|
|
111
|
-
libms -c "
|
|
90
|
+
libms -c "config/.env.default"
|
|
112
91
|
```
|
|
113
92
|
|
|
114
93
|
You can press `Ctl+C` to halt the application.
|
|
115
94
|
|
|
116
|
-
|
|
95
|
+
### Protocol Support
|
|
96
|
+
|
|
97
|
+
The **libms** supports GraphQL protocol by default.
|
|
98
|
+
It is possible to enable the HTTP protocol by setting
|
|
99
|
+
the `-H` option.
|
|
100
|
+
|
|
101
|
+
To run **libms** with a custom config for HTTP protocol, use
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
libms -H FILE-PATH
|
|
105
|
+
libms --http FILE-PATH
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
A sample configuration is [available](./config/http.json).
|
|
109
|
+
|
|
110
|
+
### Accessible URLs
|
|
111
|
+
|
|
112
|
+
The microservice is available at:
|
|
113
|
+
|
|
114
|
+
**GraphQL protocol**: 'localhost:PORT/lib'
|
|
115
|
+
**HTTP protocol**: 'localhost:PORT/lib/files'
|
|
117
116
|
|
|
118
117
|
<!-- markdownlint-disable-next-line MD013 -->
|
|
119
118
|
The [API](https://into-cps-association.github.io/DTaaS/development/user/servers/lib/LIB-MS.html) page shows sample queries and responses.
|
package/config/http.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "DTaaS Fileserver",
|
|
3
|
+
"auth": false,
|
|
4
|
+
"editor": "edward",
|
|
5
|
+
"packer": "zip",
|
|
6
|
+
"diff": true,
|
|
7
|
+
"zip": true,
|
|
8
|
+
"buffer": true,
|
|
9
|
+
"dirStorage": true,
|
|
10
|
+
"online": false,
|
|
11
|
+
"open": false,
|
|
12
|
+
"oneFilePanel": true,
|
|
13
|
+
"keysPanel": false,
|
|
14
|
+
"prefix": "/lib/files",
|
|
15
|
+
"confirmCopy": true,
|
|
16
|
+
"confirmMove": true,
|
|
17
|
+
"showConfig": false,
|
|
18
|
+
"showFileName": true,
|
|
19
|
+
"contact": false,
|
|
20
|
+
"configDialog": false,
|
|
21
|
+
"console": false,
|
|
22
|
+
"terminal": false,
|
|
23
|
+
"vim": false,
|
|
24
|
+
"columns": "name-size-date-owner-mode",
|
|
25
|
+
"export": false,
|
|
26
|
+
"import": false,
|
|
27
|
+
"dropbox": false,
|
|
28
|
+
"dropboxToken": "",
|
|
29
|
+
"log": true
|
|
30
|
+
}
|
package/dist/src/bootstrap.d.ts
CHANGED
package/dist/src/bootstrap.js
CHANGED
|
@@ -4,6 +4,7 @@ const core_1 = require("@nestjs/core");
|
|
|
4
4
|
const config_1 = require("@nestjs/config");
|
|
5
5
|
const dotenv = require("dotenv");
|
|
6
6
|
const app_module_1 = require("./app.module");
|
|
7
|
+
const cloudcmd_1 = require("./cloudcmd/cloudcmd");
|
|
7
8
|
async function bootstrap(options) {
|
|
8
9
|
const configFile = dotenv.config({
|
|
9
10
|
path: options?.config ?? '.env',
|
|
@@ -21,6 +22,9 @@ async function bootstrap(options) {
|
|
|
21
22
|
const app = await core_1.NestFactory.create(app_module_1.default);
|
|
22
23
|
const configService = app.get(config_1.ConfigService);
|
|
23
24
|
const port = configService.get('PORT');
|
|
25
|
+
if (options.httpServer) {
|
|
26
|
+
(0, cloudcmd_1.default)(app, options.httpServer, configService.get('LOCAL_PATH'));
|
|
27
|
+
}
|
|
24
28
|
await app.listen(port);
|
|
25
29
|
}
|
|
26
30
|
exports.default = bootstrap;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../../src/bootstrap.ts"],"names":[],"mappings":";;AAAA,uCAA2C;AAC3C,2CAA+C;AAC/C,iCAAiC;AACjC,6CAAqC;
|
|
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;QAEpB,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAChC,IAAI,OAAO,CAAC,OAAO,EAAE;YACnB,OAAO,CAAC,OAAO,EAAE,CAAC;SACnB;aAAM;YACL,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACjB;KACF;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;QACtB,IAAA,kBAAQ,EAAC,GAAG,EAAE,OAAO,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,CAAS,YAAY,CAAC,CAAC,CAAC;KAC5E;IAED,MAAM,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC;AAxBD,4BAwBC"}
|
|
@@ -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"}
|
|
@@ -8,19 +8,13 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
const common_1 = require("@nestjs/common");
|
|
10
10
|
const files_resolver_1 = require("./resolvers/files.resolver");
|
|
11
|
-
const gitlab_files_service_1 = require("./services/gitlab-files.service");
|
|
12
11
|
const files_service_factory_1 = require("./services/files-service.factory");
|
|
13
12
|
const local_files_service_1 = require("./services/local-files.service");
|
|
14
13
|
let FilesModule = class FilesModule {
|
|
15
14
|
};
|
|
16
15
|
FilesModule = __decorate([
|
|
17
16
|
(0, common_1.Module)({
|
|
18
|
-
providers: [
|
|
19
|
-
files_resolver_1.default,
|
|
20
|
-
local_files_service_1.default,
|
|
21
|
-
gitlab_files_service_1.default,
|
|
22
|
-
files_service_factory_1.default,
|
|
23
|
-
],
|
|
17
|
+
providers: [files_resolver_1.default, local_files_service_1.default, files_service_factory_1.default],
|
|
24
18
|
})
|
|
25
19
|
], FilesModule);
|
|
26
20
|
exports.default = FilesModule;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"files.module.js","sourceRoot":"","sources":["../../../src/files/files.module.ts"],"names":[],"mappings":";;;;;;;;AAAA,2CAAwC;AACxC,+DAAuD;AACvD,
|
|
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"}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { ConfigService } from '@nestjs/config';
|
|
2
2
|
import { IFilesService } from '../interfaces/files.service.interface';
|
|
3
|
-
import GitlabFilesService from './gitlab-files.service';
|
|
4
3
|
import LocalFilesService from './local-files.service';
|
|
5
4
|
export default class FilesServiceFactory {
|
|
6
5
|
private configService;
|
|
7
|
-
private gitlabFilesService;
|
|
8
6
|
private localFilesService;
|
|
9
|
-
constructor(configService: ConfigService,
|
|
7
|
+
constructor(configService: ConfigService, localFilesService: LocalFilesService);
|
|
10
8
|
create(): IFilesService;
|
|
11
9
|
}
|
|
@@ -14,15 +14,12 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const common_1 = require("@nestjs/common");
|
|
16
16
|
const config_1 = require("@nestjs/config");
|
|
17
|
-
const gitlab_files_service_1 = require("./gitlab-files.service");
|
|
18
17
|
const local_files_service_1 = require("./local-files.service");
|
|
19
18
|
let FilesServiceFactory = class FilesServiceFactory {
|
|
20
19
|
configService;
|
|
21
|
-
gitlabFilesService;
|
|
22
20
|
localFilesService;
|
|
23
|
-
constructor(configService,
|
|
21
|
+
constructor(configService, localFilesService) {
|
|
24
22
|
this.configService = configService;
|
|
25
|
-
this.gitlabFilesService = gitlabFilesService;
|
|
26
23
|
this.localFilesService = localFilesService;
|
|
27
24
|
}
|
|
28
25
|
create() {
|
|
@@ -30,18 +27,13 @@ let FilesServiceFactory = class FilesServiceFactory {
|
|
|
30
27
|
if (mode === 'local') {
|
|
31
28
|
return this.localFilesService;
|
|
32
29
|
}
|
|
33
|
-
if (mode === 'gitlab') {
|
|
34
|
-
return this.gitlabFilesService;
|
|
35
|
-
}
|
|
36
30
|
throw new Error(`Invalid MODE: ${mode}`);
|
|
37
31
|
}
|
|
38
32
|
};
|
|
39
33
|
FilesServiceFactory = __decorate([
|
|
40
34
|
(0, common_1.Injectable)(),
|
|
41
|
-
__param(1, (0, common_1.Inject)(
|
|
42
|
-
__param(2, (0, common_1.Inject)(local_files_service_1.default)),
|
|
35
|
+
__param(1, (0, common_1.Inject)(local_files_service_1.default)),
|
|
43
36
|
__metadata("design:paramtypes", [config_1.ConfigService,
|
|
44
|
-
gitlab_files_service_1.default,
|
|
45
37
|
local_files_service_1.default])
|
|
46
38
|
], FilesServiceFactory);
|
|
47
39
|
exports.default = FilesServiceFactory;
|
|
@@ -1 +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
|
|
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;YACpB,OAAO,IAAI,CAAC,iBAAiB,CAAC;SAC/B;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"}
|
|
@@ -36,9 +36,9 @@ let LocalFilesService = LocalFilesService_1 = class LocalFilesService {
|
|
|
36
36
|
}
|
|
37
37
|
async readFile(path) {
|
|
38
38
|
const dataPath = this.configService.get('LOCAL_PATH');
|
|
39
|
-
const
|
|
39
|
+
const fullPath = (0, path_1.join)(dataPath, path);
|
|
40
40
|
try {
|
|
41
|
-
const content = await (await fs.promises.readFile(
|
|
41
|
+
const content = await (await fs.promises.readFile(fullPath, 'utf8')).trim();
|
|
42
42
|
const name = path.split('/').pop();
|
|
43
43
|
return LocalFilesService_1.formatResponse(name, content);
|
|
44
44
|
}
|
package/dist/src/main.js
CHANGED
|
@@ -5,16 +5,16 @@ const commander_1 = require("commander");
|
|
|
5
5
|
const bootstrap_1 = require("./bootstrap");
|
|
6
6
|
const program = new commander_1.Command();
|
|
7
7
|
program
|
|
8
|
-
.description('The lib microservice is
|
|
9
|
-
.option('-c, --config <
|
|
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')
|
|
10
11
|
.helpOption('-h, --help', 'display help for libms')
|
|
11
12
|
.showHelpAfterError();
|
|
12
13
|
program.parse(process.argv);
|
|
13
14
|
const options = program.opts();
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
15
|
+
(0, bootstrap_1.default)({
|
|
16
|
+
config: options.config,
|
|
17
|
+
httpServer: options.http,
|
|
18
|
+
runHelp: () => program.help(),
|
|
19
|
+
});
|
|
20
20
|
//# sourceMappingURL=main.js.map
|
package/dist/src/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/main.ts"],"names":[],"mappings":";;;AACA,yCAAoC;AACpC,2CAAoC;
|
|
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,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.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloudcmd.spec.js","sourceRoot":"","sources":["../../../test/cloudcmd/cloudcmd.spec.ts"],"names":[],"mappings":";;AAAA,iCAA0B;AAC1B,0CAAgD;AAChD,mCAAgC;AAEhC,QAAQ,CAAC,mCAAmC,EAAE,GAAG,EA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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"}
|
|
@@ -2,8 +2,17 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const testing_1 = require("@nestjs/testing");
|
|
4
4
|
const request = require("supertest");
|
|
5
|
+
const cross_fetch_1 = require("cross-fetch");
|
|
6
|
+
const client_1 = require("@apollo/client");
|
|
5
7
|
const app_module_1 = require("../../src/app.module");
|
|
6
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
|
+
});
|
|
7
16
|
describe('End to End test for the application', () => {
|
|
8
17
|
let app;
|
|
9
18
|
beforeAll(async () => {
|
|
@@ -18,19 +27,27 @@ describe('End to End test for the application', () => {
|
|
|
18
27
|
afterAll(async () => {
|
|
19
28
|
await app.close();
|
|
20
29
|
}, 10000);
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
const response = await request('http://localhost:4001')
|
|
30
|
+
async function HTTPQuery(query, expectedResponse) {
|
|
31
|
+
const response = await request(`http://localhost:${process.env.PORT}`)
|
|
24
32
|
.post(process.env.APOLLO_PATH)
|
|
25
33
|
.send({ query });
|
|
26
|
-
expect(response.body).toEqual(
|
|
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);
|
|
27
42
|
}, 10000);
|
|
28
|
-
it('should return the content
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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);
|
|
34
51
|
}, 10000);
|
|
35
52
|
});
|
|
36
53
|
//# sourceMappingURL=app.e2e.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.e2e.spec.js","sourceRoot":"","sources":["../../../test/e2e/app.e2e.spec.ts"],"names":[],"mappings":";;AAAA,6CAAsD;AAEtD,qCAAqC;
|
|
1
|
+
{"version":3,"file":"app.e2e.spec.js","sourceRoot":"","sources":["../../../test/e2e/app.e2e.spec.ts"],"names":[],"mappings":";;AAAA,6CAAsD;AAEtD,qCAAqC;AACrC,6CAAgC;AAChC,2CAMwB;AACxB,qDAA6C;AAC7C,0CAKqB;AAErB,MAAM,MAAM,GAAG,IAAI,qBAAY,CAAC;IAC9B,IAAI,EAAE,IAAI,iBAAQ,CAAC;QACjB,GAAG,EAAE,oBAAoB,OAAO,CAAC,GAAG,CAAC,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE;QACrE,KAAK,EAAL,qBAAK;KACN,CAAC;IACF,KAAK,EAAE,IAAI,sBAAa,CAAC,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC;CACjD,CAAC,CAAC;AAEH,QAAQ,CAAC,qCAAqC,EAAE,GAAG,EAAE;IACnD,IAAI,GAAqB,CAAC;IAE1B,SAAS,CAAC,KAAK,IAAI,EAAE;QACnB,MAAM,aAAa,GAAkB,MAAM,cAAI,CAAC,mBAAmB,CAAC;YAClE,OAAO,EAAE,CAAC,oBAAS,CAAC;SACrB,CAAC,CAAC,OAAO,EAAE,CAAC;QACb,GAAG,GAAG,aAAa,CAAC,qBAAqB,EAAE,CAAC;QAC5C,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;QACjB,MAAM,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAGnC,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,C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C,6DAA6D,EAAE,KAAK,IAAI,EAAE;QAC3E,MAAM,YAAY,CAAC,IAAA,YAAG,EAAC,sBAAW,CAAC,EAAE,sCAA2B,CAAC,CAAC;IACpE,CAAC,EAAE,KAAK,CAAC,CAAC;AACZ,CAAC,CAAC,CAAC"}
|
|
@@ -5,7 +5,6 @@ const config_1 = require("@nestjs/config");
|
|
|
5
5
|
const files_resolver_1 = require("../../src/files/resolvers/files.resolver");
|
|
6
6
|
const files_service_factory_1 = require("../../src/files/services/files-service.factory");
|
|
7
7
|
const local_files_service_1 = require("../../src/files/services/local-files.service");
|
|
8
|
-
const gitlab_files_service_1 = require("../../src/files/services/gitlab-files.service");
|
|
9
8
|
const testUtil_1 = require("../testUtil");
|
|
10
9
|
describe('Integration tests for FilesResolver', () => {
|
|
11
10
|
let filesResolver;
|
|
@@ -17,7 +16,6 @@ describe('Integration tests for FilesResolver', () => {
|
|
|
17
16
|
files_resolver_1.default,
|
|
18
17
|
files_service_factory_1.default,
|
|
19
18
|
local_files_service_1.default,
|
|
20
|
-
gitlab_files_service_1.default,
|
|
21
19
|
{ provide: config_1.ConfigService, useClass: testUtil_1.MockConfigService },
|
|
22
20
|
],
|
|
23
21
|
}).compile();
|
|
@@ -26,7 +24,7 @@ describe('Integration tests for FilesResolver', () => {
|
|
|
26
24
|
afterEach(() => {
|
|
27
25
|
jest.clearAllMocks();
|
|
28
26
|
});
|
|
29
|
-
const modes = ['local'
|
|
27
|
+
const modes = ['local'];
|
|
30
28
|
for (const mode of modes) {
|
|
31
29
|
describe(`when MODE is ${mode}`, () => {
|
|
32
30
|
beforeEach(() => {
|
|
@@ -1 +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,
|
|
1
|
+
{"version":3,"file":"files.service.integration.sp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EAAE,KAAK,IAAI,EAAE;oBACjC,MAAM,KAAK,GAAG,MAAM,aAAa,CAAC,aAAa,CAAC,8BAAmB,CAAC,CAAC;oBACrE,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,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;KACJ;AACH,CAAC,CAAC,CAAC"}
|
package/dist/test/testUtil.js
CHANGED
|
@@ -53,18 +53,9 @@ exports.sleep = sleep;
|
|
|
53
53
|
class MockConfigService {
|
|
54
54
|
get(key) {
|
|
55
55
|
switch (key) {
|
|
56
|
-
case 'TOKEN':
|
|
57
|
-
return process.env.TOKEN;
|
|
58
56
|
case 'LOCAL_PATH':
|
|
59
|
-
return process.env.
|
|
60
|
-
case 'GITLAB_URL':
|
|
61
|
-
return process.env.GITLAB_URL;
|
|
62
|
-
case 'GITLAB_GROUP':
|
|
63
|
-
return 'dtaas';
|
|
57
|
+
return process.env.LOCAL_PATH;
|
|
64
58
|
case 'MODE':
|
|
65
|
-
if (process.env.MODE === 'gitlab') {
|
|
66
|
-
return 'gitlab';
|
|
67
|
-
}
|
|
68
59
|
if (process.env.MODE === 'local') {
|
|
69
60
|
return 'local';
|
|
70
61
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testUtil.js","sourceRoot":"","sources":["../../test/testUtil.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AACjC,8CAA6C;AAE7C,MAAM,C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