@bevorai/sdk 0.0.0-stage → 0.1.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.
Files changed (130) hide show
  1. package/README.md +179 -2
  2. package/dist/client.d.ts +86 -0
  3. package/dist/client.d.ts.map +1 -0
  4. package/dist/client.js +171 -0
  5. package/dist/client.js.map +1 -0
  6. package/dist/errors.d.ts +109 -0
  7. package/dist/errors.d.ts.map +1 -0
  8. package/dist/errors.js +132 -0
  9. package/dist/errors.js.map +1 -0
  10. package/dist/graph/call-node.d.ts +47 -0
  11. package/dist/graph/call-node.d.ts.map +1 -0
  12. package/dist/graph/call-node.js +338 -0
  13. package/dist/graph/call-node.js.map +1 -0
  14. package/dist/graph/cursor.d.ts +46 -0
  15. package/dist/graph/cursor.d.ts.map +1 -0
  16. package/dist/graph/cursor.js +149 -0
  17. package/dist/graph/cursor.js.map +1 -0
  18. package/dist/graph/field-metadata.d.ts +24 -0
  19. package/dist/graph/field-metadata.d.ts.map +1 -0
  20. package/dist/graph/field-metadata.js +72 -0
  21. package/dist/graph/field-metadata.js.map +1 -0
  22. package/dist/graph/graph.d.ts +87 -0
  23. package/dist/graph/graph.d.ts.map +1 -0
  24. package/dist/graph/graph.js +354 -0
  25. package/dist/graph/graph.js.map +1 -0
  26. package/dist/helpers/call-chain.d.ts +11 -0
  27. package/dist/helpers/call-chain.d.ts.map +1 -0
  28. package/dist/helpers/call-chain.js +79 -0
  29. package/dist/helpers/call-chain.js.map +1 -0
  30. package/dist/helpers/sarif.d.ts +21 -0
  31. package/dist/helpers/sarif.d.ts.map +1 -0
  32. package/dist/helpers/sarif.js +191 -0
  33. package/dist/helpers/sarif.js.map +1 -0
  34. package/dist/helpers/source-fingerprint.d.ts +32 -0
  35. package/dist/helpers/source-fingerprint.d.ts.map +1 -0
  36. package/dist/helpers/source-fingerprint.js +115 -0
  37. package/dist/helpers/source-fingerprint.js.map +1 -0
  38. package/dist/helpers/static-analysis.d.ts +18 -0
  39. package/dist/helpers/static-analysis.d.ts.map +1 -0
  40. package/dist/helpers/static-analysis.js +89 -0
  41. package/dist/helpers/static-analysis.js.map +1 -0
  42. package/dist/index.d.ts +31 -0
  43. package/dist/index.d.ts.map +1 -0
  44. package/dist/index.js +29 -0
  45. package/dist/index.js.map +1 -0
  46. package/dist/node.d.ts +4 -0
  47. package/dist/node.d.ts.map +1 -0
  48. package/dist/node.js +26 -0
  49. package/dist/node.js.map +1 -0
  50. package/dist/pagination.d.ts +13 -0
  51. package/dist/pagination.d.ts.map +1 -0
  52. package/dist/pagination.js +30 -0
  53. package/dist/pagination.js.map +1 -0
  54. package/dist/resources/analyses.d.ts +90 -0
  55. package/dist/resources/analyses.d.ts.map +1 -0
  56. package/dist/resources/analyses.js +250 -0
  57. package/dist/resources/analyses.js.map +1 -0
  58. package/dist/resources/chats.d.ts +48 -0
  59. package/dist/resources/chats.d.ts.map +1 -0
  60. package/dist/resources/chats.js +114 -0
  61. package/dist/resources/chats.js.map +1 -0
  62. package/dist/resources/codes.d.ts +64 -0
  63. package/dist/resources/codes.d.ts.map +1 -0
  64. package/dist/resources/codes.js +200 -0
  65. package/dist/resources/codes.js.map +1 -0
  66. package/dist/resources/files.d.ts +26 -0
  67. package/dist/resources/files.d.ts.map +1 -0
  68. package/dist/resources/files.js +45 -0
  69. package/dist/resources/files.js.map +1 -0
  70. package/dist/resources/findings.d.ts +49 -0
  71. package/dist/resources/findings.d.ts.map +1 -0
  72. package/dist/resources/findings.js +84 -0
  73. package/dist/resources/findings.js.map +1 -0
  74. package/dist/resources/nodes.d.ts +33 -0
  75. package/dist/resources/nodes.d.ts.map +1 -0
  76. package/dist/resources/nodes.js +65 -0
  77. package/dist/resources/nodes.js.map +1 -0
  78. package/dist/resources/projects.d.ts +11 -0
  79. package/dist/resources/projects.d.ts.map +1 -0
  80. package/dist/resources/projects.js +14 -0
  81. package/dist/resources/projects.js.map +1 -0
  82. package/dist/resources/shared.d.ts +14 -0
  83. package/dist/resources/shared.d.ts.map +1 -0
  84. package/dist/resources/shared.js +2 -0
  85. package/dist/resources/shared.js.map +1 -0
  86. package/dist/resources/summary.d.ts +17 -0
  87. package/dist/resources/summary.d.ts.map +1 -0
  88. package/dist/resources/summary.js +27 -0
  89. package/dist/resources/summary.js.map +1 -0
  90. package/dist/resources/transitions.d.ts +25 -0
  91. package/dist/resources/transitions.d.ts.map +1 -0
  92. package/dist/resources/transitions.js +30 -0
  93. package/dist/resources/transitions.js.map +1 -0
  94. package/dist/resources/users.d.ts +19 -0
  95. package/dist/resources/users.d.ts.map +1 -0
  96. package/dist/resources/users.js +36 -0
  97. package/dist/resources/users.js.map +1 -0
  98. package/dist/resources/versions.d.ts +20 -0
  99. package/dist/resources/versions.d.ts.map +1 -0
  100. package/dist/resources/versions.js +25 -0
  101. package/dist/resources/versions.js.map +1 -0
  102. package/dist/streaming.d.ts +43 -0
  103. package/dist/streaming.d.ts.map +1 -0
  104. package/dist/streaming.js +147 -0
  105. package/dist/streaming.js.map +1 -0
  106. package/dist/types/graph-data.d.ts +62 -0
  107. package/dist/types/graph-data.d.ts.map +1 -0
  108. package/dist/types/graph-data.js +2 -0
  109. package/dist/types/graph-data.js.map +1 -0
  110. package/dist/types/literals.d.ts +27 -0
  111. package/dist/types/literals.d.ts.map +1 -0
  112. package/dist/types/literals.js +16 -0
  113. package/dist/types/literals.js.map +1 -0
  114. package/dist/types/node-types.d.ts +5 -0
  115. package/dist/types/node-types.d.ts.map +1 -0
  116. package/dist/types/node-types.js +292 -0
  117. package/dist/types/node-types.js.map +1 -0
  118. package/dist/types/requests.d.ts +205 -0
  119. package/dist/types/requests.d.ts.map +1 -0
  120. package/dist/types/requests.js +3 -0
  121. package/dist/types/requests.js.map +1 -0
  122. package/dist/types/responses.d.ts +448 -0
  123. package/dist/types/responses.d.ts.map +1 -0
  124. package/dist/types/responses.js +11 -0
  125. package/dist/types/responses.js.map +1 -0
  126. package/dist/types/static-analysis.d.ts +28 -0
  127. package/dist/types/static-analysis.d.ts.map +1 -0
  128. package/dist/types/static-analysis.js +93 -0
  129. package/dist/types/static-analysis.js.map +1 -0
  130. package/package.json +46 -5
