cooper-stack 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/ai.d.ts +60 -0
- package/dist/ai.d.ts.map +1 -0
- package/dist/ai.js +66 -0
- package/dist/ai.js.map +1 -0
- package/dist/api.d.ts +31 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +40 -0
- package/dist/api.js.map +1 -0
- package/dist/auth.d.ts +13 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +16 -0
- package/dist/auth.js.map +1 -0
- package/dist/bridge.d.ts +15 -0
- package/dist/bridge.d.ts.map +1 -0
- package/dist/bridge.js +217 -0
- package/dist/bridge.js.map +1 -0
- package/dist/cache.d.ts +27 -0
- package/dist/cache.d.ts.map +1 -0
- package/dist/cache.js +69 -0
- package/dist/cache.js.map +1 -0
- package/dist/cron.d.ts +22 -0
- package/dist/cron.d.ts.map +1 -0
- package/dist/cron.js +26 -0
- package/dist/cron.js.map +1 -0
- package/dist/db.d.ts +30 -0
- package/dist/db.d.ts.map +1 -0
- package/dist/db.js +75 -0
- package/dist/db.js.map +1 -0
- package/dist/error.d.ts +16 -0
- package/dist/error.d.ts.map +1 -0
- package/dist/error.js +28 -0
- package/dist/error.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/islands.d.ts +16 -0
- package/dist/islands.d.ts.map +1 -0
- package/dist/islands.js +23 -0
- package/dist/islands.js.map +1 -0
- package/dist/middleware.d.ts +20 -0
- package/dist/middleware.d.ts.map +1 -0
- package/dist/middleware.js +26 -0
- package/dist/middleware.js.map +1 -0
- package/dist/pubsub.d.ts +24 -0
- package/dist/pubsub.d.ts.map +1 -0
- package/dist/pubsub.js +48 -0
- package/dist/pubsub.js.map +1 -0
- package/dist/queue.d.ts +36 -0
- package/dist/queue.d.ts.map +1 -0
- package/dist/queue.js +100 -0
- package/dist/queue.js.map +1 -0
- package/dist/registry.d.ts +75 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +41 -0
- package/dist/registry.js.map +1 -0
- package/dist/secrets.d.ts +10 -0
- package/dist/secrets.d.ts.map +1 -0
- package/dist/secrets.js +35 -0
- package/dist/secrets.js.map +1 -0
- package/dist/ssr.d.ts +53 -0
- package/dist/ssr.d.ts.map +1 -0
- package/dist/ssr.js +39 -0
- package/dist/ssr.js.map +1 -0
- package/dist/storage.d.ts +28 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/storage.js +61 -0
- package/dist/storage.js.map +1 -0
- package/package.json +38 -0
- package/src/ai.ts +99 -0
- package/src/api.ts +56 -0
- package/src/auth.ts +16 -0
- package/src/bridge.ts +267 -0
- package/src/cache.ts +86 -0
- package/src/cron.ts +32 -0
- package/src/db.ts +109 -0
- package/src/error.ts +42 -0
- package/src/index.ts +15 -0
- package/src/islands.ts +28 -0
- package/src/middleware.ts +27 -0
- package/src/pubsub.ts +69 -0
- package/src/queue.ts +133 -0
- package/src/registry.ts +98 -0
- package/src/secrets.ts +40 -0
- package/src/ssr.ts +58 -0
- package/src/storage.ts +79 -0
- package/tsconfig.json +17 -0
package/src/queue.ts
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { registry } from "./registry.js";
|
|
2
|
+
|
|
3
|
+
export interface QueueConfig {
|
|
4
|
+
concurrency?: number;
|
|
5
|
+
retries?: number;
|
|
6
|
+
retryDelay?: "fixed" | "exponential";
|
|
7
|
+
timeout?: string;
|
|
8
|
+
deadLetter?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface EnqueueOptions {
|
|
12
|
+
delay?: string;
|
|
13
|
+
priority?: "low" | "normal" | "high";
|
|
14
|
+
dedupeKey?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface QueueClient<T> {
|
|
18
|
+
enqueue(data: T, opts?: EnqueueOptions): Promise<void>;
|
|
19
|
+
worker(name: string, config: { handler: (data: T) => Promise<void>; onFailure?: (data: T, error: Error) => Promise<void> }): any;
|
|
20
|
+
list(): Promise<{ id: string; data: T }[]>;
|
|
21
|
+
delete(id: string): Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Declare a job queue.
|
|
26
|
+
*
|
|
27
|
+
* ```ts
|
|
28
|
+
* export const EmailQueue = queue<{ to: string; subject: string; body: string }>(
|
|
29
|
+
* "email-queue",
|
|
30
|
+
* { concurrency: 10, retries: 3, retryDelay: "exponential", timeout: "30s", deadLetter: "email-dlq" }
|
|
31
|
+
* );
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export function queue<T = any>(name: string, config?: QueueConfig): QueueClient<T> {
|
|
35
|
+
// In-memory queue for local dev — backed by NATS JetStream
|
|
36
|
+
// In production: SQS, Cloud Tasks, Azure Storage Queues, or QStash
|
|
37
|
+
const jobs: { id: string; data: T; attempts: number; priority: string; scheduledAt: number }[] = [];
|
|
38
|
+
let processing = false;
|
|
39
|
+
let workerHandler: ((data: T) => Promise<void>) | null = null;
|
|
40
|
+
let failureHandler: ((data: T, error: Error) => Promise<void>) | null = null;
|
|
41
|
+
const concurrency = config?.concurrency ?? 1;
|
|
42
|
+
const maxRetries = config?.retries ?? 0;
|
|
43
|
+
|
|
44
|
+
const parseDuration = (dur: string): number => {
|
|
45
|
+
const m = dur.match(/^(\d+)(s|m|h|d)$/);
|
|
46
|
+
if (!m) return 0;
|
|
47
|
+
const mult: Record<string, number> = { s: 1000, m: 60000, h: 3600000, d: 86400000 };
|
|
48
|
+
return parseInt(m[1]) * (mult[m[2]] ?? 1000);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const processQueue = async () => {
|
|
52
|
+
if (processing || !workerHandler) return;
|
|
53
|
+
processing = true;
|
|
54
|
+
|
|
55
|
+
while (jobs.length > 0) {
|
|
56
|
+
const batch = jobs.splice(0, concurrency);
|
|
57
|
+
await Promise.allSettled(
|
|
58
|
+
batch.map(async (job) => {
|
|
59
|
+
if (job.scheduledAt > Date.now()) {
|
|
60
|
+
jobs.push(job); // not ready yet
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
try {
|
|
64
|
+
await workerHandler!(job.data);
|
|
65
|
+
} catch (err) {
|
|
66
|
+
job.attempts++;
|
|
67
|
+
if (job.attempts <= maxRetries) {
|
|
68
|
+
const delay = config?.retryDelay === "exponential"
|
|
69
|
+
? Math.pow(2, job.attempts - 1) * 1000
|
|
70
|
+
: 1000;
|
|
71
|
+
job.scheduledAt = Date.now() + delay;
|
|
72
|
+
jobs.push(job);
|
|
73
|
+
} else if (failureHandler) {
|
|
74
|
+
await failureHandler(job.data, err as Error);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
})
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
processing = false;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const client: QueueClient<T> = {
|
|
85
|
+
async enqueue(data: T, opts?: EnqueueOptions) {
|
|
86
|
+
const id = crypto.randomUUID();
|
|
87
|
+
const delay = opts?.delay ? parseDuration(opts.delay) : 0;
|
|
88
|
+
jobs.push({
|
|
89
|
+
id,
|
|
90
|
+
data,
|
|
91
|
+
attempts: 0,
|
|
92
|
+
priority: opts?.priority ?? "normal",
|
|
93
|
+
scheduledAt: Date.now() + delay,
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
// Sort by priority
|
|
97
|
+
const priorityOrder: Record<string, number> = { high: 0, normal: 1, low: 2 };
|
|
98
|
+
jobs.sort((a, b) => (priorityOrder[a.priority] ?? 1) - (priorityOrder[b.priority] ?? 1));
|
|
99
|
+
|
|
100
|
+
// Trigger processing
|
|
101
|
+
setImmediate(() => processQueue());
|
|
102
|
+
},
|
|
103
|
+
|
|
104
|
+
worker(workerName: string, workerConfig) {
|
|
105
|
+
workerHandler = workerConfig.handler;
|
|
106
|
+
failureHandler = workerConfig.onFailure ?? null;
|
|
107
|
+
|
|
108
|
+
registry.registerQueue(name, {
|
|
109
|
+
name,
|
|
110
|
+
options: config ?? {},
|
|
111
|
+
worker: { name: workerName, handler: workerConfig.handler, onFailure: workerConfig.onFailure },
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
// Start processing any already-queued jobs
|
|
115
|
+
setImmediate(() => processQueue());
|
|
116
|
+
|
|
117
|
+
return { _cooper_type: "queue_worker", queue: name, name: workerName };
|
|
118
|
+
},
|
|
119
|
+
|
|
120
|
+
async list() {
|
|
121
|
+
return jobs.map((j) => ({ id: j.id, data: j.data }));
|
|
122
|
+
},
|
|
123
|
+
|
|
124
|
+
async delete(id: string) {
|
|
125
|
+
const idx = jobs.findIndex((j) => j.id === id);
|
|
126
|
+
if (idx >= 0) jobs.splice(idx, 1);
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
registry.registerQueue(name, { name, options: config ?? {} });
|
|
131
|
+
|
|
132
|
+
return client;
|
|
133
|
+
}
|
package/src/registry.ts
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal registry — Cooper's Rust runtime communicates with JS workers
|
|
3
|
+
* by referencing registered handlers by name. This module tracks all
|
|
4
|
+
* declarations (routes, topics, crons, queues, etc.) so the bridge
|
|
5
|
+
* can look them up at runtime.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export interface RegisteredRoute {
|
|
9
|
+
method: string;
|
|
10
|
+
path: string;
|
|
11
|
+
auth: boolean;
|
|
12
|
+
stream?: "sse" | "websocket";
|
|
13
|
+
validate?: any; // Zod schema
|
|
14
|
+
middleware: MiddlewareFn[];
|
|
15
|
+
handler: Function;
|
|
16
|
+
exportName: string;
|
|
17
|
+
sourceFile: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface RegisteredTopic {
|
|
21
|
+
name: string;
|
|
22
|
+
subscribers: Map<string, { handler: Function; options: any }>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface RegisteredCron {
|
|
26
|
+
name: string;
|
|
27
|
+
schedule: string;
|
|
28
|
+
handler: Function;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface RegisteredQueue {
|
|
32
|
+
name: string;
|
|
33
|
+
options: any;
|
|
34
|
+
worker?: { name: string; handler: Function; onFailure?: Function };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface RegisteredDatabase {
|
|
38
|
+
name: string;
|
|
39
|
+
engine: string;
|
|
40
|
+
pool: any;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface RegisteredCache {
|
|
44
|
+
name: string;
|
|
45
|
+
options: any;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface RegisteredBucket {
|
|
49
|
+
name: string;
|
|
50
|
+
options: any;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export type MiddlewareFn = (req: any, next: (req: any) => Promise<any>) => Promise<any>;
|
|
54
|
+
|
|
55
|
+
export type AuthHandlerFn = (token: string) => Promise<Record<string, any>>;
|
|
56
|
+
|
|
57
|
+
class Registry {
|
|
58
|
+
routes: Map<string, RegisteredRoute> = new Map();
|
|
59
|
+
topics: Map<string, RegisteredTopic> = new Map();
|
|
60
|
+
crons: Map<string, RegisteredCron> = new Map();
|
|
61
|
+
queues: Map<string, RegisteredQueue> = new Map();
|
|
62
|
+
databases: Map<string, RegisteredDatabase> = new Map();
|
|
63
|
+
caches: Map<string, RegisteredCache> = new Map();
|
|
64
|
+
buckets: Map<string, RegisteredBucket> = new Map();
|
|
65
|
+
secrets: Map<string, () => Promise<string>> = new Map();
|
|
66
|
+
globalMiddleware: MiddlewareFn[] = [];
|
|
67
|
+
authHandler: AuthHandlerFn | null = null;
|
|
68
|
+
|
|
69
|
+
registerRoute(key: string, route: RegisteredRoute) {
|
|
70
|
+
this.routes.set(key, route);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
registerTopic(name: string, topic: RegisteredTopic) {
|
|
74
|
+
this.topics.set(name, topic);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
registerCron(name: string, cron: RegisteredCron) {
|
|
78
|
+
this.crons.set(name, cron);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
registerQueue(name: string, queue: RegisteredQueue) {
|
|
82
|
+
this.queues.set(name, queue);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
registerDatabase(name: string, db: RegisteredDatabase) {
|
|
86
|
+
this.databases.set(name, db);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
setAuthHandler(handler: AuthHandlerFn) {
|
|
90
|
+
this.authHandler = handler;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
addGlobalMiddleware(mw: MiddlewareFn) {
|
|
94
|
+
this.globalMiddleware.push(mw);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export const registry = new Registry();
|
package/src/secrets.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Declare a secret — fetched at runtime, never in .env or source code.
|
|
3
|
+
*
|
|
4
|
+
* ```ts
|
|
5
|
+
* const stripeKey = secret("stripe-api-key");
|
|
6
|
+
* const client = new Stripe(await stripeKey());
|
|
7
|
+
* ```
|
|
8
|
+
*/
|
|
9
|
+
export function secret(name: string): () => Promise<string> {
|
|
10
|
+
let cached: string | null = null;
|
|
11
|
+
|
|
12
|
+
const resolve = async (): Promise<string> => {
|
|
13
|
+
if (cached !== null) return cached;
|
|
14
|
+
|
|
15
|
+
// 1. Check env var (set by `cooper secrets set`)
|
|
16
|
+
const envKey = `COOPER_SECRET_${name.toUpperCase().replace(/-/g, "_")}`;
|
|
17
|
+
const envVal = process.env[envKey];
|
|
18
|
+
if (envVal) {
|
|
19
|
+
cached = envVal;
|
|
20
|
+
return envVal;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// 2. Check .cooper/secrets/<env>/<name>
|
|
24
|
+
const fs = require("node:fs");
|
|
25
|
+
const path = require("node:path");
|
|
26
|
+
const env = process.env.COOPER_ENV ?? "local";
|
|
27
|
+
const secretPath = path.join(".cooper", "secrets", env, name);
|
|
28
|
+
if (fs.existsSync(secretPath)) {
|
|
29
|
+
const val: string = fs.readFileSync(secretPath, "utf-8").trim();
|
|
30
|
+
cached = val;
|
|
31
|
+
return val;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
throw new Error(
|
|
35
|
+
`Secret "${name}" not found. Set it with: cooper secrets set ${name} --env ${env}`
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
return resolve;
|
|
40
|
+
}
|
package/src/ssr.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export interface PageConfig {
|
|
2
|
+
cache?: string;
|
|
3
|
+
auth?: boolean;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface PageContext {
|
|
7
|
+
params: Record<string, string>;
|
|
8
|
+
req?: any;
|
|
9
|
+
data?: any;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Define a server-rendered page.
|
|
14
|
+
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* export default page(async ({ params }) => {
|
|
17
|
+
* const { user } = await UsersService.getUser({ id: params.id });
|
|
18
|
+
* return <div><h1>{user.name}</h1></div>;
|
|
19
|
+
* });
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export function page<T = any>(
|
|
23
|
+
render: (ctx: PageContext) => Promise<T>
|
|
24
|
+
): { _cooper_type: "page"; render: typeof render } {
|
|
25
|
+
return { _cooper_type: "page", render };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Define a layout that wraps pages.
|
|
30
|
+
*
|
|
31
|
+
* ```ts
|
|
32
|
+
* export default layout(({ children }) => (
|
|
33
|
+
* <div><Nav /><main>{children}</main><Footer /></div>
|
|
34
|
+
* ));
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export function layout<T = any>(
|
|
38
|
+
render: (props: { children: any }) => T
|
|
39
|
+
): { _cooper_type: "layout"; render: typeof render } {
|
|
40
|
+
return { _cooper_type: "layout", render };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Define a page data loader — runs on the server, data passed to the page.
|
|
45
|
+
*/
|
|
46
|
+
export function pageLoader<T>(
|
|
47
|
+
loader: (ctx: PageContext) => Promise<T>
|
|
48
|
+
): { _cooper_type: "loader"; loader: typeof loader } {
|
|
49
|
+
return { _cooper_type: "loader", loader };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Suspense boundary for streaming SSR.
|
|
54
|
+
*/
|
|
55
|
+
export function Suspense(_props: { fallback: any; children: any }) {
|
|
56
|
+
// Handled by the SSR renderer — this is a marker component
|
|
57
|
+
return null;
|
|
58
|
+
}
|
package/src/storage.ts
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
export interface BucketConfig {
|
|
2
|
+
public?: boolean;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export interface BucketClient {
|
|
6
|
+
upload(key: string, data: Buffer | Uint8Array, opts?: { contentType?: string }): Promise<void>;
|
|
7
|
+
download(key: string): Promise<Buffer>;
|
|
8
|
+
signedUrl(key: string, opts?: { ttl?: string }): Promise<string>;
|
|
9
|
+
delete(key: string): Promise<void>;
|
|
10
|
+
list(prefix?: string): Promise<{ key: string; size: number; lastModified: Date }[]>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Declare an object storage bucket.
|
|
15
|
+
*
|
|
16
|
+
* ```ts
|
|
17
|
+
* export const avatars = bucket("avatars", { public: true });
|
|
18
|
+
* await avatars.upload("user-123/avatar.png", buffer, { contentType: "image/png" });
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export function bucket(name: string, config?: BucketConfig): BucketClient {
|
|
22
|
+
const fs = require("node:fs");
|
|
23
|
+
const path = require("node:path");
|
|
24
|
+
|
|
25
|
+
// Local storage directory — in production this maps to S3/GCS/Azure Blob
|
|
26
|
+
const localDir = path.join(
|
|
27
|
+
process.env.COOPER_STORAGE_DIR ?? ".cooper/storage",
|
|
28
|
+
name
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
async upload(key: string, data: Buffer | Uint8Array, opts?: { contentType?: string }) {
|
|
33
|
+
const fullPath = path.join(localDir, key);
|
|
34
|
+
fs.mkdirSync(path.dirname(fullPath), { recursive: true });
|
|
35
|
+
fs.writeFileSync(fullPath, data);
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
async download(key: string): Promise<Buffer> {
|
|
39
|
+
const fullPath = path.join(localDir, key);
|
|
40
|
+
return fs.readFileSync(fullPath);
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
async signedUrl(key: string, opts?: { ttl?: string }): Promise<string> {
|
|
44
|
+
// In local dev, return a direct file path
|
|
45
|
+
// In production, generate a presigned S3/GCS URL
|
|
46
|
+
return `http://localhost:9400/storage/${name}/${key}`;
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
async delete(key: string): Promise<void> {
|
|
50
|
+
const fullPath = path.join(localDir, key);
|
|
51
|
+
if (fs.existsSync(fullPath)) fs.unlinkSync(fullPath);
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
async list(prefix?: string) {
|
|
55
|
+
const dir = prefix ? path.join(localDir, prefix) : localDir;
|
|
56
|
+
if (!fs.existsSync(dir)) return [];
|
|
57
|
+
|
|
58
|
+
const entries: { key: string; size: number; lastModified: Date }[] = [];
|
|
59
|
+
const walk = (d: string, rel: string) => {
|
|
60
|
+
for (const entry of fs.readdirSync(d, { withFileTypes: true })) {
|
|
61
|
+
const fullPath = path.join(d, entry.name);
|
|
62
|
+
const relPath = rel ? `${rel}/${entry.name}` : entry.name;
|
|
63
|
+
if (entry.isDirectory()) {
|
|
64
|
+
walk(fullPath, relPath);
|
|
65
|
+
} else {
|
|
66
|
+
const stat = fs.statSync(fullPath);
|
|
67
|
+
entries.push({
|
|
68
|
+
key: relPath,
|
|
69
|
+
size: stat.size,
|
|
70
|
+
lastModified: stat.mtime,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
walk(dir, "");
|
|
76
|
+
return entries;
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"declaration": true,
|
|
7
|
+
"declarationMap": true,
|
|
8
|
+
"sourceMap": true,
|
|
9
|
+
"outDir": "dist",
|
|
10
|
+
"rootDir": "src",
|
|
11
|
+
"strict": true,
|
|
12
|
+
"esModuleInterop": true,
|
|
13
|
+
"skipLibCheck": true,
|
|
14
|
+
"forceConsistentCasingInFileNames": true
|
|
15
|
+
},
|
|
16
|
+
"include": ["src/**/*.ts"]
|
|
17
|
+
}
|