@teambit/api-server 0.0.74 → 0.0.75

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.
@@ -0,0 +1,8 @@
1
+ import { Workspace } from '@teambit/workspace';
2
+ import { PathOsBasedAbsolute } from '@teambit/legacy/dist/utils/path';
3
+ export declare class APIForVSCode {
4
+ private workspace;
5
+ constructor(workspace: Workspace);
6
+ listIdsWithPaths(): Promise<{}>;
7
+ getMainFilePath(id: string): Promise<PathOsBasedAbsolute>;
8
+ }
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ require("core-js/modules/es.promise.js");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.APIForVSCode = void 0;
9
+ function _path() {
10
+ const data = _interopRequireDefault(require("path"));
11
+ _path = function () {
12
+ return data;
13
+ };
14
+ return data;
15
+ }
16
+ class APIForVSCode {
17
+ constructor(workspace) {
18
+ this.workspace = workspace;
19
+ }
20
+ async listIdsWithPaths() {
21
+ const ids = await this.workspace.listIds();
22
+ return ids.reduce((acc, id) => {
23
+ acc[id.toStringWithoutVersion()] = this.workspace.componentDir(id);
24
+ return acc;
25
+ }, {});
26
+ }
27
+ async getMainFilePath(id) {
28
+ const compId = await this.workspace.resolveComponentId(id);
29
+ const comp = await this.workspace.get(compId);
30
+ return _path().default.join(this.workspace.componentDir(compId), comp.state._consumer.mainFile);
31
+ }
32
+ }
33
+ exports.APIForVSCode = APIForVSCode;
34
+
35
+ //# sourceMappingURL=api-for-vscode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["APIForVSCode","constructor","workspace","listIdsWithPaths","ids","listIds","reduce","acc","id","toStringWithoutVersion","componentDir","getMainFilePath","compId","resolveComponentId","comp","get","path","join","state","_consumer","mainFile"],"sources":["api-for-vscode.ts"],"sourcesContent":["import path from 'path';\nimport { Workspace } from '@teambit/workspace';\nimport { PathOsBasedAbsolute } from '@teambit/legacy/dist/utils/path';\n\nexport class APIForVSCode {\n constructor(private workspace: Workspace) {}\n\n async listIdsWithPaths() {\n const ids = await this.workspace.listIds();\n return ids.reduce((acc, id) => {\n acc[id.toStringWithoutVersion()] = this.workspace.componentDir(id);\n return acc;\n }, {});\n }\n\n async getMainFilePath(id: string): Promise<PathOsBasedAbsolute> {\n const compId = await this.workspace.resolveComponentId(id);\n const comp = await this.workspace.get(compId);\n return path.join(this.workspace.componentDir(compId), comp.state._consumer.mainFile);\n }\n}\n"],"mappings":";;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAIO,MAAMA,YAAY,CAAC;EACxBC,WAAW,CAASC,SAAoB,EAAE;IAAA,KAAtBA,SAAoB,GAApBA,SAAoB;EAAG;EAE3C,MAAMC,gBAAgB,GAAG;IACvB,MAAMC,GAAG,GAAG,MAAM,IAAI,CAACF,SAAS,CAACG,OAAO,EAAE;IAC1C,OAAOD,GAAG,CAACE,MAAM,CAAC,CAACC,GAAG,EAAEC,EAAE,KAAK;MAC7BD,GAAG,CAACC,EAAE,CAACC,sBAAsB,EAAE,CAAC,GAAG,IAAI,CAACP,SAAS,CAACQ,YAAY,CAACF,EAAE,CAAC;MAClE,OAAOD,GAAG;IACZ,CAAC,EAAE,CAAC,CAAC,CAAC;EACR;EAEA,MAAMI,eAAe,CAACH,EAAU,EAAgC;IAC9D,MAAMI,MAAM,GAAG,MAAM,IAAI,CAACV,SAAS,CAACW,kBAAkB,CAACL,EAAE,CAAC;IAC1D,MAAMM,IAAI,GAAG,MAAM,IAAI,CAACZ,SAAS,CAACa,GAAG,CAACH,MAAM,CAAC;IAC7C,OAAOI,eAAI,CAACC,IAAI,CAAC,IAAI,CAACf,SAAS,CAACQ,YAAY,CAACE,MAAM,CAAC,EAAEE,IAAI,CAACI,KAAK,CAACC,SAAS,CAACC,QAAQ,CAAC;EACtF;AACF;AAAC"}
@@ -70,6 +70,20 @@ function _server() {
70
70
  };