@@ -0,0 +1,191 @@
1
+ export const BEVOR_TOOL_VERSION = "0.0.1";
2
+ export const BEVOR_TO_SARIF_LEVEL = {
3
+ critical: "error",
4
+ high: "warning",
5
+ medium: "note",
6
+ low: "none",
7
+ };
8
+ export const SARIF_TO_BEVOR_LEVEL = {
9
+ error: "critical",
10
+ warning: "high",
11
+ note: "medium",
12
+ none: "low",
13
+ };
14
+ const PHYSICAL_REGION_KEYS = [
15
+ "startLine",
16
+ "startColumn",
17
+ "endLine",
18
+ "endColumn",
19
+ "charOffset",
20
+ "charLength",
21
+ "byteOffset",
22
+ "byteLength",
23
+ ];
24
+ const NEWLINE = 0x0a;
25
+ const strictUtf8 = new TextDecoder("utf-8", { fatal: true });
26
+ const utf8Encoder = new TextEncoder();
27
+ /** Like Python's `str.title()`: each run of letters capitalized, the rest lowercased. */
28
+ const titleCase = (value) => value.replace(/[A-Za-z]+/g, (word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase());
29
+ const countNewlines = (bytes) => bytes.reduce((n, b) => (b === NEWLINE ? n + 1 : n), 0);
30
+ const codePointLength = (bytes) => [...strictUtf8.decode(bytes)].length;
31
+ export const ruleForFinding = (finding) => ({
32
+ id: finding.type,
33
+ shortDescription: {
34
+ text: `${titleCase(finding.type.replaceAll("_", " "))} Vulnerability`,
35
+ },
36
+ });
37
+ /** Bevor-specific properties; SARIF property bags here carry strings only. */
38
+ export const bevorProperties = (finding) => {
39
+ const properties = {
40
+ findingId: finding.id,
41
+ nodeId: finding.node_id,
42
+ is_acknowledged: finding.is_acknowledged,
43
+ recommendation: finding.recommendation,
44
+ poc: finding.poc,
45
+ };
46
+ const pruned = {};
47
+ for (const [key, value] of Object.entries(properties)) {
48
+ if (value === null || value === undefined)
49
+ continue;
50
+ pruned[key] = typeof value === "boolean" ? String(value) : value;
51
+ }
52
+ return { bevor: pruned };
53
+ };
54
+ export const resultFromFinding = (finding, location) => ({
55
+ ruleId: finding.type,
56
+ level: BEVOR_TO_SARIF_LEVEL[finding.level],
57
+ message: {
58
+ text: finding.name,
59
+ properties: { description: finding.explanation },
60
+ },
61
+ locations: [{ physicalLocation: location }],
62
+ properties: bevorProperties(finding),
63
+ });
64
+ /** Line/column (1-indexed), byte and code-point offsets for a byte range of a UTF-8 file. */
65
+ export const computeRegion = (content, byteStart, byteEnd) => {
66
+ const before = content.subarray(0, byteStart);
67
+ const snippet = content.subarray(byteStart, byteEnd);
68
+ const startLine = countNewlines(before) + 1;
69
+ const startColumn = byteStart - before.lastIndexOf(NEWLINE);
70
+ const snippetNewlines = countNewlines(snippet);
71
+ const endLine = startLine + snippetNewlines;
72
+ const endColumn = snippetNewlines > 0
73
+ ? byteEnd - (byteStart + snippet.lastIndexOf(NEWLINE))
74
+ : startColumn + snippet.length;
75
+ return {
76
+ byteOffset: byteStart,
77
+ byteLength: byteEnd - byteStart,
78
+ charOffset: codePointLength(before),
79
+ charLength: codePointLength(snippet),
80
+ startLine,
81
+ startColumn,
82
+ endLine,
83
+ endColumn,
84
+ };
85
+ };
86
+ const locationFromResult = (result) => {
87
+ const location = result.locations?.[0];
88
+ if (!location)
89
+ throw new Error("result has no resolvable location");
90
+ const physical = location.physicalLocation;
91
+ const uri = physical?.artifactLocation?.uri;
92
+ if (uri && physical?.region) {
93
+ // SARIF defaults both offsets to -1 ("not provided"); the Python SDK sends them filled in
94
+ const region = {
95
+ charOffset: -1,
96
+ byteOffset: -1,
97
+ ...physical.region,
98
+ };
99
+ const found = { strategy: "physical", uri };
100
+ for (const key of PHYSICAL_REGION_KEYS) {
101
+ const value = region[key];
102
+ if (value !== null && value !== undefined)
103
+ found[key] = value;
104
+ }
105
+ return found;
106
+ }
107
+ const fullyQualifiedName = location.logicalLocations?.[0]?.fullyQualifiedName;
108
+ if (fullyQualifiedName)
109
+ return { strategy: "logical", fully_qualified_name: fullyQualifiedName };
110
+ throw new Error("result has no resolvable location");
111
+ };
112
+ /** Fetches (once per file) the UTF-8 bytes of every file a finding points at. */
113
+ const getContents = async (graph, findings) => {
114
+ const fileIds = new Set(findings.map((finding) => graph.getNode(finding.node_id).file_id));
115
+ const contents = await Promise.all([...fileIds].map(async (fileId) => [
116
+ fileId,
117
+ utf8Encoder.encode(await graph.getFileContent(fileId)),
118
+ ]));
119
+ return new Map(contents);
120
+ };
121
+ /** Converts findings to a SARIF 2.1.0 log, one run per tool. The graph must be built. */
122
+ export const bevorToSarif = async (graph, findings) => {
123
+ const contents = await getContents(graph, findings);
124
+ const rules = new Map();
125
+ const results = new Map();
126
+ const append = (map, key, value) => {
127
+ const list = map.get(key);
128
+ if (list)
129
+ list.push(value);
130
+ else
131
+ map.set(key, [value]);
132
+ };
133
+ for (const finding of findings) {
134
+ const node = graph.getNode(finding.node_id);
135
+ const file = graph.getFile(node.file_id);
136
+ const content = contents.get(file.id);
137
+ const toolName = finding.tool.startsWith("bevor") ? "Bevor" : finding.tool;
138
+ const location = {
139
+ artifactLocation: { uri: file.path },
140
+ region: computeRegion(content, node.src_start_pos, node.src_end_pos),
141
+ };
142
+ append(rules, toolName, ruleForFinding(finding));
143
+ append(results, toolName, resultFromFinding(finding, location));
144
+ }
145
+ const runs = [...rules.keys()].map((toolName) => ({
146
+ tool: {
147
+ driver: {
148
+ name: toolName,
149
+ rules: rules.get(toolName),
150
+ ...(toolName === "Bevor"
151
+ ? {
152
+ semanticVersion: BEVOR_TOOL_VERSION,
153
+ informationUri: "https://bevor.io/docs",
154
+ }
155
+ : {}),
156
+ },
157
+ },
158
+ results: results.get(toolName),
159
+ }));
160
+ return { version: "2.1.0", runs };
161
+ };
162
+ /** Converts a SARIF log into finding bodies for `analyses.addFindings`. */
163
+ export const sarifToBevor = (sarif) => {
164
+ const bodies = [];
165
+ for (const run of sarif.runs ?? []) {
166
+ const tool = run.tool.driver.name;
167
+ const rules = new Map((run.tool.driver.rules ?? []).map((rule) => [rule.id, rule]));
168
+ for (const result of run.results ?? []) {
169
+ const rule = rules.get(result.ruleId ?? "");
170
+ const findingType = result.ruleId || rule?.id || rule?.name;
171
+ if (!findingType)
172
+ throw new Error("result is missing a resolvable type");
173
+ const name = rule?.name || rule?.shortDescription?.text || findingType;
174
+ const explanation = result.message.text || result.message.markdown;
175
+ if (!explanation)
176
+ throw new Error("result is missing a resolvable explanation");
177
+ bodies.push({
178
+ metadata: {
179
+ type: findingType,
180
+ level: SARIF_TO_BEVOR_LEVEL[result.level ?? "warning"],
181
+ name,
182
+ explanation,
183
+ },
184
+ tool,
185
+ location: locationFromResult(result),
186
+ });
187
+ }
188
+ }
189
+ return bodies;
190
+ };
191
+ //# sourceMappingURL=sarif.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sarif.js","sourceRoot":"","sources":["../../src/helpers/sarif.ts"],"names":[],"mappings":"AAoBA,MAAM,CAAC,MAAM,kBAAkB,GAAG,OAAO,CAAC;AAE1C,MAAM,CAAC,MAAM,oBAAoB,GAChC;IACC,QAAQ,EAAE,OAAO;IACjB,IAAI,EAAE,SAAS;IACf,MAAM,EAAE,MAAM;IACd,GAAG,EAAE,MAAM;CACX,CAAC;AAEH,MAAM,CAAC,MAAM,oBAAoB,GAChC;IACC,KAAK,EAAE,UAAU;IACjB,OAAO,EAAE,MAAM;IACf,IAAI,EAAE,QAAQ;IACd,IAAI,EAAE,KAAK;CACX,CAAC;AAEH,MAAM,oBAAoB,GAAG;IAC5B,WAAW;IACX,aAAa;IACb,SAAS;IACT,WAAW;IACX,YAAY;IACZ,YAAY;IACZ,YAAY;IACZ,YAAY;CACH,CAAC;AAEX,MAAM,OAAO,GAAG,IAAI,CAAC;AACrB,MAAM,UAAU,GAAG,IAAI,WAAW,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC7D,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;AAEtC,yFAAyF;AACzF,MAAM,SAAS,GAAG,CA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E,gBAAgB,EAAE,IAAI,IAAI,WAAW,CAAC;YACvE,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC;YACnE,IAAI,CAAC,WAAW;gBACf,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;YAE/D,MAAM,CAAC,IAAI,CAAC;gBACX,QAAQ,EAAE;oBACT,IAAI,EAAE,WAAW;oBACjB,KAAK,EAAE,oBAAoB,CAAC,MAAM,CAAC,KAAK,IAAI,SAAS,CAAC;oBACtD,IAAI;oBACJ,WAAW;iBACX;gBACD,IAAI;gBACJ,QAAQ,EAAE,kBAAkB,CAAC,MAAM,CAAC;aACpC,CAAC,CAAC;QACJ,CAAC;IACF,CAAC;IACD,OAAO,MAAM,CAAC;AACf,CAAC,CAAC"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Non-hidden build/cache/tooling directories. Hidden paths (any segment starting with `.`, e.g.
3
+ * `.git`, `.env`, dotfiles) are always skipped.
4
+ */
5
+ export declare const SKIP_DIRS: ReadonlySet<string>;
6
+ export declare const SKIP_EXTS: ReadonlySet<string>;
7
+ /** Path segments, normalized like `PurePosixPath` (empty and `.` segments dropped). */
8
+ export declare const pathParts: (relPosix: string) => string[];
9
+ /** Whether to exclude `relPosix` (relative to the repo / zip root, forward slashes). */
10
+ export declare const skipRelativePath: (relPosix: string) => boolean;
11
+ /** Orders paths as plain strings by code point, like Python's `str` (JS's default compares UTF-16 units). */
12
+ export declare const comparePaths: (a: string, b: string) => number;
13
+ export declare const isUtf8: (bytes: Uint8Array) => boolean;
14
+ export interface SourceFile {
15
+ /** Path relative to the source root, with forward slashes. */
16
+ path: string;
17
+ content: Uint8Array;
18
+ }
19
+ export interface FingerprintedSource {
20
+ zip: Uint8Array;
21
+ nFiles: number;
22
+ nFilesSkipped: number;
23
+ versionFingerprint: string;
24
+ }
25
+ /**
26
+ * Zips the files that pass the path and UTF-8 rules under `rootName`, in path order, and
27
+ * fingerprints them. Mirrors the Python SDK's `fingerprint_source`.
28
+ */
29
+ export declare const fingerprintSource: (files: Iterable<SourceFile>, rootName: string) => Promise<FingerprintedSource>;
30
+ /** Every file in a zip, relative to its top-level folder. Mirrors the Python SDK's `zip_files`. */
31
+ export declare const zipFiles: (zip: Uint8Array) => SourceFile[];
32
+ //# sourceMappingURL=source-fingerprint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source-fingerprint.d.ts","sourceRoot":"","sources":["../../src/helpers/source-fingerprint.ts"],"names":[],"mappings":"AAWA;;;GAGG;AACH,eAAO,MAAM,SAAS,EAAE,WAAW,CAAC,MAAM,CAuBxC,CAAC;AAEH,eAAO,MAAM,SAAS,EAAE,WAAW,CAAC,MAAM,CAA6B,CAAC;AAQxE,uFAAuF;AACvF,eAAO,MAAM,SAAS,aAAc,MAAM,KAAG,MAAM,EACe,CAAC;AAEnE,wFAAwF;AACxF,eAAO,MAAM,gBAAgB,aAAc,MAAM,KAAG,OAKnD,CAAC;AAEF,6GAA6G;AAC7G,eAAO,MAAM,YAAY,MAAO,MAAM,KAAK,MAAM,KAAG,MASnD,CAAC;AAKF,eAAO,MAAM,MAAM,UAAW,UAAU,KAAG,OAO1C,CAAC;AAEF,MAAM,WAAW,UAAU;IAC1B,8DAA8D;IAC9D,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,UAAU,CAAC;CACpB;AAED,MAAM,WAAW,mBAAmB;IACnC,GAAG,EAAE,UAAU,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,kBAAkB,EAAE,MAAM,CAAC;CAC3B;AAED;;;GAGG;AACH,eAAO,MAAM,iBAAiB,UACtB,QAAQ,CAAC,UAAU,CAAC,YACjB,MAAM,KACd,OAAO,CAAC,mBAAmB,CA4B7B,CAAC;AAEF,mGAAmG;AACnG,eAAO,MAAM,QAAQ,QAAS,UAAU,KAAG,UAAU,EAKlD,CAAC"}
@@ -0,0 +1,115 @@
1
+ /**
2
+ * Shared rules and aggregation for a folder's `version_fingerprint` (HASH method), matching the
3
+ * Python SDK and the API byte for byte.
4
+ *
5
+ * Paths are skipped with `skipRelativePath`; only valid UTF-8 files count. The fingerprint is an
6
+ * XXH128 over, per file in path string order (by code point), the relative POSIX path's UTF-8
7
+ * bytes followed by the 16-byte XXH128 digest of the file's raw bytes.
8
+ */
9
+ import { unzipSync, zipSync } from "fflate";
10
+ import { createXXHash128 } from "hash-wasm";
11
+ /**
12
+ * Non-hidden build/cache/tooling directories. Hidden paths (any segment starting with `.`, e.g.
13
+ * `.git`, `.env`, dotfiles) are always skipped.
14
+ */
15
+ export const SKIP_DIRS = new Set([
16
+ "__pycache__",
17
+ "venv",
18
+ "dist",
19
+ "build",
20
+ "out",
21
+ "obj",
22
+ "_build",
23
+ "htmlcov",
24
+ "coverage",
25
+ "site",
26
+ "tmp",
27
+ "tests",
28
+ "test",
29
+ "temp",
30
+ "logs",
31
+ "__MACOSX",
32
+ "playwright-report",
33
+ "test-results",
34
+ "storybook-static",
35
+ "DerivedData",
36
+ "nimcache",
37
+ ".bevor",
38
+ ]);
39
+ export const SKIP_EXTS = new Set([".pyc", ".pyo"]);
40
+ /** Python's `PurePosixPath.suffix`: the final segment's extension, ignoring a leading dot. */
41
+ const suffix = (name) => {
42
+ const dot = name.lastIndexOf(".");
43
+ return dot > 0 && dot < name.length - 1 ? name.slice(dot) : "";
44
+ };
45
+ /** Path segments, normalized like `PurePosixPath` (empty and `.` segments dropped). */
46
+ export const pathParts = (relPosix) => relPosix.split("/").filter((part) => part !== "" && part !== ".");
47
+ /** Whether to exclude `relPosix` (relative to the repo / zip root, forward slashes). */
48
+ export const skipRelativePath = (relPosix) => {
49
+ const parts = pathParts(relPosix);
50
+ if (parts.some((part) => part.startsWith(".")))
51
+ return true;
52
+ if (parts.slice(0, -1).some((part) => SKIP_DIRS.has(part)))
53
+ return true;
54
+ return SKIP_EXTS.has(suffix(parts[parts.length - 1] ?? ""));
55
+ };
56
+ /** Orders paths as plain strings by code point, like Python's `str` (JS's default compares UTF-16 units). */
57
+ export const comparePaths = (a, b) => {
58
+ const left = [...a];
59
+ const right = [...b];
60
+ for (let i = 0; i < Math.min(left.length, right.length); i++) {
61
+ const diff = (left[i]?.codePointAt(0) ?? 0) - (right[i]?.codePointAt(0) ?? 0);
62
+ if (diff !== 0)
63
+ return diff;
64
+ }
65
+ return left.length - right.length;
66
+ };
67
+ const strictUtf8 = new TextDecoder("utf-8", { fatal: true });
68
+ const utf8Encoder = new TextEncoder();
69
+ export const isUtf8 = (bytes) => {
70
+ try {
71
+ strictUtf8.decode(bytes);
72
+ return true;
73
+ }
74
+ catch {
75
+ return false;
76
+ }
77
+ };
78
+ /**
79
+ * Zips the files that pass the path and UTF-8 rules under `rootName`, in path order, and
80
+ * fingerprints them. Mirrors the Python SDK's `fingerprint_source`.
81
+ */
82
+ export const fingerprintSource = async (files, rootName) => {
83
+ const [hasher, fileHasher] = await Promise.all([
84
+ createXXHash128(),
85
+ createXXHash128(),
86
+ ]);
87
+ hasher.init();
88
+ const entries = {};
89
+ let nFiles = 0;
90
+ let nFilesSkipped = 0;
91
+ for (const file of [...files].sort((a, b) => comparePaths(a.path, b.path))) {
92
+ if (skipRelativePath(file.path) || !isUtf8(file.content)) {
93
+ nFilesSkipped++;
94
+ continue;
95
+ }
96
+ hasher.update(utf8Encoder.encode(file.path));
97
+ // fixed-width digest, so no framing ambiguity
98
+ hasher.update(fileHasher.init().update(file.content).digest("binary"));
99
+ entries[`${rootName}/${file.path}`] = file.content;
100
+ nFiles++;
101
+ }
102
+ return {
103
+ zip: zipSync(entries, { level: 6 }),
104
+ nFiles,
105
+ nFilesSkipped,
106
+ versionFingerprint: hasher.digest("hex"),
107
+ };
108
+ };
109
+ /** Every file in a zip, relative to its top-level folder. Mirrors the Python SDK's `zip_files`. */
110
+ export const zipFiles = (zip) => Object.entries(unzipSync(zip)).flatMap(([name, content]) => {
111
+ const slash = name.indexOf("/");
112
+ const path = slash === -1 ? "" : name.slice(slash + 1);
113
+ return path && !name.endsWith("/") ? [{ path, content }] : [];
114
+ });
115
+ //# sourceMappingURL=source-fingerprint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source-fingerprint.js","sourceRoot":"","sources":["../../src/helpers/source-fingerprint.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAwB,IAAI,GAAG,CAAC;IACrD,aAAa;IACb,MAAM;IACN,MAAM;IACN,OAAO;IACP,KAAK;IACL,KAAK;IACL,QAAQ;IACR,SAAS;IACT,UAAU;IACV,MAAM;IACN,KAAK;IACL,OAAO;IACP,MAAM;IACN,MAAM;IACN,MAAM;IACN,UAAU;IACV,mBAAmB;IACnB,cAAc;IACd,kBAAkB;IAClB,aAAa;IACb,UAAU;IACV,QAAQ;CACR,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,SAAS,GAAwB,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAExE,8FAA8F;AAC9F,MAAM,MAAM,GAAG,CAAC,IAAY,EAAU,EAAE;IACvC,MAAM,GAAG,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAClC,OAAO,GAAG,GAAG,CAAC,IAAI,GAAG,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAChE,CAAC,CAAC;AAEF,uFAAuF;AACvF,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,QAAgB,EAAY,EAAE,CACvD,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAA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umericAnalysisFields, type StaticAnalysisDict } from "../types/static-analysis.js";
2
+ /** Static analysis flags and counters for a graph node. */
3
+ export declare class StaticAnalysis {
4
+ state: StaticAnalysisDict;
5
+ constructor(state?: StaticAnalysisDict);
6
+ /** Wraps an existing state dict. */
7
+ static fromState(state: StaticAnalysisDict): StaticAnalysis;
8
+ /** Combines with another analysis: flags are OR'd, counters summed. */
9
+ intersect(other: StaticAnalysis): StaticAnalysis;
10
+ /** Only the fields with meaningful values (true or > 0). */
11
+ filter(): StaticAnalysisDict;
12
+ setField(field: CategoricalAnalysisFields, value?: boolean): void;
13
+ incField(field: NumericAnalysisFields, value?: number): void;
14
+ getState(): StaticAnalysisDict;
15
+ /** A bulleted, human-readable summary of the meaningful fields. */
16
+ stringify(): string;
17
+ }
18
+ //# sourceMappingURL=static-analysis.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"static-analysis.d.ts","sourceRoot":"","sources":["../../src/helpers/static-analysis.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,KAAK,yBAAyB,EAE9B,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EAEvB,MAAM,6BAA6B,CAAC;AAkDrC,2DAA2D;AAC3D,qBAAa,cAAc;IAC1B,KAAK,EAAE,kBAAkB,CAAC;IAE1B,YAAY,KAAK,GAAE,kBAAmC,EAErD;IAED,oCAAoC;IACpC,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,kBAAkB,GAAG,cAAc,CAE1D;IAED,uEAAuE;IACvE,SAAS,CAAC,KAAK,EAAE,cAAc,GAAG,cAAc,CAU/C;IAED,4DAA4D;IAC5D,MAAM,IAAI,kBAAkB,CAM3B;IAED,QAAQ,CAAC,KAAK,EAAE,yBAAyB,EAAE,KAAK,UAAO,GAAG,IAAI,CAE7D;IAED,QAAQ,CAAC,KAAK,EAAE,qBAAqB,EAAE,KAAK,SAAI,GAAG,IAAI,CAEtD;IAED,QAAQ,IAAI,kBAAkB,CAE7B;IAED,mEAAmE;IACnE,SAAS,IAAI,MAAM,CAiBlB;CACD"}
@@ -0,0 +1,89 @@
1
+ import { CATEGORICAL_ANALYSIS_FIELDS, NUMERIC_ANALYSIS_FIELDS, } from "../types/static-analysis.js";
2
+ const DESCRIPTIONS = {
3
+ calls_self: "Has recursion. Carefully check the stop conditions and gas griefing.",
4
+ has_assembly: "Uses assembly, make sure the logic is sound.",
5
+ has_block_dependency: "Has a dependency on block number or time. Consider how this could be manipulated.",
6
+ has_contract_creation: "Includes contract creation. Carefully check the constructor parameters.",
7
+ has_external_call: "Makes an external call. Evaluate potential re-entrants and checked statements.",
8
+ has_internal_call: "Makes an internal call. Carefully follow the call-chain to observe state updates and soundness of logic.",
9
+ has_loop: "Has a loop. Be sure to check the condition of the loop and consider potential gas concerns and boundedness.",
10
+ has_modifiers: "Relies on modifiers. These are common for access controls and re-entrancy protections. Evaluate their logic and check where else these states could be updated.",
11
+ has_ownership_transfer: "Includes ownership transfer. These are not inherently bad patterns, even to the zero address, but ensure this transfer is done properly.",
12
+ can_selfdestruct_contract: "Has self-destruct.",
13
+ has_unbounded_loop: "Has an unbounded loop. Follow the loop condition and ensure that there are early stop conditions, or that the logic is sound such that this code can execute given real world parameterization.",
14
+ uses_delegatecall: "Relies on delegatecall. Make sure the return is checked, and that the function guards against re-entrants",
15
+ uses_math: "Uses math, which is not inherently bad, but you should evaluate the units of the math, and make sure overflow or underflow is not possible.",
16
+ uses_txorigin: "Uses tx.origin, which should generally be avoided.",
17
+ writes_state: "Writes to global state. Be certain to consider how this could impact other functions, and make sure that these writes are done properly.",
18
+ };
19
+ /** When both are set, only the first is reported. */
20
+ const DEDUPLICATE = [["has_unbounded_loop", "has_loop"]];
21
+ const initialState = () => {
22
+ const state = {};
23
+ for (const field of CATEGORICAL_ANALYSIS_FIELDS)
24
+ state[field] = false;
25
+ for (const field of NUMERIC_ANALYSIS_FIELDS)
26
+ state[field] = 0;
27
+ return state;
28
+ };
29
+ const entries = (state) => Object.entries(state);
30
+ /** Static analysis flags and counters for a graph node. */
31
+ export class StaticAnalysis {
32
+ state;
33
+ constructor(state = initialState()) {
34
+ this.state = state;
35
+ }
36
+ /** Wraps an existing state dict. */
37
+ static fromState(state) {
38
+ return new StaticAnalysis(state);
39
+ }
40
+ /** Combines with another analysis: flags are OR'd, counters summed. */
41
+ intersect(other) {
42
+ const out = {};
43
+ for (const [field, value] of entries(this.state)) {
44
+ const theirs = other.state[field];
45
+ out[field] =
46
+ typeof value === "boolean"
47
+ ? value || Boolean(theirs)
48
+ : value + Number(theirs ?? 0);
49
+ }
50
+ return StaticAnalysis.fromState(out);
51
+ }
52
+ /** Only the fields with meaningful values (true or > 0). */
53
+ filter() {
54
+ const out = {};
55
+ for (const [field, value] of entries(this.state)) {
56
+ if (typeof value === "boolean" ? value : value > 0)
57
+ out[field] = value;
58
+ }
59
+ return out;
60
+ }
61
+ setField(field, value = true) {
62
+ this.state[field] = value;
63
+ }
64
+ incField(field, value = 1) {
65
+ this.state[field] = Number(this.state[field] ?? 0) + value;
66
+ }
67
+ getState() {
68
+ return this.state;
69
+ }
70
+ /** A bulleted, human-readable summary of the meaningful fields. */
71
+ stringify() {
72
+ const fields = this.filter();
73
+ for (const [higher, lower] of DEDUPLICATE) {
74
+ if (higher in fields && lower in fields)
75
+ delete fields[lower];
76
+ }
77
+ let out = "";
78
+ for (const [field, value] of entries(fields)) {
79
+ const description = DESCRIPTIONS[field];
80
+ // matches the Python SDK's rendering of the value, e.g. "True occurences of has_require"
81
+ const rendered = typeof value === "boolean" ? (value ? "True" : "False") : String(value);
82
+ out += description
83
+ ? `\n- ${description}`
84
+ : `\n- ${rendered} occurences of ${field}`;
85
+ }
86
+ return out.trim();
87
+ }
88
+ }
89
+ //# sourceMappingURL=static-analysis.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"static-analysis.js","sourceRoot":"","sources":["../../src/helpers/static-analysis.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,2BAA2B,EAE3B,uBAAuB,GAIvB,MAAM,6BA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AED,mEAAmE;IACnE,SAAS;QACR,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;QAC7B,KAAK,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,WAAW,EAAE,CAAC;YAC3C,IAAI,MAAM,IAAI,MAAM,IAAI,KAAK,IAAI,MAAM;gBAAE,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;QAC/D,CAAC;QAED,IAAI,GAAG,GAAG,EAAE,CAAC;QACb,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YAC9C,MAAM,WAAW,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;YACxC,yFAAyF;YACzF,MAAM,QAAQ,GACb,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACzE,GAAG,IAAI,WAAW;gBACjB,CAAC,CAAC,OAAO,WAAW,EAAE;gBACtB,CAAC,CAAC,OAAO,QAAQ,kBAAkB,KAAK,EAAE,CAAC;QAC7C,CAAC;QACD,OAAO,GAAG,CAAC,IAAI,EAAE,CAAC;IACnB,CAAC;CACD"}
@@ -0,0 +1,31 @@
1
+ export { BevorClient, type ClientOptions, type HttpMethod, type PaginationOptions, type QueryValue, type RequestConfig, type RequestOptions, type StreamingOptions, } from "./client.js";
2
+ export * from "./errors.js";
3
+ export { CallNode, type CallNodeDict } from "./graph/call-node.js";
4
+ export { GraphCursor } from "./graph/cursor.js";
5
+ export { FieldMetadata } from "./graph/field-metadata.js";
6
+ export { type EdgeFilter, Graph, type GraphSnapshot } from "./graph/graph.js";
7
+ export * from "./helpers/call-chain.js";
8
+ export * from "./helpers/sarif.js";
9
+ export { comparePaths, type FingerprintedSource, fingerprintSource, isUtf8, SKIP_DIRS, SKIP_EXTS, type SourceFile, skipRelativePath, zipFiles, } from "./helpers/source-fingerprint.js";
10
+ export { StaticAnalysis } from "./helpers/static-analysis.js";
11
+ export { PaginatedResource } from "./pagination.js";
12
+ export { AnalysisResources, type AnalysisRunResource, BoundAnalysisResources, } from "./resources/analyses.js";
13
+ export { BoundChatResources, ChatResources } from "./resources/chats.js";
14
+ export { BoundCodesResources, type CodeResource, CodesResources, type UploadFile, } from "./resources/codes.js";
15
+ export { BoundFileResources, FileResources } from "./resources/files.js";
16
+ export { BoundFindingResources, FindingResources, } from "./resources/findings.js";
17
+ export { BoundNodeResources, NodeResources } from "./resources/nodes.js";
18
+ export { ProjectResources } from "./resources/projects.js";
19
+ export type { WithoutPagination, WithoutStreaming, WithPagination, WithStreaming, } from "./resources/shared.js";
20
+ export { AnalysisSummaryResources } from "./resources/summary.js";
21
+ export { BoundTransitionResources, TransitionResources, } from "./resources/transitions.js";
22
+ export { ProjectUserResources } from "./resources/users.js";
23
+ export { AnalysisVersionsResources } from "./resources/versions.js";
24
+ export { EventResource, type EventResourceConfig, type SSEEvent, SSEParser, } from "./streaming.js";
25
+ export type * from "./types/graph-data.js";
26
+ export * from "./types/literals.js";
27
+ export * from "./types/node-types.js";
28
+ export * from "./types/requests.js";
29
+ export * from "./types/responses.js";
30
+ export * from "./types/static-analysis.js";
31
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,WAAW,EACX,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,gBAAgB,GACrB,MAAM,aAAa,CAAC;AACrB,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAE,KAAK,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,m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AAC5D,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EACN,aAAa,EACb,KAAK,mBAAmB,EACxB,KAAK,QAAQ,EACb,SAAS,GACT,MAAM,gBAAgB,CAAC;AAExB,mBAAmB,uBAAuB,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,29 @@
1
+ export { BevorClient, } from "./client.js";
2
+ export * from "./errors.js";
3
+ export { CallNode } from "./graph/call-node.js";
4
+ export { GraphCursor } from "./graph/cursor.js";
5
+ export { FieldMetadata } from "./graph/field-metadata.js";
6
+ export { Graph } from "./graph/graph.js";
7
+ export * from "./helpers/call-chain.js";
8
+ export * from "./helpers/sarif.js";
9
+ export { comparePaths, fingerprintSource, isUtf8, SKIP_DIRS, SKIP_EXTS, skipRelativePath, zipFiles, } from "./helpers/source-fingerprint.js";
10
+ export { StaticAnalysis } from "./helpers/static-analysis.js";
11
+ export { PaginatedResource } from "./pagination.js";
12
+ export { AnalysisResources, BoundAnalysisResources, } from "./resources/analyses.js";
13
+ export { BoundChatResources, ChatResources } from "./resources/chats.js";
14
+ export { BoundCodesResources, CodesResources, } from "./resources/codes.js";
15
+ export { BoundFileResources, FileResources } from "./resources/files.js";
16
+ export { BoundFindingResources, FindingResources, } from "./resources/findings.js";
17
+ export { BoundNodeResources, NodeResources } from "./resources/nodes.js";
18
+ export { ProjectResources } from "./resources/projects.js";
19
+ export { AnalysisSummaryResources } from "./resources/summary.js";
20
+ export { BoundTransitionResources, TransitionResources, } from "./resources/transitions.js";
21
+ export { ProjectUserResources } from "./resources/users.js";
22
+ export { AnalysisVersionsResources } from "./resources/versions.js";
23
+ export { EventResource, SSEParser, } from "./streaming.js";
24
+ export * from "./types/literals.js";
25
+ export * from "./types/node-types.js";
26
+ export * from "./types/requests.js";
27
+ export * from "./types/responses.js";
28
+ export * from "./types/static-analysis.js";
29
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,WAAW,GAQX,MAAM,aAAa,CAAC;AACrB,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAqB,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAmB,KAAK,EAAsB,MAAM,kBAAkB,CAAC;AAC9E,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,OAAO,EACN,YAAY,EAEZ,iBAAiB,EACjB,MAAM,EACN,SAAS,EACT,SAAS,EAET,gBAAgB,EAChB,QAAQ,GACR,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EACN,iBAAiB,EAEjB,sBAAsB,GACtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACzE,OAAO,EACN,mBAAmB,EAEnB,cAAc,GAEd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACzE,OAAO,EACN,qBAAqB,EACrB,gBAAgB,GAChB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAO3D,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EACN,wBAAwB,EACxB,mBAAmB,GACnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EACN,aAAa,EAGb,SAAS,GACT,MAAM,gBAAgB,CAAC;AAGxB,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC"}
package/dist/node.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ import type { SourceFile } from "./helpers/source-fingerprint.js";
2
+ /** Every file under `root`, relative to it. Mirrors the Python SDK's `directory_files`. */
3
+ export declare const directoryFiles: (root: string) => Promise<SourceFile[]>;
4
+ //# sourceMappingURL=node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAkBlE,2FAA2F;AAC3F,eAAO,MAAM,cAAc,SAAgB,MAAM,KAAG,OAAO,CAAC,UAAU,EAAE,CAMtE,CAAC"}
package/dist/node.js ADDED
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Node-only helpers (filesystem access). Import from `@bevor/sdk/node`.
3
+ */
4
+ import { readdir, readFile, stat } from "node:fs/promises";
5
+ import { join } from "node:path";
6
+ /** Relative POSIX paths of every file under `dir`, following file symlinks but not directory ones. */
7
+ const listFiles = async (root, dir = "") => {
8
+ const out = [];
9
+ for (const entry of await readdir(join(root, dir), { withFileTypes: true })) {
10
+ const rel = dir ? `${dir}/${entry.name}` : entry.name;
11
+ if (entry.isDirectory())
12
+ out.push(...(await listFiles(root, rel)));
13
+ else if (entry.isFile())
14
+ out.push(rel);
15
+ else if (entry.isSymbolicLink() &&
16
+ (await stat(join(root, rel)).catch(() => null))?.isFile())
17
+ out.push(rel);
18
+ }
19
+ return out;
20
+ };
21
+ /** Every file under `root`, relative to it. Mirrors the Python SDK's `directory_files`. */
22
+ export const directoryFiles = async (root) => Promise.all((await listFiles(root)).map(async (path) => ({
23
+ path,
24
+ content: new Uint8Array(await readFile(join(root, path))),
25
+ })));
26
+ //# sourceMappingURL=node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.js","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,sGAAsG;AACtG,MAAM,SAAS,GAAG,KAAK,EAAE,IAAY,EAAE,GAAG,GAAG,EAAE,EAAqB,EAAE;IACrE,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,KAAK,MAAM,KAAK,IAAI,MAAM,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;QAC7E,MAAM,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC;QACtD,IAAI,KAAK,CAAC,WAAW,EAAE;YAAE,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,SAAS,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;aAC9D,IAAI,KAAK,CAAC,MAAM,EAAE;YAAE,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;aAClC,IACJ,KAAK,CAAC,cAAc,EAAE;YACtB,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE;YAEzD,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAChB,CAAC;IACD,OAAO,GAAG,CAAC;AACZ,CAAC,CAAC;AAEF,2FAA2F;AAC3F,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EAAE,IAAY,EAAyB,EAAE,CAC3E,OAAO,CAAC,GAAG,CACV,CAAC,MAAM,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;IAC5C,IAAI;IACJ,OAAO,EAAE,IAAI,UAAU,CAAC,MAAM,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;CACzD,CAAC,CAAC,CACH,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { Pagination } from "./types/responses.js";
2
+ /** Incrementally accumulates the pages of a paginated list. */
3
+ export declare class PaginatedResource<T> {
4
+ #private;
5
+ constructor(data: Pagination<T>, fetchPage: (page: number) => Promise<Pagination<T>>);
6
+ /** Every result fetched so far, across pages. */
7
+ get results(): T[];
8
+ /** The most recently fetched page. */
9
+ get current(): Pagination<T>;
10
+ get hasMore(): boolean;
11
+ fetchNext(): Promise<void>;
12
+ }
13
+ //# sourceMappingURL=pagination.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../src/pagination.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,+DAA+D;AAC/D,qBAAa,iBAAiB,CAAC,CAAC;;IAK/B,YACC,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,EACnB,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAKnD;IAED,iDAAiD;IACjD,IAAI,OAAO,IAAI,CAAC,EAAE,CAEjB;IAED,sCAAsC;IACtC,IAAI,OAAO,IAAI,UAAU,CAAC,CAAC,CAAC,CAE3B;IAED,IAAI,OAAO,IAAI,OAAO,CAErB;IAEK,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAM/B;CACD"}