@caido-utils/backend 0.5.0 → 0.5.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.
package/dist/index.d.ts CHANGED
@@ -1,8 +1,6 @@
1
- export { Fetch, type FetchOptions } from "./fetcher";
2
1
  export { createSignal, pausePool, resumePool, runPool, stopPool } from "./pool";
3
2
  export type { PoolCallbacks, PoolConfig, PoolSignal } from "./pool";
4
3
  export { spawnCommand } from "./process";
5
4
  export { getProjectId } from "./project";
6
- export { queryRequests } from "./requests";
7
- export type { QueryRequestsOptions } from "./requests";
5
+ export { Fetch, queryRequests, type FetchOptions, type QueryRequestsOptions, } from "./requests";
8
6
  export { fileExists, readFile, storeFile } from "./storage";
package/dist/index.js CHANGED
@@ -1,6 +1,8 @@
1
- export { Fetch } from "./fetcher.js";
2
- export { createSignal, pausePool, resumePool, runPool, stopPool } from "./pool.js";
3
- export { spawnCommand } from "./process.js";
4
- export { getProjectId } from "./project.js";
5
- export { queryRequests } from "./requests.js";
6
- export { fileExists, readFile, storeFile } from "./storage.js";
1
+ export { createSignal, pausePool, resumePool, runPool, stopPool } from "./pool/index.js";
2
+ export { spawnCommand } from "./process/index.js";
3
+ export { getProjectId } from "./project/index.js";
4
+ export {
5
+ Fetch,
6
+ queryRequests
7
+ } from "./requests/index.js";
8
+ export { fileExists, readFile, storeFile } from "./storage/index.js";
@@ -0,0 +1,2 @@
1
+ export { createSignal, pausePool, resumePool, runPool, stopPool } from "./pool";
2
+ export type { PoolCallbacks, PoolConfig, PoolSignal } from "./pool";
@@ -0,0 +1 @@
1
+ export { createSignal, pausePool, resumePool, runPool, stopPool } from "./pool.js";
@@ -0,0 +1 @@
1
+ export { spawnCommand } from "./spawn";
@@ -0,0 +1 @@
1
+ export { spawnCommand } from "./spawn.js";
@@ -0,0 +1 @@
1
+ export { getProjectId } from "./project";
@@ -0,0 +1 @@
1
+ export { getProjectId } from "./project.js";
@@ -0,0 +1,2 @@
1
+ export { Fetch, type FetchOptions } from "./fetcher";
2
+ export { queryRequests, type QueryRequestsOptions } from "./query";
@@ -0,0 +1,2 @@
1
+ export { Fetch } from "./fetcher.js";
2
+ export { queryRequests } from "./query.js";
@@ -3,6 +3,7 @@ import type { RequestsConnectionItem } from "caido:utils";
3
3
  export type QueryRequestsOptions = {
4
4
  filter?: string;
5
5
  pageSize?: number;
6
+ excludeStaticAssets?: boolean;
6
7
  onPage?: (items: RequestsConnectionItem[]) => void;
7
8
  };
8
9
  /**
@@ -0,0 +1,73 @@
1
+ const STATIC_EXTENSIONS = [
2
+ "apng",
3
+ "avif",
4
+ "gif",
5
+ "jpg",
6
+ "jpeg",
7
+ "pjpeg",
8
+ "pjp",
9
+ "png",
10
+ "svg",
11
+ "webp",
12
+ "bmp",
13
+ "ico",
14
+ "cur",
15
+ "tif",
16
+ "tiff",
17
+ "css",
18
+ "woff",
19
+ "woff2",
20
+ "ttf",
21
+ "eot",
22
+ "js",
23
+ "mjs",
24
+ "jsx",
25
+ "ts",
26
+ "tsx",
27
+ "map",
28
+ "mp4",
29
+ "webm",
30
+ "ogg",
31
+ "mp3",
32
+ "wav",
33
+ "flac",
34
+ "aac",
35
+ "m4a",
36
+ "avi",
37
+ "mov",
38
+ "wmv",
39
+ "flv",
40
+ "mkv"
41
+ ];
42
+ const STATIC_ASSET_FILTER = STATIC_EXTENSIONS.map(
43
+ (ext) => `req.ext.nlike:"%.${ext}"`
44
+ ).join(" AND ");
45
+ export async function queryRequests(sdk, options) {
46
+ const pageSize = options?.pageSize ?? 1e3;
47
+ const results = [];
48
+ let cursor = void 0;
49
+ let fullFilter = options?.filter ?? "";
50
+ if (options?.excludeStaticAssets) {
51
+ fullFilter = fullFilter ? `(${fullFilter}) AND ${STATIC_ASSET_FILTER}` : STATIC_ASSET_FILTER;
52
+ }
53
+ while (true) {
54
+ let query = sdk.requests.query().first(pageSize).ascending("req", "created_at");
55
+ if (fullFilter) {
56
+ query = query.filter(fullFilter);
57
+ }
58
+ if (cursor !== void 0) {
59
+ query = query.after(cursor);
60
+ }
61
+ const page = await query.execute();
62
+ if (page.items.length > 0) {
63
+ results.push(...page.items);
64
+ options?.onPage?.(page.items);
65
+ }
66
+ if (page.pageInfo.hasNextPage) {
67
+ cursor = page.pageInfo.endCursor;
68
+ } else {
69
+ break;
70
+ }
71
+ }
72
+ return results;
73
+ }
@@ -0,0 +1 @@
1
+ export { fileExists, readFile, storeFile } from "./files";
@@ -0,0 +1 @@
1
+ export { fileExists, readFile, storeFile } from "./files.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caido-utils/backend",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
package/dist/requests.js DELETED
@@ -1,25 +0,0 @@
1
- export async function queryRequests(sdk, options) {
2
- const pageSize = options?.pageSize ?? 1e3;
3
- const results = [];
4
- let cursor = void 0;
5
- while (true) {
6
- let query = sdk.requests.query().first(pageSize).ascending("req", "created_at");
7
- if (options?.filter) {
8
- query = query.filter(options.filter);
9
- }
10
- if (cursor !== void 0) {
11
- query = query.after(cursor);
12
- }
13
- const page = await query.execute();
14
- if (page.items.length > 0) {
15
- results.push(...page.items);
16
- options?.onPage?.(page.items);
17
- }
18
- if (page.pageInfo.hasNextPage) {
19
- cursor = page.pageInfo.endCursor;
20
- } else {
21
- break;
22
- }
23
- }
24
- return results;
25
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes