@ms-cloudpack/api-server 0.48.9 → 0.49.1
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/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/trpc/createCloudpackServer.d.ts.map +1 -1
- package/lib/trpc/createCloudpackServer.js +4 -3
- package/lib/trpc/createCloudpackServer.js.map +1 -1
- package/lib/trpc/httpAdapter.d.ts +9 -8
- package/lib/trpc/httpAdapter.d.ts.map +1 -1
- package/lib/trpc/httpAdapter.js +24 -13
- package/lib/trpc/httpAdapter.js.map +1 -1
- package/lib/utilities/addOverride.js +2 -2
- package/lib/utilities/addOverride.js.map +1 -1
- package/lib/utilities/validateOverride.js +2 -2
- package/lib/utilities/validateOverride.js.map +1 -1
- package/package.json +9 -9
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export type { ApiServer } from './types/ApiServer.js';
|
|
2
2
|
export type { Context, PartialContext } from './types/Context.js';
|
|
3
|
-
export type { BundleInfo } from './types/BundleInfo.js';
|
|
3
|
+
export type { BundleInfo, BundleEntryInfo, BundleEntryConsumes } from './types/BundleInfo.js';
|
|
4
4
|
export type { Session } from '@ms-cloudpack/common-types';
|
|
5
5
|
export type { TaskStats } from './types/TaskStats.js';
|
|
6
6
|
export type { Task } from './types/Task.js';
|
|
@@ -36,5 +36,5 @@ export { getSessionPath } from './utilities/getSessionPath.js';
|
|
|
36
36
|
export { getConsumedDependencies } from './utilities/getConsumedDependencies.js';
|
|
37
37
|
export { getConsumedPaths } from './utilities/getConsumedPaths.js';
|
|
38
38
|
export { createPartialApiContext } from './common/createPartialApiContext.js';
|
|
39
|
-
export { addPackageOverride, ensurePackageBundled, getData, getSessionId, linkPath, onDataChanged, openCodeEditor, openConfigEditor, openFilePath, reportMetric, syncDownload, syncUpload, validatePackageOverride, } from './apis/index.js';
|
|
39
|
+
export { addPackageOverride, ensurePackageBundled, getData, getSessionId, linkPath, onDataChanged, openCodeEditor, openConfigEditor, openFilePath, reportMetric, restartTask, restartAllTasks, syncDownload, syncUpload, unlinkPath, validatePackageOverride, } from './apis/index.js';
|
|
40
40
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,YAAY,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAClE,YAAY,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,YAAY,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAClE,YAAY,EAAE,UAAU,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC9F,YAAY,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAC1D,YAAY,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,YAAY,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAC5C,YAAY,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,YAAY,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACxE,YAAY,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,YAAY,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,YAAY,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAC5E,YAAY,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,YAAY,EAAE,eAAe,EAAE,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C,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAGnE,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAG9E,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,OAAO,EACP,YAAY,EACZ,QAAQ,EACR,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,eAAe,EACf,YAAY,EACZ,UAAU,EACV,UAAU,EACV,uBAAuB,GACxB,MAAM,iBAAiB,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -14,5 +14,5 @@ export { getConsumedPaths } from './utilities/getConsumedPaths.js';
|
|
|
14
14
|
// Utilities
|
|
15
15
|
export { createPartialApiContext } from './common/createPartialApiContext.js';
|
|
16
16
|
// API methods
|
|
17
|
-
export { addPackageOverride, ensurePackageBundled, getData, getSessionId, linkPath, onDataChanged, openCodeEditor, openConfigEditor, openFilePath, reportMetric, syncDownload, syncUpload, validatePackageOverride, } from './apis/index.js';
|
|
17
|
+
export { addPackageOverride, ensurePackageBundled, getData, getSessionId, linkPath, onDataChanged, openCodeEditor, openConfigEditor, openFilePath, reportMetric, restartTask, restartAllTasks, syncDownload, syncUpload, unlinkPath, validatePackageOverride, } from './apis/index.js';
|
|
18
18
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAmCA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC5G,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAEnE,YAAY;AACZ,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAE9E,cAAc;AACd,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,OAAO,EACP,YAAY,EACZ,QAAQ,EACR,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,uBAAuB,GACxB,MAAM,iBAAiB,CAAC","sourcesContent":["export type { ApiServer } from './types/ApiServer.js';\nexport type { Context, PartialContext } from './types/Context.js';\nexport type { BundleInfo } from './types/BundleInfo.js';\nexport type { Session } from '@ms-cloudpack/common-types';\nexport type { TaskStats } from './types/TaskStats.js';\nexport type { Task } from './types/Task.js';\nexport type { TaskDescription } from './types/TaskDescription.js';\nexport type { TaskEndDescription } from './types/TaskEndDescription.js';\nexport type { TaskMessage } from './types/TaskMessage.js';\nexport type { TaskOptions } from './types/TaskOptions.js';\nexport type { TaskStartDescription } from './types/TaskStartDescription.js';\nexport type { ErrorEntry } from './types/ErrorEntry.js';\nexport type { CloudpackServer } from './trpc/createCloudpackServer.js';\n\n// API types\nexport type { AddPackageOverrideInput } from './apis/addPackageOverride.js';\nexport type { OpenCodeEditorInput } from './apis/openCodeEditor.js';\nexport type { OpenFilePathInput } from './apis/openFilePath.js';\nexport type { ReportMetricInput } from './apis/reportMetric.js';\nexport type { ValidatePackageOverrideInput, ValidatePackageOverrideOutput } from './apis/validatePackageOverride.js';\nexport type { RestartTaskInput } from './apis/restartTask.js';\nexport type { LinkPathInput } from './types/LinkPath.js';\n\n// TODO: delete these type exports once API reporting of \"forgotten\" exports is enabled\n// (they're not used and don't really need to be visible in the API)\nexport type {\n EnsurePackageBundledContext,\n EnsurePackageBundledInput,\n EnsurePackageBundledOutput,\n EnsurePackageBundledResult,\n} from './apis/ensurePackageBundled.js';\nexport type { BundleRequest } from './types/BundleRequest.js';\nexport type { BundleTaskOptions } from './types/BundleTaskOptions.js';\nexport type { OverrideOptions } from './types/OverrideOptions.js';\n\nexport { TaskRunner } from './utilities/TaskRunner.js';\nexport { reloadCountSource, taskListSource, taskStatsSource, errorEntrySource } from './data/busSources.js';\nexport { createCloudpackClient } from './trpc/createCloudpackClient.js';\nexport { createCloudpackServer } from './trpc/createCloudpackServer.js';\nexport { ZodTaskDescription } from './types/TaskDescription.js';\nexport { ZodTaskEndDescription } from './types/TaskEndDescription.js';\nexport { ZodTaskMessage } from './types/TaskMessage.js';\nexport { ZodTaskStartDescription } from './types/TaskStartDescription.js';\nexport { getCachePath, getLocalCachePath } from './utilities/getCachePath.js';\nexport { getActiveSessionsPath } from './utilities/getActiveSessionsPath.js';\nexport { getSessionPath } from './utilities/getSessionPath.js';\nexport { getConsumedDependencies } from './utilities/getConsumedDependencies.js';\nexport { getConsumedPaths } from './utilities/getConsumedPaths.js';\n\n// Utilities\nexport { createPartialApiContext } from './common/createPartialApiContext.js';\n\n// API methods\nexport {\n addPackageOverride,\n ensurePackageBundled,\n getData,\n getSessionId,\n linkPath,\n onDataChanged,\n openCodeEditor,\n openConfigEditor,\n openFilePath,\n reportMetric,\n syncDownload,\n syncUpload,\n validatePackageOverride,\n} from './apis/index.js';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAmCA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC5G,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAEnE,YAAY;AACZ,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAE9E,cAAc;AACd,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,OAAO,EACP,YAAY,EACZ,QAAQ,EACR,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,eAAe,EACf,YAAY,EACZ,UAAU,EACV,UAAU,EACV,uBAAuB,GACxB,MAAM,iBAAiB,CAAC","sourcesContent":["export type { ApiServer } from './types/ApiServer.js';\nexport type { Context, PartialContext } from './types/Context.js';\nexport type { BundleInfo, BundleEntryInfo, BundleEntryConsumes } from './types/BundleInfo.js';\nexport type { Session } from '@ms-cloudpack/common-types';\nexport type { TaskStats } from './types/TaskStats.js';\nexport type { Task } from './types/Task.js';\nexport type { TaskDescription } from './types/TaskDescription.js';\nexport type { TaskEndDescription } from './types/TaskEndDescription.js';\nexport type { TaskMessage } from './types/TaskMessage.js';\nexport type { TaskOptions } from './types/TaskOptions.js';\nexport type { TaskStartDescription } from './types/TaskStartDescription.js';\nexport type { ErrorEntry } from './types/ErrorEntry.js';\nexport type { CloudpackServer } from './trpc/createCloudpackServer.js';\n\n// API types\nexport type { AddPackageOverrideInput } from './apis/addPackageOverride.js';\nexport type { OpenCodeEditorInput } from './apis/openCodeEditor.js';\nexport type { OpenFilePathInput } from './apis/openFilePath.js';\nexport type { ReportMetricInput } from './apis/reportMetric.js';\nexport type { ValidatePackageOverrideInput, ValidatePackageOverrideOutput } from './apis/validatePackageOverride.js';\nexport type { RestartTaskInput } from './apis/restartTask.js';\nexport type { LinkPathInput } from './types/LinkPath.js';\n\n// TODO: delete these type exports once API reporting of \"forgotten\" exports is enabled\n// (they're not used and don't really need to be visible in the API)\nexport type {\n EnsurePackageBundledContext,\n EnsurePackageBundledInput,\n EnsurePackageBundledOutput,\n EnsurePackageBundledResult,\n} from './apis/ensurePackageBundled.js';\nexport type { BundleRequest } from './types/BundleRequest.js';\nexport type { BundleTaskOptions } from './types/BundleTaskOptions.js';\nexport type { OverrideOptions } from './types/OverrideOptions.js';\n\nexport { TaskRunner } from './utilities/TaskRunner.js';\nexport { reloadCountSource, taskListSource, taskStatsSource, errorEntrySource } from './data/busSources.js';\nexport { createCloudpackClient } from './trpc/createCloudpackClient.js';\nexport { createCloudpackServer } from './trpc/createCloudpackServer.js';\nexport { ZodTaskDescription } from './types/TaskDescription.js';\nexport { ZodTaskEndDescription } from './types/TaskEndDescription.js';\nexport { ZodTaskMessage } from './types/TaskMessage.js';\nexport { ZodTaskStartDescription } from './types/TaskStartDescription.js';\nexport { getCachePath, getLocalCachePath } from './utilities/getCachePath.js';\nexport { getActiveSessionsPath } from './utilities/getActiveSessionsPath.js';\nexport { getSessionPath } from './utilities/getSessionPath.js';\nexport { getConsumedDependencies } from './utilities/getConsumedDependencies.js';\nexport { getConsumedPaths } from './utilities/getConsumedPaths.js';\n\n// Utilities\nexport { createPartialApiContext } from './common/createPartialApiContext.js';\n\n// API methods\nexport {\n addPackageOverride,\n ensurePackageBundled,\n getData,\n getSessionId,\n linkPath,\n onDataChanged,\n openCodeEditor,\n openConfigEditor,\n openFilePath,\n reportMetric,\n restartTask,\n restartAllTasks,\n syncDownload,\n syncUpload,\n unlinkPath,\n validatePackageOverride,\n} from './apis/index.js';\n"]}
|
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4C3D;AAED,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
|
|
@@ -15,23 +15,24 @@ export async function createCloudpackServer(context) {
|
|
|
15
15
|
const https = context.session.config?.devServer?.https;
|
|
16
16
|
const port = await getPort({ port: [9890, 9891, 9892, 9893] });
|
|
17
17
|
const { router, apis } = createAppRouter();
|
|
18
|
-
const { server, listen } = createHTTPServer({
|
|
18
|
+
const { server, listen } = await createHTTPServer({
|
|
19
|
+
domain: hostname,
|
|
19
20
|
middleware: cors(),
|
|
20
21
|
router,
|
|
21
22
|
createContext,
|
|
22
23
|
https,
|
|
23
24
|
cwd: context.session.config.appPath,
|
|
24
25
|
});
|
|
25
|
-
|
|
26
|
+
await listen(port, hostname);
|
|
26
27
|
const wss = new WebSocketServer({ server });
|
|
27
28
|
applyWSSHandler({
|
|
28
29
|
wss,
|
|
29
30
|
router,
|
|
30
31
|
createContext,
|
|
31
32
|
});
|
|
32
|
-
listen(port, hostname);
|
|
33
33
|
const localCallContext = await createContext();
|
|
34
34
|
const apisWithContext = withContext(apis, localCallContext);
|
|
35
|
+
const webSocketProtocol = https ? 'wss' : 'ws';
|
|
35
36
|
const url = `${webSocketProtocol}://${hostname}:${port}`;
|
|
36
37
|
context.session.urls.apiServer = url;
|
|
37
38
|
return {
|
|
@@ -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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AAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC;gBACpD,GAAG,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;gBACpD,MAAM,CAAC,KAAK,EAAE,CAAC;YACjB,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC;AAID,8FAA8F;AAC9F,8DAA8D;AAC9D,SAAS,WAAW,CAClB,IAAW,EACX,GAAa;IAEb,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,CAChC,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,WAAW,CAAC,EAAE,EAAE;QAC1B,GAAG,CAAC,GAAkB,CAAC,GAAG,CAAC,KAAgD,EAAE,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 } = await createHTTPServer({\n domain: hostname,\n middleware: cors(),\n router,\n createContext,\n https,\n cwd: context.session.config.appPath,\n });\n\n await listen(port, hostname);\n\n const wss = new WebSocketServer({ server });\n\n applyWSSHandler<AppRouter>({\n wss,\n router,\n createContext,\n });\n\n const localCallContext = await createContext();\n const apisWithContext = withContext(apis, localCallContext);\n const webSocketProtocol = https ? 'wss' : 'ws';\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"]}
|
|
@@ -4,16 +4,17 @@ import { type NodeHTTPCreateContextFnOptions, type NodeHTTPHandlerOptions } from
|
|
|
4
4
|
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
|
-
https?: HttpsConfig;
|
|
7
|
+
https?: true | HttpsConfig;
|
|
8
8
|
cwd: string;
|
|
9
9
|
};
|
|
10
10
|
export type CreateHTTPContextOptions = NodeHTTPCreateContextFnOptions<http.IncomingMessage, http.ServerResponse>;
|
|
11
|
-
export declare function createHTTPHandler<TRouter extends AnyRouter>(options: CreateHTTPHandlerOptions<TRouter>
|
|
12
|
-
|
|
11
|
+
export declare function createHTTPHandler<TRouter extends AnyRouter>(options: CreateHTTPHandlerOptions<TRouter> & {
|
|
12
|
+
domain?: string;
|
|
13
|
+
}): (req: http.IncomingMessage, res: http.ServerResponse) => Promise<void>;
|
|
14
|
+
export declare function createHTTPServer<TRouter extends AnyRouter>(options: CreateHTTPHandlerOptions<TRouter> & {
|
|
15
|
+
domain?: string;
|
|
16
|
+
}): Promise<{
|
|
13
17
|
server: http.Server<typeof http.IncomingMessage, typeof http.ServerResponse> | https.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
14
|
-
listen: (port: number, host?: string) =>
|
|
15
|
-
|
|
16
|
-
close: () => void;
|
|
17
|
-
};
|
|
18
|
-
};
|
|
18
|
+
listen: (port: number, host?: string) => Promise<unknown>;
|
|
19
|
+
}>;
|
|
19
20
|
//# sourceMappingURL=httpAdapter.d.ts.map
|
|
@@ -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;
|
|
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;AAI1B,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,IAAI,GAAG,WAAW,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhD,MAAM,MAAM,wBAAwB,GAAG,8BAA8B,CAAC,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;AAEjH,wBAAgB,iBAAiB,CAAC,OAAO,SAAS,SAAS,EACzD,OAAO,EAAE,wBAAwB,CAAC,OAAO,CAAC,GAAG;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,SAE7C,IAAI,CAAC,eAAe,OAAO,IAAI,CAAC,cAAc,mBAkBlE;AAED,wBAAsB,gBAAgB,CAAC,OAAO,SAAS,SAAS,EAC9D,OAAO,EAAE,wBAAwB,CAAC,OAAO,CAAC,GAAG;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE;;mBAqCzC,MAAM,SAAS,MAAM;GAsB7C"}
|
package/lib/trpc/httpAdapter.js
CHANGED
|
@@ -3,11 +3,13 @@ import { makeUrl } from '@ms-cloudpack/path-string-parsing';
|
|
|
3
3
|
import { nodeHTTPRequestHandler, } from '@trpc/server/adapters/node-http';
|
|
4
4
|
import http from 'http';
|
|
5
5
|
import https from 'https';
|
|
6
|
+
const defaultDomain = 'localhost';
|
|
6
7
|
export function createHTTPHandler(options) {
|
|
7
8
|
return async (req, res) => {
|
|
8
9
|
// if no hostname, set a dummy one so that we can consistently parse the pathname.
|
|
9
10
|
const url = req.url;
|
|
10
|
-
const
|
|
11
|
+
const { domain = defaultDomain } = options;
|
|
12
|
+
const href = url.startsWith('/') ? `http://${domain}${url}` : url;
|
|
11
13
|
// get procedure path and remove the leading slash
|
|
12
14
|
// /procedure -> procedure
|
|
13
15
|
const path = makeUrl(href).pathname.slice(1);
|
|
@@ -19,17 +21,19 @@ export function createHTTPHandler(options) {
|
|
|
19
21
|
});
|
|
20
22
|
};
|
|
21
23
|
}
|
|
22
|
-
export function createHTTPServer(options) {
|
|
24
|
+
export async function createHTTPServer(options) {
|
|
23
25
|
const handler = createHTTPHandler(options);
|
|
24
|
-
const { https: httpsOptions } = options;
|
|
26
|
+
const { domain = defaultDomain, https: httpsOptions } = options;
|
|
25
27
|
let server;
|
|
26
28
|
if (httpsOptions) {
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
+
const httpsConfig = await parseHttpsConfig({ domain, https: httpsOptions, cwd: options.cwd });
|
|
30
|
+
const { ca, key, cert, passphrase } = httpsConfig || {};
|
|
31
|
+
if (!httpsConfig || !key || !cert) {
|
|
29
32
|
console.error('Invalid https config in cloudpack.config.json. Make sure key and cert are valid.');
|
|
30
33
|
throw new Error('Invalid https config.');
|
|
31
34
|
}
|
|
32
35
|
server = https.createServer({
|
|
36
|
+
ca,
|
|
33
37
|
key,
|
|
34
38
|
cert,
|
|
35
39
|
passphrase,
|
|
@@ -44,16 +48,23 @@ export function createHTTPServer(options) {
|
|
|
44
48
|
}
|
|
45
49
|
return {
|
|
46
50
|
server,
|
|
47
|
-
listen: (port, host) => {
|
|
48
|
-
server.listen(port, host);
|
|
51
|
+
listen: async (port, host) => {
|
|
49
52
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
|
|
50
53
|
const actualPort = port === 0 ? server.address().port : port;
|
|
51
|
-
return {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
return new Promise((resolve, reject) => {
|
|
55
|
+
server.addListener('listening', () => {
|
|
56
|
+
resolve({
|
|
57
|
+
port: actualPort,
|
|
58
|
+
close: () => {
|
|
59
|
+
server.close();
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
server.addListener('error', (err) => {
|
|
64
|
+
reject(err);
|
|
65
|
+
});
|
|
66
|
+
server.listen(port, host);
|
|
67
|
+
});
|
|
57
68
|
},
|
|
58
69
|
};
|
|
59
70
|
}
|
|
@@ -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;
|
|
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;AAE1B,MAAM,aAAa,GAAG,WAAW,CAAC;AAUlC,MAAM,UAAU,iBAAiB,CAC/B,OAAgE;IAEhE,OAAO,KAAK,EAAE,GAAyB,EAAE,GAAwB,EAAE,EAAE;QACnE,kFAAkF;QAClF,MAAM,GAAG,GAAG,GAAG,CAAC,GAAa,CAAC;QAC9B,MAAM,EAAE,MAAM,GAAG,aAAa,EAAE,GAAG,OAAO,CAAC;QAE3C,MAAM,IAAI,GAAG,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,MAAM,G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AAM,EAAE,KAAK,EAAE,IAAY,EAAE,IAAa,EAAE,EAAE;YAC5C,0GAA0G;YAC1G,MAAM,UAAU,GAAG,IAAI,KAAK,CAAC,CAAC,CAAC,CAAG,MAAM,CAAC,OAAO,EAAU,CAAC,IAAe,CAAC,CAAC,CAAC,IAAI,CAAC;YAElF,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;gBACrC,MAAM,CAAC,WAAW,CAAC,WAAW,EAAE,GAAG,EAAE;oBACnC,OAAO,CAAC;wBACN,IAAI,EAAE,UAAU;wBAChB,KAAK,EAAE,GAAG,EAAE;4BACV,MAAM,CAAC,KAAK,EAAE,CAAC;wBACjB,CAAC;qBACF,CAAC,CAAC;gBACL,CAAC,CAAC,CAAC;gBAEH,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;oBAClC,MAAM,CAAC,GAAG,CAAC,CAAC;gBACd,CAAC,CAAC,CAAC;gBAEH,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YAC5B,CAAC,CAAC,CAAC;QACL,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\nconst defaultDomain = 'localhost';\n\nexport type CreateHTTPHandlerOptions<TRouter extends AnyRouter> = NodeHTTPHandlerOptions<\n TRouter,\n http.IncomingMessage,\n http.ServerResponse\n> & { https?: true | HttpsConfig; cwd: string };\n\nexport type CreateHTTPContextOptions = NodeHTTPCreateContextFnOptions<http.IncomingMessage, http.ServerResponse>;\n\nexport function createHTTPHandler<TRouter extends AnyRouter>(\n options: CreateHTTPHandlerOptions<TRouter> & { domain?: string },\n) {\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 { domain = defaultDomain } = options;\n\n const href = url.startsWith('/') ? `http://${domain}${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 async function createHTTPServer<TRouter extends AnyRouter>(\n options: CreateHTTPHandlerOptions<TRouter> & { domain?: string },\n) {\n const handler = createHTTPHandler(options);\n const { domain = defaultDomain, https: httpsOptions } = options;\n\n let server: http.Server | https.Server;\n\n if (httpsOptions) {\n const httpsConfig = await parseHttpsConfig({ domain, https: httpsOptions, cwd: options.cwd });\n\n const { ca, key, cert, passphrase } = httpsConfig || {};\n\n if (!httpsConfig || !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\n server = https.createServer(\n {\n ca,\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: async (port: number, host?: string) => {\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 new Promise((resolve, reject) => {\n server.addListener('listening', () => {\n resolve({\n port: actualPort,\n close: () => {\n server.close();\n },\n });\n });\n\n server.addListener('error', (err) => {\n reject(err);\n });\n\n server.listen(port, host);\n });\n },\n };\n}\n"]}
|
|
@@ -20,7 +20,7 @@ export async function addOverride(options, context) {
|
|
|
20
20
|
overrideInProcess = overrideInProcess.then(async () => {
|
|
21
21
|
const { packageName, importPath, version, issuerUrl } = options;
|
|
22
22
|
const { session, packages } = context;
|
|
23
|
-
const { appPath
|
|
23
|
+
const { appPath } = session.config;
|
|
24
24
|
let addedOverride = false;
|
|
25
25
|
let deletedNullExport = false;
|
|
26
26
|
let requiredBy = undefined;
|
|
@@ -56,7 +56,7 @@ export async function addOverride(options, context) {
|
|
|
56
56
|
// Parse the generated config if it exists.
|
|
57
57
|
const generatedConfig = await readGeneratedConfig(appPath);
|
|
58
58
|
// Ensure packageSettings exists.
|
|
59
|
-
const generatedPackageSettings = await ensureGeneratedSettingsForPackage({ packagePath }, { config: {
|
|
59
|
+
const generatedPackageSettings = await ensureGeneratedSettingsForPackage({ packagePath }, { config: { generated: generatedConfig }, packages });
|
|
60
60
|
if (generatedPackageSettings?.exports &&
|
|
61
61
|
generatedPackageSettings.exports[normalizedImportPath] ===
|
|
62
62
|
null) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addOverride.js","sourceRoot":"","sources":["../../src/utilities/addOverride.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iCAAiC,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACpH,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,aAAa,GAEd,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAWnF;;;;;GAKG;AACH,IAAI,iBAAiB,GAA4B,OAAO,CAAC,OAAO,CAAC;IAC/D,aAAa,EAAE,KAAK;IACpB,KAAK,EAAE,SAAS;CACjB,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,OAAwB,EACxB,OAA8C;IAE9C,iBAAiB,GAAG,iBAAiB,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE;QACpD,MAAM,EAAE,WAAW,E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M,IAAI,GAAG,IAAI,WAAW,YAAY,oBAAoB,IAAI,CAAC;QACjE,IAAI,MAAM,KAAK,OAAO,EAAE,CAAC;YACvB,IAAI,iBAAiB,EAAE,CAAC;gBACtB,OAAO,CAAC,GAAG,CAAC,qCAAqC,IAAI,mCAAmC,CAAC,CAAC;gBAC1F,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;oBACzB,OAAO,CAAC,GAAG,CAAC,4DAA4D,CAAC,CAAC;gBAC5E,CAAC;YACH,CAAC;iBAAM,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;gBAChC,OAAO,CAAC,GAAG,CAAC,sBAAsB,IAAI,iCAAiC,CAAC,CAAC;YAC3E,CAAC;QACH,CAAC;QAED,0EAA0E;QAC1E,MAAM,QAAQ,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QAEnD,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;IAClC,CAAC,CAAC,CAAC;IAEH,OAAO,iBAAiB,CAAC;AAC3B,CAAC","sourcesContent":["import { ensureGeneratedSettingsForPackage, readGeneratedConfig, writeGeneratedConfig } from '@ms-cloudpack/config';\nimport { parseRequestInfo } from '@ms-cloudpack/import-map';\nimport {\n addExportsMapEntry,\n findResolveMapEntry,\n flattenExportsMap,\n getExportsMap,\n type ResolveMapEntry,\n} from '@ms-cloudpack/package-utilities';\nimport { makeUrl, normalizeRelativePath } from '@ms-cloudpack/path-string-parsing';\nimport type { Context } from '../types/Context.js';\nimport type { OverrideOptions } from '../types/OverrideOptions.js';\n\ntype OverrideReturn = {\n /** Whether the override was successfully added */\n addedOverride: boolean;\n /** The entry (if any) in the resolve map the override was added to */\n entry: ResolveMapEntry | undefined;\n};\n\n/**\n * Helper so that when addOverride is called multiple times in quick succession, we only process one at a time.\n * This is to avoid that multiple calls of addOverride first read the same version of the generated config,\n * then write the same version of the config with its corresponding update,\n * which would result in the last call overwriting the changes of the previous calls.\n */\nlet overrideInProcess: Promise<OverrideReturn> = Promise.resolve({\n addedOverride: false,\n entry: undefined,\n});\n\n/**\n * The addOverride method is triggered by a user action in the overlay, when we detect new usage of an import path\n * that isn't recognized. When the user triggers this override, we write it to the cloudpack generated config.\n */\nexport async function addOverride(\n options: OverrideOptions,\n context: Pick<Context, 'packages' | 'session'>,\n): Promise<OverrideReturn> {\n overrideInProcess = overrideInProcess.then(async () => {\n const { packageName, importPath, version, issuerUrl } = options;\n const { session, packages } = context;\n const { appPath } = session.config;\n let addedOverride = false;\n let deletedNullExport = false;\n let requiredBy = undefined;\n\n if (importPath.endsWith('/')) {\n console.error(`The import path \"${importPath}\" is invalid. Please remove the trailing slash and try again.`);\n return { addedOverride, entry: undefined };\n }\n\n if (issuerUrl) {\n const { packageName: issuerName, version: issuerVersion } = parseRequestInfo(makeUrl(issuerUrl).pathname);\n requiredBy = { name: issuerName, version: issuerVersion };\n }\n\n const entry = findResolveMapEntry({\n packageName,\n resolveMap: session.resolveMap,\n definition: requiredBy,\n version,\n });\n\n if (!entry) {\n console.error(`Could not find entry of package \"${packageName}\" in resolve map`);\n return { addedOverride, entry };\n }\n\n const packagePath = entry.path;\n\n // Get current exports. We want to add an additional entry to what's there - not replace the default exports,\n // so we need the full map for the package.\n const exports = await getExportsMap({ packagePath }, { packages, config: session.config });\n const flattenedExports = flattenExportsMap(exports);\n const normalizedImportPath = normalizeRelativePath(importPath);\n\n // Return false if the import path already exists in the exports map.\n if (flattenedExports[normalizedImportPath]) {\n console.debug(`The import path \"${importPath}\" already exists in the exports map for \"${packageName}\".`);\n return { addedOverride, entry };\n }\n\n // Parse the generated config if it exists.\n const generatedConfig = await readGeneratedConfig(appPath);\n\n // Ensure packageSettings exists.\n const generatedPackageSettings = await ensureGeneratedSettingsForPackage(\n { packagePath },\n { config: { generated: generatedConfig }, packages },\n );\n\n if (\n generatedPackageSettings?.exports &&\n (generatedPackageSettings.exports as Record<string, string | Record<string, string>>)[normalizedImportPath] ===\n null\n ) {\n delete (generatedPackageSettings.exports as Record<string, string | Record<string, string>>)[\n normalizedImportPath\n ];\n deletedNullExport = true;\n\n if (Object.keys(generatedPackageSettings.exports).length === 0) {\n delete generatedPackageSettings.exports;\n }\n addedOverride = true;\n } else {\n const generatedExports = (generatedPackageSettings.exports ??= {});\n\n // Add the single new exports entry to the exports map.\n addedOverride = await addExportsMapEntry(\n {\n exports: generatedExports,\n packagePath,\n importPath,\n },\n { packages, config: session.config },\n );\n\n if (!addedOverride) {\n console.warn(\n `Unable to add override for package \"${packageName}\" to \"cloudpack.generated.json\".` +\n ` The file \"${normalizedImportPath}\" could not be found.` +\n ` Please check the import path and try again.`,\n );\n return { addedOverride, entry };\n }\n }\n\n // Write the updated generated config\n session.config.generated = generatedConfig;\n const result = await writeGeneratedConfig(generatedConfig, appPath);\n const desc = `\"${packageName}\" (path \"${normalizedImportPath}\")`;\n if (result !== 'no-op') {\n if (deletedNullExport) {\n console.log(`Removed generated null export for ${desc} from \"cloudpack.generated.json\".`);\n if (result === 'deleted') {\n console.log(`Deleted \"cloudpack.generated.json\" because it's now empty.`);\n }\n } else if (result === 'written') {\n console.log(`Added override for ${desc} to \"cloudpack.generated.json\".`);\n }\n }\n\n // Apply the generated exports again to ensure the exports are up to date.\n await packages.get(packagePath, { refresh: true });\n\n return { addedOverride, entry };\n });\n\n return overrideInProcess;\n}\n"]}
|
|
@@ -10,7 +10,7 @@ export async function validateOverride(options, context) {
|
|
|
10
10
|
const { packageName, importPath, issuerUrl } = options;
|
|
11
11
|
const { session, packages } = context;
|
|
12
12
|
const { config } = session;
|
|
13
|
-
const { appPath
|
|
13
|
+
const { appPath } = config;
|
|
14
14
|
let requiredBy = undefined;
|
|
15
15
|
// Import paths with trailing slashes are not supported by import maps
|
|
16
16
|
// in browser as they interpret the trailing slash as a wildcard partial match.
|
|
@@ -39,7 +39,7 @@ export async function validateOverride(options, context) {
|
|
|
39
39
|
// Parse the generated config if it exists.
|
|
40
40
|
const generatedConfig = await readGeneratedConfig(appPath);
|
|
41
41
|
// Ensure packageSettings exists.
|
|
42
|
-
const generatedPackageSettings = await ensureGeneratedSettingsForPackage({ packagePath: entry.path }, { config: {
|
|
42
|
+
const generatedPackageSettings = await ensureGeneratedSettingsForPackage({ packagePath: entry.path }, { config: { generated: generatedConfig }, packages });
|
|
43
43
|
if (generatedPackageSettings?.exports &&
|
|
44
44
|
generatedPackageSettings.exports[normalizeRelativePath(importPath)] === null) {
|
|
45
45
|
return true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateOverride.js","sourceRoot":"","sources":["../../src/utilities/validateOverride.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACzF,OAAO,EAAE,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAGnF,OAAO,EAAE,iCAAiC,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE9F;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,OAAwB,EACxB,OAA8C;IAE9C,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IACvD,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IACtC,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAC3B,MAAM,EAAE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"validateOverride.js","sourceRoot":"","sources":["../../src/utilities/validateOverride.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACzF,OAAO,EAAE,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAGnF,OAAO,EAAE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eAAe,GAAG,MAAM,mBAAmB,CAAC,OAAO,CAAC,CAAC;IAE3D,iCAAiC;IACjC,MAAM,wBAAwB,GAAG,MAAM,iCAAiC,CACtE,EAAE,WAAW,EAAE,KAAK,CAAC,IAAI,EAAE,EAC3B,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,eAAe,EAAE,EAAE,QAAQ,EAAE,CACrD,CAAC;IAEF,IACE,wBAAwB,EAAE,OAAO;QAChC,wBAAwB,CAAC,OAA2D,CACnF,qBAAqB,CAAC,UAAU,CAAC,CAClC,KAAK,IAAI,EACV,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import type { PackageJson } from '@ms-cloudpack/common-types';\nimport { parseRequestInfo } from '@ms-cloudpack/import-map';\nimport { findFileInPackage, findResolveMapEntry } from '@ms-cloudpack/package-utilities';\nimport { makeUrl, normalizeRelativePath } from '@ms-cloudpack/path-string-parsing';\nimport type { Context } from '../types/Context.js';\nimport type { OverrideOptions } from '../types/OverrideOptions.js';\nimport { ensureGeneratedSettingsForPackage, readGeneratedConfig } from '@ms-cloudpack/config';\n\n/**\n * Given a package name, import path, and optional issuerUrl, returns a boolean indicating if the given\n * override is valid.\n */\nexport async function validateOverride(\n options: OverrideOptions,\n context: Pick<Context, 'session' | 'packages'>,\n): Promise<boolean> {\n const { packageName, importPath, issuerUrl } = options;\n const { session, packages } = context;\n const { config } = session;\n const { appPath } = config;\n\n let requiredBy: PackageJson | undefined = undefined;\n\n // Import paths with trailing slashes are not supported by import maps\n // in browser as they interpret the trailing slash as a wildcard partial match.\n if (importPath.endsWith('/')) {\n return false;\n }\n\n if (issuerUrl) {\n const { packageName: name, version } = parseRequestInfo(makeUrl(issuerUrl).pathname);\n requiredBy = { name, version };\n }\n\n const entry = findResolveMapEntry({\n packageName,\n resolveMap: session.resolveMap,\n definition: requiredBy,\n });\n\n if (!entry) {\n return false;\n }\n\n const { filePath } = await findFileInPackage(\n {\n packagePath: entry.path,\n filePath: importPath,\n },\n { packages, config: session.config },\n );\n\n if (filePath) {\n return true;\n }\n\n // Parse the generated config if it exists.\n const generatedConfig = await readGeneratedConfig(appPath);\n\n // Ensure packageSettings exists.\n const generatedPackageSettings = await ensureGeneratedSettingsForPackage(\n { packagePath: entry.path },\n { config: { generated: generatedConfig }, packages },\n );\n\n if (\n generatedPackageSettings?.exports &&\n (generatedPackageSettings.exports as Record<string, string | Record<string, string>>)[\n normalizeRelativePath(importPath)\n ] === null\n ) {\n return true;\n }\n\n return false;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/api-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.49.1",
|
|
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,18 +27,18 @@
|
|
|
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.
|
|
31
|
-
"@ms-cloudpack/common-types": "^0.
|
|
32
|
-
"@ms-cloudpack/config": "^0.
|
|
33
|
-
"@ms-cloudpack/create-express-app": "^1.
|
|
30
|
+
"@ms-cloudpack/bundler": "^0.22.21",
|
|
31
|
+
"@ms-cloudpack/common-types": "^0.18.0",
|
|
32
|
+
"@ms-cloudpack/config": "^0.27.0",
|
|
33
|
+
"@ms-cloudpack/create-express-app": "^1.8.1",
|
|
34
34
|
"@ms-cloudpack/data-bus": "^0.4.2",
|
|
35
35
|
"@ms-cloudpack/file-watcher": "^0.1.2",
|
|
36
|
-
"@ms-cloudpack/import-map": "^0.6.
|
|
36
|
+
"@ms-cloudpack/import-map": "^0.6.6",
|
|
37
37
|
"@ms-cloudpack/json-utilities": "^0.1.7",
|
|
38
|
-
"@ms-cloudpack/package-hashes": "^0.6.
|
|
39
|
-
"@ms-cloudpack/package-utilities": "^9.0.
|
|
38
|
+
"@ms-cloudpack/package-hashes": "^0.6.22",
|
|
39
|
+
"@ms-cloudpack/package-utilities": "^9.0.5",
|
|
40
40
|
"@ms-cloudpack/path-string-parsing": "^1.2.4",
|
|
41
|
-
"@ms-cloudpack/path-utilities": "^2.7.
|
|
41
|
+
"@ms-cloudpack/path-utilities": "^2.7.36",
|
|
42
42
|
"@ms-cloudpack/remote-cache": "^0.8.6",
|
|
43
43
|
"@ms-cloudpack/task-reporter": "^0.14.4",
|
|
44
44
|
"@ms-cloudpack/telemetry": "^0.6.1",
|