@ms-cloudpack/api-server 0.60.1 → 0.61.0
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/apis/addPackageOverride.d.ts +3 -38
- package/lib/apis/addPackageOverride.d.ts.map +1 -1
- package/lib/apis/addPackageOverride.js +2 -13
- package/lib/apis/addPackageOverride.js.map +1 -1
- package/lib/apis/ensurePackageBundled.d.ts +4 -4
- package/lib/apis/ensurePackageBundled.d.ts.map +1 -1
- package/lib/apis/ensurePackageBundled.js +6 -15
- package/lib/apis/ensurePackageBundled.js.map +1 -1
- package/lib/apis/getSessionId.d.ts +1 -1
- package/lib/apis/getSessionId.d.ts.map +1 -1
- package/lib/apis/getSessionId.js.map +1 -1
- package/lib/apis/linkPath.d.ts +1 -1
- package/lib/apis/linkPath.d.ts.map +1 -1
- package/lib/apis/linkPath.js.map +1 -1
- package/lib/apis/openConfigEditor.d.ts +1 -1
- package/lib/apis/openConfigEditor.d.ts.map +1 -1
- package/lib/apis/openConfigEditor.js +5 -2
- package/lib/apis/openConfigEditor.js.map +1 -1
- package/lib/apis/openFilePath.d.ts +1 -1
- package/lib/apis/openFilePath.d.ts.map +1 -1
- package/lib/apis/openFilePath.js.map +1 -1
- package/lib/apis/reportSpan.d.ts +1 -1
- package/lib/apis/reportSpan.d.ts.map +1 -1
- package/lib/apis/reportSpan.js.map +1 -1
- package/lib/apis/restartAllTasks.d.ts +1 -1
- package/lib/apis/restartAllTasks.d.ts.map +1 -1
- package/lib/apis/restartAllTasks.js.map +1 -1
- package/lib/apis/restartTask.d.ts +1 -1
- package/lib/apis/restartTask.d.ts.map +1 -1
- package/lib/apis/restartTask.js.map +1 -1
- package/lib/apis/syncDownload.d.ts +5 -2
- package/lib/apis/syncDownload.d.ts.map +1 -1
- package/lib/apis/syncDownload.js +4 -2
- package/lib/apis/syncDownload.js.map +1 -1
- package/lib/apis/syncUpload.d.ts +7 -4
- package/lib/apis/syncUpload.d.ts.map +1 -1
- package/lib/apis/syncUpload.js +30 -13
- package/lib/apis/syncUpload.js.map +1 -1
- package/lib/apis/unlinkPath.d.ts +1 -1
- package/lib/apis/unlinkPath.d.ts.map +1 -1
- package/lib/apis/unlinkPath.js.map +1 -1
- package/lib/apis/validatePackageOverride.d.ts +7 -32
- package/lib/apis/validatePackageOverride.d.ts.map +1 -1
- package/lib/apis/validatePackageOverride.js +3 -2
- package/lib/apis/validatePackageOverride.js.map +1 -1
- package/lib/common/createApiContext.d.ts +3 -2
- package/lib/common/createApiContext.d.ts.map +1 -1
- package/lib/common/createApiContext.js +4 -8
- package/lib/common/createApiContext.js.map +1 -1
- package/lib/index.d.ts +0 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/types/ApiParams.d.ts +9 -6
- package/lib/types/ApiParams.d.ts.map +1 -1
- package/lib/types/ApiParams.js.map +1 -1
- package/lib/types/Context.d.ts +10 -6
- package/lib/types/Context.d.ts.map +1 -1
- package/lib/types/Context.js.map +1 -1
- package/lib/utilities/TaskRunner.d.ts.map +1 -1
- package/lib/utilities/TaskRunner.js +7 -1
- package/lib/utilities/TaskRunner.js.map +1 -1
- package/lib/utilities/addOverride.d.ts +2 -2
- package/lib/utilities/addOverride.d.ts.map +1 -1
- package/lib/utilities/addOverride.js.map +1 -1
- package/lib/utilities/createBundleTask.d.ts.map +1 -1
- package/lib/utilities/createBundleTask.js +2 -4
- package/lib/utilities/createBundleTask.js.map +1 -1
- package/lib/utilities/createRemoteCacheClient.d.ts +3 -3
- package/lib/utilities/createRemoteCacheClient.d.ts.map +1 -1
- package/lib/utilities/createRemoteCacheClient.js +3 -4
- package/lib/utilities/createRemoteCacheClient.js.map +1 -1
- package/lib/utilities/notifyReload.d.ts +2 -2
- package/lib/utilities/notifyReload.d.ts.map +1 -1
- package/lib/utilities/notifyReload.js.map +1 -1
- package/lib/utilities/validateOverride.d.ts +2 -2
- package/lib/utilities/validateOverride.d.ts.map +1 -1
- package/lib/utilities/validateOverride.js.map +1 -1
- package/package.json +3 -3
- package/lib/utilities/editCloudpackConfig.d.ts +0 -5
- package/lib/utilities/editCloudpackConfig.d.ts.map +0 -1
- package/lib/utilities/editCloudpackConfig.js +0 -10
- package/lib/utilities/editCloudpackConfig.js.map +0 -1
- package/lib/utilities/getDefaultTaskStats.d.ts +0 -3
- package/lib/utilities/getDefaultTaskStats.d.ts.map +0 -1
- package/lib/utilities/getDefaultTaskStats.js +0 -8
- package/lib/utilities/getDefaultTaskStats.js.map +0 -1
package/lib/apis/syncUpload.js
CHANGED
|
@@ -9,29 +9,29 @@ import { getBundleLocation } from '../utilities/getBundleLocation.js';
|
|
|
9
9
|
import { cp } from 'fs/promises';
|
|
10
10
|
import objectHash from 'object-hash';
|
|
11
11
|
import { ensureRemoteCacheEnabled } from '../utilities/ensureRemoteCacheEnabled.js';
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
import { getRemoteCachePackageId } from '../utilities/getRemoteCachePackageId.js';
|
|
13
|
+
/**
|
|
14
|
+
* Bundle the current app and its dependencies, and upload them to the remote cache.
|
|
15
|
+
*/
|
|
16
|
+
export async function syncUpload(input, ctx) {
|
|
17
|
+
const { login } = input;
|
|
15
18
|
const { session, telemetryClient, taskRunner, remoteCacheClient: client } = ctx;
|
|
16
19
|
const { config } = session;
|
|
17
20
|
const { appPath } = config;
|
|
21
|
+
const { remoteCache: remoteCacheConfig } = config;
|
|
18
22
|
const syncInternalPackages = config?.features?.syncInternalPackages ?? false;
|
|
19
23
|
ensureRemoteCacheEnabled(config);
|
|
20
24
|
if (!client) {
|
|
21
25
|
throw new Error('Remote cache client is required to sync upload');
|
|
22
26
|
}
|
|
27
|
+
if (!remoteCacheConfig) {
|
|
28
|
+
throw new Error('Remote cache configuration is required to sync upload');
|
|
29
|
+
}
|
|
23
30
|
// Glob pattern for the files to upload.
|
|
24
31
|
const globMatches = ['**/*', '!**/*-input.json', '!**/*-output.json'];
|
|
25
32
|
return await telemetryClient.tracer.startActiveSpan(PerfMeasurementSyncUpload, async (span) => {
|
|
26
|
-
const { name, version } = await ctx.packages.get(appPath);
|
|
27
|
-
const { dependencies, result: bundleResult } = await ensurePackageBundled({
|
|
28
|
-
input: {
|
|
29
|
-
name,
|
|
30
|
-
version,
|
|
31
|
-
enqueueDependencies: true,
|
|
32
|
-
},
|
|
33
|
-
ctx,
|
|
34
|
-
});
|
|
33
|
+
const { name, version, description } = await ctx.packages.get(appPath);
|
|
34
|
+
const { dependencies, result: bundleResult } = await ensurePackageBundled({ name, version, enqueueDependencies: true }, ctx);
|
|
35
35
|
const bundledPackages = [bundleResult, ...(await dependencies)];
|
|
36
36
|
const packagesToUpload = await Promise.all(bundledPackages
|
|
37
37
|
.filter((p) => p.inputPath && (p.isExternal || syncInternalPackages))
|
|
@@ -39,7 +39,8 @@ export async function syncUpload(params) {
|
|
|
39
39
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- verified above that it's set
|
|
40
40
|
{ packagePath: p.inputPath }, ctx)));
|
|
41
41
|
if (config.features?.enableCloudHosted) {
|
|
42
|
-
const
|
|
42
|
+
const appBundleLocation = await getBundleLocation({ packagePath: appPath }, ctx);
|
|
43
|
+
const appOutputPath = appBundleLocation.path;
|
|
43
44
|
const destinationFolder = path.join(appOutputPath, '__cloudpack');
|
|
44
45
|
const routesPath = path.join(destinationFolder, 'routes');
|
|
45
46
|
for (const route of config.routes ?? []) {
|
|
@@ -50,6 +51,22 @@ export async function syncUpload(params) {
|
|
|
50
51
|
await cp(staticPath, path.join(folderPath, route.staticPath), { recursive: true });
|
|
51
52
|
}
|
|
52
53
|
}
|
|
54
|
+
const { createAppRegistryClient } = await import('@ms-cloudpack/remote-cache');
|
|
55
|
+
const appRegistryClient = await createAppRegistryClient({
|
|
56
|
+
context: ctx,
|
|
57
|
+
options: { cachePath: session.cachePath, loginMethod: login },
|
|
58
|
+
});
|
|
59
|
+
await appRegistryClient.registerApp({
|
|
60
|
+
name,
|
|
61
|
+
// Using the current date and time as the version, because most apps are not versioned.
|
|
62
|
+
version: new Date().toISOString().slice(16).replace('T', ' '),
|
|
63
|
+
resourceId: await getRemoteCachePackageId({ packagePath: appPath }, ctx),
|
|
64
|
+
storageAccount: remoteCacheConfig.storageAccount,
|
|
65
|
+
container: remoteCacheConfig.container,
|
|
66
|
+
tenantId: remoteCacheConfig.tenantId,
|
|
67
|
+
description,
|
|
68
|
+
localBundleFolderName: appBundleLocation.folderName,
|
|
69
|
+
});
|
|
53
70
|
}
|
|
54
71
|
const uploads = packagesToUpload.map((pkg) => taskRunner.add(createUploadTask({ client, options: { ...pkg, globMatches } })));
|
|
55
72
|
// Do not reject if there is a failure. Failed uploads will be logged in the task reporter.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"syncUpload.js","sourceRoot":"","sources":["../../src/apis/syncUpload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAoC,MAAM,2BAA2B,CAAC;AACnG,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,iCAAiC,EAAE,MAAM,mDAAmD,CAAC;AACtG,OAAO,EAAE,uCAAuC,EAAE,MAAM,yDAAyD,CAAC;AAClH,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,UAAU,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,wBAAwB,EAAE,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"syncUpload.js","sourceRoot":"","sources":["../../src/apis/syncUpload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAoC,MAAM,2BAA2B,CAAC;AACnG,OA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pC,WAAW;gBACX,qBAAqB,EAAE,iBAAiB,CAAC,UAAU;aACpD,CAAC,CAAC;QACL,CAAC;QAED,MAAM,OAAO,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAC3C,UAAU,CAAC,GAAG,CAAC,gBAAgB,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,GAAG,GAAG,EAAE,WAAW,EAAE,EAAE,CAAC,CAAC,CAC/E,CAAC;QAEF,2FAA2F;QAC3F,MAAM,cAAc,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAEzD,MAAM,MAAM,GAAG,iCAAiC,CAAC,cAAc,CAAC,CAAC;QACjE,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QAE3B,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC,CAAC;AACL,CAAC;AAED,kGAAkG","sourcesContent":["import { ensurePackageBundled, type EnsurePackageBundledContext } from './ensurePackageBundled.js';\nimport { PerfMeasurementSyncUpload } from '../performance/markers.js';\nimport { getRemoteCachePromiseResultCounts } from '../utilities/getRemoteCachePromiseResultCounts.js';\nimport { createRemoteCacheClientOperationOptions } from '../utilities/createRemoteCacheClientOperationOptions.js';\nimport { createUploadTask } from '../utilities/createUploadTask.js';\nimport { isStaticRoute } from '@ms-cloudpack/common-types';\nimport path from 'path';\nimport { getBundleLocation } from '../utilities/getBundleLocation.js';\nimport { cp } from 'fs/promises';\nimport objectHash from 'object-hash';\nimport type { SyncResult } from '../types/SyncResult.js';\nimport { ensureRemoteCacheEnabled } from '../utilities/ensureRemoteCacheEnabled.js';\nimport { getRemoteCachePackageId } from '../utilities/getRemoteCachePackageId.js';\nimport type { LoginMethod } from '@ms-cloudpack/remote-cache';\n\n/**\n * Bundle the current app and its dependencies, and upload them to the remote cache.\n */\nexport async function syncUpload(\n input: { login: LoginMethod },\n ctx: Omit<EnsurePackageBundledContext, 'bus' | 'watcher'>,\n): Promise<SyncResult> {\n const { login } = input;\n const { session, telemetryClient, taskRunner, remoteCacheClient: client } = ctx;\n const { config } = session;\n const { appPath } = config;\n const { remoteCache: remoteCacheConfig } = config;\n const syncInternalPackages = config?.features?.syncInternalPackages ?? false;\n\n ensureRemoteCacheEnabled(config);\n\n if (!client) {\n throw new Error('Remote cache client is required to sync upload');\n }\n\n if (!remoteCacheConfig) {\n throw new Error('Remote cache configuration is required to sync upload');\n }\n\n // Glob pattern for the files to upload.\n const globMatches = ['**/*', '!**/*-input.json', '!**/*-output.json'];\n\n return await telemetryClient.tracer.startActiveSpan(PerfMeasurementSyncUpload, async (span) => {\n const { name, version, description } = await ctx.packages.get(appPath);\n\n const { dependencies, result: bundleResult } = await ensurePackageBundled(\n { name, version, enqueueDependencies: true },\n ctx,\n );\n\n const bundledPackages = [bundleResult, ...(await dependencies)];\n const packagesToUpload = await Promise.all(\n bundledPackages\n .filter((p) => p.inputPath && (p.isExternal || syncInternalPackages))\n .map((p) =>\n createRemoteCacheClientOperationOptions(\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- verified above that it's set\n { packagePath: p.inputPath! },\n ctx,\n ),\n ),\n );\n\n if (config.features?.enableCloudHosted) {\n const appBundleLocation = await getBundleLocation({ packagePath: appPath }, ctx);\n const appOutputPath = appBundleLocation.path;\n const destinationFolder = path.join(appOutputPath, '__cloudpack');\n const routesPath = path.join(destinationFolder, 'routes');\n for (const route of config.routes ?? []) {\n if (isStaticRoute(route)) {\n const staticPath = path.resolve(appPath, route.staticPath);\n const routeHash = objectHash(route);\n const folderPath = path.join(routesPath, routeHash);\n await cp(staticPath, path.join(folderPath, route.staticPath), { recursive: true });\n }\n }\n\n const { createAppRegistryClient } = await import('@ms-cloudpack/remote-cache');\n const appRegistryClient = await createAppRegistryClient({\n context: ctx,\n options: { cachePath: session.cachePath, loginMethod: login },\n });\n\n await appRegistryClient.registerApp({\n name,\n // Using the current date and time as the version, because most apps are not versioned.\n version: new Date().toISOString().slice(16).replace('T', ' '),\n resourceId: await getRemoteCachePackageId({ packagePath: appPath }, ctx),\n storageAccount: remoteCacheConfig.storageAccount,\n container: remoteCacheConfig.container,\n tenantId: remoteCacheConfig.tenantId,\n description,\n localBundleFolderName: appBundleLocation.folderName,\n });\n }\n\n const uploads = packagesToUpload.map((pkg) =>\n taskRunner.add(createUploadTask({ client, options: { ...pkg, globMatches } })),\n );\n\n // Do not reject if there is a failure. Failed uploads will be logged in the task reporter.\n const promiseResults = await Promise.allSettled(uploads);\n\n const result = getRemoteCachePromiseResultCounts(promiseResults);\n span.setAttributes(result);\n\n return result;\n });\n}\n\n// This function doesn't have an attached procedure because it's never called via the TRPC server.\n"]}
|
package/lib/apis/unlinkPath.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { type LinkPathInput, type LinkPathOutput } from '../types/LinkPath.js';
|
|
|
3
3
|
/**
|
|
4
4
|
* Unlinks a path to the session.
|
|
5
5
|
*/
|
|
6
|
-
export declare function unlinkPath(params: ApiParams<LinkPathInput, '
|
|
6
|
+
export declare function unlinkPath(params: ApiParams<LinkPathInput, 'bus' | 'reporter' | 'telemetryClient', 'incrementSessionVersion' | 'linkedPaths' | 'projectName' | 'removeLinkedPath' | 'resolveMap' | 'sequence'>): Promise<LinkPathOutput>;
|
|
7
7
|
export declare namespace unlinkPath {
|
|
8
8
|
var procedure: import("@trpc/server").TRPCQueryProcedure<{
|
|
9
9
|
input: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unlinkPath.d.ts","sourceRoot":"","sources":["../../src/apis/unlinkPath.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EAAuC,KAAK,aAAa,EAAE,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEpH;;GAEG;AACH,wBAAsB,UAAU,CAC9B,MAAM,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"unlinkPath.d.ts","sourceRoot":"","sources":["../../src/apis/unlinkPath.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EAAuC,KAAK,aAAa,EAAE,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEpH;;GAEG;AACH,wBAAsB,UAAU,CAC9B,MAAM,EAAE,SAAS,CACf,aAAa,EACb,KAAK,GAAG,UAAU,GAAG,iBAAiB,EACtC,yBAAyB,GAAG,aAAa,GAAG,aAAa,GAAG,kBAAkB,GAAG,YAAY,GAAG,UAAU,CAC3G,GACA,OAAO,CAAC,cAAc,CAAC,CAmBzB;yBAzBqB,UAAU"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unlinkPath.js","sourceRoot":"","sources":["../../src/apis/unlinkPath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAA2C,MAAM,sBAAsB,CAAC;AAEpH;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,
|
|
1
|
+
{"version":3,"file":"unlinkPath.js","sourceRoot":"","sources":["../../src/apis/unlinkPath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAA2C,MAAM,sBAAsB,CAAC;AAEpH;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,MAIC;IAED,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC;IAC9B,MAAM,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC;IAC7B,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,eAAe,EAAE,GAAG,GAAG,CAAC;IACxD,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,sBAAsB,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;IAC3E,IAAI,MAAM,GAAG,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC;IAClF,IAAI,CAAC;QACH,MAAM,eAAe,CAAC,MAAM,CAAC,eAAe,CAAC,aAAa,EAAE,KAAK,IAAI,EAAE;YACrE,mCAAmC;YACnC,MAAM,GAAG,MAAM,OAAO,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;YACpD,IAAI,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YAClF,OAAO,CAAC,uBAAuB,EAAE,CAAC;YAClC,MAAM,YAAY,CAAC,EAAE,MAAM,EAAE,aAAa,EAAE,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC,CAAC;QACnF,CAAC,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,IAAI,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,wBAAwB,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACxF,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,UAAU,CAAC,SAAS,GAAG,eAAe,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC","sourcesContent":["import { publicProcedure } from '../trpc/common.js';\nimport type { ApiParams } from '../types/ApiParams.js';\nimport { notifyReload } from '../utilities/notifyReload.js';\nimport { ZodLinkPathInput, ZodLinkPathOutput, type LinkPathInput, type LinkPathOutput } from '../types/LinkPath.js';\n\n/**\n * Unlinks a path to the session.\n */\nexport async function unlinkPath(\n params: ApiParams<\n LinkPathInput,\n 'bus' | 'reporter' | 'telemetryClient',\n 'incrementSessionVersion' | 'linkedPaths' | 'projectName' | 'removeLinkedPath' | 'resolveMap' | 'sequence'\n >,\n): Promise<LinkPathOutput> {\n const { input, ctx } = params;\n const { linkedPath } = input;\n const { session, reporter, bus, telemetryClient } = ctx;\n const task = reporter.addTask(`Unlinking paths in ${session.projectName}`);\n let result = { resolveMap: session.resolveMap, linkedPaths: session.linkedPaths };\n try {\n await telemetryClient.tracer.startActiveSpan('UNLINK_PATH', async () => {\n // Remove linked paths from session\n result = await session.removeLinkedPath(linkedPath);\n task.complete({ status: 'complete', message: `Unlinked paths`, forceShow: true });\n session.incrementSessionVersion();\n await notifyReload({ reason: 'unlink-path' }, { bus, session, telemetryClient });\n });\n } catch (e) {\n task.complete({ status: 'fail', message: `Failed to unlink paths`, forceShow: true });\n }\n\n return result;\n}\n\nunlinkPath.procedure = publicProcedure.input(ZodLinkPathInput).output(ZodLinkPathOutput).query(unlinkPath);\n"]}
|
|
@@ -1,39 +1,14 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
1
|
import type { ApiParams } from '../types/ApiParams.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
issuerUrl: z.ZodOptional<z.ZodString>;
|
|
7
|
-
}, "strip", z.ZodTypeAny, {
|
|
8
|
-
packageName: string;
|
|
9
|
-
importPath: string;
|
|
10
|
-
issuerUrl?: string | undefined;
|
|
11
|
-
}, {
|
|
12
|
-
packageName: string;
|
|
13
|
-
importPath: string;
|
|
14
|
-
issuerUrl?: string | undefined;
|
|
15
|
-
}>;
|
|
16
|
-
export type ValidatePackageOverrideInput = z.infer<typeof ZodValidatePackageOverrideInput>;
|
|
17
|
-
declare const ZodValidatePackageOverrideOutput: z.ZodObject<{
|
|
18
|
-
fixable: z.ZodBoolean;
|
|
19
|
-
}, "strip", z.ZodTypeAny, {
|
|
2
|
+
import type { OverrideOptions } from '../types/OverrideOptions.js';
|
|
3
|
+
export type ValidatePackageOverrideInput = Omit<OverrideOptions, 'version'>;
|
|
4
|
+
export interface ValidatePackageOverrideOutput {
|
|
20
5
|
fixable: boolean;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
}>;
|
|
24
|
-
export type ValidatePackageOverrideOutput = z.infer<typeof ZodValidatePackageOverrideOutput>;
|
|
25
|
-
export declare function validatePackageOverride(params: ApiParams<ValidatePackageOverrideInput, 'session' | 'packages' | 'bus'>): Promise<ValidatePackageOverrideOutput>;
|
|
6
|
+
}
|
|
7
|
+
export declare function validatePackageOverride(params: ApiParams<ValidatePackageOverrideInput, 'bus' | 'packages', 'config' | 'resolveMap'>): Promise<ValidatePackageOverrideOutput>;
|
|
26
8
|
export declare namespace validatePackageOverride {
|
|
27
9
|
var procedure: import("@trpc/server").TRPCQueryProcedure<{
|
|
28
|
-
input:
|
|
29
|
-
|
|
30
|
-
importPath: string;
|
|
31
|
-
issuerUrl?: string | undefined;
|
|
32
|
-
};
|
|
33
|
-
output: {
|
|
34
|
-
fixable: boolean;
|
|
35
|
-
};
|
|
10
|
+
input: ValidatePackageOverrideInput;
|
|
11
|
+
output: ValidatePackageOverrideOutput;
|
|
36
12
|
}>;
|
|
37
13
|
}
|
|
38
|
-
export {};
|
|
39
14
|
//# sourceMappingURL=validatePackageOverride.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validatePackageOverride.d.ts","sourceRoot":"","sources":["../../src/apis/validatePackageOverride.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validatePackageOverride.d.ts","sourceRoot":"","sources":["../../src/apis/validatePackageOverride.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAGvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAEnE,MAAM,MAAM,4BAA4B,GAAG,IAAI,CAAC,eAAe,EAAE,SAAS,CAAC,CAAC;AAQ5E,MAAM,WAAW,6BAA6B;IAC5C,OAAO,EAAE,OAAO,CAAC;CAClB;AAMD,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,SAAS,CAAC,4BAA4B,EAAE,KAAK,GAAG,UAAU,EAAE,QAAQ,GAAG,YAAY,CAAC,GAC3F,OAAO,CAAC,6BAA6B,CAAC,CAUxC;yBAZqB,uBAAuB"}
|
|
@@ -2,12 +2,13 @@ import { z } from 'zod';
|
|
|
2
2
|
import { publicProcedure } from '../trpc/common.js';
|
|
3
3
|
import { validateOverride } from '../utilities/validateOverride.js';
|
|
4
4
|
import { errorEntrySource } from '../index.browser.js';
|
|
5
|
-
|
|
5
|
+
import { matchingZodObject } from '../utilities/matchingZodObject.js';
|
|
6
|
+
const ZodValidatePackageOverrideInput = matchingZodObject({
|
|
6
7
|
packageName: z.string(),
|
|
7
8
|
importPath: z.string(),
|
|
8
9
|
issuerUrl: z.string().optional(),
|
|
9
10
|
});
|
|
10
|
-
const ZodValidatePackageOverrideOutput =
|
|
11
|
+
const ZodValidatePackageOverrideOutput = matchingZodObject({
|
|
11
12
|
fixable: z.boolean(),
|
|
12
13
|
});
|
|
13
14
|
export async function validatePackageOverride(params) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validatePackageOverride.js","sourceRoot":"","sources":["../../src/apis/validatePackageOverride.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAEpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"validatePackageOverride.js","sourceRoot":"","sources":["../../src/apis/validatePackageOverride.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAEpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAKtE,MAAM,+BAA+B,GAAG,iBAAiB,CAA+B;IACtF,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;IACvB,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;IACtB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACjC,CAAC,CAAC;AAMH,MAAM,gCAAgC,GAAG,iBAAiB,CAAgC;IACxF,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE;CACrB,CAAC,CAAC;AAEH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,MAA4F;IAE5F,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC;IAC9B,IAAI,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,iBAAiB,EAAE,CAAC;QACnD,4GAA4G;QAC5G,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;IACxC,CAAC;IAED,OAAO;QACL,OAAO,EAAE,MAAM,gBAAgB,CAAC,KAAK,EAAE,GAAG,CAAC;KAC5C,CAAC;AACJ,CAAC;AAED,uBAAuB,CAAC,SAAS,GAAG,eAAe;KAChD,KAAK,CAAC,+BAA+B,CAAC;KACtC,MAAM,CAAC,gCAAgC,CAAC;KACxC,KAAK,CAAC,uBAAuB,CAAC,CAAC","sourcesContent":["import { z } from 'zod';\nimport { publicProcedure } from '../trpc/common.js';\nimport { validateOverride } from '../utilities/validateOverride.js';\nimport type { ApiParams } from '../types/ApiParams.js';\nimport { errorEntrySource } from '../index.browser.js';\nimport { matchingZodObject } from '../utilities/matchingZodObject.js';\nimport type { OverrideOptions } from '../types/OverrideOptions.js';\n\nexport type ValidatePackageOverrideInput = Omit<OverrideOptions, 'version'>;\n\nconst ZodValidatePackageOverrideInput = matchingZodObject<ValidatePackageOverrideInput>({\n packageName: z.string(),\n importPath: z.string(),\n issuerUrl: z.string().optional(),\n});\n\nexport interface ValidatePackageOverrideOutput {\n fixable: boolean;\n}\n\nconst ZodValidatePackageOverrideOutput = matchingZodObject<ValidatePackageOverrideOutput>({\n fixable: z.boolean(),\n});\n\nexport async function validatePackageOverride(\n params: ApiParams<ValidatePackageOverrideInput, 'bus' | 'packages', 'config' | 'resolveMap'>,\n): Promise<ValidatePackageOverrideOutput> {\n const { input, ctx } = params;\n if (ctx.session.config.features?.autoUpdateEntries) {\n // We need to publish an empty string to the errorEntrySource as the error has been received on the overlay.\n ctx.bus.publish(errorEntrySource, '');\n }\n\n return {\n fixable: await validateOverride(input, ctx),\n };\n}\n\nvalidatePackageOverride.procedure = publicProcedure\n .input(ZodValidatePackageOverrideInput)\n .output(ZodValidatePackageOverrideOutput)\n .query(validatePackageOverride);\n"]}
|
|
@@ -22,8 +22,9 @@ export declare function createPartialApiContext(options: CreateApiContextOptions
|
|
|
22
22
|
*
|
|
23
23
|
* When finished with the context, call `dispose` to clean up resources.
|
|
24
24
|
*
|
|
25
|
-
* NOTE: This version initializes the data bus and the file watcher, which are only needed
|
|
26
|
-
* starting
|
|
25
|
+
* NOTE: This version initializes the data bus and the file watcher, which are only needed when
|
|
26
|
+
* starting a server (and add unnecessary overhead otherwise). For other commands, use
|
|
27
|
+
* `createPartialApiContext`.
|
|
27
28
|
*/
|
|
28
29
|
export declare function createApiContext(options: CreateApiContextOptions): Promise<Context>;
|
|
29
30
|
//# sourceMappingURL=createApiContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createApiContext.d.ts","sourceRoot":"","sources":["../../src/common/createApiContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAI9D,MAAM,WAAW,uBACf,SAAQ,oBAAoB,EAC1B,IAAI,CAAC,OAAO,EAAE,UAAU,GAAG,iBAAiB,GAAG,YAAY,CAAC;IAC9D;;;OAGG;IACH,4BAA4B,CAAC,EAAE,WAAW,CAAC;CAC5C;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,GAAG,SAAS,GAAG,SAAS,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"createApiContext.d.ts","sourceRoot":"","sources":["../../src/common/createApiContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAI9D,MAAM,WAAW,uBACf,SAAQ,oBAAoB,EAC1B,IAAI,CAAC,OAAO,EAAE,UAAU,GAAG,iBAAiB,GAAG,YAAY,CAAC;IAC9D;;;OAGG;IACH,4BAA4B,CAAC,EAAE,WAAW,CAAC;CAC5C;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,GAAG,SAAS,GAAG,SAAS,CAAC,CAAC,CA0BvD;AAED;;;;;;;;;GASG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,OAAO,CAAC,CAqBzF"}
|
|
@@ -21,12 +21,7 @@ export function createPartialApiContext(options) {
|
|
|
21
21
|
});
|
|
22
22
|
let remoteCacheClient;
|
|
23
23
|
if (remoteCacheClientLoginMethod) {
|
|
24
|
-
remoteCacheClient = await createRemoteCacheClient({
|
|
25
|
-
input: {
|
|
26
|
-
loginMethod: remoteCacheClientLoginMethod,
|
|
27
|
-
},
|
|
28
|
-
ctx: { session, reporter, telemetryClient },
|
|
29
|
-
});
|
|
24
|
+
remoteCacheClient = await createRemoteCacheClient({ loginMethod: remoteCacheClientLoginMethod }, { session, reporter, telemetryClient });
|
|
30
25
|
}
|
|
31
26
|
return { reporter, taskRunner, telemetryClient, packageHashes, packages, session, remoteCacheClient };
|
|
32
27
|
});
|
|
@@ -37,8 +32,9 @@ export function createPartialApiContext(options) {
|
|
|
37
32
|
*
|
|
38
33
|
* When finished with the context, call `dispose` to clean up resources.
|
|
39
34
|
*
|
|
40
|
-
* NOTE: This version initializes the data bus and the file watcher, which are only needed
|
|
41
|
-
* starting
|
|
35
|
+
* NOTE: This version initializes the data bus and the file watcher, which are only needed when
|
|
36
|
+
* starting a server (and add unnecessary overhead otherwise). For other commands, use
|
|
37
|
+
* `createPartialApiContext`.
|
|
42
38
|
*/
|
|
43
39
|
export async function createApiContext(options) {
|
|
44
40
|
return options.telemetryClient.tracer.startActiveSpan('CREATE_API_CONTEXT', async () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createApiContext.js","sourceRoot":"","sources":["../../src/common/createApiContext.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAClF,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAYhE;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CACrC,OAAgC;IAEhC,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,EAAE,4BAA4B,EAAE,GAAG,OAAO,CAAC;IAEhG,OAAO,eAAe,CAAC,MAAM,CAAC,eAAe,CAAC,4BAA4B,EAAE,KAAK,IAAI,EAAE;QACrF,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AC,wBAAwB,CAAC,CAAC;QACjE,MAAM,GAAG,GAAG,aAAa,EAAE,CAAC;QAC5B,6CAA6C;QAC7C,OAAO,CAAC,UAAU,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;QAErC,OAAO;YACL,GAAG,OAAO;YACV,GAAG;YACH,OAAO;YACP,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE;SACjC,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Context } from '../types/Context.js';\nimport type { CreateSessionOptions } from './createSession.js';\nimport type { LoginMethod } from '@ms-cloudpack/remote-cache';\nimport { createRemoteCacheClient } from '../utilities/createRemoteCacheClient.js';\nimport { createPackageDefinitions } from '@ms-cloudpack/config';\n\nexport interface CreateApiContextOptions\n extends CreateSessionOptions,\n Pick<Context, 'reporter' | 'telemetryClient' | 'taskRunner'> {\n /**\n * Login method for the remote cache.\n * If this isn't provided, `context.remoteCacheClient` will not be set.\n */\n remoteCacheClientLoginMethod?: LoginMethod;\n}\n\n/**\n * Asynchronously initialize a partial `Context`, encapsulating async importing of certain modules\n * to speed up boot time.\n *\n * This version skips some properties that are only needed for starting an app.\n * For a full context, use `createApiContext`.\n */\nexport function createPartialApiContext(\n options: CreateApiContextOptions,\n): Promise<Omit<Context, 'bus' | 'watcher' | 'dispose'>> {\n const { reporter, taskRunner, telemetryClient, config, remoteCacheClientLoginMethod } = options;\n\n return telemetryClient.tracer.startActiveSpan('CREATE_PARTIAL_API_CONTEXT', async () => {\n // Start by creating the properties that are always used\n const packages = createPackageDefinitions({ config });\n\n const { createSession } = await import('./createSession.js');\n const session = await createSession(options, { reporter, packages, telemetryClient });\n\n const { PackageHashes } = await import('@ms-cloudpack/package-hashes');\n const packageHashes = new PackageHashes({\n cwd: config.appPath,\n context: { config, packages, resolveMap: session.resolveMap },\n });\n\n let remoteCacheClient: Context['remoteCacheClient'] | undefined;\n if (remoteCacheClientLoginMethod) {\n remoteCacheClient = await createRemoteCacheClient(\n { loginMethod: remoteCacheClientLoginMethod },\n { session, reporter, telemetryClient },\n );\n }\n\n return { reporter, taskRunner, telemetryClient, packageHashes, packages, session, remoteCacheClient };\n });\n}\n\n/**\n * Asynchronously initialize a `Context`, encapsulating async importing of certain packages/modules\n * to speed up boot time.\n *\n * When finished with the context, call `dispose` to clean up resources.\n *\n * NOTE: This version initializes the data bus and the file watcher, which are only needed when\n * starting a server (and add unnecessary overhead otherwise). For other commands, use\n * `createPartialApiContext`.\n */\nexport async function createApiContext(options: CreateApiContextOptions): Promise<Context> {\n return options.telemetryClient.tracer.startActiveSpan('CREATE_API_CONTEXT', async () => {\n const context = await createPartialApiContext(options);\n\n const { createWatcher } = await import('@ms-cloudpack/file-watcher');\n const watcher = createWatcher({\n type: context.session.config.features?.enableWatcherInFork ? 'fork' : 'default',\n });\n\n const { createDataBus } = await import('@ms-cloudpack/data-bus');\n const bus = createDataBus();\n // Without this line, the overlay won't work.\n context.taskRunner.connectToBus(bus);\n\n return {\n ...context,\n bus,\n watcher,\n dispose: () => watcher.dispose(),\n };\n });\n}\n"]}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export type { Context, PartialContext } from './types/Context.js';
|
|
2
2
|
export type { BundleInfo, BundleEntryInfo, BundleEntryConsumes } from './types/BundleInfo.js';
|
|
3
|
-
export type { Session } from '@ms-cloudpack/common-types';
|
|
4
3
|
export type { TaskStats } from './types/TaskStats.js';
|
|
5
4
|
export type { Task } from './types/Task.js';
|
|
6
5
|
export type { TaskDescription } from './types/TaskDescription.js';
|
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,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAClE,YAAY,EAAE,UAAU,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,uBAA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AM,8BAA8B,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,YAAY,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC"}
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACzF,OAAO,EAAE,qBAAqB,EAAwB,MAAM,iCAAiC,CAAC;AAC9F,OAAO,EAAE,qBAAqB,EAAwB,MAAM,iCAAiC,CAAC;AAC9F,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAEnE,YAAY;AACZ,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAgC,MAAM,8BAA8B,CAAC;AAEvH,iDAAiD;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC","sourcesContent":["export type { Context, PartialContext } from './types/Context.js';\nexport type { BundleInfo, BundleEntryInfo, BundleEntryConsumes } from './types/BundleInfo.js';\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 { TaskList } from './types/TaskList.js';\nexport type { TaskMessage } from './types/TaskMessage.js';\nexport type { TaskStartDescription } from './types/TaskStartDescription.js';\nexport type { EnsurePackageBundledContext, EnsurePackageBundledResult } from './apis/ensurePackageBundled.js';\n\nexport { TaskRunner } from './utilities/TaskRunner.js';\nexport { taskListSource, taskStatsSource, errorEntrySource } from './data/busSources.js';\nexport { createCloudpackClient, type CloudpackClient } from './trpc/createCloudpackClient.js';\nexport { createCloudpackServer, type CloudpackServer } from './trpc/createCloudpackServer.js';\nexport { getActiveSessionsPath } from './utilities/getActiveSessionsPath.js';\nexport { getConsumedDependencies } from './utilities/getConsumedDependencies.js';\nexport { getConsumedPaths } from './utilities/getConsumedPaths.js';\n\n// Utilities\nexport { createApiContext, createPartialApiContext, type CreateApiContextOptions } from './common/createApiContext.js';\n\n// API methods directly used outside this package\nexport { addPackageOverride } from './apis/addPackageOverride.js';\nexport { ensurePackageBundled } from './apis/ensurePackageBundled.js';\nexport { syncDownload } from './apis/syncDownload.js';\nexport { syncUpload } from './apis/syncUpload.js';\nexport type { SyncResult } from './types/SyncResult.js';\n"]}
|
package/lib/types/ApiParams.d.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Session } from '@ms-cloudpack/common-types';
|
|
2
|
+
import type { Context, PartialContext } from './Context.js';
|
|
2
3
|
/**
|
|
3
|
-
* API function parameter object. These property names are defined by
|
|
4
|
+
* tRPC API function parameter object. These property names are defined by tRPC,
|
|
5
|
+
* and the type should only be used for tRPC APIs.
|
|
4
6
|
*
|
|
5
|
-
* If `input` is not needed, use `ApiParams<void, yourKeysHere>`.
|
|
6
|
-
* If `ctx` is not needed, use `ApiParams<yourInputHere
|
|
7
|
+
* - If `input` is not needed, use `ApiParams<void, yourKeysHere>`.
|
|
8
|
+
* - If `ctx` is not needed, use `ApiParams<yourInputHere>`.
|
|
9
|
+
* - `ctx.session` will always be defined, with the given subset of keys.
|
|
7
10
|
*/
|
|
8
|
-
export interface ApiParams<TInput, TContextKeys extends keyof Context> {
|
|
11
|
+
export interface ApiParams<TInput, TContextKeys extends keyof Context = never, TSessionKeys extends keyof Session = never> {
|
|
9
12
|
input: TInput;
|
|
10
|
-
ctx:
|
|
13
|
+
ctx: PartialContext<TContextKeys, TSessionKeys>;
|
|
11
14
|
}
|
|
12
15
|
//# sourceMappingURL=ApiParams.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiParams.d.ts","sourceRoot":"","sources":["../../src/types/ApiParams.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"ApiParams.d.ts","sourceRoot":"","sources":["../../src/types/ApiParams.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE5D;;;;;;;GAOG;AACH,MAAM,WAAW,SAAS,CACxB,MAAM,EACN,YAAY,SAAS,MAAM,OAAO,GAAG,KAAK,EAC1C,YAAY,SAAS,MAAM,OAAO,GAAG,KAAK;IAE1C,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,cAAc,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;CACjD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiParams.js","sourceRoot":"","sources":["../../src/types/ApiParams.ts"],"names":[],"mappings":"","sourcesContent":["import type { Context } from './Context.js';\n\n/**\n * API function parameter object. These property names are defined by
|
|
1
|
+
{"version":3,"file":"ApiParams.js","sourceRoot":"","sources":["../../src/types/ApiParams.ts"],"names":[],"mappings":"","sourcesContent":["import type { Session } from '@ms-cloudpack/common-types';\nimport type { Context, PartialContext } from './Context.js';\n\n/**\n * tRPC API function parameter object. These property names are defined by tRPC,\n * and the type should only be used for tRPC APIs.\n *\n * - If `input` is not needed, use `ApiParams<void, yourKeysHere>`.\n * - If `ctx` is not needed, use `ApiParams<yourInputHere>`.\n * - `ctx.session` will always be defined, with the given subset of keys.\n */\nexport interface ApiParams<\n TInput,\n TContextKeys extends keyof Context = never,\n TSessionKeys extends keyof Session = never,\n> {\n input: TInput;\n ctx: PartialContext<TContextKeys, TSessionKeys>;\n}\n"]}
|
package/lib/types/Context.d.ts
CHANGED
|
@@ -5,19 +5,23 @@ import type { TaskReporter } from '@ms-cloudpack/task-reporter';
|
|
|
5
5
|
import type { TelemetryClient } from '@ms-cloudpack/telemetry';
|
|
6
6
|
import type { TaskRunner } from '../utilities/TaskRunner.js';
|
|
7
7
|
import type { RemoteCacheClient } from '@ms-cloudpack/remote-cache';
|
|
8
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* Context for Cloudpack API server procedures and other APIs.
|
|
10
|
+
*
|
|
11
|
+
* Use `PartialContext` if you only need a subset of properties.
|
|
12
|
+
*/
|
|
9
13
|
export interface Context {
|
|
10
14
|
session: Session;
|
|
11
|
-
/** Data bus for sending notifications to the client. */
|
|
12
|
-
bus: DataBus;
|
|
13
15
|
telemetryClient: TelemetryClient;
|
|
14
16
|
reporter: TaskReporter;
|
|
15
|
-
/** Only used by `ensurePackageBundled`. */
|
|
16
|
-
watcher?: Watcher;
|
|
17
17
|
packages: PackageDefinitionsCache;
|
|
18
18
|
taskRunner: TaskRunner;
|
|
19
19
|
packageHashes: PackageHashesCache;
|
|
20
20
|
remoteCacheClient?: RemoteCacheClient;
|
|
21
|
+
/** Data bus for sending notifications to the client. */
|
|
22
|
+
bus: DataBus;
|
|
23
|
+
/** Only used by `ensurePackageBundled`. */
|
|
24
|
+
watcher: Watcher;
|
|
21
25
|
/** Only set if `watcher` is initialized. */
|
|
22
26
|
dispose?: () => void | Promise<void>;
|
|
23
27
|
}
|
|
@@ -26,7 +30,7 @@ export interface Context {
|
|
|
26
30
|
* First param is context keys and second is session keys.
|
|
27
31
|
* (This can make it easier to tell which properties are actually used where.)
|
|
28
32
|
*/
|
|
29
|
-
export type PartialContext<TContextKeys extends keyof
|
|
33
|
+
export type PartialContext<TContextKeys extends keyof Context, TSessionKeys extends keyof Session = never> = Pick<Context, Exclude<TContextKeys, 'session'>> & {
|
|
30
34
|
session: Pick<Session, TSessionKeys>;
|
|
31
35
|
};
|
|
32
36
|
//# sourceMappingURL=Context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../src/types/Context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACvG,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAEpE
|
|
1
|
+
{"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../src/types/Context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACvG,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAEpE;;;;GAIG;AACH,MAAM,WAAW,OAAO;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,eAAe,EAAE,eAAe,CAAC;IACjC,QAAQ,EAAE,YAAY,CAAC;IACvB,QAAQ,EAAE,uBAAuB,CAAC;IAClC,UAAU,EAAE,UAAU,CAAC;IACvB,aAAa,EAAE,kBAAkB,CAAC;IAClC,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IAKtC,wDAAwD;IACxD,GAAG,EAAE,OAAO,CAAC;IACb,2CAA2C;IAC3C,OAAO,EAAE,OAAO,CAAC;IACjB,4CAA4C;IAC5C,OAAO,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACtC;AAED;;;;GAIG;AACH,MAAM,MAAM,cAAc,CAAC,YAAY,SAAS,MAAM,OAAO,EAAE,YAAY,SAAS,MAAM,OAAO,GAAG,KAAK,IAAI,IAAI,CAC/G,OAAO,EACP,OAAO,CAAC,YAAY,EAAE,SAAS,CAAC,CACjC,GAAG;IACF,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;CACtC,CAAC"}
|
package/lib/types/Context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Context.js","sourceRoot":"","sources":["../../src/types/Context.ts"],"names":[],"mappings":"","sourcesContent":["import type { PackageDefinitionsCache, PackageHashesCache, Session } from '@ms-cloudpack/common-types';\nimport type { DataBus } from '@ms-cloudpack/data-bus';\nimport type { Watcher } from '@ms-cloudpack/file-watcher';\nimport type { TaskReporter } from '@ms-cloudpack/task-reporter';\nimport type { TelemetryClient } from '@ms-cloudpack/telemetry';\nimport type { TaskRunner } from '../utilities/TaskRunner.js';\nimport type { RemoteCacheClient } from '@ms-cloudpack/remote-cache';\n\n
|
|
1
|
+
{"version":3,"file":"Context.js","sourceRoot":"","sources":["../../src/types/Context.ts"],"names":[],"mappings":"","sourcesContent":["import type { PackageDefinitionsCache, PackageHashesCache, Session } from '@ms-cloudpack/common-types';\nimport type { DataBus } from '@ms-cloudpack/data-bus';\nimport type { Watcher } from '@ms-cloudpack/file-watcher';\nimport type { TaskReporter } from '@ms-cloudpack/task-reporter';\nimport type { TelemetryClient } from '@ms-cloudpack/telemetry';\nimport type { TaskRunner } from '../utilities/TaskRunner.js';\nimport type { RemoteCacheClient } from '@ms-cloudpack/remote-cache';\n\n/**\n * Context for Cloudpack API server procedures and other APIs.\n *\n * Use `PartialContext` if you only need a subset of properties.\n */\nexport interface Context {\n session: Session;\n telemetryClient: TelemetryClient;\n reporter: TaskReporter;\n packages: PackageDefinitionsCache;\n taskRunner: TaskRunner;\n packageHashes: PackageHashesCache;\n remoteCacheClient?: RemoteCacheClient;\n\n // The properties below here are only needed for Cloudpack server operations (any server type),\n // such as tRPC APIs or bundling and watching files.\n\n /** Data bus for sending notifications to the client. */\n bus: DataBus;\n /** Only used by `ensurePackageBundled`. */\n watcher: Watcher;\n /** Only set if `watcher` is initialized. */\n dispose?: () => void | Promise<void>;\n}\n\n/**\n * Helper for partial context and session objects.\n * First param is context keys and second is session keys.\n * (This can make it easier to tell which properties are actually used where.)\n */\nexport type PartialContext<TContextKeys extends keyof Context, TSessionKeys extends keyof Session = never> = Pick<\n Context,\n Exclude<TContextKeys, 'session'>\n> & {\n session: Pick<Session, TSessionKeys>;\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TaskRunner.d.ts","sourceRoot":"","sources":["../../src/utilities/TaskRunner.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"TaskRunner.d.ts","sourceRoot":"","sources":["../../src/utilities/TaskRunner.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAK7C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEtD;;;;;;GAMG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,IAAI,CAAsB;IAClC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,UAAU,CAAY;IAC9B,OAAO,CAAC,aAAa,CAAgC;IACrD,OAAO,CAAC,eAAe,CAAuB;IAC9C,OAAO,CAAC,cAAc,CAAc;IAEpC,OAAO,CAAC,UAAU,CAAyB;;IAW3C;;;;OAIG;IACI,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI;IAIvC;;;;;OAKG;IACH,GAAG,CAAC,OAAO,EACT,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,EACnB,OAAO,CAAC,EAAE;QACR,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,GACA,OAAO,CAAC,OAAO,CAAC;IAiEnB;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAgBxB;;OAEG;IACH,KAAK,IAAI,IAAI;IASb,2CAA2C;IAC3C,MAAM,IAAI,IAAI;IAId,sDAAsD;IACtD,MAAM,IAAI,IAAI;IAId;;OAEG;IACH,OAAO,CAAC,YAAY;IAoCpB;;OAEG;IACH,OAAO,CAAC,UAAU;CA8BnB"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import PQueue from 'p-queue';
|
|
2
|
-
import { getDefaultTaskStats } from './getDefaultTaskStats.js';
|
|
3
2
|
import { taskListSource, taskStatsSource } from '../index.browser.js';
|
|
4
3
|
/**
|
|
5
4
|
* TaskRunner tracks the status of tasks, manages concurrency, allows reusing task results,
|
|
@@ -188,4 +187,11 @@ export class TaskRunner {
|
|
|
188
187
|
}
|
|
189
188
|
}
|
|
190
189
|
}
|
|
190
|
+
const getDefaultTaskStats = () => ({
|
|
191
|
+
status: 'idle',
|
|
192
|
+
remainingTasks: 0,
|
|
193
|
+
totalTasks: 0,
|
|
194
|
+
totalErrors: 0,
|
|
195
|
+
totalWarnings: 0,
|
|
196
|
+
});
|
|
191
197
|
//# sourceMappingURL=TaskRunner.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TaskRunner.js","sourceRoot":"","sources":["../../src/utilities/TaskRunner.ts"],"names":[],"mappings":"AAKA,OAAO,MAAM,MAAM,SAAS,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,eAAe,EAAwB,MAAM,qBAAqB,CAAC;AAG5F;;;;;;GAMG;AACH,MAAM,OAAO,UAAU;IAUrB;QACE,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,CAAC;QAC9C,IAAI,CAAC,UAAU,GAAG,mBAAmB,EAAE,CAAC;QACxC,IAAI,CAAC,aAAa,GAAG,IAAI,GAAG,EAAE,CAAC;QAC/B,IAAI,CAAC,eAAe,GAAG,IAAI,GAAG,EAAE,CAAC;QACjC,IAAI,CAAC,cAAc,GAAG,IAAI,GAAG,EAAE,CAAC;QAChC,IAAI,CAAC,UAAU,GAAG,IAAI,GAAG,EAAE,CAAC;IAC9B,CAAC;IAED;;;;OAIG;IACI,YAAY,CAAC,GAAY;QAC9B,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;IAClB,CAAC;IAED;;;;;OAKG;IACH,GAAG,CACD,IAAmB,EACnB,OAGC;QAED,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;QACnC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;QAE1C,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,C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MAAM,mBAAmB,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;QACzC,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;QAEjC,IAAI,mBAAmB,EAAE,CAAC;YACxB,IAAI,CAAC,UAAU,CAAC,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC;YACzD,IAAI,CAAC,UAAU,CAAC,WAAW,IAAI,WAAW,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC,CAAC;YAChE,IAAI,CAAC,UAAU,CAAC,aAAa,IAAI,WAAW,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC,CAAC;YAEpE,KAAK,CAAC,KAAK,CAAC,GAAG;gBACb,GAAG,mBAAmB;gBACtB,GAAG,WAAW;gBACd,MAAM,EAAE,UAAU;gBAClB,oBAAoB,EAAE,GAAG,GAAG,mBAAmB,CAAC,SAAS;gBACzD,WAAW,EAAE,GAAG;aACjB,CAAC;YAEF,IAAI,IAAI,CAAC,UAAU,CAAC,cAAc,KAAK,CAAC,EAAE,CAAC;gBACzC,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,MAAM,CAAC;YAClC,CAAC;YAED,GAAG,CAAC,OAAO,CAAC,eAAe,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;YAC9C,GAAG,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;CACF","sourcesContent":["import type { TaskStartDescription } from '../types/TaskStartDescription.js';\nimport type { TaskEndDescription } from '../types/TaskEndDescription.js';\nimport type { Task } from '../types/Task.js';\nimport type { TaskStats } from '../types/TaskStats.js';\nimport type { TaskList } from '../types/TaskList.js';\nimport PQueue from 'p-queue';\nimport { getDefaultTaskStats } from './getDefaultTaskStats.js';\nimport { taskListSource, taskStatsSource, type TaskDescription } from '../index.browser.js';\nimport type { DataBus } from '@ms-cloudpack/data-bus';\n\n/**\n * TaskRunner tracks the status of tasks, manages concurrency, allows reusing task results,\n * and sends notifications about task status to the data bus (currently just used for `start`).\n *\n * NOTE: To enable data bus notifications, you must call `connectToBus()`.\n * `createApiContext` does this with the `taskRunner` passed in.\n */\nexport class TaskRunner {\n private _bus: DataBus | undefined;\n private _queue: PQueue;\n private _taskStats: TaskStats;\n private _pendingTasks: Map<string, Promise<unknown>>;\n private _completedTasks: Map<string, unknown>;\n private _requiresRerun: Set<string>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private _prevTasks: Map<string, Task<any>>;\n\n constructor() {\n this._queue = new PQueue({ concurrency: 10 });\n this._taskStats = getDefaultTaskStats();\n this._pendingTasks = new Map();\n this._completedTasks = new Map();\n this._requiresRerun = new Set();\n this._prevTasks = new Map();\n }\n\n /**\n * Connects the TaskRunner to the data bus. Tasks will still run without this, but they won't\n * send any notifications to a client (which only matters if a client is listening, e.g.\n * the browser while running `start`).\n */\n public connectToBus(bus: DataBus): void {\n this._bus = bus;\n }\n\n /**\n * Enqueue a task and return its result promise.\n *\n * If a task with the same `id` was already added, it returns either the previous result\n * (if completed) or the promise (if pending). Pass `options.rerun` to force re-running.\n */\n add<TReturn>(\n task: Task<TReturn>,\n options?: {\n rerun?: boolean;\n priority?: number;\n },\n ): Promise<TReturn> {\n const { name, id, execute } = task;\n const { rerun, priority } = options || {};\n\n if (!this._prevTasks.get(id)) {\n this._prevTasks.set(id, task);\n }\n\n // Check if we are already completed the task with that id.\n const action = this._completedTasks.get(id) as TReturn | undefined;\n if (action !== undefined && !rerun) {\n return Promise.resolve(action);\n }\n\n // Check if we are already running the task with that id.\n const pending = this._pendingTasks.get(id) as Promise<TReturn> | undefined;\n if (pending !== undefined) {\n if (rerun) {\n this._requiresRerun.add(id);\n }\n return pending;\n }\n\n const resultPromise: Promise<TReturn> = (async () => {\n let taskResult: TReturn | undefined;\n\n do {\n // Delete from rerun list (if present).\n this._requiresRerun.delete(id);\n\n taskResult = await this._queue.add(\n execute,\n // Removes void from return type.\n // Read more on: https://github.com/sindresorhus/p-queue/issues/175\n { throwOnTimeout: true, priority },\n );\n } while (this._requiresRerun.has(id));\n\n // Delete from pending list.\n this._pendingTasks.delete(id);\n if (task.getEndDescription) {\n this._reportEnd(id, task.getEndDescription(taskResult));\n }\n\n // Extra check to ensure that the task returned a value.\n // It should never throw, if it does we have a bug.\n if (taskResult === undefined) {\n throw new Error(`Task \"${name}:${id}\" returned undefined, without throwing an error, which was unexpected.`);\n }\n\n // Update finished Tasks.\n this._completedTasks.set(id, taskResult);\n\n return taskResult;\n })();\n\n this._pendingTasks.set(id, resultPromise);\n this._completedTasks.delete(id);\n if (task.getStartDescription) {\n this._reportStart(id, task.getStartDescription());\n }\n\n return resultPromise;\n }\n\n /**\n * The remove method disposes a task if available\n * and then removes it from the TaskRunner.\n *\n * This is useful when the state of a task needs to be cleared.\n *\n * It is intended to be used by the api server\n * to clear the TaskRunner's state before reloading the page.\n */\n remove(id: string): void {\n this._prevTasks\n .get(id)\n ?.dispose?.()\n .catch(() => {\n console.debug(`Error disposing task: ${id}`);\n });\n this._prevTasks.get(id)?.onDispose?.();\n this._prevTasks.delete(id);\n this._requiresRerun.delete(id);\n if (this._pendingTasks.has(id)) {\n this._pendingTasks.delete(id);\n this._taskStats.remainingTasks = this._pendingTasks.size;\n }\n this._completedTasks.delete(id);\n }\n /**\n * The clear method disposes all tasks and clears the TaskRunner.\n */\n clear(): void {\n this._taskStats = getDefaultTaskStats();\n this._bus?.publish(taskListSource, { tasks: [] });\n\n for (const id of this._prevTasks.keys()) {\n this.remove(id);\n }\n }\n\n /** Pauses the TaskRunner (for testing). */\n _pause(): void {\n this._queue.pause();\n }\n\n /** Starts or resumes the TaskRunner (for testing). */\n _start(): void {\n this._queue.start();\n }\n\n /**\n * Internal method to report the start of a task to the bus.\n */\n private _reportStart(id: string, description: TaskStartDescription): void {\n if (!this._bus) return;\n\n const bus = this._bus;\n const { tasks } = bus.getData<TaskList>(taskListSource.path) || { tasks: [] };\n const index = tasks.findIndex((t) => t.id === id);\n const previousDescription = tasks[index];\n const now = new Date().getTime();\n\n if (!previousDescription) {\n this._taskStats.totalTasks++;\n }\n\n if (previousDescription?.status === 'complete') {\n this._taskStats.totalErrors -= previousDescription.errors?.length || 0;\n this._taskStats.totalWarnings -= previousDescription.warnings?.length || 0;\n }\n\n this._taskStats.remainingTasks = this._pendingTasks.size;\n this._taskStats.status = 'pending';\n\n const task: TaskDescription = {\n ...description,\n status: 'pending',\n startTime: now,\n };\n if (index === -1) {\n tasks.push(task);\n } else {\n tasks[index] = task;\n }\n\n bus.publish(taskStatsSource, this._taskStats);\n bus.publish(taskListSource, { tasks });\n }\n\n /**\n * Internal method to report the end of a task to the bus.\n */\n private _reportEnd(id: string, description: TaskEndDescription): void {\n if (!this._bus) return;\n\n const bus = this._bus;\n const { tasks } = bus.getData<TaskList>(taskListSource.path) || { tasks: [] };\n const index = tasks.findIndex((t) => t.id === id);\n const previousDescription = tasks[index];\n const now = new Date().getTime();\n\n if (previousDescription) {\n this._taskStats.remainingTasks = this._pendingTasks.size;\n this._taskStats.totalErrors += description?.errors?.length || 0;\n this._taskStats.totalWarnings += description?.warnings?.length || 0;\n\n tasks[index] = {\n ...previousDescription,\n ...description,\n status: 'complete',\n durationMilliseconds: now - previousDescription.startTime,\n lastUpdated: now,\n };\n\n if (this._taskStats.remainingTasks === 0) {\n this._taskStats.status = 'idle';\n }\n\n bus.publish(taskStatsSource, this._taskStats);\n bus.publish(taskListSource, { tasks });\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"TaskRunner.js","sourceRoot":"","sources":["../../src/utilities/TaskRunner.ts"],"names":[],"mappings":"AAKA,OAAO,MAAM,MAAM,SAAS,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,eAAe,EAAwB,MAAM,qBAAqB,CAAC;AAG5F;;;;;;GAMG;AACH,MAAM,OAAO,UAAU;IAUrB;QACE,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,EAAE,WAAW,EAAE,EAAE,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jB,CAAC;YAEF,IAAI,IAAI,CAAC,UAAU,CAAC,cAAc,KAAK,CAAC,EAAE,CAAC;gBACzC,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,MAAM,CAAC;YAClC,CAAC;YAED,GAAG,CAAC,OAAO,CAAC,eAAe,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;YAC9C,GAAG,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;CACF;AAED,MAAM,mBAAmB,GAAoB,GAAG,EAAE,CAAC,CAAC;IAClD,MAAM,EAAE,MAAM;IACd,cAAc,EAAE,CAAC;IACjB,UAAU,EAAE,CAAC;IACb,WAAW,EAAE,CAAC;IACd,aAAa,EAAE,CAAC;CACjB,CAAC,CAAC","sourcesContent":["import type { TaskStartDescription } from '../types/TaskStartDescription.js';\nimport type { TaskEndDescription } from '../types/TaskEndDescription.js';\nimport type { Task } from '../types/Task.js';\nimport type { TaskStats } from '../types/TaskStats.js';\nimport type { TaskList } from '../types/TaskList.js';\nimport PQueue from 'p-queue';\nimport { taskListSource, taskStatsSource, type TaskDescription } from '../index.browser.js';\nimport type { DataBus } from '@ms-cloudpack/data-bus';\n\n/**\n * TaskRunner tracks the status of tasks, manages concurrency, allows reusing task results,\n * and sends notifications about task status to the data bus (currently just used for `start`).\n *\n * NOTE: To enable data bus notifications, you must call `connectToBus()`.\n * `createApiContext` does this with the `taskRunner` passed in.\n */\nexport class TaskRunner {\n private _bus: DataBus | undefined;\n private _queue: PQueue;\n private _taskStats: TaskStats;\n private _pendingTasks: Map<string, Promise<unknown>>;\n private _completedTasks: Map<string, unknown>;\n private _requiresRerun: Set<string>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private _prevTasks: Map<string, Task<any>>;\n\n constructor() {\n this._queue = new PQueue({ concurrency: 10 });\n this._taskStats = getDefaultTaskStats();\n this._pendingTasks = new Map();\n this._completedTasks = new Map();\n this._requiresRerun = new Set();\n this._prevTasks = new Map();\n }\n\n /**\n * Connects the TaskRunner to the data bus. Tasks will still run without this, but they won't\n * send any notifications to a client (which only matters if a client is listening, e.g.\n * the browser while running `start`).\n */\n public connectToBus(bus: DataBus): void {\n this._bus = bus;\n }\n\n /**\n * Enqueue a task and return its result promise.\n *\n * If a task with the same `id` was already added, it returns either the previous result\n * (if completed) or the promise (if pending). Pass `options.rerun` to force re-running.\n */\n add<TReturn>(\n task: Task<TReturn>,\n options?: {\n rerun?: boolean;\n priority?: number;\n },\n ): Promise<TReturn> {\n const { name, id, execute } = task;\n const { rerun, priority } = options || {};\n\n if (!this._prevTasks.get(id)) {\n this._prevTasks.set(id, task);\n }\n\n // Check if we are already completed the task with that id.\n const action = this._completedTasks.get(id) as TReturn | undefined;\n if (action !== undefined && !rerun) {\n return Promise.resolve(action);\n }\n\n // Check if we are already running the task with that id.\n const pending = this._pendingTasks.get(id) as Promise<TReturn> | undefined;\n if (pending !== undefined) {\n if (rerun) {\n this._requiresRerun.add(id);\n }\n return pending;\n }\n\n const resultPromise: Promise<TReturn> = (async () => {\n let taskResult: TReturn | undefined;\n\n do {\n // Delete from rerun list (if present).\n this._requiresRerun.delete(id);\n\n taskResult = await this._queue.add(\n execute,\n // Removes void from return type.\n // Read more on: https://github.com/sindresorhus/p-queue/issues/175\n { throwOnTimeout: true, priority },\n );\n } while (this._requiresRerun.has(id));\n\n // Delete from pending list.\n this._pendingTasks.delete(id);\n if (task.getEndDescription) {\n this._reportEnd(id, task.getEndDescription(taskResult));\n }\n\n // Extra check to ensure that the task returned a value.\n // It should never throw, if it does we have a bug.\n if (taskResult === undefined) {\n throw new Error(`Task \"${name}:${id}\" returned undefined, without throwing an error, which was unexpected.`);\n }\n\n // Update finished Tasks.\n this._completedTasks.set(id, taskResult);\n\n return taskResult;\n })();\n\n this._pendingTasks.set(id, resultPromise);\n this._completedTasks.delete(id);\n if (task.getStartDescription) {\n this._reportStart(id, task.getStartDescription());\n }\n\n return resultPromise;\n }\n\n /**\n * The remove method disposes a task if available\n * and then removes it from the TaskRunner.\n *\n * This is useful when the state of a task needs to be cleared.\n *\n * It is intended to be used by the api server\n * to clear the TaskRunner's state before reloading the page.\n */\n remove(id: string): void {\n this._prevTasks\n .get(id)\n ?.dispose?.()\n .catch(() => {\n console.debug(`Error disposing task: ${id}`);\n });\n this._prevTasks.get(id)?.onDispose?.();\n this._prevTasks.delete(id);\n this._requiresRerun.delete(id);\n if (this._pendingTasks.has(id)) {\n this._pendingTasks.delete(id);\n this._taskStats.remainingTasks = this._pendingTasks.size;\n }\n this._completedTasks.delete(id);\n }\n /**\n * The clear method disposes all tasks and clears the TaskRunner.\n */\n clear(): void {\n this._taskStats = getDefaultTaskStats();\n this._bus?.publish(taskListSource, { tasks: [] });\n\n for (const id of this._prevTasks.keys()) {\n this.remove(id);\n }\n }\n\n /** Pauses the TaskRunner (for testing). */\n _pause(): void {\n this._queue.pause();\n }\n\n /** Starts or resumes the TaskRunner (for testing). */\n _start(): void {\n this._queue.start();\n }\n\n /**\n * Internal method to report the start of a task to the bus.\n */\n private _reportStart(id: string, description: TaskStartDescription): void {\n if (!this._bus) return;\n\n const bus = this._bus;\n const { tasks } = bus.getData<TaskList>(taskListSource.path) || { tasks: [] };\n const index = tasks.findIndex((t) => t.id === id);\n const previousDescription = tasks[index];\n const now = new Date().getTime();\n\n if (!previousDescription) {\n this._taskStats.totalTasks++;\n }\n\n if (previousDescription?.status === 'complete') {\n this._taskStats.totalErrors -= previousDescription.errors?.length || 0;\n this._taskStats.totalWarnings -= previousDescription.warnings?.length || 0;\n }\n\n this._taskStats.remainingTasks = this._pendingTasks.size;\n this._taskStats.status = 'pending';\n\n const task: TaskDescription = {\n ...description,\n status: 'pending',\n startTime: now,\n };\n if (index === -1) {\n tasks.push(task);\n } else {\n tasks[index] = task;\n }\n\n bus.publish(taskStatsSource, this._taskStats);\n bus.publish(taskListSource, { tasks });\n }\n\n /**\n * Internal method to report the end of a task to the bus.\n */\n private _reportEnd(id: string, description: TaskEndDescription): void {\n if (!this._bus) return;\n\n const bus = this._bus;\n const { tasks } = bus.getData<TaskList>(taskListSource.path) || { tasks: [] };\n const index = tasks.findIndex((t) => t.id === id);\n const previousDescription = tasks[index];\n const now = new Date().getTime();\n\n if (previousDescription) {\n this._taskStats.remainingTasks = this._pendingTasks.size;\n this._taskStats.totalErrors += description?.errors?.length || 0;\n this._taskStats.totalWarnings += description?.warnings?.length || 0;\n\n tasks[index] = {\n ...previousDescription,\n ...description,\n status: 'complete',\n durationMilliseconds: now - previousDescription.startTime,\n lastUpdated: now,\n };\n\n if (this._taskStats.remainingTasks === 0) {\n this._taskStats.status = 'idle';\n }\n\n bus.publish(taskStatsSource, this._taskStats);\n bus.publish(taskListSource, { tasks });\n }\n }\n}\n\nconst getDefaultTaskStats: () => TaskStats = () => ({\n status: 'idle',\n remainingTasks: 0,\n totalTasks: 0,\n totalErrors: 0,\n totalWarnings: 0,\n});\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ResolveMapEntry } from '@ms-cloudpack/common-types';
|
|
2
|
-
import type {
|
|
2
|
+
import type { PartialContext } from '../types/Context.js';
|
|
3
3
|
import type { OverrideOptions } from '../types/OverrideOptions.js';
|
|
4
4
|
type OverrideReturn = {
|
|
5
5
|
/** Whether the override was successfully added */
|
|
@@ -11,6 +11,6 @@ type OverrideReturn = {
|
|
|
11
11
|
* The addOverride method is triggered by a user action in the overlay, when we detect new usage of an import path
|
|
12
12
|
* that isn't recognized. When the user triggers this override, we write it to the cloudpack generated config.
|
|
13
13
|
*/
|
|
14
|
-
export declare function addOverride(options: OverrideOptions, context:
|
|
14
|
+
export declare function addOverride(options: OverrideOptions, context: PartialContext<'packages', 'config' | 'resolveMap'>): Promise<OverrideReturn>;
|
|
15
15
|
export {};
|
|
16
16
|
//# sourceMappingURL=addOverride.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addOverride.d.ts","sourceRoot":"","sources":["../../src/utilities/addOverride.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAUlE,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"addOverride.d.ts","sourceRoot":"","sources":["../../src/utilities/addOverride.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAUlE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAEnE,KAAK,cAAc,GAAG;IACpB,kDAAkD;IAClD,aAAa,EAAE,OAAO,CAAC;IACvB,sEAAsE;IACtE,KAAK,EAAE,eAAe,GAAG,SAAS,CAAC;CACpC,CAAC;AAaF;;;GAGG;AACH,wBAAsB,WAAW,CAC/B,OAAO,EAAE,eAAe,EACxB,OAAO,EAAE,cAAc,CAAC,UAAU,EAAE,QAAQ,GAAG,YAAY,CAAC,GAC3D,OAAO,CAAC,cAAc,CAAC,CA2GzB"}
|