@ms-cloudpack/api-server 0.47.2 → 0.47.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/trpc/createCloudpackServer.d.ts.map +1 -1
- package/lib/trpc/createCloudpackServer.js +1 -0
- package/lib/trpc/createCloudpackServer.js.map +1 -1
- package/lib/trpc/httpAdapter.d.ts +1 -0
- package/lib/trpc/httpAdapter.d.ts.map +1 -1
- package/lib/trpc/httpAdapter.js +1 -1
- package/lib/trpc/httpAdapter.js.map +1 -1
- package/package.json +10 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createCloudpackServer.d.ts","sourceRoot":"","sources":["../../src/trpc/createCloudpackServer.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAEnD;;GAEG;AACH,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,OAAO;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"createCloudpackServer.d.ts","sourceRoot":"","sources":["../../src/trpc/createCloudpackServer.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAEnD;;GAEG;AACH,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,OAAO;;;;;;;;;UA2DuB,UAAU,iDAAY;wFAAtB,UAAU,mDAAY;;;UAAtB,UAAU,sCAAY;qCAAtB,UAAU,2CAAY;;;UAAtB,UAAU,uCAAY;;;UAAtB,UAAU,4CAAY;;;;;;UAAtB,UAAU,6CAAY;yCAAtB,UAAU,+CAAY;;;;UAAtB,UAAU,2CAAY;;;;;UAAtB,UAAU,2CAAY;wCAAtB,UAAU,6DAAY;;;;UAAtB,UAAU,qDAAY;;;UAAtB,UAAU,2CAAY;;;UAAtB,UAAU,yCAAY;;;UAAtB,UAAU,mDAAY;;;;;UAAtB,UAAU,sDAAY;GAjBxG;AAED,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createCloudpackServer.js","sourceRoot":"","sources":["../../src/trpc/createCloudpackServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,OAAO,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,IAAI,CAAC;AACrC,OAAO,EAAE,eAAe,EAAkB,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAG7D;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,OAAgB;IAC1D,MAAM,aAAa,GAAG,MAAM,oBAAoB,CAAC,OAAO,CAAC,CAAC;IAC1D,MAAM,QAAQ,GAAG,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;IACtE,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,CAAC;IACvD,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IAC/D,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,eAAe,EAAE,CAAC;IAC3C,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,gBAAgB,CAAC;QAC1C,UAAU,EAAE,IAAI,EAAE;QAClB,MAAM;QACN,aAAa;QACb,KAAK;
|
|
1
|
+
{"version":3,"file":"createCloudpackServer.js","sourceRoot":"","s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AAE,EAAE;QAC7E,+DAA+D;QAC/D,WAAW,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;QAC9B,OAAO,GAAG,CAAC;IACb,CAAC,EACD,EAAuG,CACxG,CAAC;AACJ,CAAC","sourcesContent":["import { applyWSSHandler } from '@trpc/server/adapters/ws';\nimport getPort from 'get-port';\nimport { WebSocketServer } from 'ws';\nimport { createAppRouter, type AppRouter } from './createAppRouter.js';\nimport { createContextFactory } from './createContextFactory.js';\nimport { createHTTPServer } from './httpAdapter.js';\nimport cors from 'cors';\nimport { getDomain } from '@ms-cloudpack/create-express-app';\nimport type { Context } from '../types/Context.js';\n\n/**\n * Creates a cloudpack server that can be used to communicate with the cloudpack client using trpc.\n */\nexport async function createCloudpackServer(context: Context) {\n const createContext = await createContextFactory(context);\n const hostname = getDomain(context.session.config?.devServer?.domain);\n const https = context.session.config?.devServer?.https;\n const port = await getPort({ port: [9890, 9891, 9892, 9893] });\n const { router, apis } = createAppRouter();\n const { server, listen } = createHTTPServer({\n middleware: cors(),\n router,\n createContext,\n https,\n cwd: context.session.config.appPath,\n });\n const webSocketProtocol = https ? 'wss' : 'ws';\n const wss = new WebSocketServer({ server });\n\n applyWSSHandler<AppRouter>({\n wss,\n router,\n createContext,\n });\n\n listen(port, hostname);\n\n const localCallContext = await createContext();\n const apisWithContext = withContext(apis, localCallContext);\n const url = `${webSocketProtocol}://${hostname}:${port}`;\n context.session.urls.apiServer = url;\n\n return {\n ...apisWithContext,\n url,\n port,\n\n close: async () => {\n await new Promise<void>((resolve, reject) => {\n wss.clients.forEach((socket) => socket.terminate());\n wss.close((err) => (err ? reject(err) : resolve()));\n server.close();\n });\n },\n };\n}\n\nexport type CloudpackServer = ReturnType<typeof createCloudpackServer>;\n\n/** Helper to tie the local call context with the apis so callers don't have to cache them. */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction withContext<TApis extends { [key: string]: (options: { input: any; ctx: TContext }) => any }, TContext>(\n apis: TApis,\n ctx: TContext,\n) {\n return Object.entries(apis).reduce(\n (acc, [key, apiFunction]) => {\n acc[key as keyof TApis] = (input: Parameters<TApis[typeof key]>[0]['input']) =>\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n apiFunction({ input, ctx });\n return acc;\n },\n {} as { [key in keyof TApis]: (options: Parameters<TApis[key]>[0]['input']) => ReturnType<TApis[key]> },\n );\n}\n"]}
|
|
@@ -5,6 +5,7 @@ import http from 'http';
|
|
|
5
5
|
import https from 'https';
|
|
6
6
|
export type CreateHTTPHandlerOptions<TRouter extends AnyRouter> = NodeHTTPHandlerOptions<TRouter, http.IncomingMessage, http.ServerResponse> & {
|
|
7
7
|
https?: HttpsConfig;
|
|
8
|
+
cwd: string;
|
|
8
9
|
};
|
|
9
10
|
export type CreateHTTPContextOptions = NodeHTTPCreateContextFnOptions<http.IncomingMessage, http.ServerResponse>;
|
|
10
11
|
export declare function createHTTPHandler<TRouter extends AnyRouter>(options: CreateHTTPHandlerOptions<TRouter>): (req: http.IncomingMessage, res: http.ServerResponse) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"httpAdapter.d.ts","sourceRoot":"","sources":["../../src/trpc/httpAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAG9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAEL,KAAK,8BAA8B,EACnC,KAAK,sBAAsB,EAC5B,MAAM,iCAAiC,CAAC;AACzC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,MAAM,wBAAwB,CAAC,OAAO,SAAS,SAAS,IAAI,sBAAsB,CACtF,OAAO,EACP,IAAI,CAAC,eAAe,EACpB,IAAI,CAAC,cAAc,CACpB,GAAG;IAAE,KAAK,CAAC,EAAE,WAAW,CAAA;CAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"httpAdapter.d.ts","sourceRoot":"","sources":["../../src/trpc/httpAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAG9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAEL,KAAK,8BAA8B,EACnC,KAAK,sBAAsB,EAC5B,MAAM,iCAAiC,CAAC;AACzC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,MAAM,wBAAwB,CAAC,OAAO,SAAS,SAAS,IAAI,sBAAsB,CACtF,OAAO,EACP,IAAI,CAAC,eAAe,EACpB,IAAI,CAAC,cAAc,CACpB,GAAG;IAAE,KAAK,CAAC,EAAE,WAAW,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzC,MAAM,MAAM,wBAAwB,GAAG,8BAA8B,CAAC,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;AAEjH,wBAAgB,iBAAiB,CAAC,OAAO,SAAS,SAAS,EAAE,OAAO,EAAE,wBAAwB,CAAC,OAAO,CAAC,SAClF,IAAI,CAAC,eAAe,OAAO,IAAI,CAAC,cAAc,mBAgBlE;AAED,wBAAgB,gBAAgB,CAAC,OAAO,SAAS,SAAS,EAAE,OAAO,EAAE,wBAAwB,CAAC,OAAO,CAAC;;mBAgCnF,MAAM,SAAS,MAAM;;;;EAavC"}
|
package/lib/trpc/httpAdapter.js
CHANGED
|
@@ -24,7 +24,7 @@ export function createHTTPServer(options) {
|
|
|
24
24
|
const { https: httpsOptions } = options;
|
|
25
25
|
let server;
|
|
26
26
|
if (httpsOptions) {
|
|
27
|
-
const { key, cert, passphrase } = parseHttpsConfig(httpsOptions);
|
|
27
|
+
const { key, cert, passphrase } = parseHttpsConfig(httpsOptions, options.cwd);
|
|
28
28
|
if (!key || !cert) {
|
|
29
29
|
console.error('Invalid https config in cloudpack.config.json. Make sure key and cert are valid.');
|
|
30
30
|
throw new Error('Invalid https config.');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"httpAdapter.js","sourceRoot":"","sources":["../../src/trpc/httpAdapter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,mCAAmC,CAAC;AAE5D,OAAO,EACL,sBAAsB,GAGvB,MAAM,iCAAiC,CAAC;AACzC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,MAAM,OAAO,CAAC;AAU1B,MAAM,UAAU,iBAAiB,CAA4B,OAA0C;IACrG,OAAO,KAAK,EAAE,GAAyB,EAAE,GAAwB,EAAE,EAAE;QACnE,kFAAkF;QAClF,MAAM,GAAG,GAAG,GAAG,CAAC,GAAa,CAAC;QAC9B,MAAM,IAAI,GAAG,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,mBAAmB,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;QAElE,kDAAkD;QAClD,0BAA0B;QAC1B,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAE7C,MAAM,sBAAsB,CAAC;YAC3B,GAAG,OAAO;YACV,GAAG;YACH,GAAG;YACH,IAAI;SACL,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,gBAAgB,CAA4B,OAA0C;IACpG,MAAM,OAAO,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAC3C,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;IAExC,IAAI,MAAkC,CAAC;IAEvC,IAAI,YAAY,EAAE,CAAC;QACjB,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,gBA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,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;YAClB,OAAO,CAAC,KAAK,CAAC,kFAAkF,CAAC,CAAC;YAElG,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;QAC3C,CAAC;QACD,MAAM,GAAG,KAAK,CAAC,YAAY,CACzB;YACE,GAAG;YACH,IAAI;YACJ,UAAU;SACX;QACD,kEAAkE;QAClE,OAAO,CACR,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,MAAM,GAAG,IAAI,CAAC,YAAY;QACxB,kEAAkE;QAClE,OAAO,CACR,CAAC;IACJ,CAAC;IAED,OAAO;QACL,MAAM;QACN,MAAM,EAAE,CAAC,IAAY,EAAE,IAAa,EAAE,EAAE;YACtC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YAC1B,0GAA0G;YAC1G,MAAM,UAAU,GAAG,IAAI,KAAK,CAAC,CAAC,CAAC,CAAG,MAAM,CAAC,OAAO,EAAU,CAAC,IAAe,CAAC,CAAC,CAAC,IAAI,CAAC;YAElF,OAAO;gBACL,IAAI,EAAE,UAAU;gBAChB,KAAK,EAAE,GAAG,EAAE;oBACV,MAAM,CAAC,KAAK,EAAE,CAAC;gBACjB,CAAC;aACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { HttpsConfig } from '@ms-cloudpack/common-types';\nimport { parseHttpsConfig } from '@ms-cloudpack/create-express-app';\nimport { makeUrl } from '@ms-cloudpack/path-string-parsing';\nimport type { AnyRouter } from '@trpc/server';\nimport {\n nodeHTTPRequestHandler,\n type NodeHTTPCreateContextFnOptions,\n type NodeHTTPHandlerOptions,\n} from '@trpc/server/adapters/node-http';\nimport http from 'http';\nimport https from 'https';\n\nexport type CreateHTTPHandlerOptions<TRouter extends AnyRouter> = NodeHTTPHandlerOptions<\n TRouter,\n http.IncomingMessage,\n http.ServerResponse\n> & { https?: HttpsConfig; cwd: string };\n\nexport type CreateHTTPContextOptions = NodeHTTPCreateContextFnOptions<http.IncomingMessage, http.ServerResponse>;\n\nexport function createHTTPHandler<TRouter extends AnyRouter>(options: CreateHTTPHandlerOptions<TRouter>) {\n return async (req: http.IncomingMessage, res: http.ServerResponse) => {\n // if no hostname, set a dummy one so that we can consistently parse the pathname.\n const url = req.url as string;\n const href = url.startsWith('/') ? `http://127.0.0.1${url}` : url;\n\n // get procedure path and remove the leading slash\n // /procedure -> procedure\n const path = makeUrl(href).pathname.slice(1);\n\n await nodeHTTPRequestHandler({\n ...options,\n req,\n res,\n path,\n });\n };\n}\n\nexport function createHTTPServer<TRouter extends AnyRouter>(options: CreateHTTPHandlerOptions<TRouter>) {\n const handler = createHTTPHandler(options);\n const { https: httpsOptions } = options;\n\n let server: http.Server | https.Server;\n\n if (httpsOptions) {\n const { key, cert, passphrase } = parseHttpsConfig(httpsOptions, options.cwd);\n\n if (!key || !cert) {\n console.error('Invalid https config in cloudpack.config.json. Make sure key and cert are valid.');\n\n throw new Error('Invalid https config.');\n }\n server = https.createServer(\n {\n key,\n cert,\n passphrase,\n },\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n handler,\n );\n } else {\n server = http.createServer(\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n handler,\n );\n }\n\n return {\n server,\n listen: (port: number, host?: string) => {\n server.listen(port, host);\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n const actualPort = port === 0 ? ((server.address() as any).port as number) : port;\n\n return {\n port: actualPort,\n close: () => {\n server.close();\n },\n };\n },\n };\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/api-server",
|
|
3
|
-
"version": "0.47.
|
|
3
|
+
"version": "0.47.4",
|
|
4
4
|
"description": "An implementation of the API server that does interacts with a task scheduler.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -27,20 +27,20 @@
|
|
|
27
27
|
"@lage-run/logger": "^1.3.0",
|
|
28
28
|
"@lage-run/scheduler": "^1.2.1",
|
|
29
29
|
"@lage-run/target-graph": "^0.8.9",
|
|
30
|
-
"@ms-cloudpack/bundler": "^0.22.
|
|
30
|
+
"@ms-cloudpack/bundler": "^0.22.3",
|
|
31
31
|
"@ms-cloudpack/common-types": "^0.13.0",
|
|
32
|
-
"@ms-cloudpack/config": "^0.23.
|
|
33
|
-
"@ms-cloudpack/create-express-app": "^1.6.
|
|
32
|
+
"@ms-cloudpack/config": "^0.23.5",
|
|
33
|
+
"@ms-cloudpack/create-express-app": "^1.6.29",
|
|
34
34
|
"@ms-cloudpack/data-bus": "^0.4.2",
|
|
35
35
|
"@ms-cloudpack/file-watcher": "^0.1.2",
|
|
36
|
-
"@ms-cloudpack/import-map": "^0.5.
|
|
36
|
+
"@ms-cloudpack/import-map": "^0.5.24",
|
|
37
37
|
"@ms-cloudpack/json-utilities": "^0.1.4",
|
|
38
|
-
"@ms-cloudpack/package-hashes": "^0.6.
|
|
39
|
-
"@ms-cloudpack/package-utilities": "^7.8.
|
|
38
|
+
"@ms-cloudpack/package-hashes": "^0.6.10",
|
|
39
|
+
"@ms-cloudpack/package-utilities": "^7.8.6",
|
|
40
40
|
"@ms-cloudpack/path-string-parsing": "^1.2.3",
|
|
41
|
-
"@ms-cloudpack/path-utilities": "^2.7.
|
|
42
|
-
"@ms-cloudpack/remote-cache": "^0.8.
|
|
43
|
-
"@ms-cloudpack/task-reporter": "^0.14.
|
|
41
|
+
"@ms-cloudpack/path-utilities": "^2.7.26",
|
|
42
|
+
"@ms-cloudpack/remote-cache": "^0.8.3",
|
|
43
|
+
"@ms-cloudpack/task-reporter": "^0.14.2",
|
|
44
44
|
"@ms-cloudpack/telemetry": "^0.6.1",
|
|
45
45
|
"@trpc/client": "^10.45.0",
|
|
46
46
|
"@trpc/server": "^10.45.0",
|