@ms-cloudpack/api-server 0.19.1 → 0.19.2

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.
@@ -1 +1 @@
1
- {"version":3,"file":"addOverride.d.ts","sourceRoot":"","sources":["../../src/utilities/addOverride.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAEnD,MAAM,WAAW,kBAAkB;IACjC,oCAAoC;IACpC,WAAW,EAAE,MAAM,CAAC;IAEpB,8CAA8C;IAC9C,UAAU,EAAE,MAAM,CAAC;IAEnB,kCAAkC;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,UAAU,GAAG,SAAS,CAAC,iBAyD5G"}
1
+ {"version":3,"file":"addOverride.d.ts","sourceRoot":"","sources":["../../src/utilities/addOverride.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAEnD,MAAM,WAAW,kBAAkB;IACjC,oCAAoC;IACpC,WAAW,EAAE,MAAM,CAAC;IAEpB,8CAA8C;IAC9C,UAAU,EAAE,MAAM,CAAC;IAEnB,kCAAkC;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,UAAU,GAAG,SAAS,CAAC,iBAwD5G"}
@@ -1,7 +1,6 @@
1
1
  import { readUserConfig, writeUserConfig } from '@ms-cloudpack/config';
2
2
  import { addExportsMapEntry, findResolveMapEntry, getExportsMap } from '@ms-cloudpack/package-utilities';
3
- import { slash } from '@ms-cloudpack/path-string-parsing';
4
- import { parseRequestInfo } from './parseRequestInfo.js';
3
+ import { parseRequestUrl } from './parseRequestUrl.js';
5
4
  /**
6
5
  * The addOverride method is triggered by a user action in the overlay, when we detect new usage of an import path
7
6
  * that isn't recognized. When the user trigers this override, we write it to the cloudpack user config, rather
@@ -12,8 +11,7 @@ export async function addOverride(options, context) {
12
11
  const { session, packages } = context;
13
12
  let definition = undefined;
14
13
  if (issuerUrl) {
15
- const requestPath = slash(new URL(issuerUrl).pathname);
16
- const { packageName: name, version } = parseRequestInfo(requestPath);
14
+ const { packageName: name, version } = parseRequestUrl(issuerUrl);
17
15
  definition = { name, version };
18
16
  }
19
17
  const entry = findResolveMapEntry({
@@ -1 +1 @@
1
- {"version":3,"file":"addOverride.js","sourceRoot":"","sources":["../../src/utilities/addOverride.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AACzG,OAAO,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAczD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,OAA2B,EAAE,OAA8C;IAC3G,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IACvD,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IACtC,IAAI,UAAU,GAAG,SAAS,CAAC;IAE3B,IAAI,SAAS,EAAE;QACb,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC;QACvD,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,gBAAgB,CAAC,WAAW,CAAC,CAAC;QACrE,UAAU,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;KAChC;IAED,MAAM,KAAK,GAAG,mBAAmB,CAAC;QAChC,WAAW;QACX,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,UAAU;KACX,CAAC,CAAC;IAEH,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,CAAC,KAAK,CAAC,oCAAoC,WAAW,kBAAkB,CAAC,CAAC;QACjF,OAAO;KACR;IAED,6GAA6G;IAC7G,2CAA2C;IAC3C,MAAM,OAAO,GAAG,MAAM,aAAa,CAAC,EAAE,WAAW,EAAE,KAAK,CAAC,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC;IAE1E,wCAAwC;IACxC,MAAM,kBAAkB,CACtB;QACE,OAAO;QACP,WAAW,EAAE,KAAK,CAAC,IAAI;QACvB,UAAU;KACX,EACD,EAAE,QAAQ,EAAE,CACb,CAAC;IAEF,sCAAsC;IACtC,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAErD,gCAAgC;IAChC,MAAM,CAAC,eAAe,KAAK,EAAE,CAAC;IAE9B,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC;QAC1B,KAAK,EAAE;YACL,IAAI,EAAE,WAAW;YACjB,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,gCAAgC,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,SAAS;SAClG;QACD,OAAO;KACR,CAAC,CAAC;IAEH,gBAAgB;IAChB,MAAM,eAAe,CAAC,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IAE/C,OAAO,CAAC,KAAK,CAAC,uBAAuB,WAAW,+BAA+B,CAAC,CAAC;IAEjF,2GAA2G;IAC3G,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC;AACxC,CAAC","sourcesContent":["import { readUserConfig, writeUserConfig } from '@ms-cloudpack/config';\nimport { addExportsMapEntry, findResolveMapEntry, getExportsMap } from '@ms-cloudpack/package-utilities';\nimport { slash } from '@ms-cloudpack/path-string-parsing';\nimport { parseRequestInfo } from './parseRequestInfo.js';\nimport type { Context } from '../types/Context.js';\n\nexport interface AddOverrideOptions {\n /** The package name to override. */\n packageName: string;\n\n /** The import path to add for the package. */\n importPath: string;\n\n /** URL that issued the import. */\n issuerUrl?: string;\n}\n\n/**\n * The addOverride method is triggered by a user action in the overlay, when we detect new usage of an import path\n * that isn't recognized. When the user trigers this override, we write it to the cloudpack user config, rather\n * than generated configs which could get \"reset\" on `init --reset`.\n */\nexport async function addOverride(options: AddOverrideOptions, context: Pick<Context, 'packages' | 'session'>) {\n const { packageName, importPath, issuerUrl } = options;\n const { session, packages } = context;\n let definition = undefined;\n\n if (issuerUrl) {\n const requestPath = slash(new URL(issuerUrl).pathname);\n const { packageName: name, version } = parseRequestInfo(requestPath);\n definition = { name, version };\n }\n\n const entry = findResolveMapEntry({\n packageName,\n resolveMap: session.resolveMap,\n definition,\n });\n\n if (!entry) {\n console.error(`Could not find entry of package \"${packageName}\" in resolve map`);\n return;\n }\n\n // Get current exports. We want to add an additional entry to what's there - not replace the default exports,\n // so we need the full map for the package.\n const exports = await getExportsMap({ packagePath: entry.path }, context);\n\n // Now add the single new exports entry.\n await addExportsMapEntry(\n {\n exports,\n packagePath: entry.path,\n importPath,\n },\n { packages },\n );\n\n // Parse the user config if it exists.\n const config = await readUserConfig(session.appPath);\n\n // Ensure packageSettings exist.\n config.packageSettings ??= [];\n\n config.packageSettings.push({\n match: {\n name: packageName,\n version: entry.version?.match(/^\\d+\\.\\d+\\.\\d+(-[a-z0-9.-]+)?$/) ? `^${entry.version}` : undefined,\n },\n exports,\n });\n\n // Write config.\n await writeUserConfig(config, session.appPath);\n\n console.debug(`Added override for \"${packageName}\" to \"cloudpack.config.json\".`);\n\n // Instruct the package cache to reset, so that transforms can respect the modification to the exports map.\n packages.reset({ newConfig: config });\n}\n"]}
1
+ {"version":3,"file":"addOverride.js","sourceRoot":"","sources":["../../src/utilities/addOverride.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AACzG,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAcvD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,OAA2B,EAAE,OAA8C;IAC3G,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IACvD,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IACtC,IAAI,UAAU,GAAG,SAAS,CAAC;IAE3B,IAAI,SAAS,EAAE;QACb,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC;QAClE,UAAU,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;KAChC;IAED,MAAM,KAAK,GAAG,mBAAmB,CAAC;QAChC,WAAW;QACX,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,UAAU;KACX,CAAC,CAAC;IAEH,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,CAAC,KAAK,CAAC,oCAAoC,WAAW,kBAAkB,CAAC,CAAC;QACjF,OAAO;KACR;IAED,6GAA6G;IAC7G,2CAA2C;IAC3C,MAAM,OAAO,GAAG,MAAM,aAAa,CAAC,EAAE,WAAW,EAAE,KAAK,CAAC,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC;IAE1E,wCAAwC;IACxC,MAAM,kBAAkB,CACtB;QACE,OAAO;QACP,WAAW,EAAE,KAAK,CAAC,IAAI;QACvB,UAAU;KACX,EACD,EAAE,QAAQ,EAAE,CACb,CAAC;IAEF,sCAAsC;IACtC,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAErD,gCAAgC;IAChC,MAAM,CAAC,eAAe,KAAK,EAAE,CAAC;IAE9B,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC;QAC1B,KAAK,EAAE;YACL,IAAI,EAAE,WAAW;YACjB,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,gCAAgC,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,SAAS;SAClG;QACD,OAAO;KACR,CAAC,CAAC;IAEH,gBAAgB;IAChB,MAAM,eAAe,CAAC,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IAE/C,OAAO,CAAC,KAAK,CAAC,uBAAuB,WAAW,+BAA+B,CAAC,CAAC;IAEjF,2GAA2G;IAC3G,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC;AACxC,CAAC","sourcesContent":["import { readUserConfig, writeUserConfig } from '@ms-cloudpack/config';\nimport { addExportsMapEntry, findResolveMapEntry, getExportsMap } from '@ms-cloudpack/package-utilities';\nimport { parseRequestUrl } from './parseRequestUrl.js';\nimport type { Context } from '../types/Context.js';\n\nexport interface AddOverrideOptions {\n /** The package name to override. */\n packageName: string;\n\n /** The import path to add for the package. */\n importPath: string;\n\n /** URL that issued the import. */\n issuerUrl?: string;\n}\n\n/**\n * The addOverride method is triggered by a user action in the overlay, when we detect new usage of an import path\n * that isn't recognized. When the user trigers this override, we write it to the cloudpack user config, rather\n * than generated configs which could get \"reset\" on `init --reset`.\n */\nexport async function addOverride(options: AddOverrideOptions, context: Pick<Context, 'packages' | 'session'>) {\n const { packageName, importPath, issuerUrl } = options;\n const { session, packages } = context;\n let definition = undefined;\n\n if (issuerUrl) {\n const { packageName: name, version } = parseRequestUrl(issuerUrl);\n definition = { name, version };\n }\n\n const entry = findResolveMapEntry({\n packageName,\n resolveMap: session.resolveMap,\n definition,\n });\n\n if (!entry) {\n console.error(`Could not find entry of package \"${packageName}\" in resolve map`);\n return;\n }\n\n // Get current exports. We want to add an additional entry to what's there - not replace the default exports,\n // so we need the full map for the package.\n const exports = await getExportsMap({ packagePath: entry.path }, context);\n\n // Now add the single new exports entry.\n await addExportsMapEntry(\n {\n exports,\n packagePath: entry.path,\n importPath,\n },\n { packages },\n );\n\n // Parse the user config if it exists.\n const config = await readUserConfig(session.appPath);\n\n // Ensure packageSettings exist.\n config.packageSettings ??= [];\n\n config.packageSettings.push({\n match: {\n name: packageName,\n version: entry.version?.match(/^\\d+\\.\\d+\\.\\d+(-[a-z0-9.-]+)?$/) ? `^${entry.version}` : undefined,\n },\n exports,\n });\n\n // Write config.\n await writeUserConfig(config, session.appPath);\n\n console.debug(`Added override for \"${packageName}\" to \"cloudpack.config.json\".`);\n\n // Instruct the package cache to reset, so that transforms can respect the modification to the exports map.\n packages.reset({ newConfig: config });\n}\n"]}
@@ -1,7 +1,25 @@
1
+ /**
2
+ * Parse a request for package file from the bundle server, such as
3
+ * `/@scope/package@version/v3.2/bundled/path/to/file.js`
4
+ *
5
+ * Segments:
6
+ * - Package name (and optionally `@version`)
7
+ * - Optional refresh version `v#.#`
8
+ * - Optional type `bundled` or `unbundled` (defaults to unbundled)
9
+ * - Optional file path with leading slash (empty if no path)
10
+ *
11
+ * @param requestPath Pathname (server-relative URL) of the requested file.
12
+ * @returns Info about the requested file. If `requestPath` doesn't follow the expected format,
13
+ * the object will contain empty strings.
14
+ */
1
15
  export declare function parseRequestInfo(requestPath: string): {
16
+ /** Package name (empty string if invalid request) */
2
17
  packageName: string;
18
+ /** Optional package version (default: empty string) */
3
19
  version: string;
20
+ /** Whether the bundled version is requested (default: false) */
4
21
  bundled: boolean;
22
+ /** Optional file path (default: empty string) */
5
23
  filePath: string;
6
24
  };
7
25
  //# sourceMappingURL=parseRequestInfo.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"parseRequestInfo.d.ts","sourceRoot":"","sources":["../../src/utilities/parseRequestInfo.ts"],"names":[],"mappings":"AAAA,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM;;;;;EAiBnD"}
1
+ {"version":3,"file":"parseRequestInfo.d.ts","sourceRoot":"","sources":["../../src/utilities/parseRequestInfo.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG;IACrD,qDAAqD;IACrD,WAAW,EAAE,MAAM,CAAC;IACpB,uDAAuD;IACvD,OAAO,EAAE,MAAM,CAAC;IAChB,gEAAgE;IAChE,OAAO,EAAE,OAAO,CAAC;IACjB,iDAAiD;IACjD,QAAQ,EAAE,MAAM,CAAC;CAClB,CAkBA"}
@@ -1,14 +1,31 @@
1
+ /**
2
+ * Parse a request for package file from the bundle server, such as
3
+ * `/@scope/package@version/v3.2/bundled/path/to/file.js`
4
+ *
5
+ * Segments:
6
+ * - Package name (and optionally `@version`)
7
+ * - Optional refresh version `v#.#`
8
+ * - Optional type `bundled` or `unbundled` (defaults to unbundled)
9
+ * - Optional file path with leading slash (empty if no path)
10
+ *
11
+ * @param requestPath Pathname (server-relative URL) of the requested file.
12
+ * @returns Info about the requested file. If `requestPath` doesn't follow the expected format,
13
+ * the object will contain empty strings.
14
+ */
1
15
  export function parseRequestInfo(requestPath) {
2
- const matches = requestPath.match(/[/]?(@[-_a-z-A-Z0-9.]+\/[-_a-z-A-Z0-9.]+|[a-zA-Z-0-9.]+)(@([-_a-zA-Z-0-9.]+))?(\/v([0-9.]+))?(\/(bundled|unbundled))?(\/[-_/a-zA-Z0-9.+]+)?/) || [];
3
- const packageName = matches[1] || '';
4
- const version = matches[3] || '';
5
- const bundled = (matches.length > 8 && matches[7]) === 'bundled';
6
- const filePath = (matches.length > 8 && matches[8]) || '';
16
+ // This is a hot path, and the following things appear to make the regex faster:
17
+ // - /(?:Non-capturing groups)/ where capturing isn't needed
18
+ // - /(Indexed capturing groups)/ instead of /(?<namedGroups>...)/
19
+ // - For character classes containing - , putting the - at the beginning
20
+ // - Anchoring to the beginning of the string with ^
21
+ const matches = requestPath.match(
22
+ // 1 package name 2 version refresh 3 bundled 4 file path end or query
23
+ /^\/?((?:@[-\w.]+\/)?[-\w.]+)(?:@([-\w.]+))?(?:\/v[\d.]+)?(?:\/(bundled|unbundled))?(\/[-\w.+/]+)?(?:\?|$)/) || [];
7
24
  return {
8
- packageName,
9
- version,
10
- bundled,
11
- filePath,
25
+ packageName: matches[1] || '',
26
+ version: matches[2] || '',
27
+ bundled: matches[3] === 'bundled',
28
+ filePath: matches[4] || '',
12
29
  };
13
30
  }
14
31
  //# sourceMappingURL=parseRequestInfo.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"parseRequestInfo.js","sourceRoot":"","sources":["../../src/utilities/parseRequestInfo.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,gBAAgB,CAAC,WAAmB;IAClD,MAAM,OAAO,GACX,WAAW,CAAC,KAAK,CACf,6IAA6I,CAC9I,IAAI,EAAE,CAAC;IAEV,MAAM,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACrC,MAAM,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACjC,MAAM,OAAO,GAAG,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC;IACjE,MAAM,QAAQ,GAAG,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAE1D,OAAO;QACL,WAAW;QACX,OAAO;QACP,OAAO;QACP,QAAQ;KACT,CAAC;AACJ,CAAC","sourcesContent":["export function parseRequestInfo(requestPath: string) {\n const matches =\n requestPath.match(\n /[/]?(@[-_a-z-A-Z0-9.]+\\/[-_a-z-A-Z0-9.]+|[a-zA-Z-0-9.]+)(@([-_a-zA-Z-0-9.]+))?(\\/v([0-9.]+))?(\\/(bundled|unbundled))?(\\/[-_/a-zA-Z0-9.+]+)?/,\n ) || [];\n\n const packageName = matches[1] || '';\n const version = matches[3] || '';\n const bundled = (matches.length > 8 && matches[7]) === 'bundled';\n const filePath = (matches.length > 8 && matches[8]) || '';\n\n return {\n packageName,\n version,\n bundled,\n filePath,\n };\n}\n"]}
1
+ {"version":3,"file":"parseRequestInfo.js","sourceRoot":"","sources":["../../src/utilities/parseRequestInfo.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,gBAAgB,CAAC,WAAmB;IAUlD,gFAAgF;IAChF,4DAA4D;IAC5D,kEAAkE;IAClE,wEAAwE;IACxE,oDAAoD;IACpD,MAAM,OAAO,GACX,WAAW,CAAC,KAAK;IACf,8GAA8G;IAC9G,2GAA2G,CAC5G,IAAI,EAAE,CAAC;IAEV,OAAO;QACL,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE;QAC7B,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE;QACzB,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,SAAS;QACjC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE;KAC3B,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Parse a request for package file from the bundle server, such as\n * `/@scope/package@version/v3.2/bundled/path/to/file.js`\n *\n * Segments:\n * - Package name (and optionally `@version`)\n * - Optional refresh version `v#.#`\n * - Optional type `bundled` or `unbundled` (defaults to unbundled)\n * - Optional file path with leading slash (empty if no path)\n *\n * @param requestPath Pathname (server-relative URL) of the requested file.\n * @returns Info about the requested file. If `requestPath` doesn't follow the expected format,\n * the object will contain empty strings.\n */\nexport function parseRequestInfo(requestPath: string): {\n /** Package name (empty string if invalid request) */\n packageName: string;\n /** Optional package version (default: empty string) */\n version: string;\n /** Whether the bundled version is requested (default: false) */\n bundled: boolean;\n /** Optional file path (default: empty string) */\n filePath: string;\n} {\n // This is a hot path, and the following things appear to make the regex faster:\n // - /(?:Non-capturing groups)/ where capturing isn't needed\n // - /(Indexed capturing groups)/ instead of /(?<namedGroups>...)/\n // - For character classes containing - , putting the - at the beginning\n // - Anchoring to the beginning of the string with ^\n const matches =\n requestPath.match(\n // 1 package name 2 version refresh 3 bundled 4 file path end or query\n /^\\/?((?:@[-\\w.]+\\/)?[-\\w.]+)(?:@([-\\w.]+))?(?:\\/v[\\d.]+)?(?:\\/(bundled|unbundled))?(\\/[-\\w.+/]+)?(?:\\?|$)/,\n ) || [];\n\n return {\n packageName: matches[1] || '',\n version: matches[2] || '',\n bundled: matches[3] === 'bundled',\n filePath: matches[4] || '',\n };\n}\n"]}
@@ -0,0 +1,14 @@
1
+ import { parseRequestInfo } from './parseRequestInfo.js';
2
+ /**
3
+ * Parse a complete package file request URL, such as
4
+ * `http://localhost/@scope/package@version/v3.2/bundled/path/to/file.js`.
5
+ * See `parseRequestInfo` for more details.
6
+ *
7
+ * Throws an error if `requestUrl` is not a syntactically valid complete URL.
8
+ *
9
+ * @param requestUrl Full URL of the requested file.
10
+ * @returns Info about the requested file. If `requestUrl` doesn't follow the expected format,
11
+ * the object will contain empty strings.
12
+ */
13
+ export declare function parseRequestUrl(requestUrl: string): ReturnType<typeof parseRequestInfo>;
14
+ //# sourceMappingURL=parseRequestUrl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseRequestUrl.d.ts","sourceRoot":"","sources":["../../src/utilities/parseRequestUrl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAUvF"}
@@ -0,0 +1,24 @@
1
+ import { parseRequestInfo } from './parseRequestInfo.js';
2
+ /**
3
+ * Parse a complete package file request URL, such as
4
+ * `http://localhost/@scope/package@version/v3.2/bundled/path/to/file.js`.
5
+ * See `parseRequestInfo` for more details.
6
+ *
7
+ * Throws an error if `requestUrl` is not a syntactically valid complete URL.
8
+ *
9
+ * @param requestUrl Full URL of the requested file.
10
+ * @returns Info about the requested file. If `requestUrl` doesn't follow the expected format,
11
+ * the object will contain empty strings.
12
+ */
13
+ export function parseRequestUrl(requestUrl) {
14
+ let pathname;
15
+ try {
16
+ pathname = new URL(requestUrl).pathname;
17
+ }
18
+ catch (err) {
19
+ // The error for URL parsing failure doesn't include the string, so throw a more helpful error.
20
+ throw new Error(`Invalid URL: ${requestUrl}`);
21
+ }
22
+ return parseRequestInfo(pathname);
23
+ }
24
+ //# sourceMappingURL=parseRequestUrl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseRequestUrl.js","sourceRoot":"","sources":["../../src/utilities/parseRequestUrl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,eAAe,CAAC,UAAkB;IAChD,IAAI,QAAgB,CAAC;IACrB,IAAI;QACF,QAAQ,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC;KACzC;IAAC,OAAO,GAAG,EAAE;QACZ,+FAA+F;QAC/F,MAAM,IAAI,KAAK,CAAC,gBAAgB,UAAU,EAAE,CAAC,CAAC;KAC/C;IAED,OAAO,gBAAgB,CAAC,QAAQ,CAAC,CAAC;AACpC,CAAC","sourcesContent":["import { parseRequestInfo } from './parseRequestInfo.js';\n\n/**\n * Parse a complete package file request URL, such as\n * `http://localhost/@scope/package@version/v3.2/bundled/path/to/file.js`.\n * See `parseRequestInfo` for more details.\n *\n * Throws an error if `requestUrl` is not a syntactically valid complete URL.\n *\n * @param requestUrl Full URL of the requested file.\n * @returns Info about the requested file. If `requestUrl` doesn't follow the expected format,\n * the object will contain empty strings.\n */\nexport function parseRequestUrl(requestUrl: string): ReturnType<typeof parseRequestInfo> {\n let pathname: string;\n try {\n pathname = new URL(requestUrl).pathname;\n } catch (err) {\n // The error for URL parsing failure doesn't include the string, so throw a more helpful error.\n throw new Error(`Invalid URL: ${requestUrl}`);\n }\n\n return parseRequestInfo(pathname);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"validateOverride.d.ts","sourceRoot":"","sources":["../../src/utilities/validateOverride.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAEnD,MAAM,WAAW,uBAAuB;IACtC,gDAAgD;IAChD,WAAW,EAAE,MAAM,CAAC;IAEpB,kDAAkD;IAClD,UAAU,EAAE,MAAM,CAAC;IAEnB,kCAAkC;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,uBAAuB,EAChC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,SAAS,GAAG,UAAU,CAAC,oBA+B/C"}
1
+ {"version":3,"file":"validateOverride.d.ts","sourceRoot":"","sources":["../../src/utilities/validateOverride.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAEnD,MAAM,WAAW,uBAAuB;IACtC,gDAAgD;IAChD,WAAW,EAAE,MAAM,CAAC;IAEpB,kDAAkD;IAClD,UAAU,EAAE,MAAM,CAAC;IAEnB,kCAAkC;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,uBAAuB,EAChC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,SAAS,GAAG,UAAU,CAAC,oBA8B/C"}
@@ -1,6 +1,5 @@
1
1
  import { findResolveMapEntry, findFileInPackage } from '@ms-cloudpack/package-utilities';
2
- import { slash } from '@ms-cloudpack/path-string-parsing';
3
- import { parseRequestInfo } from './parseRequestInfo.js';
2
+ import { parseRequestUrl } from './parseRequestUrl.js';
4
3
  /**
5
4
  * Given a package name, import path, and optional issuerUrl, returns a boolean indicating if the given
6
5
  * override is valid.
@@ -10,8 +9,7 @@ export async function validateOverride(options, context) {
10
9
  const { session } = context;
11
10
  let definition = undefined;
12
11
  if (issuerUrl) {
13
- const requestPath = slash(new URL(issuerUrl).pathname);
14
- const { packageName: name, version } = parseRequestInfo(requestPath);
12
+ const { packageName: name, version } = parseRequestUrl(issuerUrl);
15
13
  definition = { name, version };
16
14
  }
17
15
  const entry = findResolveMapEntry({
@@ -1 +1 @@
1
- {"version":3,"file":"validateOverride.js","sourceRoot":"","sources":["../../src/utilities/validateOverride.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACzF,OAAO,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAezD;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,OAAgC,EAChC,OAA8C;IAE9C,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IACvD,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAC5B,IAAI,UAAU,GAA4B,SAAS,CAAC;IAEpD,IAAI,SAAS,EAAE;QACb,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC;QACvD,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,gBAAgB,CAAC,WAAW,CAAC,CAAC;QACrE,UAAU,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;KAChC;IAED,MAAM,KAAK,GAAG,mBAAmB,CAAC;QAChC,WAAW;QACX,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,UAAU;KACX,CAAC,CAAC;IAEH,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,KAAK,CAAC;KACd;IAED,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,iBAAiB,CAC1C;QACE,WAAW,EAAE,KAAK,CAAC,IAAI;QACvB,QAAQ,EAAE,UAAU;KACrB,EACD,OAAO,CACR,CAAC;IAEF,OAAO,CAAC,CAAC,QAAQ,CAAC;AACpB,CAAC","sourcesContent":["import { findResolveMapEntry, findFileInPackage } from '@ms-cloudpack/package-utilities';\nimport { slash } from '@ms-cloudpack/path-string-parsing';\nimport { parseRequestInfo } from './parseRequestInfo.js';\nimport type { PackageJson } from '@ms-cloudpack/bundler-types';\nimport type { Context } from '../types/Context.js';\n\nexport interface ValidateOverrideOptions {\n /** The package name the override applies to. */\n packageName: string;\n\n /** The import path overridden for the package. */\n importPath: string;\n\n /** URL that issued the import. */\n issuerUrl?: string;\n}\n\n/**\n * Given a package name, import path, and optional issuerUrl, returns a boolean indicating if the given\n * override is valid.\n */\nexport async function validateOverride(\n options: ValidateOverrideOptions,\n context: Pick<Context, 'session' | 'packages'>,\n) {\n const { packageName, importPath, issuerUrl } = options;\n const { session } = context;\n let definition: PackageJson | undefined = undefined;\n\n if (issuerUrl) {\n const requestPath = slash(new URL(issuerUrl).pathname);\n const { packageName: name, version } = parseRequestInfo(requestPath);\n definition = { name, version };\n }\n\n const entry = findResolveMapEntry({\n packageName,\n resolveMap: session.resolveMap,\n definition,\n });\n\n if (!entry) {\n return false;\n }\n\n const { filePath } = await findFileInPackage(\n {\n packagePath: entry.path,\n filePath: importPath,\n },\n context,\n );\n\n return !!filePath;\n}\n"]}
1
+ {"version":3,"file":"validateOverride.js","sourceRoot":"","sources":["../../src/utilities/validateOverride.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACzF,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAevD;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,OAAgC,EAChC,OAA8C;IAE9C,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IACvD,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAC5B,IAAI,UAAU,GAA4B,SAAS,CAAC;IAEpD,IAAI,SAAS,EAAE;QACb,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC;QAClE,UAAU,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;KAChC;IAED,MAAM,KAAK,GAAG,mBAAmB,CAAC;QAChC,WAAW;QACX,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,UAAU;KACX,CAAC,CAAC;IAEH,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,KAAK,CAAC;KACd;IAED,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,iBAAiB,CAC1C;QACE,WAAW,EAAE,KAAK,CAAC,IAAI;QACvB,QAAQ,EAAE,UAAU;KACrB,EACD,OAAO,CACR,CAAC;IAEF,OAAO,CAAC,CAAC,QAAQ,CAAC;AACpB,CAAC","sourcesContent":["import { findResolveMapEntry, findFileInPackage } from '@ms-cloudpack/package-utilities';\nimport { parseRequestUrl } from './parseRequestUrl.js';\nimport type { PackageJson } from '@ms-cloudpack/bundler-types';\nimport type { Context } from '../types/Context.js';\n\nexport interface ValidateOverrideOptions {\n /** The package name the override applies to. */\n packageName: string;\n\n /** The import path overridden for the package. */\n importPath: string;\n\n /** URL that issued the import. */\n issuerUrl?: string;\n}\n\n/**\n * Given a package name, import path, and optional issuerUrl, returns a boolean indicating if the given\n * override is valid.\n */\nexport async function validateOverride(\n options: ValidateOverrideOptions,\n context: Pick<Context, 'session' | 'packages'>,\n) {\n const { packageName, importPath, issuerUrl } = options;\n const { session } = context;\n let definition: PackageJson | undefined = undefined;\n\n if (issuerUrl) {\n const { packageName: name, version } = parseRequestUrl(issuerUrl);\n definition = { name, version };\n }\n\n const entry = findResolveMapEntry({\n packageName,\n resolveMap: session.resolveMap,\n definition,\n });\n\n if (!entry) {\n return false;\n }\n\n const { filePath } = await findFileInPackage(\n {\n packagePath: entry.path,\n filePath: importPath,\n },\n context,\n );\n\n return !!filePath;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ms-cloudpack/api-server",
3
- "version": "0.19.1",
3
+ "version": "0.19.2",
4
4
  "description": "An implementation of the API server that does interacts with a task scheduler.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -22,10 +22,10 @@
22
22
  },
23
23
  "dependencies": {
24
24
  "@lage-run/logger": "^1.3.0",
25
- "@lage-run/scheduler": "^1.0.0",
25
+ "@lage-run/scheduler": "^1.1.9",
26
26
  "@lage-run/target-graph": "^0.8.7",
27
- "@lage-run/hasher": "^1.0.0",
28
- "@ms-cloudpack/bundler": "^0.14.15",
27
+ "@lage-run/hasher": "^1.0.5",
28
+ "@ms-cloudpack/bundler": "^0.14.16",
29
29
  "@ms-cloudpack/bundler-types": "^0.19.1",
30
30
  "@ms-cloudpack/config": "^0.12.5",
31
31
  "@ms-cloudpack/create-express-app": "^1.3.9",
@@ -37,7 +37,7 @@
37
37
  "@ms-cloudpack/path-utilities": "^2.3.2",
38
38
  "@ms-cloudpack/task-reporter": "^0.8.0",
39
39
  "@ms-cloudpack/telemetry": "^0.3.8",
40
- "@ms-cloudpack/remote-cache": "^0.1.7",
40
+ "@ms-cloudpack/remote-cache": "^0.1.8",
41
41
  "@trpc/client": "^10.38.1",
42
42
  "@trpc/server": "^10.38.1",
43
43
  "chokidar": "^3.5.3",