@ms-cloudpack/api-server 0.13.0 → 0.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"findImports.d.ts","sourceRoot":"","sources":["../../src/utilities/findImports.ts"],"names":[],"mappings":"AAUA;;;GAGG;AACH,wBAAsB,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAsE3F"}
1
+ {"version":3,"file":"findImports.d.ts","sourceRoot":"","sources":["../../src/utilities/findImports.ts"],"names":[],"mappings":"AAUA;;;GAGG;AACH,wBAAsB,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAuE3F"}
@@ -23,14 +23,15 @@ export async function findImports(filePaths) {
23
23
  const source = await fsPromises.readFile(filePath, 'utf-8');
24
24
  let rawImports;
25
25
  try {
26
- [rawImports] = parse(source);
26
+ // es-module-lexer/parse may return Promise in some conditions
27
+ // although it is not declared in the type definition
28
+ // https://github.com/guybedford/es-module-lexer/issues/155
29
+ [rawImports] = await parse(source);
27
30
  }
28
31
  catch (err) {
29
32
  // This could happen if the source file isn't valid JS
30
33
  // (unlikely after adding the check above to only attempt parsing JS/TS files)
31
- const stack = err instanceof Error ? err.stack : '';
32
- const type = typeof err;
33
- console.warn(`Failed to parse ${filePath}:`, err, 'Type', type, 'Stack', stack, '\nSource is:\n', source);
34
+ console.warn(`Failed to parse ${filePath}:`, err, '\nSource is:\n', source);
34
35
  continue;
35
36
  }
36
37
  const imports = Array.from(new Set(rawImports))
@@ -1 +1 @@
1
- {"version":3,"file":"findImports.js","sourceRoot":"","sources":["../../src/utilities/findImports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iBA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CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE;gBACnG,eAAe,CAAC,WAAW,CAAC,KAAK,IAAI,GAAG,EAAE,CAAC;gBAC3C,eAAe,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,UAAU,IAAI,GAAG,CAAC,CAAC;aACrD;SACF;KACF;IAED,OAAO,eAAe,CAAC;AACzB,CAAC","sourcesContent":["import { parse } from 'es-module-lexer';\nimport fsPromises from 'fs/promises';\nimport path from 'path';\nimport { parseImportString, type ImportStringResult } from '@ms-cloudpack/path-string-parsing';\nimport { sourceExtensions } from '@ms-cloudpack/path-utilities';\nimport { builtinModules } from 'module';\n\n/** Treat files with no extension as JS for purposes below */\nconst allSourceExtensions = [...sourceExtensions, ''];\n\n/**\n * Returns a dictionary where key is the package name and value is a set of required paths.\n * Eg. `{ '@fluentui/react': new Set([ '.', './lib/Button' ]) }`\n */\nexport async function findImports(filePaths: string[]): Promise<Record<string, Set<string>>> {\n const requiredExports: Record<string, Set<string>> = {};\n const visitedPaths = new Set(filePaths);\n const pathsToParse: string[] = [...filePaths];\n\n while (pathsToParse.length) {\n const filePath = pathsToParse.shift();\n // Ignore any non-JS/TS files such as SVGs and sourcemaps\n if (!filePath || !allSourceExtensions.includes(path.extname(filePath))) {\n continue;\n }\n\n const source = await fsPromises.readFile(filePath, 'utf-8');\n let rawImports: ReturnType<typeof parse>[0];\n try {\n [rawImports] = parse(source);\n } catch (err) {\n // This could happen if the source file isn't valid JS\n // (unlikely after adding the check above to only attempt parsing JS/TS files)\n const stack = err instanceof Error ? err.stack : '';\n const type = typeof err;\n console.warn(`Failed to parse ${filePath}:`, err, 'Type', type, 'Stack', stack, '\\nSource is:\\n', source);\n continue;\n }\n const imports = Array.from(new Set(rawImports))\n .map((i) => {\n // The es-module-lexer returns entries where the \"n\" property equals the import source.\n // This includes the package name and path. For example, in this case:\n //\n // import { Button } from '@fluentui/react/lib/Button';\n //\n // The \"n\" property would be \"@fluentui/react/lib/Button\".\n // The \"s\" and \"e\" properties represent the start/end character positions of\n // the import source. The \"ss\" and \"se\" properties represent the start/end\n // character positions of the import specifier starting with \"import\". This\n // may be useful for determining if the import is sync or async.\n //\n // Currently when the import source is a backtick string, the \"n\" property\n // is undefined. This is a bug in es-module-lexer. We may need to handle this\n // at the javascript layer and expand it into multiple potential imports.\n if (!i.n) {\n console.debug(\n `Found an import that didn't parse correctly:\\nFilename:\\n${filePath}\\n\\nImport:\\n${source.slice(\n i.s,\n i.e,\n )}`,\n );\n return undefined;\n }\n\n return parseImportString(i.n);\n })\n .filter(Boolean) as ImportStringResult[];\n\n for (const { packageName, importPath } of imports) {\n if (packageName?.startsWith('.')) {\n const localPath = path.resolve(path.dirname(filePath), packageName, importPath || '');\n\n if (!visitedPaths.has(localPath)) {\n visitedPaths.add(localPath);\n pathsToParse.push(localPath);\n }\n } else if (packageName && !packageName.startsWith('node:') && !builtinModules.includes(packageName)) {\n requiredExports[packageName] ??= new Set();\n requiredExports[packageName].add(importPath || '.');\n }\n }\n }\n\n return requiredExports;\n}\n"]}
1
+ {"version":3,"file":"findImports.js","sourceRoot":"","sources":["../../src/utilities/findImports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAA2B,MAAM,mCAAmC,CAAC;AAC/F,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAExC,6DAA6D;AAC7D,MAAM,mBAAmB,GAAG,CAAC,GAAG,gBAAgB,EAAE,EAAE,CAAC,CAAC;AAEtD;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,SAAmB;IACnD,MAAM,eAAe,GAAgC,EAAE,CAAC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C,EACH,CAAC,CAAC,CAAC,CACJ,EAAE,CACJ,CAAC;gBACF,OAAO,SAAS,CAAC;aAClB;YAED,OAAO,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAChC,CAAC,CAAC;aACD,MAAM,CAAC,OAAO,CAAyB,CAAC;QAE3C,KAAK,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,IAAI,OAAO,EAAE;YACjD,IAAI,WAAW,EAAE,UAAU,CAAC,GAAG,CAAC,EAAE;gBAChC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,WAAW,EAAE,UAAU,IAAI,EAAE,CAAC,CAAC;gBAEtF,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;oBAChC,YAAY,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;oBAC5B,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;iBAC9B;aACF;iBAAM,IAAI,WAAW,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE;gBACnG,eAAe,CAAC,WAAW,CAAC,KAAK,IAAI,GAAG,EAAE,CAAC;gBAC3C,eAAe,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,UAAU,IAAI,GAAG,CAAC,CAAC;aACrD;SACF;KACF;IAED,OAAO,eAAe,CAAC;AACzB,CAAC","sourcesContent":["import { parse } from 'es-module-lexer';\nimport fsPromises from 'fs/promises';\nimport path from 'path';\nimport { parseImportString, type ImportStringResult } from '@ms-cloudpack/path-string-parsing';\nimport { sourceExtensions } from '@ms-cloudpack/path-utilities';\nimport { builtinModules } from 'module';\n\n/** Treat files with no extension as JS for purposes below */\nconst allSourceExtensions = [...sourceExtensions, ''];\n\n/**\n * Returns a dictionary where key is the package name and value is a set of required paths.\n * Eg. `{ '@fluentui/react': new Set([ '.', './lib/Button' ]) }`\n */\nexport async function findImports(filePaths: string[]): Promise<Record<string, Set<string>>> {\n const requiredExports: Record<string, Set<string>> = {};\n const visitedPaths = new Set(filePaths);\n const pathsToParse: string[] = [...filePaths];\n\n while (pathsToParse.length) {\n const filePath = pathsToParse.shift();\n // Ignore any non-JS/TS files such as SVGs and sourcemaps\n if (!filePath || !allSourceExtensions.includes(path.extname(filePath))) {\n continue;\n }\n\n const source = await fsPromises.readFile(filePath, 'utf-8');\n let rawImports: ReturnType<typeof parse>[0];\n try {\n // es-module-lexer/parse may return Promise in some conditions\n // although it is not declared in the type definition\n // https://github.com/guybedford/es-module-lexer/issues/155\n [rawImports] = await (parse(source) as unknown as Promise<ReturnType<typeof parse>>);\n } catch (err) {\n // This could happen if the source file isn't valid JS\n // (unlikely after adding the check above to only attempt parsing JS/TS files)\n console.warn(`Failed to parse ${filePath}:`, err, '\\nSource is:\\n', source);\n continue;\n }\n const imports = Array.from(new Set(rawImports))\n .map((i) => {\n // The es-module-lexer returns entries where the \"n\" property equals the import source.\n // This includes the package name and path. For example, in this case:\n //\n // import { Button } from '@fluentui/react/lib/Button';\n //\n // The \"n\" property would be \"@fluentui/react/lib/Button\".\n // The \"s\" and \"e\" properties represent the start/end character positions of\n // the import source. The \"ss\" and \"se\" properties represent the start/end\n // character positions of the import specifier starting with \"import\". This\n // may be useful for determining if the import is sync or async.\n //\n // Currently when the import source is a backtick string, the \"n\" property\n // is undefined. This is a bug in es-module-lexer. We may need to handle this\n // at the javascript layer and expand it into multiple potential imports.\n if (!i.n) {\n console.debug(\n `Found an import that didn't parse correctly:\\nFilename:\\n${filePath}\\n\\nImport:\\n${source.slice(\n i.s,\n i.e,\n )}`,\n );\n return undefined;\n }\n\n return parseImportString(i.n);\n })\n .filter(Boolean) as ImportStringResult[];\n\n for (const { packageName, importPath } of imports) {\n if (packageName?.startsWith('.')) {\n const localPath = path.resolve(path.dirname(filePath), packageName, importPath || '');\n\n if (!visitedPaths.has(localPath)) {\n visitedPaths.add(localPath);\n pathsToParse.push(localPath);\n }\n } else if (packageName && !packageName.startsWith('node:') && !builtinModules.includes(packageName)) {\n requiredExports[packageName] ??= new Set();\n requiredExports[packageName].add(importPath || '.');\n }\n }\n }\n\n return requiredExports;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ms-cloudpack/api-server",
3
- "version": "0.13.0",
3
+ "version": "0.13.1",
4
4
  "description": "An implementation of the API server that does interacts with a task scheduler.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -21,19 +21,19 @@
21
21
  "@lage-run/scheduler": "^1.0.0",
22
22
  "@lage-run/target-graph": "^0.8.6",
23
23
  "@lage-run/hasher": "^1.0.0",
24
- "@ms-cloudpack/bundler": "^0.14.6",
24
+ "@ms-cloudpack/bundler": "^0.14.7",
25
25
  "@ms-cloudpack/bundler-types": "^0.17.0",
26
- "@ms-cloudpack/config": "^0.11.0",
26
+ "@ms-cloudpack/config": "^0.11.1",
27
27
  "@ms-cloudpack/create-express-app": "^1.3.9",
28
28
  "@ms-cloudpack/data-bus": "^0.4.0",
29
29
  "@ms-cloudpack/file-watcher": "^0.0.3",
30
30
  "@ms-cloudpack/json-utilities": "^0.0.7",
31
- "@ms-cloudpack/package-utilities": "^5.1.0",
31
+ "@ms-cloudpack/package-utilities": "^5.1.1",
32
32
  "@ms-cloudpack/path-string-parsing": "^1.0.3",
33
33
  "@ms-cloudpack/path-utilities": "^2.3.2",
34
34
  "@ms-cloudpack/task-reporter": "^0.7.1",
35
35
  "@ms-cloudpack/telemetry": "^0.3.6",
36
- "@ms-cloudpack/remote-cache": "^0.1.0",
36
+ "@ms-cloudpack/remote-cache": "^0.1.1",
37
37
  "@trpc/client": "^10.21.1",
38
38
  "@trpc/server": "^10.21.1",
39
39
  "chokidar": "^3.5.3",