flingit 0.0.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.
- package/README.md +84 -0
- package/dist/cli/commands/db.d.ts +9 -0
- package/dist/cli/commands/db.d.ts.map +1 -0
- package/dist/cli/commands/db.js +215 -0
- package/dist/cli/commands/db.js.map +1 -0
- package/dist/cli/commands/dev.d.ts +6 -0
- package/dist/cli/commands/dev.d.ts.map +1 -0
- package/dist/cli/commands/dev.js +145 -0
- package/dist/cli/commands/dev.js.map +1 -0
- package/dist/cli/commands/feedback.d.ts +6 -0
- package/dist/cli/commands/feedback.d.ts.map +1 -0
- package/dist/cli/commands/feedback.js +116 -0
- package/dist/cli/commands/feedback.js.map +1 -0
- package/dist/cli/commands/init.d.ts +6 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +161 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/launch.d.ts +12 -0
- package/dist/cli/commands/launch.d.ts.map +1 -0
- package/dist/cli/commands/launch.js +176 -0
- package/dist/cli/commands/launch.js.map +1 -0
- package/dist/cli/commands/login.d.ts +6 -0
- package/dist/cli/commands/login.d.ts.map +1 -0
- package/dist/cli/commands/login.js +90 -0
- package/dist/cli/commands/login.js.map +1 -0
- package/dist/cli/commands/logout.d.ts +6 -0
- package/dist/cli/commands/logout.d.ts.map +1 -0
- package/dist/cli/commands/logout.js +32 -0
- package/dist/cli/commands/logout.js.map +1 -0
- package/dist/cli/commands/logs.d.ts +12 -0
- package/dist/cli/commands/logs.d.ts.map +1 -0
- package/dist/cli/commands/logs.js +261 -0
- package/dist/cli/commands/logs.js.map +1 -0
- package/dist/cli/commands/onboard.d.ts +22 -0
- package/dist/cli/commands/onboard.d.ts.map +1 -0
- package/dist/cli/commands/onboard.js +244 -0
- package/dist/cli/commands/onboard.js.map +1 -0
- package/dist/cli/commands/project.d.ts +6 -0
- package/dist/cli/commands/project.d.ts.map +1 -0
- package/dist/cli/commands/project.js +142 -0
- package/dist/cli/commands/project.js.map +1 -0
- package/dist/cli/commands/push.d.ts +6 -0
- package/dist/cli/commands/push.d.ts.map +1 -0
- package/dist/cli/commands/push.js +351 -0
- package/dist/cli/commands/push.js.map +1 -0
- package/dist/cli/commands/register.d.ts +6 -0
- package/dist/cli/commands/register.d.ts.map +1 -0
- package/dist/cli/commands/register.js +115 -0
- package/dist/cli/commands/register.js.map +1 -0
- package/dist/cli/commands/secret.d.ts +11 -0
- package/dist/cli/commands/secret.d.ts.map +1 -0
- package/dist/cli/commands/secret.js +124 -0
- package/dist/cli/commands/secret.js.map +1 -0
- package/dist/cli/commands/whoami.d.ts +6 -0
- package/dist/cli/commands/whoami.d.ts.map +1 -0
- package/dist/cli/commands/whoami.js +54 -0
- package/dist/cli/commands/whoami.js.map +1 -0
- package/dist/cli/deploy/assets.d.ts +73 -0
- package/dist/cli/deploy/assets.d.ts.map +1 -0
- package/dist/cli/deploy/assets.js +167 -0
- package/dist/cli/deploy/assets.js.map +1 -0
- package/dist/cli/deploy/base64-stream.d.ts +16 -0
- package/dist/cli/deploy/base64-stream.d.ts.map +1 -0
- package/dist/cli/deploy/base64-stream.js +44 -0
- package/dist/cli/deploy/base64-stream.js.map +1 -0
- package/dist/cli/deploy/bucket-stream.d.ts +18 -0
- package/dist/cli/deploy/bucket-stream.d.ts.map +1 -0
- package/dist/cli/deploy/bucket-stream.js +63 -0
- package/dist/cli/deploy/bucket-stream.js.map +1 -0
- package/dist/cli/deploy/bundler.d.ts +22 -0
- package/dist/cli/deploy/bundler.d.ts.map +1 -0
- package/dist/cli/deploy/bundler.js +131 -0
- package/dist/cli/deploy/bundler.js.map +1 -0
- package/dist/cli/deploy/worker-entry.d.ts +14 -0
- package/dist/cli/deploy/worker-entry.d.ts.map +1 -0
- package/dist/cli/deploy/worker-entry.js +60 -0
- package/dist/cli/deploy/worker-entry.js.map +1 -0
- package/dist/cli/deploy/wrangler-config.d.ts +20 -0
- package/dist/cli/deploy/wrangler-config.d.ts.map +1 -0
- package/dist/cli/deploy/wrangler-config.js +54 -0
- package/dist/cli/deploy/wrangler-config.js.map +1 -0
- package/dist/cli/index.d.ts +10 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +72 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/utils/config.d.ts +39 -0
- package/dist/cli/utils/config.d.ts.map +1 -0
- package/dist/cli/utils/config.js +105 -0
- package/dist/cli/utils/config.js.map +1 -0
- package/dist/cli/utils/duration.d.ts +21 -0
- package/dist/cli/utils/duration.d.ts.map +1 -0
- package/dist/cli/utils/duration.js +44 -0
- package/dist/cli/utils/duration.js.map +1 -0
- package/dist/cli/utils/environment.d.ts +17 -0
- package/dist/cli/utils/environment.d.ts.map +1 -0
- package/dist/cli/utils/environment.js +27 -0
- package/dist/cli/utils/environment.js.map +1 -0
- package/dist/cli/utils/project.d.ts +24 -0
- package/dist/cli/utils/project.d.ts.map +1 -0
- package/dist/cli/utils/project.js +47 -0
- package/dist/cli/utils/project.js.map +1 -0
- package/dist/cli/utils/registry.d.ts +34 -0
- package/dist/cli/utils/registry.d.ts.map +1 -0
- package/dist/cli/utils/registry.js +94 -0
- package/dist/cli/utils/registry.js.map +1 -0
- package/dist/cli/utils/token.d.ts +12 -0
- package/dist/cli/utils/token.d.ts.map +1 -0
- package/dist/cli/utils/token.js +27 -0
- package/dist/cli/utils/token.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/runtime/cron.d.ts +50 -0
- package/dist/runtime/cron.d.ts.map +1 -0
- package/dist/runtime/cron.js +80 -0
- package/dist/runtime/cron.js.map +1 -0
- package/dist/runtime/db.d.ts +93 -0
- package/dist/runtime/db.d.ts.map +1 -0
- package/dist/runtime/db.js +137 -0
- package/dist/runtime/db.js.map +1 -0
- package/dist/runtime/http.d.ts +33 -0
- package/dist/runtime/http.d.ts.map +1 -0
- package/dist/runtime/http.js +36 -0
- package/dist/runtime/http.js.map +1 -0
- package/dist/runtime/log.d.ts +90 -0
- package/dist/runtime/log.d.ts.map +1 -0
- package/dist/runtime/log.js +211 -0
- package/dist/runtime/log.js.map +1 -0
- package/dist/runtime/migrate.d.ts +54 -0
- package/dist/runtime/migrate.d.ts.map +1 -0
- package/dist/runtime/migrate.js +130 -0
- package/dist/runtime/migrate.js.map +1 -0
- package/dist/runtime/secrets.d.ts +36 -0
- package/dist/runtime/secrets.d.ts.map +1 -0
- package/dist/runtime/secrets.js +75 -0
- package/dist/runtime/secrets.js.map +1 -0
- package/dist/worker-runtime/index.d.ts +79 -0
- package/dist/worker-runtime/index.d.ts.map +1 -0
- package/dist/worker-runtime/index.js +203 -0
- package/dist/worker-runtime/index.js.map +1 -0
- package/package.json +81 -0
- package/templates/default/.nvmrc +1 -0
- package/templates/default/CLAUDE.md +197 -0
- package/templates/default/index.html +13 -0
- package/templates/default/package.json +25 -0
- package/templates/default/public/vite.svg +1 -0
- package/templates/default/skills/fling/API.md +335 -0
- package/templates/default/skills/fling/EXAMPLES.md +204 -0
- package/templates/default/skills/fling/FEEDBACK.md +73 -0
- package/templates/default/skills/fling/SKILL.md +159 -0
- package/templates/default/src/react-app/App.css +34 -0
- package/templates/default/src/react-app/App.tsx +27 -0
- package/templates/default/src/react-app/index.css +15 -0
- package/templates/default/src/react-app/main.tsx +10 -0
- package/templates/default/src/react-app/vite-env.d.ts +1 -0
- package/templates/default/src/worker/index.ts +27 -0
- package/templates/default/tsconfig.app.json +22 -0
- package/templates/default/tsconfig.json +7 -0
- package/templates/default/tsconfig.worker.json +11 -0
- package/templates/default/vite.config.ts +21 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Environment targeting utilities.
|
|
3
|
+
* Provides helpers for determining target environment (local vs prod) from CLI options.
|
|
4
|
+
*/
|
|
5
|
+
import { Command } from "commander";
|
|
6
|
+
export type TargetEnv = "local" | "prod";
|
|
7
|
+
/**
|
|
8
|
+
* Get target environment from a Command's global options.
|
|
9
|
+
* Handles type casting internally so callers don't need to.
|
|
10
|
+
*/
|
|
11
|
+
export declare function getTargetEnv(command: Command): TargetEnv;
|
|
12
|
+
/**
|
|
13
|
+
* Require login when targeting prod environment.
|
|
14
|
+
* Exits with helpful error message if not logged in.
|
|
15
|
+
*/
|
|
16
|
+
export declare function requireProdAuth(env: TargetEnv): void;
|
|
17
|
+
//# sourceMappingURL=environment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/environment.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,MAAM,CAAC;AAEzC;;;GAGG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS,CAGxD;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,SAAS,GAAG,IAAI,CAQpD"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Environment targeting utilities.
|
|
3
|
+
* Provides helpers for determining target environment (local vs prod) from CLI options.
|
|
4
|
+
*/
|
|
5
|
+
import { isLoggedIn } from "./config.js";
|
|
6
|
+
/**
|
|
7
|
+
* Get target environment from a Command's global options.
|
|
8
|
+
* Handles type casting internally so callers don't need to.
|
|
9
|
+
*/
|
|
10
|
+
export function getTargetEnv(command) {
|
|
11
|
+
const opts = command.optsWithGlobals();
|
|
12
|
+
return opts["prod"] ? "prod" : "local";
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Require login when targeting prod environment.
|
|
16
|
+
* Exits with helpful error message if not logged in.
|
|
17
|
+
*/
|
|
18
|
+
export function requireProdAuth(env) {
|
|
19
|
+
if (env === "prod" && !isLoggedIn()) {
|
|
20
|
+
console.error("Error: Not logged in - cannot access production environment.\n");
|
|
21
|
+
console.error("To connect to Fling platform, run:");
|
|
22
|
+
console.error(" fling login\n");
|
|
23
|
+
console.error("To work with local environment instead, remove the --prod flag.");
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=environment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment.js","sourceRoot":"","sources":["../../../src/cli/utils/environment.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAIzC;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,OAAgB;IAC3C,MAAM,IAAI,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IACvC,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;AACzC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,GAAc;IAC5C,IAAI,GAAG,KAAK,MAAM,IAAI,CAAC,UAAU,EAAE,EAAE,CAAC;QACpC,OAAO,CAAC,KAAK,CAAC,gEAAgE,CAAC,CAAC;QAChF,OAAO,CAAC,KAAK,CAAC,oCAAoC,CAAC,CAAC;QACpD,OAAO,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;QACjC,OAAO,CAAC,KAAK,CAAC,iEAAiE,CAAC,CAAC;QACjF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project utility functions.
|
|
3
|
+
*
|
|
4
|
+
* Provides helpers for locating project files and validating project structure.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Get the worker entry point path.
|
|
8
|
+
* Always expects src/worker/index.ts.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getWorkerEntryPath(projectDir: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* Check if worker entry point exists.
|
|
13
|
+
*/
|
|
14
|
+
export declare function hasWorkerEntry(projectDir: string): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Check if a directory is a Fling project root (has a fling Claude skill).
|
|
17
|
+
*/
|
|
18
|
+
export declare function isProjectRoot(dir: string): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Walk up from startDir looking for an enclosing Fling project.
|
|
21
|
+
* Returns the project root path, or null if none found.
|
|
22
|
+
*/
|
|
23
|
+
export declare function findEnclosingProject(startDir: string): string | null;
|
|
24
|
+
//# sourceMappingURL=project.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/project.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAE7D;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAE1D;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAElD;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAepE"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project utility functions.
|
|
3
|
+
*
|
|
4
|
+
* Provides helpers for locating project files and validating project structure.
|
|
5
|
+
*/
|
|
6
|
+
import { existsSync } from "node:fs";
|
|
7
|
+
import { join, dirname, resolve } from "node:path";
|
|
8
|
+
/**
|
|
9
|
+
* Get the worker entry point path.
|
|
10
|
+
* Always expects src/worker/index.ts.
|
|
11
|
+
*/
|
|
12
|
+
export function getWorkerEntryPath(projectDir) {
|
|
13
|
+
return join(projectDir, "src", "worker", "index.ts");
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Check if worker entry point exists.
|
|
17
|
+
*/
|
|
18
|
+
export function hasWorkerEntry(projectDir) {
|
|
19
|
+
return existsSync(getWorkerEntryPath(projectDir));
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Check if a directory is a Fling project root (has a fling Claude skill).
|
|
23
|
+
*/
|
|
24
|
+
export function isProjectRoot(dir) {
|
|
25
|
+
return existsSync(join(dir, ".claude", "skills", "fling"));
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Walk up from startDir looking for an enclosing Fling project.
|
|
29
|
+
* Returns the project root path, or null if none found.
|
|
30
|
+
*/
|
|
31
|
+
export function findEnclosingProject(startDir) {
|
|
32
|
+
let current = resolve(startDir);
|
|
33
|
+
let parent = dirname(current);
|
|
34
|
+
while (current !== parent) {
|
|
35
|
+
if (isProjectRoot(current)) {
|
|
36
|
+
return current;
|
|
37
|
+
}
|
|
38
|
+
current = parent;
|
|
39
|
+
parent = dirname(current);
|
|
40
|
+
}
|
|
41
|
+
// Check the filesystem root itself
|
|
42
|
+
if (isProjectRoot(current)) {
|
|
43
|
+
return current;
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=project.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.js","sourceRoot":"","sources":["../../../src/cli/utils/project.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEnD;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,UAAkB;IACnD,OAAO,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;AACvD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,UAAkB;IAC/C,OAAO,UAAU,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC,CAAC;AACpD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,GAAW;IACvC,OAAO,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;AAC7D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,QAAgB;IACnD,IAAI,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAChC,IAAI,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC9B,OAAO,OAAO,KAAK,MAAM,EAAE,CAAC;QAC1B,IAAI,aAAa,CAAC,OAAO,CAAC,EAAE,CAAC;YAC3B,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,OAAO,GAAG,MAAM,CAAC;QACjB,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5B,CAAC;IACD,mCAAmC;IACnC,IAAI,aAAa,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3B,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project registry utilities.
|
|
3
|
+
* Manages a list of known Fling project paths in ~/.fling/projects.json
|
|
4
|
+
* (or FLING_CONFIG_DIR if set).
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Read the project registry. Returns an empty array if the file
|
|
8
|
+
* is missing or malformed.
|
|
9
|
+
*/
|
|
10
|
+
export declare function readRegistry(): string[];
|
|
11
|
+
/**
|
|
12
|
+
* Write the project registry.
|
|
13
|
+
*/
|
|
14
|
+
export declare function writeRegistry(projects: string[]): void;
|
|
15
|
+
/**
|
|
16
|
+
* Register a project path. Idempotent — resolves to absolute path
|
|
17
|
+
* before storing.
|
|
18
|
+
*/
|
|
19
|
+
export declare function registerProject(projectPath: string): void;
|
|
20
|
+
/**
|
|
21
|
+
* Unregister a project path.
|
|
22
|
+
*/
|
|
23
|
+
export declare function unregisterProject(projectPath: string): void;
|
|
24
|
+
/**
|
|
25
|
+
* Get valid projects — those whose directories still exist and
|
|
26
|
+
* contain a .fling/ subdirectory. Stale entries are auto-pruned
|
|
27
|
+
* from the registry file.
|
|
28
|
+
*/
|
|
29
|
+
export declare function getValidProjects(): string[];
|
|
30
|
+
/**
|
|
31
|
+
* Check if a path is registered.
|
|
32
|
+
*/
|
|
33
|
+
export declare function isRegistered(projectPath: string): boolean;
|
|
34
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/registry.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAuBH;;;GAGG;AACH,wBAAgB,YAAY,IAAI,MAAM,EAAE,CAcvC;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,CAOtD;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAOzD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAO3D;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,EAAE,CAS3C;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAGzD"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project registry utilities.
|
|
3
|
+
* Manages a list of known Fling project paths in ~/.fling/projects.json
|
|
4
|
+
* (or FLING_CONFIG_DIR if set).
|
|
5
|
+
*/
|
|
6
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
7
|
+
import { join, resolve } from "node:path";
|
|
8
|
+
import { homedir } from "node:os";
|
|
9
|
+
import { isProjectRoot } from "./project.js";
|
|
10
|
+
function getConfigDir() {
|
|
11
|
+
const envDir = process.env["FLING_CONFIG_DIR"];
|
|
12
|
+
if (envDir) {
|
|
13
|
+
return envDir;
|
|
14
|
+
}
|
|
15
|
+
return join(homedir(), ".fling");
|
|
16
|
+
}
|
|
17
|
+
function getRegistryPath() {
|
|
18
|
+
return join(getConfigDir(), "projects.json");
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Read the project registry. Returns an empty array if the file
|
|
22
|
+
* is missing or malformed.
|
|
23
|
+
*/
|
|
24
|
+
export function readRegistry() {
|
|
25
|
+
const registryPath = getRegistryPath();
|
|
26
|
+
if (!existsSync(registryPath)) {
|
|
27
|
+
return [];
|
|
28
|
+
}
|
|
29
|
+
try {
|
|
30
|
+
const data = JSON.parse(readFileSync(registryPath, "utf-8"));
|
|
31
|
+
if (Array.isArray(data.projects)) {
|
|
32
|
+
return data.projects;
|
|
33
|
+
}
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return [];
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Write the project registry.
|
|
42
|
+
*/
|
|
43
|
+
export function writeRegistry(projects) {
|
|
44
|
+
const configDir = getConfigDir();
|
|
45
|
+
if (!existsSync(configDir)) {
|
|
46
|
+
mkdirSync(configDir, { recursive: true });
|
|
47
|
+
}
|
|
48
|
+
const data = { projects };
|
|
49
|
+
writeFileSync(getRegistryPath(), JSON.stringify(data, null, 2) + "\n");
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Register a project path. Idempotent — resolves to absolute path
|
|
53
|
+
* before storing.
|
|
54
|
+
*/
|
|
55
|
+
export function registerProject(projectPath) {
|
|
56
|
+
const abs = resolve(projectPath);
|
|
57
|
+
const projects = readRegistry();
|
|
58
|
+
if (!projects.includes(abs)) {
|
|
59
|
+
projects.push(abs);
|
|
60
|
+
writeRegistry(projects);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Unregister a project path.
|
|
65
|
+
*/
|
|
66
|
+
export function unregisterProject(projectPath) {
|
|
67
|
+
const abs = resolve(projectPath);
|
|
68
|
+
const projects = readRegistry();
|
|
69
|
+
const filtered = projects.filter((p) => p !== abs);
|
|
70
|
+
if (filtered.length !== projects.length) {
|
|
71
|
+
writeRegistry(filtered);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Get valid projects — those whose directories still exist and
|
|
76
|
+
* contain a .fling/ subdirectory. Stale entries are auto-pruned
|
|
77
|
+
* from the registry file.
|
|
78
|
+
*/
|
|
79
|
+
export function getValidProjects() {
|
|
80
|
+
const projects = readRegistry();
|
|
81
|
+
const valid = projects.filter((p) => existsSync(p) && isProjectRoot(p));
|
|
82
|
+
if (valid.length !== projects.length) {
|
|
83
|
+
writeRegistry(valid);
|
|
84
|
+
}
|
|
85
|
+
return valid;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Check if a path is registered.
|
|
89
|
+
*/
|
|
90
|
+
export function isRegistered(projectPath) {
|
|
91
|
+
const abs = resolve(projectPath);
|
|
92
|
+
return readRegistry().includes(abs);
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../src/cli/utils/registry.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Token utilities for Fling CLI
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Normalize an invite token:
|
|
6
|
+
* - Trims whitespace
|
|
7
|
+
* - Prepends 'inv_' if missing
|
|
8
|
+
* - Lowercases short-format codes (xxx-xxx) for case-insensitive entry
|
|
9
|
+
* - Preserves case for legacy long-format tokens
|
|
10
|
+
*/
|
|
11
|
+
export declare function normalizeInviteToken(token: string): string;
|
|
12
|
+
//# sourceMappingURL=token.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/token.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAc1D"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Token utilities for Fling CLI
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Normalize an invite token:
|
|
6
|
+
* - Trims whitespace
|
|
7
|
+
* - Prepends 'inv_' if missing
|
|
8
|
+
* - Lowercases short-format codes (xxx-xxx) for case-insensitive entry
|
|
9
|
+
* - Preserves case for legacy long-format tokens
|
|
10
|
+
*/
|
|
11
|
+
export function normalizeInviteToken(token) {
|
|
12
|
+
const trimmed = token.trim();
|
|
13
|
+
let withPrefix;
|
|
14
|
+
if (trimmed.startsWith("inv_")) {
|
|
15
|
+
withPrefix = trimmed;
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
withPrefix = "inv_" + trimmed;
|
|
19
|
+
}
|
|
20
|
+
// Only normalize case for short codes (inv_ + xxx-xxx = 11 chars total)
|
|
21
|
+
const code = withPrefix.slice(4);
|
|
22
|
+
if (code.length === 7 && code[3] === "-") {
|
|
23
|
+
return "inv_" + code.toLowerCase();
|
|
24
|
+
}
|
|
25
|
+
return withPrefix;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=token.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token.js","sourceRoot":"","sources":["../../../src/cli/utils/token.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAa;IAChD,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAC7B,IAAI,UAAkB,CAAC;IACvB,IAAI,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;QAC/B,UAAU,GAAG,OAAO,CAAC;IACvB,CAAC;SAAM,CAAC;QACN,UAAU,GAAG,MAAM,GAAG,OAAO,CAAC;IAChC,CAAC;IACD,wEAAwE;IACxE,MAAM,IAAI,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACjC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;QACzC,OAAO,MAAM,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IACrC,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fling - Personal Software Platform
|
|
3
|
+
*
|
|
4
|
+
* Main entry point for the fling runtime package.
|
|
5
|
+
* Re-exports all primitives: app, cron, db, secrets
|
|
6
|
+
*/
|
|
7
|
+
export { app } from "./runtime/http.js";
|
|
8
|
+
export { cron } from "./runtime/cron.js";
|
|
9
|
+
export { db } from "./runtime/db.js";
|
|
10
|
+
export { migrate } from "./runtime/migrate.js";
|
|
11
|
+
export { secrets } from "./runtime/secrets.js";
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fling - Personal Software Platform
|
|
3
|
+
*
|
|
4
|
+
* Main entry point for the fling runtime package.
|
|
5
|
+
* Re-exports all primitives: app, cron, db, secrets
|
|
6
|
+
*/
|
|
7
|
+
export { app } from "./runtime/http.js";
|
|
8
|
+
export { cron } from "./runtime/cron.js";
|
|
9
|
+
export { db } from "./runtime/db.js";
|
|
10
|
+
export { migrate } from "./runtime/migrate.js";
|
|
11
|
+
export { secrets } from "./runtime/secrets.js";
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cron primitive for scheduled tasks
|
|
3
|
+
*
|
|
4
|
+
* Cron jobs use standard cron syntax. Declarations must be at the
|
|
5
|
+
* top level of a module. Each handler runs in isolation.
|
|
6
|
+
*/
|
|
7
|
+
import { Cron } from "croner";
|
|
8
|
+
interface CronJob {
|
|
9
|
+
name: string;
|
|
10
|
+
schedule: string;
|
|
11
|
+
handler: () => Promise<void> | void;
|
|
12
|
+
instance: Cron;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Register a cron job with standard cron syntax.
|
|
16
|
+
*
|
|
17
|
+
* @param name - Unique identifier for the cron job
|
|
18
|
+
* @param schedule - Cron expression (e.g., "0 9 * * *" for 9 AM daily)
|
|
19
|
+
* @param handler - Async function to execute on schedule
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* import { cron } from "fling";
|
|
24
|
+
*
|
|
25
|
+
* cron("daily-digest", "0 9 * * *", async () => {
|
|
26
|
+
* // Runs at 9 AM every day
|
|
27
|
+
* const items = await fetchNews();
|
|
28
|
+
* await db.prepare("INSERT INTO digests ...").run();
|
|
29
|
+
* });
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare function cron(name: string, schedule: string, handler: () => Promise<void> | void): void;
|
|
33
|
+
/**
|
|
34
|
+
* Get all registered cron jobs (internal use)
|
|
35
|
+
*/
|
|
36
|
+
export declare function getCronJobs(): Map<string, CronJob>;
|
|
37
|
+
/**
|
|
38
|
+
* Start all cron jobs (called by dev server)
|
|
39
|
+
*/
|
|
40
|
+
export declare function startCronJobs(): void;
|
|
41
|
+
/**
|
|
42
|
+
* Stop all cron jobs (called on shutdown)
|
|
43
|
+
*/
|
|
44
|
+
export declare function stopCronJobs(): void;
|
|
45
|
+
/**
|
|
46
|
+
* Manually trigger a cron job by name (for testing)
|
|
47
|
+
*/
|
|
48
|
+
export declare function triggerCronJob(name: string): Promise<void>;
|
|
49
|
+
export {};
|
|
50
|
+
//# sourceMappingURL=cron.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cron.d.ts","sourceRoot":"","sources":["../../src/runtime/cron.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAG9B,UAAU,OAAO;IACf,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACpC,QAAQ,EAAE,IAAI,CAAC;CAChB;AAKD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,IAAI,CAClB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,GAClC,IAAI,CAkBN;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAElD;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,IAAI,CAKpC;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI,IAAI,CAInC;AAED;;GAEG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAMhE"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cron primitive for scheduled tasks
|
|
3
|
+
*
|
|
4
|
+
* Cron jobs use standard cron syntax. Declarations must be at the
|
|
5
|
+
* top level of a module. Each handler runs in isolation.
|
|
6
|
+
*/
|
|
7
|
+
import { Cron } from "croner";
|
|
8
|
+
import { withLogContext } from "./log.js";
|
|
9
|
+
// Registry of all cron jobs
|
|
10
|
+
const cronJobs = new Map();
|
|
11
|
+
/**
|
|
12
|
+
* Register a cron job with standard cron syntax.
|
|
13
|
+
*
|
|
14
|
+
* @param name - Unique identifier for the cron job
|
|
15
|
+
* @param schedule - Cron expression (e.g., "0 9 * * *" for 9 AM daily)
|
|
16
|
+
* @param handler - Async function to execute on schedule
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* import { cron } from "fling";
|
|
21
|
+
*
|
|
22
|
+
* cron("daily-digest", "0 9 * * *", async () => {
|
|
23
|
+
* // Runs at 9 AM every day
|
|
24
|
+
* const items = await fetchNews();
|
|
25
|
+
* await db.prepare("INSERT INTO digests ...").run();
|
|
26
|
+
* });
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export function cron(name, schedule, handler) {
|
|
30
|
+
if (cronJobs.has(name)) {
|
|
31
|
+
throw new Error(`Cron job with name "${name}" already exists`);
|
|
32
|
+
}
|
|
33
|
+
// Create cron instance but don't start it yet
|
|
34
|
+
// The scheduler will start jobs when `fling dev` runs
|
|
35
|
+
const instance = new Cron(schedule, { paused: true }, async () => {
|
|
36
|
+
try {
|
|
37
|
+
await withLogContext({ cronJob: name }, async () => {
|
|
38
|
+
await handler();
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
console.error(`[cron:${name}] Error:`, error);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
cronJobs.set(name, { name, schedule, handler, instance });
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Get all registered cron jobs (internal use)
|
|
49
|
+
*/
|
|
50
|
+
export function getCronJobs() {
|
|
51
|
+
return cronJobs;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Start all cron jobs (called by dev server)
|
|
55
|
+
*/
|
|
56
|
+
export function startCronJobs() {
|
|
57
|
+
for (const job of cronJobs.values()) {
|
|
58
|
+
job.instance.resume();
|
|
59
|
+
console.log(`[cron] Started "${job.name}" with schedule "${job.schedule}"`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Stop all cron jobs (called on shutdown)
|
|
64
|
+
*/
|
|
65
|
+
export function stopCronJobs() {
|
|
66
|
+
for (const job of cronJobs.values()) {
|
|
67
|
+
job.instance.stop();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Manually trigger a cron job by name (for testing)
|
|
72
|
+
*/
|
|
73
|
+
export async function triggerCronJob(name) {
|
|
74
|
+
const job = cronJobs.get(name);
|
|
75
|
+
if (!job) {
|
|
76
|
+
throw new Error(`Cron job "${name}" not found`);
|
|
77
|
+
}
|
|
78
|
+
await job.handler();
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=cron.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cron.js","sourceRoot":"","sources":["../../src/runtime/cron.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAS1C,4BAA4B;AAC5B,MAAM,QAAQ,GAAyB,IAAI,GAAG,EAAE,CAAC;AAEjD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,IAAI,CAClB,IAAY,EACZ,QAAgB,EAChB,OAAmC;IAEnC,IAAI,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,uBAAuB,IAAI,kBAAkB,CAAC,CAAC;IACjE,CAAC;IAED,8CAA8C;IAC9C,sDAAsD;IACtD,MAAM,QAAQ,GAAG,IAAI,IAAI,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,KAAK,IAAI,EAAE;QAC/D,IAAI,CAAC;YACH,MAAM,cAAc,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,KAAK,IAAI,EAAE;gBACjD,MAAM,OAAO,EAAE,CAAC;YAClB,CAAC,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,SAAS,IAAI,UAAU,EAAE,KAAK,CAAC,CAAC;QAChD,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC;AAC5D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW;IACzB,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa;IAC3B,KAAK,MAAM,GAAG,IAAI,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC;QACpC,GAAG,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;QACtB,OAAO,CAAC,GAAG,CAAC,mBAAmB,GAAG,CAAC,IAAI,oBAAoB,GAAG,CAAC,QAAQ,GAAG,CAAC,CAAC;IAC9E,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY;IAC1B,KAAK,MAAM,GAAG,IAAI,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC;QACpC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;IACtB,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,IAAY;IAC/C,MAAM,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC/B,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,IAAI,KAAK,CAAC,aAAa,IAAI,aAAa,CAAC,CAAC;IAClD,CAAC;IACD,MAAM,GAAG,CAAC,OAAO,EAAE,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Database primitive using SQLite
|
|
3
|
+
*
|
|
4
|
+
* The database API matches Cloudflare D1 for portability.
|
|
5
|
+
* Locally, this runs against SQLite via better-sqlite3.
|
|
6
|
+
* In production, it runs against Cloudflare D1.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* D1-compatible prepared statement wrapper
|
|
10
|
+
*/
|
|
11
|
+
declare class PreparedStatement {
|
|
12
|
+
private sql;
|
|
13
|
+
private params;
|
|
14
|
+
constructor(sql: string);
|
|
15
|
+
/**
|
|
16
|
+
* Bind parameters to the statement
|
|
17
|
+
*/
|
|
18
|
+
bind(...params: unknown[]): PreparedStatement;
|
|
19
|
+
/**
|
|
20
|
+
* Execute and return the first row
|
|
21
|
+
*/
|
|
22
|
+
first<T = Record<string, unknown>>(): T | null;
|
|
23
|
+
/**
|
|
24
|
+
* Execute and return all rows
|
|
25
|
+
*/
|
|
26
|
+
all<T = Record<string, unknown>>(): {
|
|
27
|
+
results: T[];
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Execute a statement (INSERT/UPDATE/DELETE)
|
|
31
|
+
*/
|
|
32
|
+
run(): {
|
|
33
|
+
success: boolean;
|
|
34
|
+
meta: {
|
|
35
|
+
changes: number;
|
|
36
|
+
last_row_id: number;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* D1-compatible database interface
|
|
42
|
+
*/
|
|
43
|
+
export declare const db: {
|
|
44
|
+
/**
|
|
45
|
+
* Prepare a SQL statement with parameter binding
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* const episode = await db.prepare("SELECT * FROM episodes WHERE id = ?")
|
|
50
|
+
* .bind(episodeId)
|
|
51
|
+
* .first();
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
prepare(sql: string): PreparedStatement;
|
|
55
|
+
/**
|
|
56
|
+
* Execute raw SQL (for DDL statements like CREATE TABLE)
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
60
|
+
* await db.exec(`
|
|
61
|
+
* CREATE TABLE IF NOT EXISTS episodes (
|
|
62
|
+
* id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
63
|
+
* title TEXT NOT NULL
|
|
64
|
+
* )
|
|
65
|
+
* `);
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
exec(sql: string): void;
|
|
69
|
+
/**
|
|
70
|
+
* Execute multiple statements atomically
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```typescript
|
|
74
|
+
* await db.batch([
|
|
75
|
+
* db.prepare("INSERT INTO users (id, name) VALUES (?, ?)").bind(id, name),
|
|
76
|
+
* db.prepare("INSERT INTO projects (id, user_id) VALUES (?, ?)").bind(projId, id),
|
|
77
|
+
* ]);
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
batch(statements: PreparedStatement[]): {
|
|
81
|
+
success: boolean;
|
|
82
|
+
meta: {
|
|
83
|
+
changes: number;
|
|
84
|
+
last_row_id: number;
|
|
85
|
+
};
|
|
86
|
+
}[];
|
|
87
|
+
/**
|
|
88
|
+
* Close the database connection (internal use)
|
|
89
|
+
*/
|
|
90
|
+
close(): void;
|
|
91
|
+
};
|
|
92
|
+
export {};
|
|
93
|
+
//# sourceMappingURL=db.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../src/runtime/db.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA0BH;;GAEG;AACH,cAAM,iBAAiB;IACrB,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,MAAM,CAAiB;gBAEnB,GAAG,EAAE,MAAM;IAIvB;;OAEG;IACH,IAAI,CAAC,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,iBAAiB;IAK7C;;OAEG;IACH,KAAK,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI;IAM9C;;OAEG;IACH,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK;QAAE,OAAO,EAAE,CAAC,EAAE,CAAA;KAAE;IAOpD;;OAEG;IACH,GAAG,IAAI;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE;YAAE,OAAO,EAAE,MAAM,CAAC;YAAC,WAAW,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE;CAY5E;AAED;;GAEG;AACH,eAAO,MAAM,EAAE;IACb;;;;;;;;;OASG;iBACU,MAAM,GAAG,iBAAiB;IAIvC;;;;;;;;;;;;OAYG;cACO,MAAM,GAAG,IAAI;IAKvB;;;;;;;;;;OAUG;sBAEW,iBAAiB,EAAE,GAC9B;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE;YAAE,OAAO,EAAE,MAAM,CAAC;YAAC,WAAW,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,EAAE;IAQzE;;OAEG;aACM,IAAI;CAMd,CAAC"}
|