@ms-cloudpack/api-server 0.58.16 → 0.59.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 +1 -1
- package/lib/apis/addPackageOverride.d.ts.map +1 -1
- package/lib/apis/addPackageOverride.js.map +1 -1
- package/lib/apis/ensurePackageBundled.d.ts +7 -1
- package/lib/apis/ensurePackageBundled.d.ts.map +1 -1
- package/lib/apis/ensurePackageBundled.js +17 -16
- package/lib/apis/ensurePackageBundled.js.map +1 -1
- package/lib/apis/restartTask.d.ts +4 -0
- package/lib/apis/restartTask.d.ts.map +1 -1
- package/lib/apis/restartTask.js +4 -0
- package/lib/apis/restartTask.js.map +1 -1
- package/lib/apis/syncUpload.d.ts +1 -1
- package/lib/apis/syncUpload.d.ts.map +1 -1
- package/lib/apis/syncUpload.js.map +1 -1
- package/lib/common/createPartialApiContext.d.ts.map +1 -1
- package/lib/common/createPartialApiContext.js +2 -9
- package/lib/common/createPartialApiContext.js.map +1 -1
- package/lib/common/createSession.d.ts +7 -0
- package/lib/common/createSession.d.ts.map +1 -1
- package/lib/common/createSession.js +1 -0
- package/lib/common/createSession.js.map +1 -1
- package/lib/trpc/common.d.ts +5 -3
- package/lib/trpc/common.d.ts.map +1 -1
- package/lib/trpc/common.js.map +1 -1
- package/lib/trpc/createCloudpackServer.d.ts.map +1 -1
- package/lib/trpc/createCloudpackServer.js +1 -2
- package/lib/trpc/createCloudpackServer.js.map +1 -1
- package/lib/types/BundleRequest.d.ts +3 -1
- package/lib/types/BundleRequest.d.ts.map +1 -1
- package/lib/types/BundleRequest.js.map +1 -1
- package/lib/types/Context.d.ts +1 -2
- package/lib/types/Context.d.ts.map +1 -1
- package/lib/types/Context.js.map +1 -1
- package/lib/types/Task.d.ts +1 -0
- package/lib/types/Task.d.ts.map +1 -1
- package/lib/types/Task.js.map +1 -1
- package/lib/utilities/bundleTask.js +3 -2
- package/lib/utilities/bundleTask.js.map +1 -1
- package/lib/utilities/createBundleTask.d.ts +1 -1
- package/lib/utilities/createBundleTask.d.ts.map +1 -1
- package/lib/utilities/createBundleTask.js.map +1 -1
- package/lib/utilities/notifyReload.d.ts +2 -8
- package/lib/utilities/notifyReload.d.ts.map +1 -1
- package/lib/utilities/notifyReload.js.map +1 -1
- package/package.json +13 -13
- package/lib/trpc/createContextFactory.d.ts +0 -9
- package/lib/trpc/createContextFactory.d.ts.map +0 -1
- package/lib/trpc/createContextFactory.js +0 -17
- package/lib/trpc/createContextFactory.js.map +0 -1
|
@@ -32,7 +32,7 @@ export type AddPackageOverrideInput = z.infer<typeof ZodAddPackageOverrideInput>
|
|
|
32
32
|
/**
|
|
33
33
|
* Adds an override to the Cloudpack config.
|
|
34
34
|
*/
|
|
35
|
-
export declare function addPackageOverride(params: ApiParams<AddPackageOverrideInput, 'bus' | '
|
|
35
|
+
export declare function addPackageOverride(params: ApiParams<AddPackageOverrideInput, 'bus' | 'taskRunner' | 'packages' | 'session' | 'packageHashes' | 'telemetryClient'>): Promise<boolean>;
|
|
36
36
|
export declare namespace addPackageOverride {
|
|
37
37
|
var procedure: import("@trpc/server").TRPCMutationProcedure<{
|
|
38
38
|
input: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addPackageOverride.d.ts","sourceRoot":"","sources":["../../src/apis/addPackageOverride.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAGvD,QAAA,MAAM,0BAA0B;IAC9B;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;;;;;;;;;;;EAEH,CAAC;AACH,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAEjF;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,SAAS,CACf,uBAAuB,
|
|
1
|
+
{"version":3,"file":"addPackageOverride.d.ts","sourceRoot":"","sources":["../../src/apis/addPackageOverride.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAGvD,QAAA,MAAM,0BAA0B;IAC9B;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;;;;;;;;;;;EAEH,CAAC;AACH,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAEjF;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,SAAS,CACf,uBAAuB,EACvB,KAAK,GAAG,YAAY,GAAG,UAAU,GAAG,SAAS,GAAG,eAAe,GAAG,iBAAiB,CACpF,GACA,OAAO,CAAC,OAAO,CAAC,CAqBlB;yBA1BqB,kBAAkB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addPackageOverride.js","sourceRoot":"","sources":["../../src/apis/addPackageOverride.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAE5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,MAAM,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C;;OAEG;IACH,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;IAEvB;;OAEG;IACH,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;IAEtB;;OAEG;IACH,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAE9B;;OAEG;IACH,SAAS,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,GAAG,CAAC;YACtB,WAAW,EAAE,KAAK,CAAC,IAAI;YACvB,sBAAsB,EAAE,KAAK;YAC7B,iBAAiB,EAAE,IAAI;SACxB,CAAC,CAAC;QACH,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC9B,gFAAgF;QAChF,OAAO,CAAC,sBAAsB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC3C,IAAI,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,iBAAiB,EAAE,CAAC;YAC/C,uEAAuE;YACvE,GAAG,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;QACpC,CAAC;QACD,MAAM,YAAY,CAAC,EAAE,MAAM,EAAE,sBAAsB,EAAE,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC,CAAC;IAC5F,CAAC;IACD,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,kBAAkB,CAAC,SAAS,GAAG,eAAe,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC","sourcesContent":["import { z } from 'zod';\nimport { publicProcedure } from '../trpc/common.js';\nimport { addOverride } from '../utilities/addOverride.js';\nimport { notifyReload } from '../utilities/notifyReload.js';\nimport type { ApiParams } from '../types/ApiParams.js';\nimport { errorEntrySource } from '../data/busSources.js';\n\nconst ZodAddPackageOverrideInput = z.object({\n /**\n * The package name to override.\n */\n packageName: z.string(),\n\n /**\n * The import path to add for the package.\n */\n importPath: z.string(),\n\n /**\n * The version of the package to override.\n */\n version: z.string().optional(),\n\n /**\n * URL that issued the import.\n */\n issuerUrl: z.string().optional(),\n});\nexport type AddPackageOverrideInput = z.infer<typeof ZodAddPackageOverrideInput>;\n\n/**\n * Adds an override to the Cloudpack config.\n */\nexport async function addPackageOverride(\n params: ApiParams<\n AddPackageOverrideInput,\n 'bus' | 'taskRunner' | 'packages' | 'session' | 'packageHashes' | 'telemetryClient'\n >,\n): Promise<boolean> {\n const { input, ctx } = params;\n const { session, bus, packages, taskRunner, packageHashes, telemetryClient } = ctx;\n const { addedOverride, entry } = await addOverride(input, { session, packages });\n if (entry && addedOverride) {\n // The import map hash needs to be recalculated to ensure that the client is up to date.\n await packageHashes.get({\n packagePath: entry.path,\n isSourceHashingEnabled: false,\n shouldRecalculate: true,\n });\n taskRunner.remove(entry.path);\n // Incrementing the target version will cause the import map to be recalculated.\n session.incrementTargetVersion(entry.path);\n if (session.config.features?.autoUpdateEntries) {\n // We can clear the error message now that the override has been added.\n bus.publish(errorEntrySource, '');\n }\n await notifyReload({ reason: 'add-package-override' }, { bus, session, telemetryClient });\n }\n return addedOverride;\n}\n\naddPackageOverride.procedure = publicProcedure.input(ZodAddPackageOverrideInput).mutation(addPackageOverride);\n"]}
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import type { BundleRequest } from '../types/BundleRequest.js';
|
|
2
2
|
import type { ApiParams } from '../types/ApiParams.js';
|
|
3
|
+
import type { TargetEnvironment } from '@ms-cloudpack/common-types';
|
|
3
4
|
/**
|
|
4
5
|
* Input for `ensurePackageBundled`.
|
|
5
6
|
*/
|
|
6
7
|
export interface EnsurePackageBundledInput extends Pick<BundleRequest, 'outputPath' | 'version' | 'disableSourceMaps' | 'shouldGetBundleInfo'> {
|
|
7
8
|
/** Package name */
|
|
8
9
|
name: string;
|
|
10
|
+
/**
|
|
11
|
+
* Target environment for the bundle.
|
|
12
|
+
* @default 'browser'
|
|
13
|
+
*/
|
|
14
|
+
targetEnvironment?: TargetEnvironment;
|
|
9
15
|
/** Whether to also ensure dependencies are bundled */
|
|
10
16
|
enqueueDependencies?: boolean;
|
|
11
17
|
/** Whether to re-run the bundle task */
|
|
@@ -55,6 +61,6 @@ export interface EnsurePackageBundledOutput {
|
|
|
55
61
|
* Checks if the package is bundled or needs bundling, and returns the result. For internal packages,
|
|
56
62
|
* we also notify the watcher to monitor for code changes.
|
|
57
63
|
*/
|
|
58
|
-
export declare function ensurePackageBundled(params: ApiParams<EnsurePackageBundledInput, 'bus' | 'taskRunner' | 'session' | 'watcher' | 'packages' | 'reporter' | 'telemetryClient' | '
|
|
64
|
+
export declare function ensurePackageBundled(params: ApiParams<EnsurePackageBundledInput, 'bus' | 'taskRunner' | 'session' | 'watcher' | 'packages' | 'reporter' | 'telemetryClient' | 'packageHashes' | 'remoteCacheClient'>): Promise<EnsurePackageBundledOutput>;
|
|
59
65
|
export type EnsurePackageBundledContext = Parameters<typeof ensurePackageBundled>[0]['ctx'];
|
|
60
66
|
//# sourceMappingURL=ensurePackageBundled.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ensurePackageBundled.d.ts","sourceRoot":"","sources":["../../src/apis/ensurePackageBundled.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE/D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"ensurePackageBundled.d.ts","sourceRoot":"","sources":["../../src/apis/ensurePackageBundled.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE/D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAGvD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAEpE;;GAEG;AACH,MAAM,WAAW,yBACf,SAAQ,IAAI,CAAC,aAAa,EAAE,YAAY,GAAG,SAAS,GAAG,mBAAmB,GAAG,qBAAqB,CAAC;IACnG,mBAAmB;IACnB,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,sDAAsD;IACtD,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,wCAAwC;IACxC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,4DAA4D;IAC5D,WAAW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
|
|
62
62
|
}
|
|
63
63
|
async function ensurePackageBundledInternal(params) {
|
|
64
64
|
const { input, ctx, visited } = params;
|
|
65
|
-
const { name, version, shouldWatch, disableSourceMaps, outputPath, shouldGetBundleInfo, shouldRerun, shouldForce, disableCache, isIncremental, useHashAsId, priority, } = input;
|
|
65
|
+
const { name, version, shouldWatch, disableSourceMaps, outputPath, shouldGetBundleInfo, shouldRerun, shouldForce, disableCache, isIncremental, useHashAsId, priority, targetEnvironment = 'browser', } = input;
|
|
66
66
|
const { taskRunner, session, watcher, packageHashes } = ctx;
|
|
67
67
|
const { resolveMap, config } = session;
|
|
68
68
|
const { features } = config;
|
|
@@ -76,19 +76,6 @@ async function ensurePackageBundledInternal(params) {
|
|
|
76
76
|
throw new Error(`Could not find package ${name} in the resolve map.`);
|
|
77
77
|
}
|
|
78
78
|
const isExternal = !!packageEntry.isExternal;
|
|
79
|
-
const bundleRequest = {
|
|
80
|
-
id: packageEntry.path,
|
|
81
|
-
packagePath: packageEntry.path,
|
|
82
|
-
packageName: name,
|
|
83
|
-
isExternal,
|
|
84
|
-
isIncremental,
|
|
85
|
-
outputPath,
|
|
86
|
-
version,
|
|
87
|
-
disableSourceMaps: disableSourceMaps ?? features?.disableSourceMaps,
|
|
88
|
-
shouldGetBundleInfo: shouldGetBundleInfo || enqueueDependencies,
|
|
89
|
-
disableCache,
|
|
90
|
-
mode: config.mode,
|
|
91
|
-
};
|
|
92
79
|
let hash = undefined;
|
|
93
80
|
let sourceHash = undefined;
|
|
94
81
|
if (useHashAsId) {
|
|
@@ -107,9 +94,23 @@ async function ensurePackageBundledInternal(params) {
|
|
|
107
94
|
shouldRecalculate: true,
|
|
108
95
|
});
|
|
109
96
|
}
|
|
110
|
-
// Use the hash as the id
|
|
111
|
-
bundleRequest.id = hash;
|
|
112
97
|
}
|
|
98
|
+
const bundleRequest = {
|
|
99
|
+
// TODO: David had this as follows--think about what it should be
|
|
100
|
+
// id: hash ?? `${packageEntry.path}--env:${targetEnvironment}`,
|
|
101
|
+
id: (useHashAsId && hash) || packageEntry.path,
|
|
102
|
+
packagePath: packageEntry.path,
|
|
103
|
+
packageName: name,
|
|
104
|
+
targetEnvironment,
|
|
105
|
+
isExternal,
|
|
106
|
+
isIncremental,
|
|
107
|
+
outputPath,
|
|
108
|
+
version,
|
|
109
|
+
disableSourceMaps: disableSourceMaps ?? features?.disableSourceMaps,
|
|
110
|
+
shouldGetBundleInfo: shouldGetBundleInfo || enqueueDependencies,
|
|
111
|
+
disableCache,
|
|
112
|
+
mode: config.mode,
|
|
113
|
+
};
|
|
113
114
|
// Make priority negative to have retry count set to positive values.
|
|
114
115
|
const retryCount = priority ? -1 * priority : undefined;
|
|
115
116
|
const task = createBundleTask({ bundleRequest, force: shouldForce, hash, sourceHash, retryCount }, ctx);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ensurePackageBundled.js","sourceRoot":"","sources":["../../src/apis/ensurePackageBundled.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAE5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAGpE,OAAO,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AA0DlF;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,MAYC;IAED,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC;IAC9B,MAAM,OAAO,GAAiC,EAAE,CAAC;IACjD,MAAM,OAAO,GAAG,IAAI,GAAG,EAAyB,CAAC;IAEjD,4BAA4B;IAC5B,IAAI,MAAkC,CAAC;IACvC,IAAI,gBAA6C,CAAC;IAClD,IAAI,CAAC;QACH,CAAC,EAAE,MAAM,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,GAAG,MAAM,4BAA4B,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,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BAAmB;aACpB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO;QACL,MAAM,EAAE;YACN,OAAO;YACP,IAAI;YACJ,UAAU;YACV,GAAG,MAAM;SACV;QACD,gBAAgB;KACjB,CAAC;AACJ,CAAC;AAED,SAAS,cAAc,CAAC,KAAgC,EAAE,KAAc;IACtE,MAAM,IAAI,GAAG,gCAAgC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;IAC7G,OAAO;QACL,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,sBAAsB,EAAE,CAAC;KACnD,CAAC;AACJ,CAAC;AAID,kGAAkG","sourcesContent":["import { findResolveMapEntry } from '@ms-cloudpack/package-utilities';\nimport { notifyReload } from '../utilities/notifyReload.js';\nimport type { BundleRequest } from '../types/BundleRequest.js';\nimport { createBundleTask } from '../utilities/createBundleTask.js';\nimport type { ApiParams } from '../types/ApiParams.js';\nimport type { WatchOptions } from '@ms-cloudpack/file-watcher';\nimport { getConsumedDependencies } from '../utilities/getConsumedDependencies.js';\n\n/**\n * Input for `ensurePackageBundled`.\n */\nexport interface EnsurePackageBundledInput\n extends Pick<BundleRequest, 'outputPath' | 'version' | 'disableSourceMaps' | 'shouldGetBundleInfo'> {\n /** Package name */\n name: string;\n /** Whether to also ensure dependencies are bundled */\n enqueueDependencies?: boolean;\n /** Whether to re-run the bundle task */\n shouldRerun?: boolean;\n /** Whether to watch for changes (internal packages only) */\n shouldWatch?: boolean;\n /** Whether to force re-bundling */\n shouldForce?: boolean;\n /** Whether to disable caching. */\n disableCache?: boolean;\n /** Whether to support incremental rebuilds. Defaults to true for internal libraries. */\n isIncremental?: boolean;\n /**\n * Whether to use a hash as the bundle id instead of the path.\n * Reduces performance when used with shouldForce as it hashes twice,\n * but eliminates task cache artifacts when handling many apps.\n */\n useHashAsId?: boolean;\n /** Priority for bundling. Greater priority will be scheduled first (defaults to 0). */\n priority?: number;\n}\n\n/**\n * Result of ensuring a single package is bundled.\n */\nexport interface EnsurePackageBundledResult\n extends Omit<NonNullable<BundleRequest['result']>, 'rebuild' | 'dispose' | 'bundlerName' | 'inputPath'> {\n /** Package name */\n name: string;\n /** Package version */\n version: string;\n /** Package dependency names (prod and peer) */\n dependencies?: string[];\n /** Whether the package is external (not defined in this repo). Unset if it's not found. */\n isExternal?: boolean;\n /** Absolute path of the package. Will be unset if the package couldn't be found. */\n inputPath?: string;\n}\n\n/**\n * Complete output for `ensurePackageBundled`.\n */\nexport interface EnsurePackageBundledOutput {\n /** Result of bundling this package */\n result: EnsurePackageBundledResult;\n /** Results of bundling dependencies */\n dependencies: Promise<EnsurePackageBundledResult[]>;\n}\n\n/**\n * Checks if the package is bundled or needs bundling, and returns the result. For internal packages,\n * we also notify the watcher to monitor for code changes.\n */\nexport async function ensurePackageBundled(\n params: ApiParams<\n EnsurePackageBundledInput,\n | 'bus'\n | 'taskRunner'\n | 'session'\n | 'watcher'\n | 'packages'\n | 'reporter'\n | 'telemetryClient'\n | 'packageImportPaths'\n | 'packageHashes'\n | 'remoteCacheClient'\n >,\n): Promise<EnsurePackageBundledOutput> {\n const { input, ctx } = params;\n const results: EnsurePackageBundledResult[] = [];\n const visited = new Set<`${string}@${string}`>();\n\n // Bundle the package itself\n let result: EnsurePackageBundledResult;\n let mainDependencies: EnsurePackageBundledInput[];\n try {\n ({ result, dependencyInputs: mainDependencies } = await ensurePackageBundledInternal({ input, ctx, visited }));\n } catch (err) {\n return {\n result: getErrorResult(input, err),\n dependencies: Promise.resolve([]),\n };\n }\n\n // Enqueue main dependencies\n // TODO: should processing this queue have a rate limit? right now if enqueueDependencies is enabled,\n // `await dependencies` will fire off all deps at once.\n let pending = 0;\n const dependencies = new Promise<EnsurePackageBundledResult[]>((resolve) => {\n const enqueue = (dependencyInputs: EnsurePackageBundledInput[]) => {\n for (const dependencyInput of dependencyInputs) {\n pending++;\n\n void ensurePackageBundledInternal({\n input: dependencyInput,\n ctx,\n visited,\n })\n .then((dependencyBundleResult) => {\n // Save result and enqueue this dep's deps\n results.push(dependencyBundleResult.result);\n enqueue(dependencyBundleResult.dependencyInputs);\n })\n .catch((err) => {\n // If there's an error (most likely that the dependency wasn't found in the resolve map),\n // save it in a result instead of throwing. This generally gives better logging.\n results.push(getErrorResult(dependencyInput, err));\n })\n .then(() => {\n pending--;\n if (!pending) {\n resolve(results);\n }\n });\n }\n };\n\n enqueue(mainDependencies);\n });\n\n return {\n result,\n dependencies,\n };\n}\n\nasync function ensurePackageBundledInternal(\n params: Parameters<typeof ensurePackageBundled>[0] & {\n visited: Set<`${string}@${string}`>;\n },\n): Promise<{ result: EnsurePackageBundledResult; dependencyInputs: EnsurePackageBundledInput[] }> {\n const { input, ctx, visited } = params;\n const {\n name,\n version,\n shouldWatch,\n disableSourceMaps,\n outputPath,\n shouldGetBundleInfo,\n shouldRerun,\n shouldForce,\n disableCache,\n isIncremental,\n useHashAsId,\n priority,\n } = input;\n const { taskRunner, session, watcher, packageHashes } = ctx;\n const { resolveMap, config } = session;\n const { features } = config;\n const enqueueDependencies = input.enqueueDependencies ?? features?.enqueueDependencies;\n const dependencyInputs: EnsurePackageBundledInput[] = [];\n\n visited.add(`${name}@${version}`);\n\n // First, we find the resolve map entry. This helps us resolve the physical location of the package\n // according to the resolveMap used in the session. (This can change based on linking.)\n const packageEntry = findResolveMapEntry({ packageName: name, version, resolveMap });\n\n if (!packageEntry) {\n throw new Error(`Could not find package ${name} in the resolve map.`);\n }\n\n const isExternal = !!packageEntry.isExternal;\n\n const bundleRequest: BundleRequest = {\n id: packageEntry.path,\n packagePath: packageEntry.path,\n packageName: name,\n isExternal,\n isIncremental,\n outputPath,\n version,\n disableSourceMaps: disableSourceMaps ?? features?.disableSourceMaps,\n shouldGetBundleInfo: shouldGetBundleInfo || enqueueDependencies,\n disableCache,\n mode: config.mode,\n };\n\n let hash: string | undefined = undefined;\n let sourceHash: string | undefined = undefined;\n\n if (useHashAsId) {\n // If we are using the hash as the task id, we need to calculate it once and pass it to the task\n // to prevent a race condition in which we get a different hash than the one used in the task id.\n hash = await packageHashes.get({\n packagePath: packageEntry.path,\n isSourceHashingEnabled: false,\n shouldRecalculate: true,\n });\n\n if (!packageEntry.isExternal) {\n // We only need the source hash for internal packages for cache validation.\n sourceHash = await packageHashes.get({\n packagePath: packageEntry.path,\n isSourceHashingEnabled: true,\n shouldRecalculate: true,\n });\n }\n\n // Use the hash as the id\n bundleRequest.id = hash;\n }\n\n // Make priority negative to have retry count set to positive values.\n const retryCount = priority ? -1 * priority : undefined;\n\n const task = createBundleTask({ bundleRequest, force: shouldForce, hash, sourceHash, retryCount }, ctx);\n\n // TODO: Add lage scheduling back.\n const { result } = await taskRunner.add<BundleRequest>(task, { rerun: shouldRerun, priority });\n\n if (!result) {\n throw new Error('Bundle failed, no result');\n }\n\n // For internal packages, make sure we're watching the source to re-trigger bundling.\n if (shouldWatch && !isExternal) {\n const definition = await ctx.packages.get(packageEntry.path);\n const watchOptions: WatchOptions = {\n id: bundleRequest.id,\n path: packageEntry.path,\n watchPaths: definition.cloudpack?.inputPaths,\n };\n\n const onPackageChange = async () => {\n const watchedResult = await taskRunner.add<BundleRequest>(task, { rerun: true });\n\n // If the result was successful, notify potential clients for reload.\n if (watchedResult.result?.errors?.length === 0) {\n await notifyReload({ reason: 'on-package-change' }, ctx);\n }\n };\n watcher.watch(watchOptions, () => {\n void onPackageChange();\n });\n }\n\n // If enabled, enqueue dependencies.\n if (enqueueDependencies && result.info) {\n for (const dependencyName of getConsumedDependencies(result.info)) {\n const dependencyVersion = packageEntry.dependencies[dependencyName];\n\n // If we've already visited this package from another package, skip it.\n if (visited.has(`${dependencyName}@${dependencyVersion}`)) {\n continue;\n }\n\n dependencyInputs.push({\n name: dependencyName,\n version: dependencyVersion,\n shouldWatch,\n enqueueDependencies,\n });\n }\n }\n\n return {\n result: {\n version,\n name,\n isExternal,\n ...result,\n },\n dependencyInputs,\n };\n}\n\nfunction getErrorResult(input: EnsurePackageBundledInput, error: unknown): EnsurePackageBundledResult {\n const text = `Error thrown while bundling: ${error instanceof Error ? error.stack || error.message : error}`;\n return {\n name: input.name,\n version: input.version,\n errors: [{ text, source: 'ensurePackageBundled' }],\n };\n}\n\nexport type EnsurePackageBundledContext = Parameters<typeof ensurePackageBundled>[0]['ctx'];\n\n// This function doesn't have an attached procedure because it's never called via the TRPC server.\n"]}
|
|
1
|
+
{"version":3,"file":"ensurePackageBundled.js","sourceRoot":"","sources":["../../src/apis/ensurePackageBundled.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAE5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAGpE,OAAO,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAgElF;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,MAWC;IAED,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC;IAC9B,MAAM,OAAO,GAAiC,EAAE,CAAC;IACjD,MAAM,OAAO,GAAG,IAAI,GAAG,EAAyB,CAAC;IAEjD,4BAA4B;IAC5B,IAAI,MAAkC,CAAC;IACvC,IAAI,gBAA6C,CAAC;IAClD,IAAI,CAAC;QACH,CAAC,EAAE,MAAM,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,GAAG,MAAM,4BAA4B,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;IACjH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO;YACL,MAAM,EAAE,cAAc,CAAC,KAAK,EAAE,GAAG,CAAC;YAClC,YAAY,EAAE,OA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U;YACV,GAAG,MAAM;SACV;QACD,gBAAgB;KACjB,CAAC;AACJ,CAAC;AAED,SAAS,cAAc,CAAC,KAAgC,EAAE,KAAc;IACtE,MAAM,IAAI,GAAG,gCAAgC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;IAC7G,OAAO;QACL,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,sBAAsB,EAAE,CAAC;KACnD,CAAC;AACJ,CAAC;AAID,kGAAkG","sourcesContent":["import { findResolveMapEntry } from '@ms-cloudpack/package-utilities';\nimport { notifyReload } from '../utilities/notifyReload.js';\nimport type { BundleRequest } from '../types/BundleRequest.js';\nimport { createBundleTask } from '../utilities/createBundleTask.js';\nimport type { ApiParams } from '../types/ApiParams.js';\nimport type { WatchOptions } from '@ms-cloudpack/file-watcher';\nimport { getConsumedDependencies } from '../utilities/getConsumedDependencies.js';\nimport type { TargetEnvironment } from '@ms-cloudpack/common-types';\n\n/**\n * Input for `ensurePackageBundled`.\n */\nexport interface EnsurePackageBundledInput\n extends Pick<BundleRequest, 'outputPath' | 'version' | 'disableSourceMaps' | 'shouldGetBundleInfo'> {\n /** Package name */\n name: string;\n /**\n * Target environment for the bundle.\n * @default 'browser'\n */\n targetEnvironment?: TargetEnvironment;\n /** Whether to also ensure dependencies are bundled */\n enqueueDependencies?: boolean;\n /** Whether to re-run the bundle task */\n shouldRerun?: boolean;\n /** Whether to watch for changes (internal packages only) */\n shouldWatch?: boolean;\n /** Whether to force re-bundling */\n shouldForce?: boolean;\n /** Whether to disable caching. */\n disableCache?: boolean;\n /** Whether to support incremental rebuilds. Defaults to true for internal libraries. */\n isIncremental?: boolean;\n /**\n * Whether to use a hash as the bundle id instead of the path.\n * Reduces performance when used with shouldForce as it hashes twice,\n * but eliminates task cache artifacts when handling many apps.\n */\n useHashAsId?: boolean;\n /** Priority for bundling. Greater priority will be scheduled first (defaults to 0). */\n priority?: number;\n}\n\n/**\n * Result of ensuring a single package is bundled.\n */\nexport interface EnsurePackageBundledResult\n extends Omit<NonNullable<BundleRequest['result']>, 'rebuild' | 'dispose' | 'bundlerName' | 'inputPath'> {\n /** Package name */\n name: string;\n /** Package version */\n version: string;\n /** Package dependency names (prod and peer) */\n dependencies?: string[];\n /** Whether the package is external (not defined in this repo). Unset if it's not found. */\n isExternal?: boolean;\n /** Absolute path of the package. Will be unset if the package couldn't be found. */\n inputPath?: string;\n}\n\n/**\n * Complete output for `ensurePackageBundled`.\n */\nexport interface EnsurePackageBundledOutput {\n /** Result of bundling this package */\n result: EnsurePackageBundledResult;\n /** Results of bundling dependencies */\n dependencies: Promise<EnsurePackageBundledResult[]>;\n}\n\n/**\n * Checks if the package is bundled or needs bundling, and returns the result. For internal packages,\n * we also notify the watcher to monitor for code changes.\n */\nexport async function ensurePackageBundled(\n params: ApiParams<\n EnsurePackageBundledInput,\n | 'bus'\n | 'taskRunner'\n | 'session'\n | 'watcher'\n | 'packages'\n | 'reporter'\n | 'telemetryClient'\n | 'packageHashes'\n | 'remoteCacheClient'\n >,\n): Promise<EnsurePackageBundledOutput> {\n const { input, ctx } = params;\n const results: EnsurePackageBundledResult[] = [];\n const visited = new Set<`${string}@${string}`>();\n\n // Bundle the package itself\n let result: EnsurePackageBundledResult;\n let mainDependencies: EnsurePackageBundledInput[];\n try {\n ({ result, dependencyInputs: mainDependencies } = await ensurePackageBundledInternal({ input, ctx, visited }));\n } catch (err) {\n return {\n result: getErrorResult(input, err),\n dependencies: Promise.resolve([]),\n };\n }\n\n // Enqueue main dependencies\n // TODO: should processing this queue have a rate limit? right now if enqueueDependencies is enabled,\n // `await dependencies` will fire off all deps at once.\n let pending = 0;\n const dependencies = new Promise<EnsurePackageBundledResult[]>((resolve) => {\n const enqueue = (dependencyInputs: EnsurePackageBundledInput[]) => {\n for (const dependencyInput of dependencyInputs) {\n pending++;\n\n void ensurePackageBundledInternal({\n input: dependencyInput,\n ctx,\n visited,\n })\n .then((dependencyBundleResult) => {\n // Save result and enqueue this dep's deps\n results.push(dependencyBundleResult.result);\n enqueue(dependencyBundleResult.dependencyInputs);\n })\n .catch((err) => {\n // If there's an error (most likely that the dependency wasn't found in the resolve map),\n // save it in a result instead of throwing. This generally gives better logging.\n results.push(getErrorResult(dependencyInput, err));\n })\n .then(() => {\n pending--;\n if (!pending) {\n resolve(results);\n }\n });\n }\n };\n\n enqueue(mainDependencies);\n });\n\n return {\n result,\n dependencies,\n };\n}\n\nasync function ensurePackageBundledInternal(\n params: Parameters<typeof ensurePackageBundled>[0] & {\n visited: Set<`${string}@${string}`>;\n },\n): Promise<{ result: EnsurePackageBundledResult; dependencyInputs: EnsurePackageBundledInput[] }> {\n const { input, ctx, visited } = params;\n const {\n name,\n version,\n shouldWatch,\n disableSourceMaps,\n outputPath,\n shouldGetBundleInfo,\n shouldRerun,\n shouldForce,\n disableCache,\n isIncremental,\n useHashAsId,\n priority,\n targetEnvironment = 'browser',\n } = input;\n const { taskRunner, session, watcher, packageHashes } = ctx;\n const { resolveMap, config } = session;\n const { features } = config;\n const enqueueDependencies = input.enqueueDependencies ?? features?.enqueueDependencies;\n const dependencyInputs: EnsurePackageBundledInput[] = [];\n\n visited.add(`${name}@${version}`);\n\n // First, we find the resolve map entry. This helps us resolve the physical location of the package\n // according to the resolveMap used in the session. (This can change based on linking.)\n const packageEntry = findResolveMapEntry({ packageName: name, version, resolveMap });\n\n if (!packageEntry) {\n throw new Error(`Could not find package ${name} in the resolve map.`);\n }\n\n const isExternal = !!packageEntry.isExternal;\n\n let hash: string | undefined = undefined;\n let sourceHash: string | undefined = undefined;\n\n if (useHashAsId) {\n // If we are using the hash as the task id, we need to calculate it once and pass it to the task\n // to prevent a race condition in which we get a different hash than the one used in the task id.\n hash = await packageHashes.get({\n packagePath: packageEntry.path,\n isSourceHashingEnabled: false,\n shouldRecalculate: true,\n });\n\n if (!packageEntry.isExternal) {\n // We only need the source hash for internal packages for cache validation.\n sourceHash = await packageHashes.get({\n packagePath: packageEntry.path,\n isSourceHashingEnabled: true,\n shouldRecalculate: true,\n });\n }\n }\n\n const bundleRequest: BundleRequest = {\n // TODO: David had this as follows--think about what it should be\n // id: hash ?? `${packageEntry.path}--env:${targetEnvironment}`,\n id: (useHashAsId && hash) || packageEntry.path,\n packagePath: packageEntry.path,\n packageName: name,\n targetEnvironment,\n isExternal,\n isIncremental,\n outputPath,\n version,\n disableSourceMaps: disableSourceMaps ?? features?.disableSourceMaps,\n shouldGetBundleInfo: shouldGetBundleInfo || enqueueDependencies,\n disableCache,\n mode: config.mode,\n };\n\n // Make priority negative to have retry count set to positive values.\n const retryCount = priority ? -1 * priority : undefined;\n\n const task = createBundleTask({ bundleRequest, force: shouldForce, hash, sourceHash, retryCount }, ctx);\n\n // TODO: Add lage scheduling back.\n const { result } = await taskRunner.add<BundleRequest>(task, { rerun: shouldRerun, priority });\n\n if (!result) {\n throw new Error('Bundle failed, no result');\n }\n\n // For internal packages, make sure we're watching the source to re-trigger bundling.\n if (shouldWatch && !isExternal) {\n const definition = await ctx.packages.get(packageEntry.path);\n const watchOptions: WatchOptions = {\n id: bundleRequest.id,\n path: packageEntry.path,\n watchPaths: definition.cloudpack?.inputPaths,\n };\n\n const onPackageChange = async () => {\n const watchedResult = await taskRunner.add<BundleRequest>(task, { rerun: true });\n\n // If the result was successful, notify potential clients for reload.\n if (watchedResult.result?.errors?.length === 0) {\n await notifyReload({ reason: 'on-package-change' }, ctx);\n }\n };\n watcher.watch(watchOptions, () => {\n void onPackageChange();\n });\n }\n\n // If enabled, enqueue dependencies.\n if (enqueueDependencies && result.info) {\n for (const dependencyName of getConsumedDependencies(result.info)) {\n const dependencyVersion = packageEntry.dependencies[dependencyName];\n\n // If we've already visited this package from another package, skip it.\n if (visited.has(`${dependencyName}@${dependencyVersion}`)) {\n continue;\n }\n\n dependencyInputs.push({\n name: dependencyName,\n version: dependencyVersion,\n shouldWatch,\n enqueueDependencies,\n });\n }\n }\n\n return {\n result: {\n version,\n name,\n isExternal,\n ...result,\n },\n dependencyInputs,\n };\n}\n\nfunction getErrorResult(input: EnsurePackageBundledInput, error: unknown): EnsurePackageBundledResult {\n const text = `Error thrown while bundling: ${error instanceof Error ? error.stack || error.message : error}`;\n return {\n name: input.name,\n version: input.version,\n errors: [{ text, source: 'ensurePackageBundled' }],\n };\n}\n\nexport type EnsurePackageBundledContext = Parameters<typeof ensurePackageBundled>[0]['ctx'];\n\n// This function doesn't have an attached procedure because it's never called via the TRPC server.\n"]}
|
|
@@ -11,6 +11,10 @@ declare const ZodRestartTaskInput: z.ZodObject<{
|
|
|
11
11
|
inputPath: string;
|
|
12
12
|
}>;
|
|
13
13
|
export type RestartTaskInput = z.infer<typeof ZodRestartTaskInput>;
|
|
14
|
+
/**
|
|
15
|
+
* Remove the record of a specific task (usually bundle result) and notify the client to reload,
|
|
16
|
+
* which will trigger the task to be re-run.
|
|
17
|
+
*/
|
|
14
18
|
export declare function restartTask(params: ApiParams<RestartTaskInput, 'session' | 'bus' | 'taskRunner' | 'telemetryClient'>): Promise<void>;
|
|
15
19
|
export declare namespace restartTask {
|
|
16
20
|
var procedure: import("@trpc/server").TRPCMutationProcedure<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"restartTask.d.ts","sourceRoot":"","sources":["../../src/apis/restartTask.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEvD,QAAA,MAAM,mBAAmB;;;;;;;;;EAGvB,CAAC;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEnE,wBAAsB,WAAW,CAC/B,MAAM,EAAE,SAAS,CAAC,gBAAgB,EAAE,SAAS,GAAG,KAAK,GAAG,YAAY,GAAG,iBAAiB,CAAC,GACxF,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"restartTask.d.ts","sourceRoot":"","sources":["../../src/apis/restartTask.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEvD,QAAA,MAAM,mBAAmB;;;;;;;;;EAGvB,CAAC;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEnE;;;GAGG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,SAAS,CAAC,gBAAgB,EAAE,SAAS,GAAG,KAAK,GAAG,YAAY,GAAG,iBAAiB,CAAC,GACxF,OAAO,CAAC,IAAI,CAAC,CASf;yBAXqB,WAAW"}
|
package/lib/apis/restartTask.js
CHANGED
|
@@ -5,6 +5,10 @@ const ZodRestartTaskInput = z.object({
|
|
|
5
5
|
id: z.string(),
|
|
6
6
|
inputPath: z.string(),
|
|
7
7
|
});
|
|
8
|
+
/**
|
|
9
|
+
* Remove the record of a specific task (usually bundle result) and notify the client to reload,
|
|
10
|
+
* which will trigger the task to be re-run.
|
|
11
|
+
*/
|
|
8
12
|
export async function restartTask(params) {
|
|
9
13
|
const { input, ctx } = params;
|
|
10
14
|
const { id, inputPath } = input;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"restartTask.js","sourceRoot":"","sources":["../../src/apis/restartTask.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAG5D,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IACnC,EAA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,GAAG,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC,CAAC;AACpF,CAAC;AAED,2CAA2C;AAC3C,WAAW,CAAC,SAAS,GAAG,eAAe,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC","sourcesContent":["import { z } from 'zod';\nimport { publicProcedure } from '../trpc/common.js';\nimport { notifyReload } from '../utilities/notifyReload.js';\nimport type { ApiParams } from '../types/ApiParams.js';\n\nconst ZodRestartTaskInput = z.object({\n id: z.string(),\n inputPath: z.string(),\n});\nexport type RestartTaskInput = z.infer<typeof ZodRestartTaskInput>;\n\n/**\n * Remove the record of a specific task (usually bundle result) and notify the client to reload,\n * which will trigger the task to be re-run.\n */\nexport async function restartTask(\n params: ApiParams<RestartTaskInput, 'session' | 'bus' | 'taskRunner' | 'telemetryClient'>,\n): Promise<void> {\n const { input, ctx } = params;\n const { id, inputPath } = input;\n const { session, bus, taskRunner, telemetryClient } = ctx;\n\n console.debug(`ApiServer: Restarting task ${id}`);\n taskRunner.remove(id);\n session.incrementTargetVersion(inputPath);\n await notifyReload({ reason: 'restart-task' }, { bus, session, telemetryClient });\n}\n\n// Attach a trpc procedure to the function.\nrestartTask.procedure = publicProcedure.input(ZodRestartTaskInput).mutation(restartTask);\n"]}
|
package/lib/apis/syncUpload.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { ApiParams } from '../types/ApiParams.js';
|
|
2
2
|
import type { SyncResult } from '../types/SyncResult.js';
|
|
3
|
-
export declare function syncUpload(params: ApiParams<undefined, 'session' | 'packages' | 'reporter' | 'bus' | 'taskRunner' | 'watcher' | 'telemetryClient' | '
|
|
3
|
+
export declare function syncUpload(params: ApiParams<undefined, 'session' | 'packages' | 'reporter' | 'bus' | 'taskRunner' | 'watcher' | 'telemetryClient' | 'packageHashes' | 'remoteCacheClient'>): Promise<SyncResult>;
|
|
4
4
|
//# sourceMappingURL=syncUpload.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"syncUpload.d.ts","sourceRoot":"","sources":["../../src/apis/syncUpload.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AASvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAGzD,wBAAsB,UAAU,CAC9B,MAAM,EAAE,SAAS,CACf,SAAS,EACP,SAAS,GACT,UAAU,GACV,UAAU,GACV,KAAK,GACL,YAAY,GACZ,SAAS,GACT,iBAAiB,GACjB,
|
|
1
|
+
{"version":3,"file":"syncUpload.d.ts","sourceRoot":"","sources":["../../src/apis/syncUpload.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AASvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAGzD,wBAAsB,UAAU,CAC9B,MAAM,EAAE,SAAS,CACf,SAAS,EACP,SAAS,GACT,UAAU,GACV,UAAU,GACV,KAAK,GACL,YAAY,GACZ,SAAS,GACT,iBAAiB,GACjB,eAAe,GACf,mBAAmB,CACtB,GACA,OAAO,CAAC,UAAU,CAAC,CAmErB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"syncUpload.js","sourceRoot":"","sources":["../../src/apis/syncUpload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAEtE,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,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} from '../performance/markers.js';\nimport type { ApiParams } from '../types/ApiParams.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';\n\nexport async function syncUpload(\n params: ApiParams<\n undefined,\n | 'session'\n | 'packages'\n | 'reporter'\n | 'bus'\n | 'taskRunner'\n | 'watcher'\n | 'telemetryClient'\n | 'packageHashes'\n | 'remoteCacheClient'\n >,\n): Promise<SyncResult> {\n const { ctx } = params;\n const { session, telemetryClient, taskRunner, remoteCacheClient: client } = ctx;\n const { config } = session;\n const { appPath } = 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 // 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 } = await ctx.packages.get(appPath);\n\n const { dependencies, result: bundleResult } = await ensurePackageBundled({\n input: {\n name,\n version,\n enqueueDependencies: true,\n },\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 appOutputPath = (await getBundleLocation({ packagePath: appPath }, ctx)).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\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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createPartialApiContext.d.ts","sourceRoot":"","sources":["../../src/common/createPartialApiContext.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"createPartialApiContext.d.ts","sourceRoot":"","sources":["../../src/common/createPartialApiContext.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAqB,MAAM,4BAA4B,CAAC;AAOjF,MAAM,WAAW,qBAAsB,SAAQ,oBAAoB;IACjE,QAAQ,EAAE,YAAY,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,eAAe,CAAC;IACjC,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,4BAA4B,CAAC,EAAE,WAAW,CAAC;CAC5C;AAiJD,wBAAsB,uBAAuB,CAC3C,KAAK,SAAS,OAAO,CAAC,MAAM,OAAO,EAAE,SAAS,CAAC,EAC/C,OAAO,SAAS,IAAI,CAAC,OAAO,EAAE,KAAK,GAAG,SAAS,GAAG,UAAU,GAAG,iBAAiB,CAAC,EACjF,OAAO,EAAE,qBAAqB,GAAG;IAAE,KAAK,EAAE,CAAC,KAAK,GAAG,SAAS,GAAG,IAAI,GAAG,KAAK,CAAC,EAAE,CAAA;CAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAyBpG"}
|
|
@@ -9,7 +9,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
9
9
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
|
-
var _LazyApiContext_bus, _LazyApiContext_watcher, _LazyApiContext_packages, _LazyApiContext_taskRunner, _LazyApiContext_session,
|
|
12
|
+
var _LazyApiContext_bus, _LazyApiContext_watcher, _LazyApiContext_packages, _LazyApiContext_taskRunner, _LazyApiContext_session, _LazyApiContext_packageHashes, _LazyApiContext_remoteCacheClient;
|
|
13
13
|
import { createRemoteCacheClient } from '../utilities/createRemoteCacheClient.js';
|
|
14
14
|
class LazyApiContext {
|
|
15
15
|
constructor(options) {
|
|
@@ -19,7 +19,6 @@ class LazyApiContext {
|
|
|
19
19
|
_LazyApiContext_packages.set(this, void 0);
|
|
20
20
|
_LazyApiContext_taskRunner.set(this, void 0);
|
|
21
21
|
_LazyApiContext_session.set(this, void 0);
|
|
22
|
-
_LazyApiContext_packageImportPaths.set(this, void 0);
|
|
23
22
|
_LazyApiContext_packageHashes.set(this, void 0);
|
|
24
23
|
_LazyApiContext_remoteCacheClient.set(this, void 0);
|
|
25
24
|
const { taskRunner } = options;
|
|
@@ -110,12 +109,6 @@ class LazyApiContext {
|
|
|
110
109
|
}
|
|
111
110
|
return __classPrivateFieldGet(this, _LazyApiContext_session, "f");
|
|
112
111
|
}
|
|
113
|
-
get packageImportPaths() {
|
|
114
|
-
if (!__classPrivateFieldGet(this, _LazyApiContext_packageImportPaths, "f")) {
|
|
115
|
-
__classPrivateFieldSet(this, _LazyApiContext_packageImportPaths, Promise.resolve(new Map()), "f");
|
|
116
|
-
}
|
|
117
|
-
return __classPrivateFieldGet(this, _LazyApiContext_packageImportPaths, "f");
|
|
118
|
-
}
|
|
119
112
|
get remoteCacheClient() {
|
|
120
113
|
if (!__classPrivateFieldGet(this, _LazyApiContext_remoteCacheClient, "f")) {
|
|
121
114
|
const createRemoteCacheClientLazy = async () => {
|
|
@@ -144,7 +137,7 @@ class LazyApiContext {
|
|
|
144
137
|
}
|
|
145
138
|
}
|
|
146
139
|
}
|
|
147
|
-
_LazyApiContext_bus = new WeakMap(), _LazyApiContext_watcher = new WeakMap(), _LazyApiContext_packages = new WeakMap(), _LazyApiContext_taskRunner = new WeakMap(), _LazyApiContext_session = new WeakMap(),
|
|
140
|
+
_LazyApiContext_bus = new WeakMap(), _LazyApiContext_watcher = new WeakMap(), _LazyApiContext_packages = new WeakMap(), _LazyApiContext_taskRunner = new WeakMap(), _LazyApiContext_session = new WeakMap(), _LazyApiContext_packageHashes = new WeakMap(), _LazyApiContext_remoteCacheClient = new WeakMap();
|
|
148
141
|
export async function createPartialApiContext(options) {
|
|
149
142
|
const { reporter, telemetryClient, items } = options;
|
|
150
143
|
return telemetryClient.tracer.startActiveSpan('CREATE_PARTIAL_API_CONTEXT', async (span) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createPartialApiContext.js","sourceRoot":"","sources":["../../src/common/createPartialApiContext.ts"],"names":[],"mappings":";;;;;;;;;;;;AAUA,OAAO,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAclF,MAAM,cAAc;IAUlB,YAA6B,OAA8B;QAA9B,YAAO,GAAP,OAAO,CAAuB;QAT3D,sCAAmC;QACnC,0CAAuC;QACvC,2CAAwD;QACxD,6CAA6C;QAC7C,0CAAuC;QACvC,qDAA6D;QAC7D,gDAAwD;QACxD,oDAAuE;QAGrE,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;QAC/B,IAAI,UAAU,EAAE,CAAC;YACf,uBAAA,IAAI,8BAAe,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,MAAA,CAAC;QACjD,CAAC;IACH,CAAC;IAED,IAAW,eAAe;QACxB,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;IACvD,CAAC;IAED,IAAW,GAAG;QACZ,IAAI,CAAC,uBAAA,IAAI,2BAAK,EAAE,CAAC;YACf,MAAM,iBAAiB,GAAG,KAAK,IAAI,EAAE;gBACnC,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,MAAM,CAAC,wBAAwB,CAAC,CAAC;gBACjE,OAAO,aAAa,EAAE,CAAC;YACzB,CAAC,CAAC;YACF,uBAAA,IAAI,uBAAQ,iBAAiB,EAAE,MAAA,CAAC;QAClC,CAAC;QAED,OAAO,uBAAA,IAAI,2BAAK,CAAC;IACnB,CAAC;IAED,IAAW,OAAO;QAChB,IAAI,CAAC,uBAAA,IAAI,+BAAS,EAAE,CAAC;YACnB,MAAM,iBAAiB,GAAG,KAAK,IAAI,EAAE;gBACnC,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,MAAM,CAAC,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O,CAAC;IACrD,OAAO,eAAe,CAAC,MAAM,CAAC,eAAe,CAAC,4BAA4B,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QACzF,MAAM,WAAW,GAAG,IAAI,cAAc,CAAC,OAAO,CAAC,CAAC;QAEhD,MAAM,MAAM,GAAG;YACb,QAAQ;YACR,eAAe;YACf,OAAO,EAAE,GAAG,EAAE;gBACZ,OAAO,WAAW,CAAC,OAAO,EAAE,CAAC;YAC/B,CAAC;SACS,CAAC;QAEb,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,IAAI,IAAI,EAAE,CAAC;gBACT,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,WAAW,CAAC,IAAI,CAAC,CAAmB,CAAC;YAC7D,CAAC;QACH,CAAC;QAED,IAAI,CAAC,aAAa,CAAC;YACjB,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;SAChD,CAAC,CAAC;QAEH,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC,CAAC;AACL,CAAC","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 { Context } from '../types/Context.js';\nimport type { TaskRunner } from '../utilities/TaskRunner.js';\nimport type { PackageImportPaths } from '@ms-cloudpack/import-map';\nimport type { CreateSessionOptions } from './createSession.js';\nimport type { LoginMethod, RemoteCacheClient } from '@ms-cloudpack/remote-cache';\nimport { createRemoteCacheClient } from '../utilities/createRemoteCacheClient.js';\n\ntype PromisifyProperties<T> = {\n [K in keyof T]: T[K] extends (...args: unknown[]) => unknown ? T[K] : Promise<T[K]>;\n};\n\nexport interface LazyApiContextOptions extends CreateSessionOptions {\n reporter: TaskReporter;\n appPath: string;\n telemetryClient: TelemetryClient;\n taskRunner?: TaskRunner;\n remoteCacheClientLoginMethod?: LoginMethod;\n}\n\nclass LazyApiContext implements PromisifyProperties<Context> {\n #bus: Promise<DataBus> | undefined;\n #watcher: Promise<Watcher> | undefined;\n #packages: Promise<PackageDefinitionsCache> | undefined;\n #taskRunner: Promise<TaskRunner> | undefined;\n #session: Promise<Session> | undefined;\n #packageImportPaths: Promise<PackageImportPaths> | undefined;\n #packageHashes: Promise<PackageHashesCache> | undefined;\n #remoteCacheClient: Promise<RemoteCacheClient | undefined> | undefined;\n\n constructor(private readonly options: LazyApiContextOptions) {\n const { taskRunner } = options;\n if (taskRunner) {\n this.#taskRunner = Promise.resolve(taskRunner);\n }\n }\n\n public get telemetryClient(): Promise<TelemetryClient> {\n return Promise.resolve(this.options.telemetryClient);\n }\n\n public get bus(): Promise<DataBus> {\n if (!this.#bus) {\n const createDataBusLazy = async () => {\n const { createDataBus } = await import('@ms-cloudpack/data-bus');\n return createDataBus();\n };\n this.#bus = createDataBusLazy();\n }\n\n return this.#bus;\n }\n\n public get watcher(): Promise<Watcher> {\n if (!this.#watcher) {\n const createWatcherLazy = async () => {\n const { createWatcher } = await import('@ms-cloudpack/file-watcher');\n return createWatcher({\n type: this.options?.config?.features?.enableWatcherInFork ? 'fork' : 'default',\n });\n };\n this.#watcher = createWatcherLazy();\n }\n\n return this.#watcher;\n }\n\n public get reporter(): Promise<TaskReporter> {\n return Promise.resolve(this.options.reporter);\n }\n\n public get packages(): Promise<PackageDefinitionsCache> {\n if (!this.#packages) {\n const createPackageDefinitionsLazy = async () => {\n const { createPackageDefinitions } = await import('@ms-cloudpack/config');\n return createPackageDefinitions({ config: this.options.config });\n };\n this.#packages = createPackageDefinitionsLazy();\n }\n\n return this.#packages;\n }\n\n public get packageHashes(): Promise<PackageHashesCache> {\n if (!this.#packageHashes) {\n const createPackageHashesLazy = async () => {\n const { PackageHashes } = await import('@ms-cloudpack/package-hashes');\n return new PackageHashes({\n cwd: this.options.appPath,\n context: {\n config: this.options.config,\n packages: await this.packages,\n resolveMap: (await this.session).resolveMap,\n },\n });\n };\n this.#packageHashes = createPackageHashesLazy();\n }\n\n return this.#packageHashes;\n }\n\n public get taskRunner(): Promise<TaskRunner> {\n if (!this.#taskRunner) {\n const createTaskRunnerLazy = async () => {\n const { TaskRunner } = await import('../utilities/TaskRunner.js');\n return new TaskRunner({\n bus: await this.bus,\n reporter: await this.reporter,\n session: await this.session,\n });\n };\n this.#taskRunner = createTaskRunnerLazy();\n }\n return this.#taskRunner;\n }\n\n public get session(): Promise<Session> {\n if (!this.#session) {\n const createSessionLazy = async () => {\n const { createSession } = await import('./createSession.js');\n return createSession(this.options, {\n reporter: await this.reporter,\n packages: await this.packages,\n telemetryClient: await this.telemetryClient,\n });\n };\n this.#session = createSessionLazy();\n }\n\n return this.#session;\n }\n\n public get packageImportPaths(): Promise<PackageImportPaths> {\n if (!this.#packageImportPaths) {\n this.#packageImportPaths = Promise.resolve(new Map<string, string[]>());\n }\n return this.#packageImportPaths;\n }\n\n public get remoteCacheClient(): Promise<RemoteCacheClient | undefined> {\n if (!this.#remoteCacheClient) {\n const createRemoteCacheClientLazy = async () => {\n if (!this.options.remoteCacheClientLoginMethod) {\n throw new Error('remoteCacheClientLoginMethod is required to create api context with remote cache');\n }\n\n return createRemoteCacheClient({\n ctx: {\n session: await this.session,\n reporter: await this.reporter,\n telemetryClient: await this.telemetryClient,\n },\n input: {\n loginMethod: this.options.remoteCacheClientLoginMethod,\n },\n });\n };\n this.#remoteCacheClient = createRemoteCacheClientLazy();\n }\n return this.#remoteCacheClient;\n }\n\n public async dispose(): Promise<void> {\n if (this.#watcher) {\n const watcher = await this.#watcher;\n await watcher.dispose();\n }\n }\n}\n\nexport async function createPartialApiContext<\n TKeys extends Exclude<keyof Context, 'dispose'>,\n TReturn extends Pick<Context, TKeys | 'dispose' | 'reporter' | 'telemetryClient'>,\n>(options: LazyApiContextOptions & { items: (false | undefined | null | TKeys)[] }): Promise<TReturn> {\n const { reporter, telemetryClient, items } = options;\n return telemetryClient.tracer.startActiveSpan('CREATE_PARTIAL_API_CONTEXT', async (span) => {\n const lazyContext = new LazyApiContext(options);\n\n const result = {\n reporter,\n telemetryClient,\n dispose: () => {\n return lazyContext.dispose();\n },\n } as TReturn;\n\n for (const item of items) {\n if (item) {\n result[item] = (await lazyContext[item]) as TReturn[TKeys];\n }\n }\n\n span.setAttributes({\n items: items.filter((item) => !!item).join(','),\n });\n\n return result;\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"createPartialApiContext.js","sourceRoot":"","sources":["../../src/common/createPartialApiContext.ts"],"names":[],"mappings":";;;;;;;;;;;;AASA,OAAO,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAclF,MAAM,cAAc;IASlB,YAA6B,OAA8B;QAA9B,YAAO,GAAP,OAAO,CAAuB;QAR3D,sCAAmC;QACnC,0CAAuC;QACvC,2CAAwD;QACxD,6CAA6C;QAC7C,0CAAuC;QACvC,gDAAwD;QACxD,oDAAuE;QAGrE,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;QAC/B,IAAI,UAAU,EAAE,CAAC;YACf,uBAAA,IAAI,8BAAe,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,MAAA,CAAC;QACjD,CAAC;IACH,CAAC;IAED,IAAW,eAAe;QACxB,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;IACvD,CAAC;IAED,IAAW,GAAG;QACZ,IAAI,CAAC,uBAAA,IAAI,2BAAK,EAAE,CAAC;YACf,MAAM,iBAAiB,GAAG,KAAK,IAAI,EAAE;gBACnC,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,MAAM,CAAC,wBAAwB,CAAC,CAAC;gBACjE,OAAO,aAAa,EAAE,CAAC;YACzB,CAAC,CAAC;YACF,uBAAA,IA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,EAAE,eAAe,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;IACrD,OAAO,eAAe,CAAC,MAAM,CAAC,eAAe,CAAC,4BAA4B,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QACzF,MAAM,WAAW,GAAG,IAAI,cAAc,CAAC,OAAO,CAAC,CAAC;QAEhD,MAAM,MAAM,GAAG;YACb,QAAQ;YACR,eAAe;YACf,OAAO,EAAE,GAAG,EAAE;gBACZ,OAAO,WAAW,CAAC,OAAO,EAAE,CAAC;YAC/B,CAAC;SACS,CAAC;QAEb,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,IAAI,IAAI,EAAE,CAAC;gBACT,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,WAAW,CAAC,IAAI,CAAC,CAAmB,CAAC;YAC7D,CAAC;QACH,CAAC;QAED,IAAI,CAAC,aAAa,CAAC;YACjB,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;SAChD,CAAC,CAAC;QAEH,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC,CAAC;AACL,CAAC","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 { Context } from '../types/Context.js';\nimport type { TaskRunner } from '../utilities/TaskRunner.js';\nimport type { CreateSessionOptions } from './createSession.js';\nimport type { LoginMethod, RemoteCacheClient } from '@ms-cloudpack/remote-cache';\nimport { createRemoteCacheClient } from '../utilities/createRemoteCacheClient.js';\n\ntype PromisifyProperties<T> = {\n [K in keyof T]: T[K] extends (...args: unknown[]) => unknown ? T[K] : Promise<T[K]>;\n};\n\nexport interface LazyApiContextOptions extends CreateSessionOptions {\n reporter: TaskReporter;\n appPath: string;\n telemetryClient: TelemetryClient;\n taskRunner?: TaskRunner;\n remoteCacheClientLoginMethod?: LoginMethod;\n}\n\nclass LazyApiContext implements PromisifyProperties<Context> {\n #bus: Promise<DataBus> | undefined;\n #watcher: Promise<Watcher> | undefined;\n #packages: Promise<PackageDefinitionsCache> | undefined;\n #taskRunner: Promise<TaskRunner> | undefined;\n #session: Promise<Session> | undefined;\n #packageHashes: Promise<PackageHashesCache> | undefined;\n #remoteCacheClient: Promise<RemoteCacheClient | undefined> | undefined;\n\n constructor(private readonly options: LazyApiContextOptions) {\n const { taskRunner } = options;\n if (taskRunner) {\n this.#taskRunner = Promise.resolve(taskRunner);\n }\n }\n\n public get telemetryClient(): Promise<TelemetryClient> {\n return Promise.resolve(this.options.telemetryClient);\n }\n\n public get bus(): Promise<DataBus> {\n if (!this.#bus) {\n const createDataBusLazy = async () => {\n const { createDataBus } = await import('@ms-cloudpack/data-bus');\n return createDataBus();\n };\n this.#bus = createDataBusLazy();\n }\n\n return this.#bus;\n }\n\n public get watcher(): Promise<Watcher> {\n if (!this.#watcher) {\n const createWatcherLazy = async () => {\n const { createWatcher } = await import('@ms-cloudpack/file-watcher');\n return createWatcher({\n type: this.options?.config?.features?.enableWatcherInFork ? 'fork' : 'default',\n });\n };\n this.#watcher = createWatcherLazy();\n }\n\n return this.#watcher;\n }\n\n public get reporter(): Promise<TaskReporter> {\n return Promise.resolve(this.options.reporter);\n }\n\n public get packages(): Promise<PackageDefinitionsCache> {\n if (!this.#packages) {\n const createPackageDefinitionsLazy = async () => {\n const { createPackageDefinitions } = await import('@ms-cloudpack/config');\n return createPackageDefinitions({ config: this.options.config });\n };\n this.#packages = createPackageDefinitionsLazy();\n }\n\n return this.#packages;\n }\n\n public get packageHashes(): Promise<PackageHashesCache> {\n if (!this.#packageHashes) {\n const createPackageHashesLazy = async () => {\n const { PackageHashes } = await import('@ms-cloudpack/package-hashes');\n return new PackageHashes({\n cwd: this.options.appPath,\n context: {\n config: this.options.config,\n packages: await this.packages,\n resolveMap: (await this.session).resolveMap,\n },\n });\n };\n this.#packageHashes = createPackageHashesLazy();\n }\n\n return this.#packageHashes;\n }\n\n public get taskRunner(): Promise<TaskRunner> {\n if (!this.#taskRunner) {\n const createTaskRunnerLazy = async () => {\n const { TaskRunner } = await import('../utilities/TaskRunner.js');\n return new TaskRunner({\n bus: await this.bus,\n reporter: await this.reporter,\n session: await this.session,\n });\n };\n this.#taskRunner = createTaskRunnerLazy();\n }\n return this.#taskRunner;\n }\n\n public get session(): Promise<Session> {\n if (!this.#session) {\n const createSessionLazy = async () => {\n const { createSession } = await import('./createSession.js');\n return createSession(this.options, {\n reporter: await this.reporter,\n packages: await this.packages,\n telemetryClient: await this.telemetryClient,\n });\n };\n this.#session = createSessionLazy();\n }\n\n return this.#session;\n }\n\n public get remoteCacheClient(): Promise<RemoteCacheClient | undefined> {\n if (!this.#remoteCacheClient) {\n const createRemoteCacheClientLazy = async () => {\n if (!this.options.remoteCacheClientLoginMethod) {\n throw new Error('remoteCacheClientLoginMethod is required to create api context with remote cache');\n }\n\n return createRemoteCacheClient({\n ctx: {\n session: await this.session,\n reporter: await this.reporter,\n telemetryClient: await this.telemetryClient,\n },\n input: {\n loginMethod: this.options.remoteCacheClientLoginMethod,\n },\n });\n };\n this.#remoteCacheClient = createRemoteCacheClientLazy();\n }\n return this.#remoteCacheClient;\n }\n\n public async dispose(): Promise<void> {\n if (this.#watcher) {\n const watcher = await this.#watcher;\n await watcher.dispose();\n }\n }\n}\n\nexport async function createPartialApiContext<\n TKeys extends Exclude<keyof Context, 'dispose'>,\n TReturn extends Pick<Context, TKeys | 'dispose' | 'reporter' | 'telemetryClient'>,\n>(options: LazyApiContextOptions & { items: (false | undefined | null | TKeys)[] }): Promise<TReturn> {\n const { reporter, telemetryClient, items } = options;\n return telemetryClient.tracer.startActiveSpan('CREATE_PARTIAL_API_CONTEXT', async (span) => {\n const lazyContext = new LazyApiContext(options);\n\n const result = {\n reporter,\n telemetryClient,\n dispose: () => {\n return lazyContext.dispose();\n },\n } as TReturn;\n\n for (const item of items) {\n if (item) {\n result[item] = (await lazyContext[item]) as TReturn[TKeys];\n }\n }\n\n span.setAttributes({\n items: items.filter((item) => !!item).join(','),\n });\n\n return result;\n });\n}\n"]}
|
|
@@ -5,7 +5,14 @@ export type SessionVersions = {
|
|
|
5
5
|
targetVersions: Record<string, number>;
|
|
6
6
|
};
|
|
7
7
|
export interface CreateSessionOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Path to the `@ms-cloudpack/overlay` package root directory.
|
|
10
|
+
*/
|
|
8
11
|
overlayPath?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Custom cache folder for the session.
|
|
14
|
+
* If not provided, will use the one from user preferences if set, or the default cache path.
|
|
15
|
+
*/
|
|
9
16
|
cachePath?: string;
|
|
10
17
|
config: CloudpackConfig;
|
|
11
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSession.d.ts","sourceRoot":"","sources":["../../src/common/createSession.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,OAAO,EAAc,MAAM,4BAA4B,CAAC;AAMvF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAInD,MAAM,MAAM,eAAe,GAAG;IAC5B,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACxC,CAAC;AAEF,MAAM,WAAW,oBAAoB;IACnC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,eAAe,CAAC;CACzB;AAED,wBAAsB,aAAa,CACjC,OAAO,EAAE,oBAAoB,EAC7B,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,UAAU,GAAG,UAAU,GAAG,iBAAiB,CAAC,GAClE,OAAO,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"createSession.d.ts","sourceRoot":"","sources":["../../src/common/createSession.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,OAAO,EAAc,MAAM,4BAA4B,CAAC;AAMvF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAInD,MAAM,MAAM,eAAe,GAAG;IAC5B,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACxC,CAAC;AAEF,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,eAAe,CAAC;CACzB;AAED,wBAAsB,aAAa,CACjC,OAAO,EAAE,oBAAoB,EAC7B,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,UAAU,GAAG,UAAU,GAAG,iBAAiB,CAAC,GAClE,OAAO,CAAC,OAAO,CAAC,CAyGlB;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE/D"}
|
|
@@ -61,6 +61,7 @@ export async function createSession(options, context) {
|
|
|
61
61
|
set importMap(newImportMap) {
|
|
62
62
|
importMap = newImportMap;
|
|
63
63
|
},
|
|
64
|
+
packageImportPaths: new Map(),
|
|
64
65
|
linkedPaths,
|
|
65
66
|
addLinkedPath: async (linkedPath) => {
|
|
66
67
|
if (linkedPaths.find((p) => p.path === linkedPath.path)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSession.js","sourceRoot":"","sources":["../../src/common/createSession.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEvE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,aAAa,EAAE,MA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AC;YAEF,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC;QACrC,CAAC;QACD,SAAS;KACV,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CAAC,OAAe;IACrD,OAAO,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,EAAE,sBAAsB,CAAC,CAAC;AACvE,CAAC","sourcesContent":["import type { CloudpackConfig, Session, LinkedPath } from '@ms-cloudpack/common-types';\nimport { getCachePath, getLocalCachePath } from '@ms-cloudpack/config';\nimport type { ImportMap } from '@ms-cloudpack/import-map';\nimport { readJson, writeJson, writeJsonSync } from '@ms-cloudpack/json-utilities';\nimport fs from 'fs';\nimport path from 'path';\nimport type { Context } from '../types/Context.js';\nimport { resolveDependenciesTask } from '../utilities/resolveDependenciesTask.js';\nimport { randomUUID } from 'crypto';\n\nexport type SessionVersions = {\n sessionVersion: number;\n targetVersions: Record<string, number>;\n};\n\nexport interface CreateSessionOptions {\n /**\n * Path to the `@ms-cloudpack/overlay` package root directory.\n */\n overlayPath?: string;\n /**\n * Custom cache folder for the session.\n * If not provided, will use the one from user preferences if set, or the default cache path.\n */\n cachePath?: string;\n config: CloudpackConfig;\n}\n\nexport async function createSession(\n options: CreateSessionOptions,\n context: Pick<Context, 'reporter' | 'packages' | 'telemetryClient'>,\n): Promise<Session> {\n const { config, overlayPath } = options;\n const { appPath } = config;\n\n const projectName = path.basename(appPath);\n const id = randomUUID();\n let resolveMap = await resolveDependenciesTask(\n {\n appPath,\n additionalPaths: overlayPath ? [overlayPath] : [],\n },\n context,\n );\n\n let importMap: ImportMap | undefined = undefined;\n\n const versionsPath = _getSessionVersionsPath(appPath);\n const previousVersions = await readJson<SessionVersions>(versionsPath);\n const versions = previousVersions || { sessionVersion: 0, targetVersions: {} };\n if (!previousVersions) {\n await writeJson(versionsPath, versions);\n }\n\n // In the future, we might put all the user preferences in the session, but right now the only\n // preference is cachePath, so we just read that and save the custom or default value.\n const cachePath = await getCachePath(options.cachePath);\n\n const linkedPaths: LinkedPath[] = [];\n\n return {\n id,\n config,\n projectName,\n get resolveMap() {\n return resolveMap;\n },\n set resolveMap(newResolveMap) {\n // If the resolve map changes, clear the import map\n // so that it is regenerated on the next request\n importMap = undefined;\n resolveMap = newResolveMap;\n },\n sequence: 0,\n urls: {},\n targetVersions: versions.targetVersions,\n get sessionVersion() {\n return versions.sessionVersion;\n },\n incrementSessionVersion: () => {\n versions.sessionVersion++;\n importMap = undefined;\n // Write the new session version to the file\n fs.writeFileSync(versionsPath, JSON.stringify(versions, null, 2));\n },\n incrementTargetVersion: (inputPath: string) => {\n versions.targetVersions[inputPath] ??= 0;\n versions.targetVersions[inputPath]++;\n importMap = undefined;\n writeJsonSync(versionsPath, versions);\n },\n get importMap() {\n return importMap;\n },\n set importMap(newImportMap) {\n importMap = newImportMap;\n },\n packageImportPaths: new Map(),\n linkedPaths,\n addLinkedPath: async (linkedPath: LinkedPath) => {\n if (linkedPaths.find((p) => p.path === linkedPath.path)) {\n return { resolveMap: resolveMap, linkedPaths: linkedPaths };\n }\n\n linkedPaths.push(linkedPath);\n resolveMap = await resolveDependenciesTask(\n {\n appPath,\n additionalPaths: overlayPath ? [overlayPath] : [],\n linkedPaths,\n },\n context,\n );\n\n return { resolveMap, linkedPaths };\n },\n removeLinkedPath: async (linkedPath: LinkedPath) => {\n const index = linkedPaths.findIndex((p) => p.path === linkedPath.path);\n if (index === -1) {\n return { resolveMap: resolveMap, linkedPaths: linkedPaths };\n }\n\n linkedPaths.splice(index, 1);\n resolveMap = await resolveDependenciesTask(\n {\n appPath,\n additionalPaths: overlayPath ? [overlayPath] : [],\n linkedPaths,\n },\n context,\n );\n\n return { resolveMap, linkedPaths };\n },\n cachePath,\n };\n}\n\n/**\n * Get `sessionVersions.json` path. Exported for the test.\n * @internal\n */\nexport function _getSessionVersionsPath(appPath: string): string {\n return path.join(getLocalCachePath(appPath), 'sessionVersions.json');\n}\n"]}
|
package/lib/trpc/common.d.ts
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
|
+
import type { Context } from '../types/Context.js';
|
|
2
|
+
export type CreateContext = () => Promise<Context>;
|
|
1
3
|
/** Reusable TRPC router helper. */
|
|
2
4
|
export declare const createRouter: {
|
|
3
5
|
<TInput extends import("@trpc/server").RouterRecord>(input: TInput): import("@trpc/server/unstable-core-do-not-import").BuiltRouter<{
|
|
4
|
-
ctx:
|
|
6
|
+
ctx: Context;
|
|
5
7
|
meta: object;
|
|
6
8
|
errorShape: import("@trpc/server/unstable-core-do-not-import").DefaultErrorShape;
|
|
7
9
|
transformer: false;
|
|
8
10
|
}, TInput>;
|
|
9
11
|
<TInput extends import("@trpc/server/unstable-core-do-not-import").CreateRouterOptions>(input: TInput): import("@trpc/server/unstable-core-do-not-import").BuiltRouter<{
|
|
10
|
-
ctx:
|
|
12
|
+
ctx: Context;
|
|
11
13
|
meta: object;
|
|
12
14
|
errorShape: import("@trpc/server/unstable-core-do-not-import").DefaultErrorShape;
|
|
13
15
|
transformer: false;
|
|
14
16
|
}, import("@trpc/server/unstable-core-do-not-import").DecorateCreateRouterOptions<TInput>>;
|
|
15
17
|
};
|
|
16
18
|
/** Reusable TRPC procedure helper. */
|
|
17
|
-
export declare const publicProcedure: import("@trpc/server/unstable-core-do-not-import").ProcedureBuilder<
|
|
19
|
+
export declare const publicProcedure: import("@trpc/server/unstable-core-do-not-import").ProcedureBuilder<Context, object, object, typeof import("@trpc/server/unstable-core-do-not-import").unsetMarker, typeof import("@trpc/server/unstable-core-do-not-import").unsetMarker, typeof import("@trpc/server/unstable-core-do-not-import").unsetMarker, typeof import("@trpc/server/unstable-core-do-not-import").unsetMarker, false>;
|
|
18
20
|
//# sourceMappingURL=common.d.ts.map
|
package/lib/trpc/common.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/trpc/common.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/trpc/common.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAEnD,MAAM,MAAM,aAAa,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;AAKnD,mCAAmC;AACnC,eAAO,MAAM,YAAY;2BAI46E,cAAU;;;;;;2BAAoa,0CAAU;;;;;;CAJz1F,CAAC;AAErC,sCAAsC;AACtC,eAAO,MAAM,eAAe,iYAAc,CAAC"}
|
package/lib/trpc/common.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/trpc/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/trpc/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAKxC,wEAAwE;AACxE,MAAM,CAAC,GAAG,QAAQ,CAAC,OAAO,EAAiB,CAAC,MAAM,EAAE,CAAC;AAErD,mCAAmC;AACnC,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC;AAErC,sCAAsC;AACtC,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,SAAS,CAAC","sourcesContent":["import { initTRPC } from '@trpc/server';\nimport type { Context } from '../types/Context.js';\n\nexport type CreateContext = () => Promise<Context>;\n\n// Initialization of tRPC backend. Should be done only once per backend!\nconst t = initTRPC.context<CreateContext>().create();\n\n/** Reusable TRPC router helper. */\nexport const createRouter = t.router;\n\n/** Reusable TRPC procedure helper. */\nexport const publicProcedure = t.procedure;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createCloudpackServer.d.ts","sourceRoot":"","sources":["../../src/trpc/createCloudpackServer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createCloudpackServer.d.ts","sourceRoot":"","sources":["../../src/trpc/createCloudpackServer.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAKnD,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5B;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE;IACP,gDAAgD;IAChD,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC1B,EACD,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,eAAe,CAAC,CAgD1B"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { applyWSSHandler } from '@trpc/server/adapters/ws';
|
|
2
2
|
import getPort from 'get-port';
|
|
3
3
|
import { WebSocketServer } from 'ws';
|
|
4
|
-
import { createContextFactory } from './createContextFactory.js';
|
|
5
4
|
import { createHTTPServer } from './httpAdapter.js';
|
|
6
5
|
import cors from 'cors';
|
|
7
6
|
import { getDomain } from '@ms-cloudpack/create-express-app';
|
|
@@ -16,7 +15,7 @@ export async function createCloudpackServer(options, context) {
|
|
|
16
15
|
if (portArg && !portArg.includes(port)) {
|
|
17
16
|
throw new Error(`No ports from range ${JSON.stringify(portArg)} are available`);
|
|
18
17
|
}
|
|
19
|
-
const createContext =
|
|
18
|
+
const createContext = () => Promise.resolve(context);
|
|
20
19
|
const hostname = getDomain(context.session.config?.server?.domain);
|
|
21
20
|
const https = context.session.config?.server?.https;
|
|
22
21
|
const procedures = Object.fromEntries(Object.entries(apis).map(([name, api]) => [name, api.procedure]));
|
|
@@ -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,O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E;YAChB,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;gBAC1C,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,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","sourcesContent":["import { applyWSSHandler } from '@trpc/server/adapters/ws';\nimport getPort from 'get-port';\nimport { WebSocketServer } from 'ws';\nimport { createHTTPServer } from './httpAdapter.js';\nimport cors from 'cors';\nimport { getDomain } from '@ms-cloudpack/create-express-app';\nimport type { Context } from '../types/Context.js';\nimport * as apis from '../apis/index.js';\nimport { createRouter } from './common.js';\nimport type { AppRouter } from '../types/AppRouter.js';\n\nexport interface CloudpackServer {\n url: string;\n close: () => Promise<void>;\n}\n\n/**\n * Creates a cloudpack server that can be used to communicate with the cloudpack client using trpc.\n */\nexport async function createCloudpackServer(\n options: {\n /** Custom port(s) to try for the API server. */\n port?: number | number[];\n },\n context: Context,\n): Promise<CloudpackServer> {\n const portArg = Array.isArray(options.port) ? options.port : options.port ? [options.port] : undefined;\n const port = await getPort({ port: portArg || [9890, 9891, 9892, 9893] });\n if (portArg && !portArg.includes(port)) {\n throw new Error(`No ports from range ${JSON.stringify(portArg)} are available`);\n }\n\n const createContext = () => Promise.resolve(context);\n const hostname = getDomain(context.session.config?.server?.domain);\n const https = context.session.config?.server?.https;\n\n const procedures = Object.fromEntries(Object.entries(apis).map(([name, api]) => [name, api.procedure]));\n // AppRouter is the correct type, but doesn't get inferred correctly after Object.entries\n const router = createRouter(procedures) as unknown as AppRouter;\n\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 webSocketProtocol = https ? 'wss' : 'ws';\n const url = `${webSocketProtocol}://${hostname}:${port}`;\n context.session.urls.apiServer = url;\n\n return {\n url,\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"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BundleMode, BundleResult } from '@ms-cloudpack/common-types';
|
|
1
|
+
import type { BundleMode, BundleResult, TargetEnvironment } from '@ms-cloudpack/common-types';
|
|
2
2
|
import type { BundleInfo } from './BundleInfo.js';
|
|
3
3
|
/**
|
|
4
4
|
* Tracks a given bundle request and its result.
|
|
@@ -20,6 +20,8 @@ export interface BundleRequest {
|
|
|
20
20
|
isIncremental?: boolean;
|
|
21
21
|
/** Bundle mode */
|
|
22
22
|
mode: BundleMode;
|
|
23
|
+
/** Target environment for the bundle. */
|
|
24
|
+
targetEnvironment: TargetEnvironment;
|
|
23
25
|
/** Result of bundling */
|
|
24
26
|
result?: Omit<BundleResult, 'inputPath'> & {
|
|
25
27
|
/** Input path. Will be unset if the package couldn't be found or had an unhandled error. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BundleRequest.d.ts","sourceRoot":"","sources":["../../src/types/BundleRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"BundleRequest.d.ts","sourceRoot":"","sources":["../../src/types/BundleRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC9F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,0FAA0F;IAC1F,EAAE,EAAE,MAAM,CAAC;IAEX,iCAAiC;IACjC,WAAW,EAAE,MAAM,CAAC;IAEpB,oCAAoC;IACpC,OAAO,EAAE,MAAM,CAAC;IAEhB,mCAAmC;IACnC,WAAW,EAAE,MAAM,CAAC;IAEpB,0CAA0C;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,4DAA4D;IAC5D,UAAU,EAAE,OAAO,CAAC;IAEpB,oDAAoD;IACpD,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB,kBAAkB;IAClB,IAAI,EAAE,UAAU,CAAC;IAEjB,yCAAyC;IACzC,iBAAiB,EAAE,iBAAiB,CAAC;IAErC,yBAAyB;IACzB,MAAM,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE,WAAW,CAAC,GAAG;QACzC,4FAA4F;QAC5F,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,IAAI,CAAC,EAAE,UAAU,CAAC;QAClB,YAAY,CAAC,EAAE,cAAc,GAAG,aAAa,GAAG,SAAS,CAAC;KAC3D,CAAC;IAEF,2EAA2E;IAE3E,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B,qCAAqC;IACrC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAE5B,+DAA+D;IAC/D,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B,iCAAiC;IACjC,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BundleRequest.js","sourceRoot":"","sources":["../../src/types/BundleRequest.ts"],"names":[],"mappings":"","sourcesContent":["import type { BundleMode, BundleResult } from '@ms-cloudpack/common-types';\nimport type { BundleInfo } from './BundleInfo.js';\n\n/**\n * Tracks a given bundle request and its result.\n */\nexport interface BundleRequest {\n /** ID for the bundle. This will usually be the package path, or occasionally the hash. */\n id: string;\n /** Package name being bundled */\n packageName: string;\n /** Package version being bundled */\n version: string;\n /** Absolute path to the package */\n packagePath: string;\n /** Absolute path for the bundle output */\n outputPath?: string;\n /** Whether this is an external package (in node_modules) */\n isExternal: boolean;\n /** Whether we should force the incremental flag. */\n isIncremental?: boolean;\n /** Bundle mode */\n mode: BundleMode;\n /** Result of bundling */\n result?: Omit<BundleResult, 'inputPath'> & {\n /** Input path. Will be unset if the package couldn't be found or had an unhandled error. */\n inputPath?: string;\n hash?: string;\n info?: BundleInfo;\n bundleSource?: 'remote-cache' | 'local-cache' | 'bundler';\n };\n /** Whether the result was retrieved from the cache (set while bundling) */\n // TODO: this seems like it should be a property of the result?\n resultFromCache?: boolean;\n /** Whether to disable source maps */\n disableSourceMaps?: boolean;\n /** Whether to scan the bundled code for imports and exports */\n shouldGetBundleInfo?: boolean;\n /** Whether to disable caching */\n disableCache?: boolean;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"BundleRequest.js","sourceRoot":"","sources":["../../src/types/BundleRequest.ts"],"names":[],"mappings":"","sourcesContent":["import type { BundleMode, BundleResult, TargetEnvironment } from '@ms-cloudpack/common-types';\nimport type { BundleInfo } from './BundleInfo.js';\n\n/**\n * Tracks a given bundle request and its result.\n */\nexport interface BundleRequest {\n /** ID for the bundle. This will usually be the package path, or occasionally the hash. */\n id: string;\n\n /** Package name being bundled */\n packageName: string;\n\n /** Package version being bundled */\n version: string;\n\n /** Absolute path to the package */\n packagePath: string;\n\n /** Absolute path for the bundle output */\n outputPath?: string;\n\n /** Whether this is an external package (in node_modules) */\n isExternal: boolean;\n\n /** Whether we should force the incremental flag. */\n isIncremental?: boolean;\n\n /** Bundle mode */\n mode: BundleMode;\n\n /** Target environment for the bundle. */\n targetEnvironment: TargetEnvironment;\n\n /** Result of bundling */\n result?: Omit<BundleResult, 'inputPath'> & {\n /** Input path. Will be unset if the package couldn't be found or had an unhandled error. */\n inputPath?: string;\n hash?: string;\n info?: BundleInfo;\n bundleSource?: 'remote-cache' | 'local-cache' | 'bundler';\n };\n\n /** Whether the result was retrieved from the cache (set while bundling) */\n // TODO: this seems like it should be a property of the result?\n resultFromCache?: boolean;\n\n /** Whether to disable source maps */\n disableSourceMaps?: boolean;\n\n /** Whether to scan the bundled code for imports and exports */\n shouldGetBundleInfo?: boolean;\n\n /** Whether to disable caching */\n disableCache?: boolean;\n}\n"]}
|
package/lib/types/Context.d.ts
CHANGED
|
@@ -4,18 +4,17 @@ import type { Watcher } from '@ms-cloudpack/file-watcher';
|
|
|
4
4
|
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
|
-
import type { PackageImportPaths } from '@ms-cloudpack/import-map';
|
|
8
7
|
import type { RemoteCacheClient } from '@ms-cloudpack/remote-cache';
|
|
9
8
|
/** Context for Cloudpack API server procedures. */
|
|
10
9
|
export interface Context {
|
|
11
10
|
session: Session;
|
|
11
|
+
/** Data bus for sending notifications to the client. */
|
|
12
12
|
bus: DataBus;
|
|
13
13
|
telemetryClient: TelemetryClient;
|
|
14
14
|
reporter: TaskReporter;
|
|
15
15
|
watcher: Watcher;
|
|
16
16
|
packages: PackageDefinitionsCache;
|
|
17
17
|
taskRunner: TaskRunner;
|
|
18
|
-
packageImportPaths: PackageImportPaths;
|
|
19
18
|
packageHashes: PackageHashesCache;
|
|
20
19
|
remoteCacheClient?: RemoteCacheClient;
|
|
21
20
|
dispose(): void | Promise<void>;
|
|
@@ -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;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ED;;;;GAIG;AACH,MAAM,MAAM,cAAc,CACxB,YAAY,SAAS,MAAM,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,EACnD,YAAY,SAAS,MAAM,OAAO,IAChC,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,GAAG;IAChC,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 {
|
|
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/** Context for Cloudpack API server procedures. */\nexport interface Context {\n session: Session;\n /** Data bus for sending notifications to the client. */\n bus: DataBus;\n telemetryClient: TelemetryClient;\n reporter: TaskReporter;\n watcher: Watcher;\n packages: PackageDefinitionsCache;\n taskRunner: TaskRunner;\n packageHashes: PackageHashesCache;\n remoteCacheClient?: RemoteCacheClient;\n // This typically returns a promise. Allow a non-promise for convenience for tests.\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<\n TContextKeys extends keyof Omit<Context, 'session'>,\n TSessionKeys extends keyof Session,\n> = Pick<Context, TContextKeys> & {\n session: Pick<Session, TSessionKeys>;\n};\n"]}
|
package/lib/types/Task.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { TaskStartDescription } from './TaskStartDescription.js';
|
|
2
2
|
import type { TaskEndDescription } from './TaskEndDescription.js';
|
|
3
3
|
import type { TaskMessage } from './TaskMessage.js';
|
|
4
|
+
/** Task for `TaskRunner`. */
|
|
4
5
|
export interface Task<TReturn> {
|
|
5
6
|
name: string;
|
|
6
7
|
id: string;
|
package/lib/types/Task.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Task.d.ts","sourceRoot":"","sources":["../../src/types/Task.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,MAAM,WAAW,IAAI,CAAC,OAAO;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,CAAC;IAC5C,KAAK,CAAC,EAAE,MAAM,IAAI,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,WAAW,EAAE,GAAG,SAAS,CAAC;IAC5C,mBAAmB,CAAC,EAAE,MAAM,oBAAoB,CAAC;IACjD,iBAAiB,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,GAAG,SAAS,KAAK,kBAAkB,CAAC;CACzE"}
|
|
1
|
+
{"version":3,"file":"Task.d.ts","sourceRoot":"","sources":["../../src/types/Task.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,6BAA6B;AAC7B,MAAM,WAAW,IAAI,CAAC,OAAO;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,CAAC;IAC5C,KAAK,CAAC,EAAE,MAAM,IAAI,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,WAAW,EAAE,GAAG,SAAS,CAAC;IAC5C,mBAAmB,CAAC,EAAE,MAAM,oBAAoB,CAAC;IACjD,iBAAiB,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,GAAG,SAAS,KAAK,kBAAkB,CAAC;CACzE"}
|
package/lib/types/Task.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Task.js","sourceRoot":"","sources":["../../src/types/Task.ts"],"names":[],"mappings":"","sourcesContent":["import type { TaskStartDescription } from './TaskStartDescription.js';\nimport type { TaskEndDescription } from './TaskEndDescription.js';\nimport type { TaskMessage } from './TaskMessage.js';\n\nexport interface Task<TReturn> {\n name: string;\n id: string;\n dir?: string;\n execute: () => Promise<TReturn | undefined>;\n clear?: () => void;\n watch?: boolean;\n dispose?: () => Promise<void>;\n onDispose?: () => void;\n getErrors?: () => TaskMessage[] | undefined;\n getStartDescription?: () => TaskStartDescription;\n getEndDescription?: (result: TReturn | undefined) => TaskEndDescription;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Task.js","sourceRoot":"","sources":["../../src/types/Task.ts"],"names":[],"mappings":"","sourcesContent":["import type { TaskStartDescription } from './TaskStartDescription.js';\nimport type { TaskEndDescription } from './TaskEndDescription.js';\nimport type { TaskMessage } from './TaskMessage.js';\n\n/** Task for `TaskRunner`. */\nexport interface Task<TReturn> {\n name: string;\n id: string;\n dir?: string;\n execute: () => Promise<TReturn | undefined>;\n clear?: () => void;\n watch?: boolean;\n dispose?: () => Promise<void>;\n onDispose?: () => void;\n getErrors?: () => TaskMessage[] | undefined;\n getStartDescription?: () => TaskStartDescription;\n getEndDescription?: (result: TReturn | undefined) => TaskEndDescription;\n}\n"]}
|
|
@@ -54,7 +54,7 @@ export async function bundleTask(options, context) {
|
|
|
54
54
|
*/
|
|
55
55
|
async function bundleTaskInternal(options, context) {
|
|
56
56
|
const { bundleRequest, force, hash, sourceHash } = options;
|
|
57
|
-
const { packageName, version } = bundleRequest;
|
|
57
|
+
const { packageName, version, targetEnvironment } = bundleRequest;
|
|
58
58
|
const { packageHashes, packages, session } = context;
|
|
59
59
|
const { config } = session;
|
|
60
60
|
const { mode } = config;
|
|
@@ -94,12 +94,13 @@ async function bundleTaskInternal(options, context) {
|
|
|
94
94
|
const bundleOptions = {
|
|
95
95
|
bundler,
|
|
96
96
|
minify: mode === 'production',
|
|
97
|
+
targetEnvironment,
|
|
97
98
|
bundlerOptions,
|
|
98
99
|
inputPath: packagePath,
|
|
99
100
|
outputPath,
|
|
100
101
|
incremental: isIncremental !== undefined ? isIncremental : false,
|
|
101
102
|
sourcemap: !disableSourceMaps,
|
|
102
|
-
entries: await getEntriesMapFromPackage({ inputPath: packagePath }, { packages, config }),
|
|
103
|
+
entries: await getEntriesMapFromPackage({ inputPath: packagePath, targetEnvironment }, { packages, config }),
|
|
103
104
|
inlined: inlinedDependencies,
|
|
104
105
|
external: await getExternalsFromPackage({ inputPath: packagePath }, { packages }),
|
|
105
106
|
dynamicImports,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundleTask.js","sourceRoot":"","sources":["../../src/utilities/bundleTask.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAElG,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAEnE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAsB7E;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,OAA0B,EAAE,OAA0B;IACrF,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC;IAClC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,aAAa,CAAC;IAC/C,MAAM,EAAE,QAAQ,EAAE,eAAe,EAAE,OAAO,EA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BAAmB,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,IAAI,aAAa,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC;QAC9G,+EAA+E;QAC/E,iFAAiF;QACjF,2EAA2E;QAC3E,8CAA8C;QAC9C,MAAM,UAAU,GAAG,MAAM,aAAa,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;QAE9E,MAAM,UAAU,GAAG,MAAM,aAAa,CAAC;YACrC,UAAU;YACV,WAAW,EAAE,aAAa,CAAC,MAAM,CAAC,WAAW;YAC7C,UAAU;YACV,UAAU;YACV,WAAW;SACZ,CAAC,CAAC;QAEH,aAAa,CAAC,MAAM,CAAC,IAAI,GAAG,UAAU,CAAC;QAEvC,IAAI,MAAM,CAAC,aAAa,EAAE,CAAC;YACzB,8DAA8D;YAC9D,KAAK,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,kBAAkB,CAAC,EAAE,UAAU,CAAC,CAAC;QACxE,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import { bundle, getEntriesMapFromPackage, getExternalsFromPackage } from '@ms-cloudpack/bundler';\nimport type { BundleOptions } from '@ms-cloudpack/common-types';\nimport { writeJson } from '@ms-cloudpack/json-utilities';\nimport { getExportsMap } from '@ms-cloudpack/package-utilities';\nimport { formatPackageName } from '@ms-cloudpack/task-reporter';\nimport path from 'path';\nimport { prepareOutputPath } from '../common/prepareOutputPath.js';\nimport type { BundleRequest } from '../types/BundleRequest.js';\nimport { getBundleInfo } from './getBundleInfo.js';\nimport { getBundleLocation } from './getBundleLocation.js';\nimport { isCachedResultValid } from './isCachedResultValid.js';\nimport { readResultFromCache } from './readResultFromCache.js';\nimport { saveResultToCache } from './saveResultToCache.js';\nimport { formatBundleTaskResult } from './formatBundleTaskResult.js';\nimport type { PartialContext } from '../types/Context.js';\nimport { writeStubForDensityEntries } from './writeStubForDensityEntries.js';\n\n/**\n * Options for a bundle task.\n */\nexport interface BundleTaskOptions {\n /** Force a bundle to be rerun */\n force?: boolean;\n /** Hash to avoid re-computing */\n hash?: string;\n /** Source hash to avoid recomputing */\n sourceHash?: string;\n /** Retry count for the task */\n retryCount?: number;\n bundleRequest: BundleRequest;\n}\n\nexport type BundleTaskContext = PartialContext<\n 'packages' | 'packageHashes' | 'reporter' | 'telemetryClient' | 'remoteCacheClient',\n 'resolveMap' | 'config' | 'sequence' | 'cachePath'\n>;\n\n/**\n * Create and run a TaskReporter task which calls `bundle()` from `@ms-cloudpack/bundler` and formats the result.\n */\nexport async function bundleTask(options: BundleTaskOptions, context: BundleTaskContext): Promise<void> {\n const { bundleRequest } = options;\n const { packageName, version } = bundleRequest;\n const { reporter, telemetryClient, session } = context;\n const { sequence } = session;\n const { retryCount } = options;\n\n const task = reporter.addTask(\n `Bundle ${formatPackageName({ name: packageName, version })}${retryCount ? ` (retry ${retryCount})` : ''}`,\n );\n\n try {\n await telemetryClient.tracer.startActiveSpan('BUNDLE_TASK', async (span) => {\n await bundleTaskInternal(options, context);\n\n span.setAttributes({\n sequence,\n isCacheHit: !!bundleRequest.resultFromCache,\n isExternal: bundleRequest.isExternal,\n packageName: bundleRequest.packageName,\n packageVersion: bundleRequest.version,\n bundleSource: bundleRequest.result?.bundleSource,\n bundler: bundleRequest.result?.bundler,\n bundlerVersion: bundleRequest.result?.bundlerVersion,\n });\n });\n } catch (err) {\n // If an unexpected error is thrown, add it to the result.\n // This ensures consistent handling of either actual bundler errors or exceptions.\n bundleRequest.result ??= {};\n bundleRequest.result.errors ??= [];\n bundleRequest.result.errors.push({\n text: `Unexpected exception while bundling: ${(err as Error).stack || String(err)}`,\n source: 'bundleTask',\n });\n }\n\n task.complete(formatBundleTaskResult(bundleRequest));\n}\n\n/**\n * Actually read the result from the cache or call `bundle()`.\n * NOTE: The result is returned by mutating `options.bundleRequest.result`.\n */\nasync function bundleTaskInternal(options: BundleTaskOptions, context: BundleTaskContext): Promise<void> {\n const { bundleRequest, force, hash, sourceHash } = options;\n const { packageName, version } = bundleRequest;\n const { packageHashes, packages, session } = context;\n const { config } = session;\n const { mode } = config;\n\n // If force is set, dispose the existing result.\n if (force && bundleRequest.result?.dispose) {\n bundleRequest.result.dispose();\n bundleRequest.result = undefined;\n }\n\n const { packagePath, isExternal, isIncremental, disableSourceMaps, shouldGetBundleInfo } = bundleRequest;\n\n const outputPath =\n bundleRequest.outputPath ??\n (await getBundleLocation({ packagePath, shouldRecalculate: force, hash }, context)).path;\n\n // Rehydrate the result if not incremental.\n if (bundleRequest.result === undefined && !force) {\n bundleRequest.result = await readResultFromCache(\n { packageName, version, inputPath: packagePath, outputPath },\n context,\n );\n }\n\n const cacheValidationHash = !isExternal\n ? sourceHash || (await packageHashes.get({ packagePath, isSourceHashingEnabled: true, shouldRecalculate: true }))\n : undefined;\n\n // if the cached result is valid, use it.\n if (!force && isCachedResultValid({ bundleRequest, hash: cacheValidationHash })) {\n console.debug(`Using cached result for ${bundleRequest.packageName}@${bundleRequest.version}`);\n bundleRequest.resultFromCache = true;\n } else {\n bundleRequest.resultFromCache = false;\n\n // Only use cached result if it's successful.\n await prepareOutputPath(outputPath);\n\n if (bundleRequest.result?.rebuild) {\n bundleRequest.result = {\n ...(await bundleRequest.result.rebuild()),\n outputPath: bundleRequest.result.outputPath,\n hash: cacheValidationHash,\n };\n } else {\n const {\n bundler,\n bundlerOptions,\n inlinedDependencies,\n dynamicImports,\n bundlerCapabilities,\n ignoredBundlerWarnings,\n unsafeCjsExportNames,\n } = (await packages.get(packagePath)).cloudpack || {};\n\n const bundleOptions: BundleOptions = {\n bundler,\n minify: mode === 'production',\n bundlerOptions,\n inputPath: packagePath,\n outputPath,\n incremental: isIncremental !== undefined ? isIncremental : false,\n sourcemap: !disableSourceMaps,\n entries: await getEntriesMapFromPackage({ inputPath: packagePath }, { packages, config }),\n inlined: inlinedDependencies,\n external: await getExternalsFromPackage({ inputPath: packagePath }, { packages }),\n dynamicImports,\n ignoredBundlerWarnings,\n bundlerCapabilities,\n unsafeCjsExportNames,\n };\n\n const bundleInternalResult = await bundle(bundleOptions, { config });\n bundleRequest.result = {\n ...bundleInternalResult,\n outputPath: bundleOptions.outputPath ?? outputPath,\n hash: cacheValidationHash,\n bundleSource: 'bundler',\n };\n\n if (bundlerCapabilities?.density) {\n // Get export maps that need to be written as stubs for density.\n // If there are density exports, write stubs for them.\n const densityErrors = await writeStubForDensityEntries({\n options: {\n packageName,\n packagePath,\n result: bundleInternalResult,\n },\n context: { packages, config },\n });\n\n // Add any errors to the result.\n if (densityErrors.length > 0) {\n bundleRequest.result.errors = [...(bundleRequest.result.errors ?? []), ...densityErrors];\n }\n }\n }\n\n // Write the result to disk.\n await saveResultToCache(bundleRequest.result);\n }\n\n // If we should find required imports and exports per bundle\n if (shouldGetBundleInfo && !bundleRequest.result?.errors?.length && bundleRequest.result?.outputFiles?.length) {\n // Exports map is needed to find the bundle info per entry we intend to bundle.\n // Exports map is used instead of bundleRequest.entries since it is easier to use\n // because it contains the paths other packages use to import the entry and\n // the relative location of the bundled files.\n const exportsMap = await getExportsMap({ packagePath }, { packages, config });\n\n const bundleInfo = await getBundleInfo({\n outputPath,\n outputFiles: bundleRequest.result.outputFiles,\n exportsMap,\n isExternal,\n packagePath,\n });\n\n bundleRequest.result.info = bundleInfo;\n\n if (config.logBundleInfo) {\n // Write to cache for future use. (Ignore the promise result.)\n void writeJson(path.join(outputPath, 'bundle-info.json'), bundleInfo);\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"bundleTask.js","sourceRoot":"","sources":["../../src/utilities/bundleTask.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAElG,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,iBAAiB,EA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AAC,MAAM,CAAC,IAAI,GAAG,UAAU,CAAC;QAEvC,IAAI,MAAM,CAAC,aAAa,EAAE,CAAC;YACzB,8DAA8D;YAC9D,KAAK,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,kBAAkB,CAAC,EAAE,UAAU,CAAC,CAAC;QACxE,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import { bundle, getEntriesMapFromPackage, getExternalsFromPackage } from '@ms-cloudpack/bundler';\nimport type { BundleOptions } from '@ms-cloudpack/common-types';\nimport { writeJson } from '@ms-cloudpack/json-utilities';\nimport { getExportsMap } from '@ms-cloudpack/package-utilities';\nimport { formatPackageName } from '@ms-cloudpack/task-reporter';\nimport path from 'path';\nimport { prepareOutputPath } from '../common/prepareOutputPath.js';\nimport type { BundleRequest } from '../types/BundleRequest.js';\nimport { getBundleInfo } from './getBundleInfo.js';\nimport { getBundleLocation } from './getBundleLocation.js';\nimport { isCachedResultValid } from './isCachedResultValid.js';\nimport { readResultFromCache } from './readResultFromCache.js';\nimport { saveResultToCache } from './saveResultToCache.js';\nimport { formatBundleTaskResult } from './formatBundleTaskResult.js';\nimport type { PartialContext } from '../types/Context.js';\nimport { writeStubForDensityEntries } from './writeStubForDensityEntries.js';\n\n/**\n * Options for a bundle task.\n */\nexport interface BundleTaskOptions {\n /** Force a bundle to be rerun */\n force?: boolean;\n /** Hash to avoid re-computing */\n hash?: string;\n /** Source hash to avoid recomputing */\n sourceHash?: string;\n /** Retry count for the task */\n retryCount?: number;\n bundleRequest: BundleRequest;\n}\n\nexport type BundleTaskContext = PartialContext<\n 'packages' | 'packageHashes' | 'reporter' | 'telemetryClient' | 'remoteCacheClient',\n 'resolveMap' | 'config' | 'sequence' | 'cachePath'\n>;\n\n/**\n * Create and run a TaskReporter task which calls `bundle()` from `@ms-cloudpack/bundler` and formats the result.\n */\nexport async function bundleTask(options: BundleTaskOptions, context: BundleTaskContext): Promise<void> {\n const { bundleRequest } = options;\n const { packageName, version } = bundleRequest;\n const { reporter, telemetryClient, session } = context;\n const { sequence } = session;\n const { retryCount } = options;\n\n const task = reporter.addTask(\n `Bundle ${formatPackageName({ name: packageName, version })}${retryCount ? ` (retry ${retryCount})` : ''}`,\n );\n\n try {\n await telemetryClient.tracer.startActiveSpan('BUNDLE_TASK', async (span) => {\n await bundleTaskInternal(options, context);\n\n span.setAttributes({\n sequence,\n isCacheHit: !!bundleRequest.resultFromCache,\n isExternal: bundleRequest.isExternal,\n packageName: bundleRequest.packageName,\n packageVersion: bundleRequest.version,\n bundleSource: bundleRequest.result?.bundleSource,\n bundler: bundleRequest.result?.bundler,\n bundlerVersion: bundleRequest.result?.bundlerVersion,\n });\n });\n } catch (err) {\n // If an unexpected error is thrown, add it to the result.\n // This ensures consistent handling of either actual bundler errors or exceptions.\n bundleRequest.result ??= {};\n bundleRequest.result.errors ??= [];\n bundleRequest.result.errors.push({\n text: `Unexpected exception while bundling: ${(err as Error).stack || String(err)}`,\n source: 'bundleTask',\n });\n }\n\n task.complete(formatBundleTaskResult(bundleRequest));\n}\n\n/**\n * Actually read the result from the cache or call `bundle()`.\n * NOTE: The result is returned by mutating `options.bundleRequest.result`.\n */\nasync function bundleTaskInternal(options: BundleTaskOptions, context: BundleTaskContext): Promise<void> {\n const { bundleRequest, force, hash, sourceHash } = options;\n const { packageName, version, targetEnvironment } = bundleRequest;\n const { packageHashes, packages, session } = context;\n const { config } = session;\n const { mode } = config;\n\n // If force is set, dispose the existing result.\n if (force && bundleRequest.result?.dispose) {\n bundleRequest.result.dispose();\n bundleRequest.result = undefined;\n }\n\n const { packagePath, isExternal, isIncremental, disableSourceMaps, shouldGetBundleInfo } = bundleRequest;\n\n const outputPath =\n bundleRequest.outputPath ??\n (await getBundleLocation({ packagePath, shouldRecalculate: force, hash }, context)).path;\n\n // Rehydrate the result if not incremental.\n if (bundleRequest.result === undefined && !force) {\n bundleRequest.result = await readResultFromCache(\n { packageName, version, inputPath: packagePath, outputPath },\n context,\n );\n }\n\n const cacheValidationHash = !isExternal\n ? sourceHash || (await packageHashes.get({ packagePath, isSourceHashingEnabled: true, shouldRecalculate: true }))\n : undefined;\n\n // if the cached result is valid, use it.\n if (!force && isCachedResultValid({ bundleRequest, hash: cacheValidationHash })) {\n console.debug(`Using cached result for ${bundleRequest.packageName}@${bundleRequest.version}`);\n bundleRequest.resultFromCache = true;\n } else {\n bundleRequest.resultFromCache = false;\n\n // Only use cached result if it's successful.\n await prepareOutputPath(outputPath);\n\n if (bundleRequest.result?.rebuild) {\n bundleRequest.result = {\n ...(await bundleRequest.result.rebuild()),\n outputPath: bundleRequest.result.outputPath,\n hash: cacheValidationHash,\n };\n } else {\n const {\n bundler,\n bundlerOptions,\n inlinedDependencies,\n dynamicImports,\n bundlerCapabilities,\n ignoredBundlerWarnings,\n unsafeCjsExportNames,\n } = (await packages.get(packagePath)).cloudpack || {};\n\n const bundleOptions: BundleOptions = {\n bundler,\n minify: mode === 'production',\n targetEnvironment,\n bundlerOptions,\n inputPath: packagePath,\n outputPath,\n incremental: isIncremental !== undefined ? isIncremental : false,\n sourcemap: !disableSourceMaps,\n entries: await getEntriesMapFromPackage({ inputPath: packagePath, targetEnvironment }, { packages, config }),\n inlined: inlinedDependencies,\n external: await getExternalsFromPackage({ inputPath: packagePath }, { packages }),\n dynamicImports,\n ignoredBundlerWarnings,\n bundlerCapabilities,\n unsafeCjsExportNames,\n };\n\n const bundleInternalResult = await bundle(bundleOptions, { config });\n bundleRequest.result = {\n ...bundleInternalResult,\n outputPath: bundleOptions.outputPath ?? outputPath,\n hash: cacheValidationHash,\n bundleSource: 'bundler',\n };\n\n if (bundlerCapabilities?.density) {\n // Get export maps that need to be written as stubs for density.\n // If there are density exports, write stubs for them.\n const densityErrors = await writeStubForDensityEntries({\n options: {\n packageName,\n packagePath,\n result: bundleInternalResult,\n },\n context: { packages, config },\n });\n\n // Add any errors to the result.\n if (densityErrors.length > 0) {\n bundleRequest.result.errors = [...(bundleRequest.result.errors ?? []), ...densityErrors];\n }\n }\n }\n\n // Write the result to disk.\n await saveResultToCache(bundleRequest.result);\n }\n\n // If we should find required imports and exports per bundle\n if (shouldGetBundleInfo && !bundleRequest.result?.errors?.length && bundleRequest.result?.outputFiles?.length) {\n // Exports map is needed to find the bundle info per entry we intend to bundle.\n // Exports map is used instead of bundleRequest.entries since it is easier to use\n // because it contains the paths other packages use to import the entry and\n // the relative location of the bundled files.\n const exportsMap = await getExportsMap({ packagePath }, { packages, config });\n\n const bundleInfo = await getBundleInfo({\n outputPath,\n outputFiles: bundleRequest.result.outputFiles,\n exportsMap,\n isExternal,\n packagePath,\n });\n\n bundleRequest.result.info = bundleInfo;\n\n if (config.logBundleInfo) {\n // Write to cache for future use. (Ignore the promise result.)\n void writeJson(path.join(outputPath, 'bundle-info.json'), bundleInfo);\n }\n }\n}\n"]}
|
|
@@ -6,5 +6,5 @@ import type { PartialContext } from '../types/Context.js';
|
|
|
6
6
|
* Create a bundle task (internally calls `bundleTask()`) that can be executed by the server's TaskRunner.
|
|
7
7
|
* This allows active tasks to be tracked remotely (e.g. in the browser) and allows the user to cancel tasks.
|
|
8
8
|
*/
|
|
9
|
-
export declare function createBundleTask(options: BundleTaskOptions, context: BundleTaskContext & PartialContext<'packageHashes'
|
|
9
|
+
export declare function createBundleTask(options: BundleTaskOptions, context: BundleTaskContext & PartialContext<'packageHashes', keyof BundleTaskContext['session'] | 'importMap' | 'packageImportPaths' | 'urls'>): Task<BundleRequest>;
|
|
10
10
|
//# sourceMappingURL=createBundleTask.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createBundleTask.d.ts","sourceRoot":"","sources":["../../src/utilities/createBundleTask.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAc,KAAK,iBAAiB,EAAE,KAAK,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAC7F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,iBAAiB,EAC1B,OAAO,EAAE,iBAAiB,GACxB,cAAc,CAAC,eAAe,
|
|
1
|
+
{"version":3,"file":"createBundleTask.d.ts","sourceRoot":"","sources":["../../src/utilities/createBundleTask.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAc,KAAK,iBAAiB,EAAE,KAAK,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAC7F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,iBAAiB,EAC1B,OAAO,EAAE,iBAAiB,GACxB,cAAc,CAAC,eAAe,EAAE,MAAM,iBAAiB,CAAC,SAAS,CAAC,GAAG,WAAW,GAAG,oBAAoB,GAAG,MAAM,CAAC,GAClH,IAAI,CAAC,aAAa,CAAC,CAgErB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createBundleTask.js","sourceRoot":"","sources":["../../src/utilities/createBundleTask.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,OAAO,EAAE,UAAU,EAAkD,MAAM,iBAAiB,CAAC;AAG7F;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAC9B,OAA0B,EAC1B,OACmH;IAEnH,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC;IAClC,MAAM,EAAE,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,WA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,CAAC;QACvB,CAAC;QACD,KAAK,EAAE,GAAG,EAAE;YACV,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC;gBACtC,OAAO;YACT,CAAC;YAED,aAAa,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC;YAEjC,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YAE7E,aAAa,CAAC,MAAM,GAAG,SAAS,CAAC;QACnC,CAAC;QACD,SAAS,EAAE,GAAG,EAAE;YACd,aAAa,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,CAAC;QACpC,CAAC;QACD,SAAS,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM;QAC7C,mBAAmB,EAAE,GAAG,EAAE,CAAC,CAAC;YAC1B,EAAE;YACF,kCAAkC;YAClC,IAAI;YACJ,SAAS,EAAE,WAAW,IAAI,EAAE;SAC7B,CAAC;QACF,iBAAiB,EAAE,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;YAClC,EAAE;YACF,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM;YAClC,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ;YACtC,UAAU,EAAE,aAAa,CAAC,MAAM,EAAE,UAAU,IAAI,EAAE;SACnD,CAAC;KACH,CAAC;AACJ,CAAC","sourcesContent":["import { addImportMapHash } from '@ms-cloudpack/import-map';\nimport fs from 'fs';\nimport path from 'path';\nimport type { BundleRequest } from '../types/BundleRequest.js';\nimport type { Task } from '../types/Task.js';\nimport { bundleTask, type BundleTaskContext, type BundleTaskOptions } from './bundleTask.js';\nimport type { PartialContext } from '../types/Context.js';\n\n/**\n * Create a bundle task (internally calls `bundleTask()`) that can be executed by the server's TaskRunner.\n * This allows active tasks to be tracked remotely (e.g. in the browser) and allows the user to cancel tasks.\n */\nexport function createBundleTask(\n options: BundleTaskOptions,\n context: BundleTaskContext &\n PartialContext<'packageHashes'
|
|
1
|
+
{"version":3,"file":"createBundleTask.js","sourceRoot":"","sources":["../../src/utilities/createBundleTask.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,OAAO,EAAE,UAAU,EAAkD,MAAM,iBAAiB,CAAC;AAG7F;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAC9B,OAA0B,EAC1B,OACmH;IAEnH,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC;IAClC,MAAM,EAAE,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,aAAa,CAAC;IAC5E,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAC3C,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IACrC,MAAM,IAAI,GAAG,UAAU,WAAW,IAAI,OAAO,EAAE,CAAC;IAEhD,OAAO;QACL,gCAAgC;QAChC,IAAI;QACJ,EAAE;QACF,GAAG,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,EAAE;QACvC,KAAK,EAAE,CAAC,UAAU;QAClB,KAAK,CAAC,OAAO;YACX,MAAM,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAEnC,IAAI,CAAC;gBACH,iDAAiD;gBACjD,0FAA0F;gBAC1F,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;gBACpC,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;gBAEjD,IAAI,SAAS,IAAI,YAAY,IAAI,SAAS,EAAE,CAAC;oBAC3C,MAAM,aAAa,GACjB,UAAU,IAAI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C,EAAE;YACF,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM;YAClC,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ;YACtC,UAAU,EAAE,aAAa,CAAC,MAAM,EAAE,UAAU,IAAI,EAAE;SACnD,CAAC;KACH,CAAC;AACJ,CAAC","sourcesContent":["import { addImportMapHash } from '@ms-cloudpack/import-map';\nimport fs from 'fs';\nimport path from 'path';\nimport type { BundleRequest } from '../types/BundleRequest.js';\nimport type { Task } from '../types/Task.js';\nimport { bundleTask, type BundleTaskContext, type BundleTaskOptions } from './bundleTask.js';\nimport type { PartialContext } from '../types/Context.js';\n\n/**\n * Create a bundle task (internally calls `bundleTask()`) that can be executed by the server's TaskRunner.\n * This allows active tasks to be tracked remotely (e.g. in the browser) and allows the user to cancel tasks.\n */\nexport function createBundleTask(\n options: BundleTaskOptions,\n context: BundleTaskContext &\n PartialContext<'packageHashes', keyof BundleTaskContext['session'] | 'importMap' | 'packageImportPaths' | 'urls'>,\n): Task<BundleRequest> {\n const { bundleRequest } = options;\n const { id, packageName, version, packagePath, isExternal } = bundleRequest;\n const { packageHashes, session } = context;\n const { hash, sourceHash } = options;\n const name = `Bundle ${packageName}@${version}`;\n\n return {\n // Name for task runner logging.\n name,\n id,\n dir: `${path.join(packagePath, 'src')}`,\n watch: !isExternal,\n async execute(): Promise<BundleRequest> {\n await bundleTask(options, context);\n\n try {\n // Add a hash to the import map for this package.\n // (Read the session properties here rather than above because they might not be set yet.)\n const importMap = session.importMap;\n const { bundleServer, appServer } = session.urls;\n\n if (importMap && bundleServer && appServer) {\n const importMapHash =\n sourceHash || hash || (await packageHashes.get({ packagePath, isSourceHashingEnabled: !isExternal }));\n addImportMapHash(\n { packageName, version, hash: importMapHash },\n { ...context, ...session, importMap, urls: { bundleServer, appServer } },\n );\n }\n } catch (e) {\n console.error(`Error adding hash to import map for ${bundleRequest.packagePath}:`, (e as Error).stack || e);\n }\n\n return bundleRequest;\n },\n clear: () => {\n if (!bundleRequest.result?.outputPath) {\n return;\n }\n\n bundleRequest.result.dispose?.();\n\n fs.rmSync(bundleRequest.result.outputPath, { recursive: true, force: true });\n\n bundleRequest.result = undefined;\n },\n onDispose: () => {\n bundleRequest.result?.dispose?.();\n },\n getErrors: () => bundleRequest.result?.errors,\n getStartDescription: () => ({\n id,\n // Name to display in the overlay.\n name,\n inputPath: packagePath || '',\n }),\n getEndDescription: (taskResult) => ({\n id,\n errors: taskResult?.result?.errors,\n warnings: taskResult?.result?.warnings,\n outputPath: bundleRequest.result?.outputPath || '',\n }),\n };\n}\n"]}
|
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { Session } from '@ms-cloudpack/common-types';
|
|
3
|
-
import type { TelemetryClient } from '@ms-cloudpack/telemetry';
|
|
1
|
+
import type { Context } from '../types/Context.js';
|
|
4
2
|
/**
|
|
5
3
|
* Notifies clients that a reload is needed by incrementing the session version.
|
|
6
4
|
*/
|
|
7
5
|
export declare function notifyReload(options: {
|
|
8
6
|
reason: string;
|
|
9
|
-
}, context:
|
|
10
|
-
bus: DataBus;
|
|
11
|
-
session: Session;
|
|
12
|
-
telemetryClient: TelemetryClient;
|
|
13
|
-
}): Promise<void>;
|
|
7
|
+
}, context: Pick<Context, 'bus' | 'session' | 'telemetryClient'>): Promise<void>;
|
|
14
8
|
//# sourceMappingURL=notifyReload.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notifyReload.d.ts","sourceRoot":"","sources":["../../src/utilities/notifyReload.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"notifyReload.d.ts","sourceRoot":"","sources":["../../src/utilities/notifyReload.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAEnD;;GAEG;AACH,wBAAsB,YAAY,CAChC,OAAO,EAAE;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,EAC3B,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,KAAK,GAAG,SAAS,GAAG,iBAAiB,CAAC,GAC5D,OAAO,CAAC,IAAI,CAAC,CAWf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notifyReload.js","sourceRoot":"","sources":["../../src/utilities/notifyReload.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"notifyReload.js","sourceRoot":"","sources":["../../src/utilities/notifyReload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAG1D;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,OAA2B,EAC3B,OAA6D;IAE7D,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAC3B,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC;IAElD,MAAM,eAAe,CAAC,MAAM,CAAC,eAAe,CAAC,eAAe,EAAE,CAAC,IAAI,EAAE,EAAE;QACrE,OAAO,CAAC,QAAQ,EAAE,CAAC;QAEnB,IAAI,CAAC,aAAa,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;QAE3D,GAAG,CAAC,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IACnD,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { reloadCountSource } from '../data/busSources.js';\nimport type { Context } from '../types/Context.js';\n\n/**\n * Notifies clients that a reload is needed by incrementing the session version.\n */\nexport async function notifyReload(\n options: { reason: string },\n context: Pick<Context, 'bus' | 'session' | 'telemetryClient'>,\n): Promise<void> {\n const { reason } = options;\n const { bus, session, telemetryClient } = context;\n\n await telemetryClient.tracer.startActiveSpan('NOTIFY_RELOAD', (span) => {\n session.sequence++;\n\n span.setAttributes({ sequence: session.sequence, reason });\n\n bus.publish(reloadCountSource, session.sequence);\n });\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.59.0",
|
|
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,22 +27,22 @@
|
|
|
27
27
|
"@lage-run/logger": "^1.3.0",
|
|
28
28
|
"@lage-run/scheduler": "^1.2.1",
|
|
29
29
|
"@lage-run/target-graph": "^0.11.0",
|
|
30
|
-
"@ms-cloudpack/bundler": "^0.
|
|
31
|
-
"@ms-cloudpack/common-types": "^0.24.
|
|
32
|
-
"@ms-cloudpack/config": "^0.33.
|
|
33
|
-
"@ms-cloudpack/create-express-app": "^1.10.
|
|
30
|
+
"@ms-cloudpack/bundler": "^0.24.0",
|
|
31
|
+
"@ms-cloudpack/common-types": "^0.24.7",
|
|
32
|
+
"@ms-cloudpack/config": "^0.33.16",
|
|
33
|
+
"@ms-cloudpack/create-express-app": "^1.10.19",
|
|
34
34
|
"@ms-cloudpack/data-bus": "^0.4.3",
|
|
35
|
-
"@ms-cloudpack/esm-stub-utilities": "^0.14.
|
|
35
|
+
"@ms-cloudpack/esm-stub-utilities": "^0.14.8",
|
|
36
36
|
"@ms-cloudpack/file-watcher": "^0.2.0",
|
|
37
|
-
"@ms-cloudpack/import-map": "^0.8.
|
|
37
|
+
"@ms-cloudpack/import-map": "^0.8.30",
|
|
38
38
|
"@ms-cloudpack/json-utilities": "^0.1.10",
|
|
39
|
-
"@ms-cloudpack/package-hashes": "^0.7.
|
|
40
|
-
"@ms-cloudpack/package-utilities": "^11.3.
|
|
39
|
+
"@ms-cloudpack/package-hashes": "^0.7.28",
|
|
40
|
+
"@ms-cloudpack/package-utilities": "^11.3.4",
|
|
41
41
|
"@ms-cloudpack/path-string-parsing": "^1.2.6",
|
|
42
|
-
"@ms-cloudpack/path-utilities": "^3.0.
|
|
43
|
-
"@ms-cloudpack/remote-cache": "^0.10.
|
|
44
|
-
"@ms-cloudpack/task-reporter": "^0.15.
|
|
45
|
-
"@ms-cloudpack/telemetry": "^0.10.
|
|
42
|
+
"@ms-cloudpack/path-utilities": "^3.0.4",
|
|
43
|
+
"@ms-cloudpack/remote-cache": "^0.10.10",
|
|
44
|
+
"@ms-cloudpack/task-reporter": "^0.15.1",
|
|
45
|
+
"@ms-cloudpack/telemetry": "^0.10.14",
|
|
46
46
|
"@trpc/client": "11.0.0-rc.682",
|
|
47
47
|
"@trpc/server": "11.0.0-rc.682",
|
|
48
48
|
"cors": "^2.8.5",
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { Context } from '../types/Context.js';
|
|
2
|
-
export type CreateContext = () => Promise<Context>;
|
|
3
|
-
/**
|
|
4
|
-
* Creates the server context and returns a connection context factory.
|
|
5
|
-
* The context object is accessible to apis and serves as a way to share stateful
|
|
6
|
-
* objects across them.
|
|
7
|
-
*/
|
|
8
|
-
export declare function createContextFactory(context: Context): Promise<CreateContext>;
|
|
9
|
-
//# sourceMappingURL=createContextFactory.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createContextFactory.d.ts","sourceRoot":"","sources":["../../src/trpc/createContextFactory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAEnD,MAAM,MAAM,aAAa,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;AAEnD;;;;GAIG;AAEH,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,CAUnF"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates the server context and returns a connection context factory.
|
|
3
|
-
* The context object is accessible to apis and serves as a way to share stateful
|
|
4
|
-
* objects across them.
|
|
5
|
-
*/
|
|
6
|
-
// eslint-disable-next-line @typescript-eslint/require-await
|
|
7
|
-
export async function createContextFactory(context) {
|
|
8
|
-
// Return the factory function which creates a context object per connection. This allows
|
|
9
|
-
// us to choose what we expose to each client from server context, but also allows us to
|
|
10
|
-
// add additional context to each connection.
|
|
11
|
-
// eslint-disable-next-line @typescript-eslint/require-await
|
|
12
|
-
const createContext = async () => {
|
|
13
|
-
return context;
|
|
14
|
-
};
|
|
15
|
-
return createContext;
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=createContextFactory.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createContextFactory.js","sourceRoot":"","sources":["../../src/trpc/createContextFactory.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,4DAA4D;AAC5D,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,OAAgB;IACzD,yFAAyF;IACzF,wFAAwF;IACxF,6CAA6C;IAC7C,4DAA4D;IAC5D,MAAM,aAAa,GAAkB,KAAK,IAAI,EAAE;QAC9C,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC;IAEF,OAAO,aAAa,CAAC;AACvB,CAAC","sourcesContent":["import type { Context } from '../types/Context.js';\n\nexport type CreateContext = () => Promise<Context>;\n\n/**\n * Creates the server context and returns a connection context factory.\n * The context object is accessible to apis and serves as a way to share stateful\n * objects across them.\n */\n// eslint-disable-next-line @typescript-eslint/require-await\nexport async function createContextFactory(context: Context): Promise<CreateContext> {\n // Return the factory function which creates a context object per connection. This allows\n // us to choose what we expose to each client from server context, but also allows us to\n // add additional context to each connection.\n // eslint-disable-next-line @typescript-eslint/require-await\n const createContext: CreateContext = async () => {\n return context;\n };\n\n return createContext;\n}\n"]}
|