@teambit/api-server 0.0.179 → 0.0.180
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/api-server.main.runtime.d.ts +6 -3
- package/dist/api-server.main.runtime.js +19 -4
- package/dist/api-server.main.runtime.js.map +1 -1
- package/dist/ide.route.js +1 -1
- package/dist/ide.route.js.map +1 -1
- package/package.json +17 -16
- /package/dist/{preview-1695053895626.js → preview-1695093455493.js} +0 -0
|
@@ -8,6 +8,7 @@ import { WatcherMain } from '@teambit/watcher';
|
|
|
8
8
|
import { ExportMain } from '@teambit/export';
|
|
9
9
|
import { CheckoutMain } from '@teambit/checkout';
|
|
10
10
|
import { InstallMain } from '@teambit/install';
|
|
11
|
+
import { ImporterMain } from '@teambit/importer';
|
|
11
12
|
import { Workspace } from '@teambit/workspace';
|
|
12
13
|
export declare class ApiServerMain {
|
|
13
14
|
private workspace;
|
|
@@ -15,13 +16,14 @@ export declare class ApiServerMain {
|
|
|
15
16
|
private express;
|
|
16
17
|
private watcher;
|
|
17
18
|
private installer;
|
|
18
|
-
|
|
19
|
+
private importer;
|
|
20
|
+
constructor(workspace: Workspace, logger: Logger, express: ExpressMain, watcher: WatcherMain, installer: InstallMain, importer: ImporterMain);
|
|
19
21
|
runApiServer(options: {
|
|
20
22
|
port: number;
|
|
21
23
|
}): Promise<unknown>;
|
|
22
24
|
static dependencies: import("@teambit/harmony").Aspect[];
|
|
23
25
|
static runtime: import("@teambit/harmony").RuntimeDefinition;
|
|
24
|
-
static provider([cli, workspace, loggerMain, express, watcher, snapping, lanes, installer, exporter, checkout, componentLog,]: [
|
|
26
|
+
static provider([cli, workspace, loggerMain, express, watcher, snapping, lanes, installer, exporter, checkout, componentLog, importer,]: [
|
|
25
27
|
CLIMain,
|
|
26
28
|
Workspace,
|
|
27
29
|
LoggerMain,
|
|
@@ -32,7 +34,8 @@ export declare class ApiServerMain {
|
|
|
32
34
|
InstallMain,
|
|
33
35
|
ExportMain,
|
|
34
36
|
CheckoutMain,
|
|
35
|
-
ComponentLogMain
|
|
37
|
+
ComponentLogMain,
|
|
38
|
+
ImporterMain
|
|
36
39
|
]): Promise<ApiServerMain>;
|
|
37
40
|
}
|
|
38
41
|
export default ApiServerMain;
|
|
@@ -74,6 +74,13 @@ function _install() {
|
|
|
74
74
|
};
|
|
75
75
|
return data;
|
|
76
76
|
}
|
|
77
|
+
function _importer() {
|
|
78
|
+
const data = _interopRequireDefault(require("@teambit/importer"));
|
|
79
|
+
_importer = function () {
|
|
80
|
+
return data;
|
|
81
|
+
};
|
|
82
|
+
return data;
|
|
83
|
+
}
|
|
77
84
|
function _workspace() {
|
|
78
85
|
const data = _interopRequireDefault(require("@teambit/workspace"));
|
|
79
86
|
_workspace = function () {
|
|
@@ -128,12 +135,13 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
128
135
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
129
136
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
130
137
|
class ApiServerMain {
|
|
131
|
-
constructor(workspace, logger, express, watcher, installer) {
|
|
138
|
+
constructor(workspace, logger, express, watcher, installer, importer) {
|
|
132
139
|
this.workspace = workspace;
|
|
133
140
|
this.logger = logger;
|
|
134
141
|
this.express = express;
|
|
135
142
|
this.watcher = watcher;
|
|
136
143
|
this.installer = installer;
|
|
144
|
+
this.importer = importer;
|
|
137
145
|
}
|
|
138
146
|
async runApiServer(options) {
|
|
139
147
|
const port = options.port || 3000;
|
|
@@ -149,6 +157,13 @@ class ApiServerMain {
|
|
|
149
157
|
});
|
|
150
158
|
});
|
|
151
159
|
this.workspace.registerOnBitmapChange(async () => {
|
|
160
|
+
const lastModifiedTimestamp = await this.workspace.bitMap.getLastModifiedBitmapThroughBit();
|
|
161
|
+
const secondsPassedSinceLastModified = lastModifiedTimestamp && (Date.now() - lastModifiedTimestamp) / 1000;
|
|
162
|
+
if (secondsPassedSinceLastModified && secondsPassedSinceLastModified > 1) {
|
|
163
|
+
// changes by bit were done more than a second ago, so probably this .bitmap change was done by "git pull"
|
|
164
|
+
this.logger.debug(`running import because we assume the .bitmap file has changed due to "git pull", last time it was modified by bit was ${secondsPassedSinceLastModified} seconds ago`);
|
|
165
|
+
await this.importer.importCurrentObjects();
|
|
166
|
+
}
|
|
152
167
|
(0, _sseEvents().sendEventsToClients)('onBitmapChange', {});
|
|
153
168
|
});
|
|
154
169
|
this.installer.registerPostInstall(async () => {
|
|
@@ -166,9 +181,9 @@ class ApiServerMain {
|
|
|
166
181
|
this.logger.consoleSuccess(`Bit Server is listening on port ${port}`);
|
|
167
182
|
});
|
|
168
183
|
}
|
|
169
|
-
static async provider([cli, workspace, loggerMain, express, watcher, snapping, lanes, installer, exporter, checkout, componentLog]) {
|
|
184
|
+
static async provider([cli, workspace, loggerMain, express, watcher, snapping, lanes, installer, exporter, checkout, componentLog, importer]) {
|
|
170
185
|
const logger = loggerMain.createLogger(_apiServer().ApiServerAspect.id);
|
|
171
|
-
const apiServer = new ApiServerMain(workspace, logger, express, watcher, installer);
|
|
186
|
+
const apiServer = new ApiServerMain(workspace, logger, express, watcher, installer, importer);
|
|
172
187
|
cli.register(new (_server().ServerCmd)(apiServer));
|
|
173
188
|
const cliRoute = new (_cli2().CLIRoute)(logger, cli);
|
|
174
189
|
const apiForIDE = new (_apiForIde().APIForIDE)(workspace, snapping, lanes, installer, exporter, checkout, componentLog);
|
|
@@ -182,7 +197,7 @@ class ApiServerMain {
|
|
|
182
197
|
}
|
|
183
198
|
}
|
|
184
199
|
exports.ApiServerMain = ApiServerMain;
|
|
185
|
-
_defineProperty(ApiServerMain, "dependencies", [_cli().CLIAspect, _workspace().default, _logger().LoggerAspect, _express().ExpressAspect, _watcher().default, _snapping().default, _lanes().default, _install().default, _export().ExportAspect, _checkout().default, _componentLog().default]);
|
|
200
|
+
_defineProperty(ApiServerMain, "dependencies", [_cli().CLIAspect, _workspace().default, _logger().LoggerAspect, _express().ExpressAspect, _watcher().default, _snapping().default, _lanes().default, _install().default, _export().ExportAspect, _checkout().default, _componentLog().default, _importer().default]);
|
|
186
201
|
_defineProperty(ApiServerMain, "runtime", _cli().MainRuntime);
|
|
187
202
|
_apiServer().ApiServerAspect.addRuntime(ApiServerMain);
|
|
188
203
|
var _default = ApiServerMain;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_cli","data","require","_express","_logger","_lanes","_interopRequireDefault","_snapping","_componentLog","_watcher","_export","_checkout","_install","_workspace","_apiServer","_cli2","_server","_ide","_apiForIde","_sseEvents","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","ApiServerMain","constructor","workspace","logger","express","watcher","installer","runApiServer","options","port","listen","Error","process","cwd","registerOnComponentChange","component","files","removedFiles","sendEventsToClients","id","toStringWithoutVersion","registerOnBitmapChange","registerPostInstall","watch","preCompile","catch","err","error","Promise","consoleSuccess","provider","cli","loggerMain","snapping","lanes","exporter","checkout","componentLog","createLogger","ApiServerAspect","apiServer","register","ServerCmd","cliRoute","CLIRoute","apiForIDE","APIForIDE","vscodeRoute","IDERoute","sseEventsRoute","SSEEventsRoute","exports","CLIAspect","WorkspaceAspect","LoggerAspect","ExpressAspect","WatcherAspect","SnappingAspect","LanesAspect","InstallAspect","ExportAspect","CheckoutAspect","ComponentLogAspect","MainRuntime","addRuntime","_default"],"sources":["api-server.main.runtime.ts"],"sourcesContent":["import { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli';\nimport { ExpressAspect, ExpressMain } from '@teambit/express';\nimport { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';\nimport LanesAspect, { LanesMain } from '@teambit/lanes';\nimport SnappingAspect, { SnappingMain } from '@teambit/snapping';\nimport ComponentLogAspect, { ComponentLogMain } from '@teambit/component-log';\nimport WatcherAspect, { WatcherMain } from '@teambit/watcher';\nimport { ExportAspect, ExportMain } from '@teambit/export';\nimport CheckoutAspect, { CheckoutMain } from '@teambit/checkout';\nimport InstallAspect, { InstallMain } from '@teambit/install';\nimport { Component } from '@teambit/component';\nimport WorkspaceAspect, { Workspace } from '@teambit/workspace';\nimport { ApiServerAspect } from './api-server.aspect';\nimport { CLIRoute } from './cli.route';\nimport { ServerCmd } from './server.cmd';\nimport { IDERoute } from './ide.route';\nimport { APIForIDE } from './api-for-ide';\nimport { SSEEventsRoute, sendEventsToClients } from './sse-events.route';\n\nexport class ApiServerMain {\n constructor(\n private workspace: Workspace,\n private logger: Logger,\n private express: ExpressMain,\n private watcher: WatcherMain,\n private installer: InstallMain\n ) {}\n\n async runApiServer(options: { port: number }) {\n const port = options.port || 3000;\n await this.express.listen(port);\n if (!this.workspace) {\n throw new Error(`unable to run bit-server, the current directory ${process.cwd()} is not a workspace`);\n }\n\n this.workspace.registerOnComponentChange(\n async (\n component: Component,\n files: string[], // os absolute paths\n removedFiles?: string[] // os absolute paths\n ) => {\n sendEventsToClients('onComponentChange', {\n id: component.id.toStringWithoutVersion(),\n files,\n removedFiles,\n });\n }\n );\n\n this.workspace.registerOnBitmapChange(async () => {\n sendEventsToClients('onBitmapChange', {});\n });\n\n this.installer.registerPostInstall(async () => {\n sendEventsToClients('onPostInstall', {});\n });\n\n this.watcher\n .watch({\n preCompile: false,\n })\n .catch((err) => {\n // don't throw an error, we don't want to break the \"run\" process\n this.logger.error('watcher found an error', err);\n });\n\n // never ending promise to not exit the process (is there a better way?)\n return new Promise(() => {\n this.logger.consoleSuccess(`Bit Server is listening on port ${port}`);\n });\n }\n\n static dependencies = [\n CLIAspect,\n WorkspaceAspect,\n LoggerAspect,\n ExpressAspect,\n WatcherAspect,\n SnappingAspect,\n LanesAspect,\n InstallAspect,\n ExportAspect,\n CheckoutAspect,\n ComponentLogAspect,\n ];\n static runtime = MainRuntime;\n static async provider([\n cli,\n workspace,\n loggerMain,\n express,\n watcher,\n snapping,\n lanes,\n installer,\n exporter,\n checkout,\n componentLog,\n ]: [\n CLIMain,\n Workspace,\n LoggerMain,\n ExpressMain,\n WatcherMain,\n SnappingMain,\n LanesMain,\n InstallMain,\n ExportMain,\n CheckoutMain,\n ComponentLogMain\n ]) {\n const logger = loggerMain.createLogger(ApiServerAspect.id);\n const apiServer = new ApiServerMain(workspace, logger, express, watcher, installer);\n cli.register(new ServerCmd(apiServer));\n\n const cliRoute = new CLIRoute(logger, cli);\n const apiForIDE = new APIForIDE(workspace, snapping, lanes, installer, exporter, checkout, componentLog);\n const vscodeRoute = new IDERoute(logger, apiForIDE);\n const sseEventsRoute = new SSEEventsRoute(logger, cli);\n // register only when the workspace is available. don't register this on a remote-scope, for security reasons.\n if (workspace) {\n express.register([cliRoute, vscodeRoute, sseEventsRoute]);\n }\n\n return apiServer;\n }\n}\n\nApiServerAspect.addRuntime(ApiServerMain);\n\nexport default ApiServerMain;\n"],"mappings":";;;;;;AAAA,SAAAA,KAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,IAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,SAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,QAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,QAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,OAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,OAAA;EAAA,MAAAJ,IAAA,GAAAK,sBAAA,CAAAJ,OAAA;EAAAG,MAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;E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A,IAAI7B,SAAS,EAAE;MACbE,OAAO,CAACqC,QAAQ,CAAC,CAACE,QAAQ,EAAEI,WAAW,EAAEE,cAAc,CAAC,CAAC;IAC3D;IAEA,OAAOT,SAAS;EAClB;AACF;AAACW,OAAA,CAAAnD,aAAA,GAAAA,aAAA;AAAAtB,eAAA,CA3GYsB,aAAa,kBAqDF,CACpBoD,gBAAS,EACTC,oBAAe,EACfC,sBAAY,EACZC,wBAAa,EACbC,kBAAa,EACbC,mBAAc,EACdC,gBAAW,EACXC,kBAAa,EACbC,sBAAY,EACZC,mBAAc,EACdC,uBAAkB,CACnB;AAAApF,eAAA,CAjEUsB,aAAa,aAkEP+D,kBAAW;AA2C9BxB,4BAAe,CAACyB,UAAU,CAAChE,aAAa,CAAC;AAAC,IAAAiE,QAAA,GAE3BjE,aAAa;AAAAmD,OAAA,CAAA1E,OAAA,GAAAwF,QAAA"}
|
|
1
|
+
{"version":3,"names":["_cli","data","require","_express","_logger","_lanes","_interopRequireDefault","_snapping","_componentLog","_watcher","_export","_checkout","_install","_importer","_workspace","_apiServer","_cli2","_server","_ide","_apiForIde","_sseEvents","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","ApiServerMain","constructor","workspace","logger","express","watcher","installer","importer","runApiServer","options","port","listen","Error","process","cwd","registerOnComponentChange","component","files","removedFiles","sendEventsToClients","id","toStringWithoutVersion","registerOnBitmapChange","lastModifiedTimestamp","bitMap","getLastModifiedBitmapThroughBit","secondsPassedSinceLastModified","Date","now","debug","importCurrentObjects","registerPostInstall","watch","preCompile","catch","err","error","Promise","consoleSuccess","provider","cli","loggerMain","snapping","lanes","exporter","checkout","componentLog","createLogger","ApiServerAspect","apiServer","register","ServerCmd","cliRoute","CLIRoute","apiForIDE","APIForIDE","vscodeRoute","IDERoute","sseEventsRoute","SSEEventsRoute","exports","CLIAspect","WorkspaceAspect","LoggerAspect","ExpressAspect","WatcherAspect","SnappingAspect","LanesAspect","InstallAspect","ExportAspect","CheckoutAspect","ComponentLogAspect","ImporterAspect","MainRuntime","addRuntime","_default"],"sources":["api-server.main.runtime.ts"],"sourcesContent":["import { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli';\nimport { ExpressAspect, ExpressMain } from '@teambit/express';\nimport { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';\nimport LanesAspect, { LanesMain } from '@teambit/lanes';\nimport SnappingAspect, { SnappingMain } from '@teambit/snapping';\nimport ComponentLogAspect, { ComponentLogMain } from '@teambit/component-log';\nimport WatcherAspect, { WatcherMain } from '@teambit/watcher';\nimport { ExportAspect, ExportMain } from '@teambit/export';\nimport CheckoutAspect, { CheckoutMain } from '@teambit/checkout';\nimport InstallAspect, { InstallMain } from '@teambit/install';\nimport ImporterAspect, { ImporterMain } from '@teambit/importer';\nimport { Component } from '@teambit/component';\nimport WorkspaceAspect, { Workspace } from '@teambit/workspace';\nimport { ApiServerAspect } from './api-server.aspect';\nimport { CLIRoute } from './cli.route';\nimport { ServerCmd } from './server.cmd';\nimport { IDERoute } from './ide.route';\nimport { APIForIDE } from './api-for-ide';\nimport { SSEEventsRoute, sendEventsToClients } from './sse-events.route';\n\nexport class ApiServerMain {\n constructor(\n private workspace: Workspace,\n private logger: Logger,\n private express: ExpressMain,\n private watcher: WatcherMain,\n private installer: InstallMain,\n private importer: ImporterMain\n ) {}\n\n async runApiServer(options: { port: number }) {\n const port = options.port || 3000;\n await this.express.listen(port);\n if (!this.workspace) {\n throw new Error(`unable to run bit-server, the current directory ${process.cwd()} is not a workspace`);\n }\n\n this.workspace.registerOnComponentChange(\n async (\n component: Component,\n files: string[], // os absolute paths\n removedFiles?: string[] // os absolute paths\n ) => {\n sendEventsToClients('onComponentChange', {\n id: component.id.toStringWithoutVersion(),\n files,\n removedFiles,\n });\n }\n );\n\n this.workspace.registerOnBitmapChange(async () => {\n const lastModifiedTimestamp = await this.workspace.bitMap.getLastModifiedBitmapThroughBit();\n const secondsPassedSinceLastModified = lastModifiedTimestamp && (Date.now() - lastModifiedTimestamp) / 1000;\n if (secondsPassedSinceLastModified && secondsPassedSinceLastModified > 1) {\n // changes by bit were done more than a second ago, so probably this .bitmap change was done by \"git pull\"\n this.logger.debug(\n `running import because we assume the .bitmap file has changed due to \"git pull\", last time it was modified by bit was ${secondsPassedSinceLastModified} seconds ago`\n );\n await this.importer.importCurrentObjects();\n }\n sendEventsToClients('onBitmapChange', {});\n });\n\n this.installer.registerPostInstall(async () => {\n sendEventsToClients('onPostInstall', {});\n });\n\n this.watcher\n .watch({\n preCompile: false,\n })\n .catch((err) => {\n // don't throw an error, we don't want to break the \"run\" process\n this.logger.error('watcher found an error', err);\n });\n\n // never ending promise to not exit the process (is there a better way?)\n return new Promise(() => {\n this.logger.consoleSuccess(`Bit Server is listening on port ${port}`);\n });\n }\n\n static dependencies = [\n CLIAspect,\n WorkspaceAspect,\n LoggerAspect,\n ExpressAspect,\n WatcherAspect,\n SnappingAspect,\n LanesAspect,\n InstallAspect,\n ExportAspect,\n CheckoutAspect,\n ComponentLogAspect,\n ImporterAspect,\n ];\n static runtime = MainRuntime;\n static async provider([\n cli,\n workspace,\n loggerMain,\n express,\n watcher,\n snapping,\n lanes,\n installer,\n exporter,\n checkout,\n componentLog,\n importer,\n ]: [\n CLIMain,\n Workspace,\n LoggerMain,\n ExpressMain,\n WatcherMain,\n SnappingMain,\n LanesMain,\n InstallMain,\n ExportMain,\n CheckoutMain,\n ComponentLogMain,\n ImporterMain\n ]) {\n const logger = loggerMain.createLogger(ApiServerAspect.id);\n const apiServer = new ApiServerMain(workspace, logger, express, watcher, installer, importer);\n cli.register(new ServerCmd(apiServer));\n\n const cliRoute = new CLIRoute(logger, cli);\n const apiForIDE = new APIForIDE(workspace, snapping, lanes, installer, exporter, checkout, componentLog);\n const vscodeRoute = new IDERoute(logger, apiForIDE);\n const sseEventsRoute = new SSEEventsRoute(logger, cli);\n // register only when the workspace is available. don't register this on a remote-scope, for security reasons.\n if (workspace) {\n express.register([cliRoute, vscodeRoute, sseEventsRoute]);\n }\n\n return apiServer;\n }\n}\n\nApiServerAspect.addRuntime(ApiServerMain);\n\nexport default ApiServerMain;\n"],"mappings":";;;;;;AAAA,SAAAA,KAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,IAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,SAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,QAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,QAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,OAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,OAAA;EAAA,MAAAJ,IAAA,GAAAK,sBAAA,CAAAJ,OAAA;EAAAG,MAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,UAAA;EAAA,MAAAN,IAAA,GAAAK,sBAAA,CAAAJ,OAAA;EAAAK,SAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAO,cAAA;EAAA,MAAAP,IAAA,GAAAK,sBAAA,CAAAJ,OAAA;EAAAM,aAAA,YAAAA,CAAA;IAAA,OAAAP,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAQ,SAAA;EAAA,MAAAR,IAAA,GAAAK,sBAAA,CAAAJ,OAAA;EAAAO,QAAA,YAAAA,CAAA;IAAA,OAAAR,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAS,QAAA;EAAA,MAAAT,IAAA,GAAAC,OAAA;EAAAQ,OAAA,YAAAA,CAAA;IAAA,OAAAT,IAAA;EAAA;E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GAAG,KAAIC,2BAAc,EAACxD,MAAM,EAAEqC,GAAG,CAAC;IACtD;IACA,IAAItC,SAAS,EAAE;MACbE,OAAO,CAAC8C,QAAQ,CAAC,CAACE,QAAQ,EAAEI,WAAW,EAAEE,cAAc,CAAC,CAAC;IAC3D;IAEA,OAAOT,SAAS;EAClB;AACF;AAACW,OAAA,CAAA5D,aAAA,GAAAA,aAAA;AAAAtB,eAAA,CAxHYsB,aAAa,kBA+DF,CACpB6D,gBAAS,EACTC,oBAAe,EACfC,sBAAY,EACZC,wBAAa,EACbC,kBAAa,EACbC,mBAAc,EACdC,gBAAW,EACXC,kBAAa,EACbC,sBAAY,EACZC,mBAAc,EACdC,uBAAkB,EAClBC,mBAAc,CACf;AAAA9F,eAAA,CA5EUsB,aAAa,aA6EPyE,kBAAW;AA6C9BzB,4BAAe,CAAC0B,UAAU,CAAC1E,aAAa,CAAC;AAAC,IAAA2E,QAAA,GAE3B3E,aAAa;AAAA4D,OAAA,CAAAnF,OAAA,GAAAkG,QAAA"}
|
package/dist/ide.route.js
CHANGED
|
@@ -45,7 +45,7 @@ class IDERoute {
|
|
|
45
45
|
const result = await this.apiForIDE[req.params.method](...args);
|
|
46
46
|
const duration = (0, _prettyTime().default)(process.hrtime(startTask));
|
|
47
47
|
this.logger.consoleSuccess(`api-IDE call: ${req.params.method} had been completed in ${duration}`);
|
|
48
|
-
res.json(result
|
|
48
|
+
res.json(result);
|
|
49
49
|
} catch (err) {
|
|
50
50
|
this.logger.error(`api-IDE call: ${req.params.method} had failed`, err);
|
|
51
51
|
this.logger.consoleFailure(`api-IDE call: ${req.params.method} had failed. ${err.message}`);
|
package/dist/ide.route.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_prettyTime","data","_interopRequireDefault","require","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","IDERoute","constructor","logger","apiForIDE","req","debug","params","method","Error","body","args","console","length","startTask","process","hrtime","result","duration","prettyTime","consoleSuccess","json","err","error","consoleFailure","message","status","jsonp","exports"],"sources":["ide.route.ts"],"sourcesContent":["import prettyTime from 'pretty-time';\nimport { Route, Request, Response } from '@teambit/express';\nimport { Logger } from '@teambit/logger';\nimport { APIForIDE } from './api-for-ide';\n\n/**\n * example usage:\n * post to http://localhost:3000/api/ide/list-dirs\n * with the following json as the body\n *\n{\n \"args\": [\"some-args\"]\n}\n */\nexport class IDERoute implements Route {\n constructor(private logger: Logger, private apiForIDE: APIForIDE) {}\n\n method = 'post';\n route = '/ide/:method';\n\n middlewares = [\n async (req: Request, res: Response) => {\n this.logger.debug(`api-IDE: got request for ${req.params.method}`);\n try {\n if (!this.apiForIDE[req.params.method]) {\n throw new Error(`API \"${req.params.method}\" was not found`);\n }\n const body = req.body;\n const { args } = body;\n this.logger.console(`started a new api-IDE call: ${req.params.method}, total: ${args?.length || 0} args`);\n const startTask = process.hrtime();\n const result = await this.apiForIDE[req.params.method](...args);\n const duration = prettyTime(process.hrtime(startTask));\n this.logger.consoleSuccess(`api-IDE call: ${req.params.method} had been completed in ${duration}`);\n res.json(result
|
|
1
|
+
{"version":3,"names":["_prettyTime","data","_interopRequireDefault","require","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","IDERoute","constructor","logger","apiForIDE","req","debug","params","method","Error","body","args","console","length","startTask","process","hrtime","result","duration","prettyTime","consoleSuccess","json","err","error","consoleFailure","message","status","jsonp","exports"],"sources":["ide.route.ts"],"sourcesContent":["import prettyTime from 'pretty-time';\nimport { Route, Request, Response } from '@teambit/express';\nimport { Logger } from '@teambit/logger';\nimport { APIForIDE } from './api-for-ide';\n\n/**\n * example usage:\n * post to http://localhost:3000/api/ide/list-dirs\n * with the following json as the body\n *\n{\n \"args\": [\"some-args\"]\n}\n */\nexport class IDERoute implements Route {\n constructor(private logger: Logger, private apiForIDE: APIForIDE) {}\n\n method = 'post';\n route = '/ide/:method';\n\n middlewares = [\n async (req: Request, res: Response) => {\n this.logger.debug(`api-IDE: got request for ${req.params.method}`);\n try {\n if (!this.apiForIDE[req.params.method]) {\n throw new Error(`API \"${req.params.method}\" was not found`);\n }\n const body = req.body;\n const { args } = body;\n this.logger.console(`started a new api-IDE call: ${req.params.method}, total: ${args?.length || 0} args`);\n const startTask = process.hrtime();\n const result = await this.apiForIDE[req.params.method](...args);\n const duration = prettyTime(process.hrtime(startTask));\n this.logger.consoleSuccess(`api-IDE call: ${req.params.method} had been completed in ${duration}`);\n res.json(result);\n } catch (err: any) {\n this.logger.error(`api-IDE call: ${req.params.method} had failed`, err);\n this.logger.consoleFailure(`api-IDE call: ${req.params.method} had failed. ${err.message}`);\n res.status(500).jsonp(err.message);\n }\n },\n ];\n}\n"],"mappings":";;;;;;AAAA,SAAAA,YAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,WAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAqC,SAAAC,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,gBAAAH,GAAA,EAAAI,GAAA,EAAAC,KAAA,IAAAD,GAAA,GAAAE,cAAA,CAAAF,GAAA,OAAAA,GAAA,IAAAJ,GAAA,IAAAO,MAAA,CAAAC,cAAA,CAAAR,GAAA,EAAAI,GAAA,IAAAC,KAAA,EAAAA,KAAA,EAAAI,UAAA,QAAAC,YAAA,QAAAC,QAAA,oBAAAX,GAAA,CAAAI,GAAA,IAAAC,KAAA,WAAAL,GAAA;AAAA,SAAAM,eAAAM,GAAA,QAAAR,GAAA,GAAAS,YAAA,CAAAD,GAAA,2BAAAR,GAAA,gBAAAA,G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AM,CAAC,CAAC;QAClC,MAAMC,MAAM,GAAG,MAAM,IAAI,CAACb,SAAS,CAACC,GAAG,CAACE,MAAM,CAACC,MAAM,CAAC,CAAC,GAAGG,IAAI,CAAC;QAC/D,MAAMO,QAAQ,GAAG,IAAAC,qBAAU,EAACJ,OAAO,CAACC,MAAM,CAACF,SAAS,CAAC,CAAC;QACtD,IAAI,CAACX,MAAM,CAACiB,cAAc,CAAE,iBAAgBf,GAAG,CAACE,MAAM,CAACC,MAAO,0BAAyBU,QAAS,EAAC,CAAC;QAClGrB,GAAG,CAACwB,IAAI,CAACJ,MAAM,CAAC;MAClB,CAAC,CAAC,OAAOK,GAAQ,EAAE;QACjB,IAAI,CAACnB,MAAM,CAACoB,KAAK,CAAE,iBAAgBlB,GAAG,CAACE,MAAM,CAACC,MAAO,aAAY,EAAEc,GAAG,CAAC;QACvE,IAAI,CAACnB,MAAM,CAACqB,cAAc,CAAE,iBAAgBnB,GAAG,CAACE,MAAM,CAACC,MAAO,gBAAec,GAAG,CAACG,OAAQ,EAAC,CAAC;QAC3F5B,GAAG,CAAC6B,MAAM,CAAC,GAAG,CAAC,CAACC,KAAK,CAACL,GAAG,CAACG,OAAO,CAAC;MACpC;IACF,CAAC,CACF;EA1BkE;AA2BrE;AAACG,OAAA,CAAA3B,QAAA,GAAAA,QAAA"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/api-server",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.180",
|
|
4
4
|
"homepage": "https://bit.cloud/teambit/harmony/api-server",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.harmony",
|
|
8
8
|
"name": "api-server",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.180"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"fs-extra": "10.0.0",
|
|
@@ -14,19 +14,20 @@
|
|
|
14
14
|
"lodash": "4.17.21",
|
|
15
15
|
"pretty-time": "1.1.0",
|
|
16
16
|
"@teambit/harmony": "0.4.6",
|
|
17
|
-
"@teambit/checkout": "0.0.
|
|
18
|
-
"@teambit/component-log": "0.0.
|
|
19
|
-
"@teambit/export": "0.0.
|
|
20
|
-
"@teambit/install": "0.0.
|
|
21
|
-
"@teambit/lanes": "0.0.
|
|
22
|
-
"@teambit/merging": "0.0.
|
|
23
|
-
"@teambit/snapping": "0.0.
|
|
24
|
-
"@teambit/workspace": "0.0.
|
|
25
|
-
"@teambit/cli": "0.0.
|
|
26
|
-
"@teambit/component": "0.0.
|
|
27
|
-
"@teambit/express": "0.0.
|
|
28
|
-
"@teambit/
|
|
29
|
-
"@teambit/
|
|
17
|
+
"@teambit/checkout": "0.0.337",
|
|
18
|
+
"@teambit/component-log": "0.0.545",
|
|
19
|
+
"@teambit/export": "0.0.1168",
|
|
20
|
+
"@teambit/install": "0.0.252",
|
|
21
|
+
"@teambit/lanes": "0.0.740",
|
|
22
|
+
"@teambit/merging": "0.0.483",
|
|
23
|
+
"@teambit/snapping": "0.0.483",
|
|
24
|
+
"@teambit/workspace": "0.0.1168",
|
|
25
|
+
"@teambit/cli": "0.0.779",
|
|
26
|
+
"@teambit/component": "0.0.1168",
|
|
27
|
+
"@teambit/express": "0.0.878",
|
|
28
|
+
"@teambit/importer": "0.0.597",
|
|
29
|
+
"@teambit/logger": "0.0.872",
|
|
30
|
+
"@teambit/watcher": "0.0.180"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
32
33
|
"@types/fs-extra": "9.0.7",
|
|
@@ -39,7 +40,7 @@
|
|
|
39
40
|
"@types/testing-library__jest-dom": "5.9.5"
|
|
40
41
|
},
|
|
41
42
|
"peerDependencies": {
|
|
42
|
-
"@teambit/legacy": "1.0.
|
|
43
|
+
"@teambit/legacy": "1.0.564",
|
|
43
44
|
"react": "^16.8.0 || ^17.0.0",
|
|
44
45
|
"react-dom": "^16.8.0 || ^17.0.0"
|
|
45
46
|
},
|
|
File without changes
|