attio 0.0.1-experimental.20250808 → 0.0.1-experimental.20250808.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,6 +1,7 @@
1
1
  import fs from "fs/promises";
2
2
  import path from "path";
3
3
  import { Project } from "ts-morph";
4
+ import { complete, errored, isComplete } from "@attio/fetchable-npm";
4
5
  import { generateRandomFileName } from "./generate-random-file-name.js";
5
6
  import { parseFileExports } from "./parse-file-exports.js";
6
7
  import { surfaceTypeDefinitions } from "./surface-types.js";
@@ -31,25 +32,38 @@ export async function findSurfaceExports(rootDir) {
31
32
  };
32
33
  const typeChecker = tsProject.getTypeChecker();
33
34
  async function loadSourceFile(filePath) {
34
- const fileContent = await fs.readFile(filePath, "utf-8");
35
- return tsProject.createSourceFile(filePath, fileContent, { overwrite: true });
35
+ try {
36
+ const fileContent = await fs.readFile(filePath, "utf-8");
37
+ return complete(tsProject.createSourceFile(filePath, fileContent, { overwrite: true }));
38
+ }
39
+ catch (err) {
40
+ if (typeof err === "object" && err !== null && "code" in err && err.code === "ENOENT") {
41
+ return errored({ code: "FILE_NOT_FOUND" });
42
+ }
43
+ return errored({ code: "UNKNOWN_ERROR" });
44
+ }
36
45
  }
37
46
  const loadSourceFilesPromises = [];
38
47
  const surfaceExportsByPath = [];
39
48
  for await (const filePath of walkDir(rootDir)) {
40
49
  loadSourceFilesPromises.push(loadSourceFile(filePath));
41
50
  }
42
- const sourceFiles = await Promise.all(loadSourceFilesPromises);
43
- sourceFiles.map((sourceFile) => {
51
+ const sourceFileResults = await Promise.all(loadSourceFilesPromises);
52
+ sourceFileResults
53
+ .filter((sourceFileResult) => isComplete(sourceFileResult))
54
+ .map((sourceFileResult) => {
44
55
  const surfaceExports = parseFileExports({
45
- sourceFile,
56
+ sourceFile: sourceFileResult.value,
46
57
  existingExportSymbols,
47
58
  existingIds,
48
59
  typeChecker,
49
60
  surfaceTypes,
50
61
  });
51
62
  if (surfaceExports.size > 0) {
52
- surfaceExportsByPath.push([sourceFile.getFilePath(), [...surfaceExports]]);
63
+ surfaceExportsByPath.push([
64
+ sourceFileResult.value.getFilePath(),
65
+ [...surfaceExports],
66
+ ]);
53
67
  }
54
68
  });
55
69
  return surfaceExportsByPath;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "attio",
3
- "version": "0.0.1-experimental.20250808",
3
+ "version": "0.0.1-experimental.20250808.1",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "lib",