@gapi/cli 1.8.147 → 1.8.149
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/dist/core/services/root.service.d.ts +0 -2
- package/dist/core/services/root.service.js +10 -10
- package/dist/daemon-server/core/services/ipfs-hash-map.service.js +1 -1
- package/dist/tasks/start.d.ts +0 -5
- package/dist/tasks/start.js +38 -42
- package/package.json +3 -3
- package/dist/core/helpers/ps-list.d.ts +0 -12
- package/dist/core/helpers/ps-list.js +0 -68
- package/dist/core/helpers/stringEnum.d.ts +0 -3
- package/dist/core/helpers/stringEnum.js +0 -10
- package/dist/core/services/daemon-executor/daemon-executor.service.d.ts +0 -5
- package/dist/core/services/daemon-executor/daemon-executor.service.js +0 -38
- package/dist/core/services/file.d.ts +0 -12
- package/dist/core/services/file.js +0 -109
- package/dist/daemon-server/api-introspection/index.d.ts +0 -53
- package/dist/daemon-server/api-introspection/index.js +0 -6
- package/dist/daemon-server/core/core.module.d.ts +0 -2
- package/dist/daemon-server/core/core.module.js +0 -22
- package/dist/daemon-server/core/interceptors/notify.interceptor.d.ts +0 -5
- package/dist/daemon-server/core/interceptors/notify.interceptor.js +0 -41
- package/dist/daemon-server/core/services/child.service.d.ts +0 -3
- package/dist/daemon-server/core/services/child.service.js +0 -39
- package/dist/daemon-server/core/services/daemon.service.d.ts +0 -16
- package/dist/daemon-server/core/services/daemon.service.js +0 -107
- package/dist/daemon-server/core/services/ipfs/external-importer.d.ts +0 -57
- package/dist/daemon-server/core/services/ipfs/external-importer.js +0 -359
- package/dist/daemon-server/core/services/ipfs/npm-service.d.ts +0 -12
- package/dist/daemon-server/core/services/ipfs/npm-service.js +0 -55
- package/dist/daemon-server/core/services/ipfs/providers.d.ts +0 -5
- package/dist/daemon-server/core/services/ipfs/providers.js +0 -21
- package/dist/daemon-server/core/services/ipfs/request-cache.d.ts +0 -7
- package/dist/daemon-server/core/services/ipfs/request-cache.js +0 -31
- package/dist/daemon-server/core/services/ipfs/request.d.ts +0 -6
- package/dist/daemon-server/core/services/ipfs/request.js +0 -60
- package/dist/daemon-server/core/services/list.service.d.ts +0 -10
- package/dist/daemon-server/core/services/list.service.js +0 -55
- package/dist/daemon-server/core/services/plugin-loader.service.d.ts +0 -29
- package/dist/daemon-server/core/services/plugin-loader.service.js +0 -118
- package/dist/daemon-server/core/services/plugin-watcher.service.d.ts +0 -9
- package/dist/daemon-server/core/services/plugin-watcher.service.js +0 -92
- package/dist/daemon-server/core/templates/gapi-cli-config.template.d.ts +0 -1
- package/dist/daemon-server/core/templates/gapi-cli-config.template.js +0 -9
- package/dist/daemon-server/server.controller.d.ts +0 -16
- package/dist/daemon-server/server.controller.js +0 -85
- package/dist/daemon-server/server.module.d.ts +0 -2
- package/dist/daemon-server/server.module.js +0 -21
- package/dist/daemon-server/types/link-list.type.d.ts +0 -4
- package/dist/daemon-server/types/link-list.type.js +0 -22
- package/dist/daemon-server/types/server-metadata.type.d.ts +0 -5
- package/dist/daemon-server/types/server-metadata.type.js +0 -20
- package/dist/tasks/bootstrap.d.ts +0 -7
- package/dist/tasks/bootstrap.js +0 -64
- package/dist/tasks/daemon.d.ts +0 -45
- package/dist/tasks/daemon.js +0 -340
|
@@ -1,60 +0,0 @@
|
|
|
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.RequestService = void 0;
|
|
13
|
-
const core_1 = require("@rxdi/core");
|
|
14
|
-
const http_1 = require("http");
|
|
15
|
-
const https_1 = require("https");
|
|
16
|
-
const rxjs_1 = require("rxjs");
|
|
17
|
-
const operators_1 = require("rxjs/operators");
|
|
18
|
-
const request_cache_1 = require("./request-cache");
|
|
19
|
-
let RequestService = class RequestService {
|
|
20
|
-
get(link) {
|
|
21
|
-
if (this.cache.cacheLayer.map.has(link)) {
|
|
22
|
-
this.logger.log(`Item returned from cacahe: ${link}`);
|
|
23
|
-
return rxjs_1.of(this.cache.cacheLayer.get(link).data);
|
|
24
|
-
}
|
|
25
|
-
return new rxjs_1.Observable((o) => {
|
|
26
|
-
if (link.includes('https://')) {
|
|
27
|
-
https_1.get(link, (resp) => {
|
|
28
|
-
let data = '';
|
|
29
|
-
resp.on('data', (chunk) => (data += chunk));
|
|
30
|
-
resp.on('end', () => o.next(data));
|
|
31
|
-
}).on('error', (err) => {
|
|
32
|
-
console.error('Error: ' + err.message);
|
|
33
|
-
o.error(err);
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
http_1.get(link, (resp) => {
|
|
38
|
-
let data = '';
|
|
39
|
-
resp.on('data', (chunk) => (data += chunk));
|
|
40
|
-
resp.on('end', () => o.next(data));
|
|
41
|
-
}).on('error', (err) => {
|
|
42
|
-
console.error('Error: ' + err.message);
|
|
43
|
-
o.error(err);
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
}).pipe(operators_1.tap((res) => this.cache.cacheLayer.putItem({ key: link, data: res })));
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
__decorate([
|
|
50
|
-
core_1.Injector(request_cache_1.RequestCacheService),
|
|
51
|
-
__metadata("design:type", request_cache_1.RequestCacheService)
|
|
52
|
-
], RequestService.prototype, "cache", void 0);
|
|
53
|
-
__decorate([
|
|
54
|
-
core_1.Injector(core_1.BootstrapLogger),
|
|
55
|
-
__metadata("design:type", core_1.BootstrapLogger)
|
|
56
|
-
], RequestService.prototype, "logger", void 0);
|
|
57
|
-
RequestService = __decorate([
|
|
58
|
-
core_1.Service()
|
|
59
|
-
], RequestService);
|
|
60
|
-
exports.RequestService = RequestService;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ILinkListType } from '../../api-introspection/index';
|
|
2
|
-
export declare class ListService {
|
|
3
|
-
private linkedList;
|
|
4
|
-
readList(): Promise<ILinkListType[]>;
|
|
5
|
-
findByRepoPath(repoPath: string): Promise<ILinkListType[]>;
|
|
6
|
-
findByLinkName(linkName: string): {
|
|
7
|
-
results: () => Promise<ILinkListType[]>;
|
|
8
|
-
exclude: (isNotLike: string) => Promise<ILinkListType[]>;
|
|
9
|
-
};
|
|
10
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
9
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
10
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
11
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
12
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
13
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
14
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.ListService = void 0;
|
|
19
|
-
const core_1 = require("@rxdi/core");
|
|
20
|
-
const fs_1 = require("fs");
|
|
21
|
-
const util_1 = require("util");
|
|
22
|
-
const daemon_config_1 = require("../../daemon.config");
|
|
23
|
-
let ListService = class ListService {
|
|
24
|
-
constructor() {
|
|
25
|
-
this.linkedList = [];
|
|
26
|
-
}
|
|
27
|
-
readList() {
|
|
28
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
-
try {
|
|
30
|
-
this.linkedList = JSON.parse(yield util_1.promisify(fs_1.readFile)(daemon_config_1.GAPI_DAEMON_PROCESS_LIST_FOLDER, {
|
|
31
|
-
encoding: 'utf-8',
|
|
32
|
-
}));
|
|
33
|
-
}
|
|
34
|
-
catch (e) { }
|
|
35
|
-
return this.linkedList;
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
findByRepoPath(repoPath) {
|
|
39
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
-
return (yield this.readList()).filter((l) => l.repoPath === repoPath);
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
findByLinkName(linkName) {
|
|
44
|
-
return {
|
|
45
|
-
results: () => __awaiter(this, void 0, void 0, function* () { return (yield this.readList()).filter((l) => l.linkName === linkName); }),
|
|
46
|
-
exclude: (isNotLike) => __awaiter(this, void 0, void 0, function* () {
|
|
47
|
-
return (yield this.readList()).filter((l) => l.linkName === linkName && l.repoPath !== isNotLike);
|
|
48
|
-
}),
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
ListService = __decorate([
|
|
53
|
-
core_1.Injectable()
|
|
54
|
-
], ListService);
|
|
55
|
-
exports.ListService = ListService;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Metadata } from '@rxdi/core';
|
|
2
|
-
import { FileService } from '../../../core/services/file';
|
|
3
|
-
import { IpfsHashMapService } from './ipfs-hash-map.service';
|
|
4
|
-
import { ExternalImporter } from './ipfs/external-importer';
|
|
5
|
-
import { PluginWatcherService } from './plugin-watcher.service';
|
|
6
|
-
interface CustomMetadata extends Function {
|
|
7
|
-
metadata: Metadata;
|
|
8
|
-
}
|
|
9
|
-
export declare class PluginLoader {
|
|
10
|
-
private externalImporterService;
|
|
11
|
-
private fileService;
|
|
12
|
-
private pluginWatcherService;
|
|
13
|
-
private ipfsHashMapService;
|
|
14
|
-
private defaultIpfsProvider;
|
|
15
|
-
private defaultDownloadFilename;
|
|
16
|
-
private filterDups;
|
|
17
|
-
cache: {
|
|
18
|
-
[key: string]: CustomMetadata;
|
|
19
|
-
};
|
|
20
|
-
constructor(externalImporterService: ExternalImporter, fileService: FileService, pluginWatcherService: PluginWatcherService, ipfsHashMapService: IpfsHashMapService);
|
|
21
|
-
loadPlugins(): import("rxjs").Observable<CustomMetadata[]>;
|
|
22
|
-
private loadIpfsHashes;
|
|
23
|
-
private getModule;
|
|
24
|
-
private cacheModule;
|
|
25
|
-
private loadModule;
|
|
26
|
-
private makeIpfsHashFile;
|
|
27
|
-
private makePluginsDirectories;
|
|
28
|
-
}
|
|
29
|
-
export {};
|
|
@@ -1,118 +0,0 @@
|
|
|
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
12
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
13
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
14
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
15
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
16
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
17
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.PluginLoader = void 0;
|
|
22
|
-
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
23
|
-
const core_1 = require("@rxdi/core");
|
|
24
|
-
const fs_1 = require("fs");
|
|
25
|
-
const rxjs_1 = require("rxjs");
|
|
26
|
-
const operators_1 = require("rxjs/operators");
|
|
27
|
-
const util_1 = require("util");
|
|
28
|
-
const file_1 = require("../../../core/services/file");
|
|
29
|
-
const daemon_config_1 = require("../../daemon.config");
|
|
30
|
-
const ipfs_hash_map_service_1 = require("./ipfs-hash-map.service");
|
|
31
|
-
const external_importer_1 = require("./ipfs/external-importer");
|
|
32
|
-
const plugin_watcher_service_1 = require("./plugin-watcher.service");
|
|
33
|
-
let PluginLoader = class PluginLoader {
|
|
34
|
-
constructor(externalImporterService, fileService, pluginWatcherService, ipfsHashMapService) {
|
|
35
|
-
this.externalImporterService = externalImporterService;
|
|
36
|
-
this.fileService = fileService;
|
|
37
|
-
this.pluginWatcherService = pluginWatcherService;
|
|
38
|
-
this.ipfsHashMapService = ipfsHashMapService;
|
|
39
|
-
this.defaultIpfsProvider = 'https://ipfs.io/ipfs/';
|
|
40
|
-
this.defaultDownloadFilename = 'gapi-plugin';
|
|
41
|
-
this.filterDups = (modules) => [...new Set(modules.map((i) => i.metadata.moduleHash))].map((m) => this.cache[m]);
|
|
42
|
-
this.cache = {};
|
|
43
|
-
}
|
|
44
|
-
loadPlugins() {
|
|
45
|
-
return this.makePluginsDirectories().pipe(operators_1.switchMap(() => this.ipfsHashMapService.readHashMap()), operators_1.switchMap(() => this.pluginWatcherService.watch()),
|
|
46
|
-
// switchMap(() => this.fileService.fileWalker(pluginsFolder)),
|
|
47
|
-
operators_1.map((p) => [...new Set(p)].map((path) => !new RegExp(/^(.(?!.*\.js$))*$/g).test(path)
|
|
48
|
-
? this.loadModule(require(path))
|
|
49
|
-
: null)), operators_1.switchMap((pluginModules) => rxjs_1.of(null).pipe(operators_1.combineLatest([...new Set(this.loadIpfsHashes())].map((hash) => this.getModule(hash))), operators_1.map((externalModules) => externalModules.concat(pluginModules)), operators_1.map((m) => m.filter((i) => !!i)), operators_1.map((modules) => this.filterDups(modules)), operators_1.tap(() => this.ipfsHashMapService.writeHashMapToFile()))));
|
|
50
|
-
}
|
|
51
|
-
loadIpfsHashes() {
|
|
52
|
-
let hashes = [];
|
|
53
|
-
try {
|
|
54
|
-
hashes = JSON.parse(fs_1.readFileSync(daemon_config_1.IPFS_HASHED_MODULES, { encoding: 'utf8' }));
|
|
55
|
-
}
|
|
56
|
-
catch (e) { }
|
|
57
|
-
return hashes;
|
|
58
|
-
}
|
|
59
|
-
getModule(hash, provider = this.defaultIpfsProvider) {
|
|
60
|
-
return this.externalImporterService
|
|
61
|
-
.downloadIpfsModuleConfig({
|
|
62
|
-
hash,
|
|
63
|
-
provider,
|
|
64
|
-
})
|
|
65
|
-
.pipe(operators_1.take(1), operators_1.tap((externalModule) => {
|
|
66
|
-
const isPresent = this.ipfsHashMapService.hashMap.filter((h) => h.hash === hash).length;
|
|
67
|
-
if (!isPresent) {
|
|
68
|
-
this.ipfsHashMapService.hashMap.push({
|
|
69
|
-
hash,
|
|
70
|
-
module: {
|
|
71
|
-
fileName: this.defaultDownloadFilename,
|
|
72
|
-
namespace: externalModule.name,
|
|
73
|
-
extension: 'js',
|
|
74
|
-
outputFolder: `${daemon_config_1.GAPI_DAEMON_IPFS_PLUGINS_FOLDER}/`,
|
|
75
|
-
link: `${this.defaultIpfsProvider}${externalModule.module}`,
|
|
76
|
-
},
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
}), operators_1.switchMap((externalModule) => this.externalImporterService.importModule({
|
|
80
|
-
fileName: this.defaultDownloadFilename,
|
|
81
|
-
namespace: externalModule.name,
|
|
82
|
-
extension: 'js',
|
|
83
|
-
outputFolder: `${daemon_config_1.GAPI_DAEMON_IPFS_PLUGINS_FOLDER}/`,
|
|
84
|
-
link: `${this.defaultIpfsProvider}${externalModule.module}`,
|
|
85
|
-
}, externalModule.name, { folderOverride: `//` })), operators_1.map((data) => this.loadModule(data)));
|
|
86
|
-
}
|
|
87
|
-
cacheModule(currentModule) {
|
|
88
|
-
if (!currentModule.metadata) {
|
|
89
|
-
throw new Error('Missing metadata for module maybe it is not from @rxdi infrastructure ?');
|
|
90
|
-
}
|
|
91
|
-
return (this.cache[currentModule.metadata.moduleHash] = currentModule);
|
|
92
|
-
}
|
|
93
|
-
loadModule(m) {
|
|
94
|
-
const currentModule = m[Object.keys(m)[0]];
|
|
95
|
-
if (!currentModule) {
|
|
96
|
-
throw new Error(`Missing cache module ${JSON.stringify(m)}`);
|
|
97
|
-
}
|
|
98
|
-
return this.cacheModule(currentModule);
|
|
99
|
-
}
|
|
100
|
-
makeIpfsHashFile() {
|
|
101
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
102
|
-
if (!(yield util_1.promisify(fs_1.exists)(daemon_config_1.IPFS_HASHED_MODULES))) {
|
|
103
|
-
yield util_1.promisify(fs_1.writeFile)(daemon_config_1.IPFS_HASHED_MODULES, JSON.stringify([], null, 4), { encoding: 'utf8' });
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
makePluginsDirectories() {
|
|
108
|
-
return rxjs_1.of(true).pipe(operators_1.switchMap(() => this.fileService.mkdirp(daemon_config_1.GAPI_DAEMON_IPFS_PLUGINS_FOLDER)), operators_1.switchMap(() => this.fileService.mkdirp(daemon_config_1.GAPI_DAEMON_HTTP_PLUGINS_FOLDER)), operators_1.switchMap(() => this.fileService.mkdirp(daemon_config_1.GAPI_DAEMON_PLUGINS_FOLDER)), operators_1.switchMap(() => this.makeIpfsHashFile()));
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
PluginLoader = __decorate([
|
|
112
|
-
core_1.Injectable(),
|
|
113
|
-
__metadata("design:paramtypes", [external_importer_1.ExternalImporter,
|
|
114
|
-
file_1.FileService,
|
|
115
|
-
plugin_watcher_service_1.PluginWatcherService,
|
|
116
|
-
ipfs_hash_map_service_1.IpfsHashMapService])
|
|
117
|
-
], PluginLoader);
|
|
118
|
-
exports.PluginLoader = PluginLoader;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Observable } from 'rxjs';
|
|
2
|
-
import { ChildService } from './child.service';
|
|
3
|
-
export declare class PluginWatcherService {
|
|
4
|
-
private childService;
|
|
5
|
-
constructor(childService: ChildService);
|
|
6
|
-
private isNotFromExternalPlugins;
|
|
7
|
-
watch(): Observable<string[]>;
|
|
8
|
-
private restartDaemon;
|
|
9
|
-
}
|
|
@@ -1,92 +0,0 @@
|
|
|
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
12
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
13
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
14
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
15
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
16
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
17
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.PluginWatcherService = void 0;
|
|
22
|
-
const core_1 = require("@rxdi/core");
|
|
23
|
-
const chokidar_1 = require("chokidar");
|
|
24
|
-
const rxjs_1 = require("rxjs");
|
|
25
|
-
const daemon_config_1 = require("../../daemon.config");
|
|
26
|
-
const child_service_1 = require("./child.service");
|
|
27
|
-
let PluginWatcherService = class PluginWatcherService {
|
|
28
|
-
constructor(childService) {
|
|
29
|
-
this.childService = childService;
|
|
30
|
-
}
|
|
31
|
-
isNotFromExternalPlugins(path) {
|
|
32
|
-
return !path.includes('ipfs-plugins');
|
|
33
|
-
}
|
|
34
|
-
watch() {
|
|
35
|
-
return new rxjs_1.Observable((observer) => {
|
|
36
|
-
const initPlugins = [];
|
|
37
|
-
let isInitFinished = false;
|
|
38
|
-
const watcher = chokidar_1.watch([
|
|
39
|
-
`${daemon_config_1.GAPI_DAEMON_IPFS_PLUGINS_FOLDER}/**/*.js`,
|
|
40
|
-
`${daemon_config_1.GAPI_DAEMON_HTTP_PLUGINS_FOLDER}/**/*.js`,
|
|
41
|
-
`${daemon_config_1.GAPI_DAEMON_PLUGINS_FOLDER}/**/*.js`,
|
|
42
|
-
daemon_config_1.IPFS_HASHED_MODULES,
|
|
43
|
-
], {
|
|
44
|
-
ignored: /^\./,
|
|
45
|
-
persistent: true,
|
|
46
|
-
});
|
|
47
|
-
watcher
|
|
48
|
-
.on('add', (path) => {
|
|
49
|
-
if (!isInitFinished && this.isNotFromExternalPlugins(path)) {
|
|
50
|
-
console.log('Plugin', path, 'has been added');
|
|
51
|
-
initPlugins.push(path);
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
console.log('Present external module', path);
|
|
55
|
-
}
|
|
56
|
-
if (isInitFinished && this.isNotFromExternalPlugins(path)) {
|
|
57
|
-
this.restartDaemon();
|
|
58
|
-
}
|
|
59
|
-
})
|
|
60
|
-
.on('change', (path) => {
|
|
61
|
-
console.log('File', path, 'has been changed');
|
|
62
|
-
if (isInitFinished) {
|
|
63
|
-
this.restartDaemon();
|
|
64
|
-
}
|
|
65
|
-
})
|
|
66
|
-
.on('ready', () => {
|
|
67
|
-
console.log('Initial scan complete. Ready for changes');
|
|
68
|
-
observer.next(initPlugins);
|
|
69
|
-
observer.complete();
|
|
70
|
-
isInitFinished = true;
|
|
71
|
-
})
|
|
72
|
-
.on('unlink', (path) => {
|
|
73
|
-
console.log('File', path, 'has been removed');
|
|
74
|
-
if (isInitFinished) {
|
|
75
|
-
this.restartDaemon();
|
|
76
|
-
}
|
|
77
|
-
})
|
|
78
|
-
.on('error', (error) => console.error('Error happened', error));
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
restartDaemon() {
|
|
82
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
-
yield this.childService.spawn('gapi', ['daemon', 'restart'], process.cwd());
|
|
84
|
-
process.exit();
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
PluginWatcherService = __decorate([
|
|
89
|
-
core_1.Injectable(),
|
|
90
|
-
__metadata("design:paramtypes", [child_service_1.ChildService])
|
|
91
|
-
], PluginWatcherService);
|
|
92
|
-
exports.PluginWatcherService = PluginWatcherService;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const GAPI_CLI_CONFIG_TEMPLATE: (port: number) => string;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GAPI_CLI_CONFIG_TEMPLATE = void 0;
|
|
4
|
-
exports.GAPI_CLI_CONFIG_TEMPLATE = (port) => `
|
|
5
|
-
config:
|
|
6
|
-
schema:
|
|
7
|
-
introspectionEndpoint: http://localhost:${port}/graphql
|
|
8
|
-
introspectionOutputFolder: ./api-introspection
|
|
9
|
-
`;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { PubSubService } from '@gapi/core';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
|
-
import { ILinkListType } from './api-introspection';
|
|
4
|
-
import { DaemonService } from './core/services/daemon.service';
|
|
5
|
-
import { ListService } from './core/services/list.service';
|
|
6
|
-
export declare class ServerController {
|
|
7
|
-
private listService;
|
|
8
|
-
private daemonService;
|
|
9
|
-
private pubsub;
|
|
10
|
-
constructor(listService: ListService, daemonService: DaemonService, pubsub: PubSubService);
|
|
11
|
-
statusSubscription(message: any): {
|
|
12
|
-
repoPath: any;
|
|
13
|
-
};
|
|
14
|
-
getLinkList(): Promise<ILinkListType[]>;
|
|
15
|
-
notifyDaemon(root: any, payload: ILinkListType): Observable<ILinkListType>;
|
|
16
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
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.ServerController = void 0;
|
|
13
|
-
const core_1 = require("@gapi/core");
|
|
14
|
-
const rxjs_1 = require("rxjs");
|
|
15
|
-
const notify_interceptor_1 = require("./core/interceptors/notify.interceptor");
|
|
16
|
-
const daemon_service_1 = require("./core/services/daemon.service");
|
|
17
|
-
const list_service_1 = require("./core/services/list.service");
|
|
18
|
-
const link_list_type_1 = require("./types/link-list.type");
|
|
19
|
-
const server_metadata_type_1 = require("./types/server-metadata.type");
|
|
20
|
-
let ServerController = class ServerController {
|
|
21
|
-
constructor(listService, daemonService, pubsub) {
|
|
22
|
-
this.listService = listService;
|
|
23
|
-
this.daemonService = daemonService;
|
|
24
|
-
this.pubsub = pubsub;
|
|
25
|
-
let count = 0;
|
|
26
|
-
setInterval(() => {
|
|
27
|
-
pubsub.publish('CREATE_SIGNAL_BASIC', count++);
|
|
28
|
-
}, 2000);
|
|
29
|
-
}
|
|
30
|
-
statusSubscription(message) {
|
|
31
|
-
return {
|
|
32
|
-
repoPath: message,
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
getLinkList() {
|
|
36
|
-
return this.listService.readList();
|
|
37
|
-
}
|
|
38
|
-
notifyDaemon(root, payload) {
|
|
39
|
-
return this.daemonService.notifyDaemon(payload);
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
__decorate([
|
|
43
|
-
core_1.Type(link_list_type_1.LinkListType),
|
|
44
|
-
core_1.Subscribe((self) => self.pubsub.asyncIterator('CREATE_SIGNAL_BASIC')),
|
|
45
|
-
core_1.Interceptor(notify_interceptor_1.NotifyInterceptor),
|
|
46
|
-
core_1.Subscription(),
|
|
47
|
-
__metadata("design:type", Function),
|
|
48
|
-
__metadata("design:paramtypes", [Object]),
|
|
49
|
-
__metadata("design:returntype", void 0)
|
|
50
|
-
], ServerController.prototype, "statusSubscription", null);
|
|
51
|
-
__decorate([
|
|
52
|
-
core_1.Type(new core_1.GraphQLList(link_list_type_1.LinkListType)),
|
|
53
|
-
core_1.Query(),
|
|
54
|
-
__metadata("design:type", Function),
|
|
55
|
-
__metadata("design:paramtypes", []),
|
|
56
|
-
__metadata("design:returntype", void 0)
|
|
57
|
-
], ServerController.prototype, "getLinkList", null);
|
|
58
|
-
__decorate([
|
|
59
|
-
core_1.Type(link_list_type_1.LinkListType),
|
|
60
|
-
core_1.Interceptor(notify_interceptor_1.NotifyInterceptor),
|
|
61
|
-
core_1.Mutation({
|
|
62
|
-
repoPath: {
|
|
63
|
-
type: new core_1.GraphQLNonNull(core_1.GraphQLString),
|
|
64
|
-
},
|
|
65
|
-
introspectionPath: {
|
|
66
|
-
type: core_1.GraphQLString,
|
|
67
|
-
},
|
|
68
|
-
linkName: {
|
|
69
|
-
type: core_1.GraphQLString,
|
|
70
|
-
},
|
|
71
|
-
serverMetadata: {
|
|
72
|
-
type: server_metadata_type_1.ServerMetadataInputType,
|
|
73
|
-
},
|
|
74
|
-
}),
|
|
75
|
-
__metadata("design:type", Function),
|
|
76
|
-
__metadata("design:paramtypes", [Object, Object]),
|
|
77
|
-
__metadata("design:returntype", rxjs_1.Observable)
|
|
78
|
-
], ServerController.prototype, "notifyDaemon", null);
|
|
79
|
-
ServerController = __decorate([
|
|
80
|
-
core_1.Controller(),
|
|
81
|
-
__metadata("design:paramtypes", [list_service_1.ListService,
|
|
82
|
-
daemon_service_1.DaemonService,
|
|
83
|
-
core_1.PubSubService])
|
|
84
|
-
], ServerController);
|
|
85
|
-
exports.ServerController = ServerController;
|
|
@@ -1,21 +0,0 @@
|
|
|
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
|
-
exports.ServerModule = void 0;
|
|
10
|
-
const core_1 = require("@gapi/core");
|
|
11
|
-
const core_module_1 = require("./core/core.module");
|
|
12
|
-
const server_controller_1 = require("./server.controller");
|
|
13
|
-
let ServerModule = class ServerModule {
|
|
14
|
-
};
|
|
15
|
-
ServerModule = __decorate([
|
|
16
|
-
core_1.Module({
|
|
17
|
-
imports: [core_module_1.CoreModule],
|
|
18
|
-
controllers: [server_controller_1.ServerController],
|
|
19
|
-
})
|
|
20
|
-
], ServerModule);
|
|
21
|
-
exports.ServerModule = ServerModule;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LinkListType = void 0;
|
|
4
|
-
const graphql_1 = require("graphql");
|
|
5
|
-
const server_metadata_type_1 = require("./server-metadata.type");
|
|
6
|
-
exports.LinkListType = new graphql_1.GraphQLObjectType({
|
|
7
|
-
name: 'LinkListType',
|
|
8
|
-
fields: () => ({
|
|
9
|
-
repoPath: {
|
|
10
|
-
type: graphql_1.GraphQLString,
|
|
11
|
-
},
|
|
12
|
-
introspectionPath: {
|
|
13
|
-
type: graphql_1.GraphQLString,
|
|
14
|
-
},
|
|
15
|
-
linkName: {
|
|
16
|
-
type: graphql_1.GraphQLString,
|
|
17
|
-
},
|
|
18
|
-
serverMetadata: {
|
|
19
|
-
type: server_metadata_type_1.ServerMetadataType,
|
|
20
|
-
},
|
|
21
|
-
}),
|
|
22
|
-
});
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ServerMetadataInputType = exports.ServerMetadataType = void 0;
|
|
4
|
-
const graphql_1 = require("graphql");
|
|
5
|
-
exports.ServerMetadataType = new graphql_1.GraphQLObjectType({
|
|
6
|
-
name: 'ServerMetadataType',
|
|
7
|
-
fields: () => ({
|
|
8
|
-
port: {
|
|
9
|
-
type: graphql_1.GraphQLInt,
|
|
10
|
-
},
|
|
11
|
-
}),
|
|
12
|
-
});
|
|
13
|
-
exports.ServerMetadataInputType = new graphql_1.GraphQLInputObjectType({
|
|
14
|
-
name: 'ServerMetadataInputType',
|
|
15
|
-
fields: () => ({
|
|
16
|
-
port: {
|
|
17
|
-
type: graphql_1.GraphQLInt,
|
|
18
|
-
},
|
|
19
|
-
}),
|
|
20
|
-
});
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { CoreModuleConfig } from '@gapi/core';
|
|
2
|
-
import { PluginLoader } from '../daemon-server/core/services/plugin-loader.service';
|
|
3
|
-
export declare class BootstrapTask {
|
|
4
|
-
private pluginLoader;
|
|
5
|
-
constructor(pluginLoader: PluginLoader);
|
|
6
|
-
run(options?: CoreModuleConfig): Promise<void>;
|
|
7
|
-
}
|