71
71
  return data;
72
72
  }
73
+ function _vscode() {
74
+ const data = require("./vscode.route");
75
+ _vscode = function () {
76
+ return data;
77
+ };
78
+ return data;
79
+ }
80
+ function _apiForVscode() {
81
+ const data = require("./api-for-vscode");
82
+ _apiForVscode = function () {
83
+ return data;
84
+ };
85
+ return data;
86
+ }
73
87
  class ApiServerMain {
74
88
  constructor(workspace, logger, express, watcher) {
75
89
  this.workspace = workspace;
@@ -100,9 +114,11 @@ class ApiServerMain {
100
114
  const apiServer = new ApiServerMain(workspace, logger, express, watcher);
101
115
  cli.register(new (_server().ServerCmd)(apiServer));
102
116
  const cliRoute = new (_cli2().CLIRoute)(logger, cli);
117
+ const apiForVscode = new (_apiForVscode().APIForVSCode)(workspace);
118
+ const vscodeRoute = new (_vscode().VSCodeRoute)(logger, apiForVscode);
103
119
  // register only when the workspace is available. don't register this on a remote-scope, for security reasons.
104
120
  if (workspace) {
105
- express.register([cliRoute]);
121
+ express.register([cliRoute, vscodeRoute]);
106
122
  }
107
123
  return apiServer;
108
124
  }
@@ -1 +1 @@
1
- {"version":3,"names":["ApiServerMain","constructor","workspace","logger","express","watcher","runApiServer","options","port","listen","Error","process","cwd","watch","preCompile","catch","err","error","Promise","consoleSuccess","provider","cli","loggerMain","createLogger","ApiServerAspect","id","apiServer","register","ServerCmd","cliRoute","CLIRoute","CLIAspect","WorkspaceAspect","LoggerAspect","ExpressAspect","WatcherAspect","MainRuntime","addRuntime"],"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 WatcherAspect, { WatcherMain } from '@teambit/watcher';\nimport WorkspaceAspect, { Workspace } from '@teambit/workspace';\nimport { ApiServerAspect } from './api-server.aspect';\nimport { CLIRoute } from './cli.route';\nimport { ServerCmd } from './server.cmd';\n\nexport class ApiServerMain {\n constructor(\n private workspace: Workspace,\n private logger: Logger,\n private express: ExpressMain,\n private watcher: WatcherMain\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 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 = [CLIAspect, WorkspaceAspect, LoggerAspect, ExpressAspect, WatcherAspect];\n static runtime = MainRuntime;\n static async provider([cli, workspace, loggerMain, express, watcher]: [\n CLIMain,\n Workspace,\n LoggerMain,\n ExpressMain,\n WatcherMain\n ]) {\n const logger = loggerMain.createLogger(ApiServerAspect.id);\n const apiServer = new ApiServerMain(workspace, logger, express, watcher);\n cli.register(new ServerCmd(apiServer));\n\n const cliRoute = new CLIRoute(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]);\n }\n\n return apiServer;\n }\n}\n\nApiServerAspect.addRuntime(ApiServerMain);\n\nexport default ApiServerMain;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEO,MAAMA,aAAa,CAAC;EACzBC,WAAW,CACDC,SAAoB,EACpBC,MAAc,EACdC,OAAoB,EACpBC,OAAoB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S,EAAE;MACbE,OAAO,CAACuB,QAAQ,CAAC,CAACE,QAAQ,CAAC,CAAC;IAC9B;IAEA,OAAOH,SAAS;EAClB;AACF;AAAC;AAAA,gCAlDY1B,aAAa,kBA6BF,CAAC+B,gBAAS,EAAEC,oBAAe,EAAEC,sBAAY,EAAEC,wBAAa,EAAEC,kBAAa,CAAC;AAAA,gCA7BnFnC,aAAa,aA8BPoC,kBAAW;AAsB9BZ,4BAAe,CAACa,UAAU,CAACrC,aAAa,CAAC;AAAC,eAE3BA,aAAa;AAAA"}
1
+ {"version":3,"names":["ApiServerMain","constructor","workspace","logger","express","watcher","runApiServer","options","port","listen","Error","process","cwd","watch","preCompile","catch","err","error","Promise","consoleSuccess","provider","cli","loggerMain","createLogger","ApiServerAspect","id","apiServer","register","ServerCmd","cliRoute","CLIRoute","apiForVscode","APIForVSCode","vscodeRoute","VSCodeRoute","CLIAspect","WorkspaceAspect","LoggerAspect","ExpressAspect","WatcherAspect","MainRuntime","addRuntime"],"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 WatcherAspect, { WatcherMain } from '@teambit/watcher';\nimport WorkspaceAspect, { Workspace } from '@teambit/workspace';\nimport { ApiServerAspect } from './api-server.aspect';\nimport { CLIRoute } from './cli.route';\nimport { ServerCmd } from './server.cmd';\nimport { VSCodeRoute } from './vscode.route';\nimport { APIForVSCode } from './api-for-vscode';\n\nexport class ApiServerMain {\n constructor(\n private workspace: Workspace,\n private logger: Logger,\n private express: ExpressMain,\n private watcher: WatcherMain\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 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 = [CLIAspect, WorkspaceAspect, LoggerAspect, ExpressAspect, WatcherAspect];\n static runtime = MainRuntime;\n static async provider([cli, workspace, loggerMain, express, watcher]: [\n CLIMain,\n Workspace,\n LoggerMain,\n ExpressMain,\n WatcherMain\n ]) {\n const logger = loggerMain.createLogger(ApiServerAspect.id);\n const apiServer = new ApiServerMain(workspace, logger, express, watcher);\n cli.register(new ServerCmd(apiServer));\n\n const cliRoute = new CLIRoute(logger, cli);\n const apiForVscode = new APIForVSCode(workspace);\n const vscodeRoute = new VSCodeRoute(logger, apiForVscode);\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]);\n }\n\n return apiServer;\n }\n}\n\nApiServerAspect.addRuntime(ApiServerMain);\n\nexport default ApiServerMain;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEO,MAAMA,aAAa,CAAC;EACzBC,WAAW,CACDC,SAAoB,EACpBC,MAAc,EACdC,OAAoB,EACpBC,OAAoB,EAC5B;IAAA,KAJQH,SAAoB,GAApBA,SAAoB;IAAA,KACpBC,MAAc,GAAdA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IC,qBAAW,EAAC/B,MAAM,EAAE4B,YAAY,CAAC;IACzD;IACA,IAAI7B,SAAS,EAAE;MACbE,OAAO,CAACuB,QAAQ,CAAC,CAACE,QAAQ,EAAEI,WAAW,CAAC,CAAC;IAC3C;IAEA,OAAOP,SAAS;EAClB;AACF;AAAC;AAAA,gCApDY1B,aAAa,kBA6BF,CAACmC,gBAAS,EAAEC,oBAAe,EAAEC,sBAAY,EAAEC,wBAAa,EAAEC,kBAAa,CAAC;AAAA,gCA7BnFvC,aAAa,aA8BPwC,kBAAW;AAwB9BhB,4BAAe,CAACiB,UAAU,CAACzC,aAAa,CAAC;AAAC,eAE3BA,aAAa;AAAA"}
@@ -0,0 +1,20 @@
1
+ import { Route, Request, Response } from '@teambit/express';
2
+ import { Logger } from '@teambit/logger';
3
+ import { APIForVSCode } from './api-for-vscode';
4
+ /**
5
+ * example usage:
6
+ * post to http://localhost:3000/api/vscode/list-dirs
7
+ * with the following json as the body
8
+ *
9
+ {
10
+ "args": ["some-args"]
11
+ }
12
+ */
13
+ export declare class VSCodeRoute implements Route {
14
+ private logger;
15
+ private apiForVscode;
16
+ constructor(logger: Logger, apiForVscode: APIForVSCode);
17
+ method: string;
18
+ route: string;
19
+ middlewares: ((req: Request, res: Response) => Promise<void>)[];
20
+ }
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ require("core-js/modules/es.promise.js");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.VSCodeRoute = void 0;
9
+ function _defineProperty2() {
10
+ const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+ _defineProperty2 = function () {
12
+ return data;
13
+ };
14
+ return data;
15
+ }
16
+ function _prettyTime() {
17
+ const data = _interopRequireDefault(require("pretty-time"));
18
+ _prettyTime = function () {
19
+ return data;
20
+ };
21
+ return data;
22
+ }
23
+ /**
24
+ * example usage:
25
+ * post to http://localhost:3000/api/vscode/list-dirs
26
+ * with the following json as the body
27
+ *
28
+ {
29
+ "args": ["some-args"]
30
+ }
31
+ */
32
+ class VSCodeRoute {
33
+ constructor(logger, apiForVscode) {
34
+ this.logger = logger;
35
+ this.apiForVscode = apiForVscode;
36
+ (0, _defineProperty2().default)(this, "method", 'post');
37
+ (0, _defineProperty2().default)(this, "route", '/vscode/:method');
38
+ (0, _defineProperty2().default)(this, "middlewares", [async (req, res) => {
39
+ this.logger.debug(`cli server: got request for ${req.params.method}`);
40
+ try {
41
+ if (!this.apiForVscode[req.params.method]) {
42
+ throw new Error(`API "${req.params.method}" was not found`);
43
+ }
44
+ const body = req.body;
45
+ const {
46
+ args
47
+ } = body;
48
+ this.logger.console(`started a new api-vscode call: ${req.params.method}, total: ${(args === null || args === void 0 ? void 0 : args.length) || 0} args`);
49
+ const startTask = process.hrtime();
50
+ const result = await this.apiForVscode[req.params.method](args);
51
+ const duration = (0, _prettyTime().default)(process.hrtime(startTask));
52
+ this.logger.consoleSuccess(`api-vscode call: ${req.params.method} had been completed in ${duration}`);
53
+ res.json(result);
54
+ } catch (err) {
55
+ this.logger.error(`api-vscode call: ${req.params.method} had failed`, err);
56
+ this.logger.consoleFailure(`api-vscode call: ${req.params.method} had failed. ${err.message}`);
57
+ res.status(500).jsonp(err.message);
58
+ }
59
+ }]);
60
+ }
61
+ }
62
+ exports.VSCodeRoute = VSCodeRoute;
63
+
64
+ //# sourceMappingURL=vscode.route.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["VSCodeRoute","constructor","logger","apiForVscode","req","res","debug","params","method","Error","body","args","console","length","startTask","process","hrtime","result","duration","prettyTime","consoleSuccess","json","err","error","consoleFailure","message","status","jsonp"],"sources":["vscode.route.ts"],"sourcesContent":["import prettyTime from 'pretty-time';\nimport { Route, Request, Response } from '@teambit/express';\nimport { Logger } from '@teambit/logger';\nimport { APIForVSCode } from './api-for-vscode';\n\n/**\n * example usage:\n * post to http://localhost:3000/api/vscode/list-dirs\n * with the following json as the body\n *\n{\n \"args\": [\"some-args\"]\n}\n */\nexport class VSCodeRoute implements Route {\n constructor(private logger: Logger, private apiForVscode: APIForVSCode) {}\n\n method = 'post';\n route = '/vscode/:method';\n\n middlewares = [\n async (req: Request, res: Response) => {\n this.logger.debug(`cli server: got request for ${req.params.method}`);\n try {\n if (!this.apiForVscode[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-vscode call: ${req.params.method}, total: ${args?.length || 0} args`);\n const startTask = process.hrtime();\n const result = await this.apiForVscode[req.params.method](args);\n const duration = prettyTime(process.hrtime(startTask));\n this.logger.consoleSuccess(`api-vscode call: ${req.params.method} had been completed in ${duration}`);\n res.json(result);\n } catch (err: any) {\n this.logger.error(`api-vscode call: ${req.params.method} had failed`, err);\n this.logger.consoleFailure(`api-vscode call: ${req.params.method} had failed. ${err.message}`);\n res.status(500).jsonp(err.message);\n }\n },\n ];\n}\n"],"mappings":";;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,WAAW,CAAkB;EACxCC,WAAW,CAASC,MAAc,EAAUC,YAA0B,EAAE;IAAA,KAApDD,MAAc,GAAdA,MAAc;IAAA,KAAUC,YAA0B,GAA1BA,YAA0B;IAAA,gDAE7D,MAAM;IAAA,+CACP,iBAAiB;IAAA,qDAEX,CACZ,OAAOC,GAAY,EAAEC,GAAa,KAAK;MACrC,IAAI,CAACH,MAAM,CAACI,KAAK,CAAE,+BAA8BF,GAAG,CAACG,MAAM,CAACC,MAAO,EAAC,CAAC;MACrE,IAAI;QACF,IAAI,CAAC,IAAI,CAACL,YAAY,CAACC,GAAG,CAACG,MAAM,CAACC,MAAM,CAAC,EAAE;UACzC,MAAM,IAAIC,KAAK,CAAE,QAAOL,GAAG,CAACG,MAAM,CAACC,MAAO,iBAAgB,CAAC;QAC7D;QACA,MAAME,IAAI,GAAGN,GAAG,CAACM,IAAI;QACrB,MAAM;UAAEC;QAAK,CAAC,GAAGD,IAAI;QACrB,IAAI,CAACR,MAAM,CAACU,OAAO,CAAE,kCAAiCR,GAAG,CAACG,MAAM,CAACC,MAAO,YAAW,CAAAG,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEE,MAAM,KAAI,CAAE,OAAM,CAAC;QAC5G,MAAMC,SAAS,GAAGC,OAAO,CAACC,MAAM,EAAE;QAClC,MAAMC,MAAM,GAAG,MAAM,IAAI,CAACd,YAAY,CAACC,GAAG,CAACG,MAAM,CAACC,MAAM,CAAC,CAACG,IAAI,CAAC;QAC/D,MAAMO,QAAQ,GAAG,IAAAC,qBAAU,EAACJ,OAAO,CAACC,MAAM,CAACF,SAAS,CAAC,CAAC;QACtD,IAAI,CAACZ,MAAM,CAACkB,cAAc,CAAE,oBAAmBhB,GAAG,CAACG,MAAM,CAACC,MAAO,0BAAyBU,QAAS,EAAC,CAAC;QACrGb,GAAG,CAACgB,IAAI,CAACJ,MAAM,CAAC;MAClB,CAAC,CAAC,OAAOK,GAAQ,EAAE;QACjB,IAAI,CAACpB,MAAM,CAACqB,KAAK,CAAE,oBAAmBnB,GAAG,CAACG,MAAM,CAACC,MAAO,aAAY,EAAEc,GAAG,CAAC;QAC1E,IAAI,CAACpB,MAAM,CAACsB,cAAc,CAAE,oBAAmBpB,GAAG,CAACG,MAAM,CAACC,MAAO,gBAAec,GAAG,CAACG,OAAQ,EAAC,CAAC;QAC9FpB,GAAG,CAACqB,MAAM,CAAC,GAAG,CAAC,CAACC,KAAK,CAACL,GAAG,CAACG,OAAO,CAAC;MACpC;IACF,CAAC,CACF;EA1BwE;AA2B3E;AAAC"}
package/package.json CHANGED
@@ -1,23 +1,23 @@
1
1
  {
2
2
  "name": "@teambit/api-server",
3
- "version": "0.0.74",
3
+ "version": "0.0.75",
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.74"
9
+ "version": "0.0.75"
10
10
  },
11
11
  "dependencies": {
12
12
  "pretty-time": "1.1.0",
13
13
  "core-js": "^3.0.0",
14
14
  "@babel/runtime": "7.20.0",
15
15
  "@teambit/harmony": "0.4.6",
16
- "@teambit/cli": "0.0.715",
17
- "@teambit/express": "0.0.813",
18
- "@teambit/logger": "0.0.808",
19
- "@teambit/watcher": "0.0.74",
20
- "@teambit/workspace": "0.0.1062"
16
+ "@teambit/workspace": "0.0.1063",
17
+ "@teambit/cli": "0.0.716",
18
+ "@teambit/express": "0.0.814",
19
+ "@teambit/logger": "0.0.809",
20
+ "@teambit/watcher": "0.0.75"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@types/mocha": "9.1.0",
@@ -28,7 +28,7 @@
28
28
  "@types/testing-library__jest-dom": "5.9.5"
29
29
  },
30
30
  "peerDependencies": {
31
- "@teambit/legacy": "1.0.495",
31
+ "@teambit/legacy": "1.0.496",
32
32
  "react": "^16.8.0 || ^17.0.0",
33
33
  "react-dom": "^16.8.0 || ^17.0.0"
34
34
  },