flingit 0.0.9 → 0.0.11
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/cli/commands/admin.d.ts.map +1 -1
- package/dist/cli/commands/admin.js +29 -16
- package/dist/cli/commands/admin.js.map +1 -1
- package/dist/cli/commands/cron.d.ts.map +1 -1
- package/dist/cli/commands/cron.js +7 -3
- package/dist/cli/commands/cron.js.map +1 -1
- package/dist/cli/commands/db.d.ts.map +1 -1
- package/dist/cli/commands/db.js +5 -2
- package/dist/cli/commands/db.js.map +1 -1
- package/dist/cli/commands/feedback.d.ts.map +1 -1
- package/dist/cli/commands/feedback.js +6 -1
- package/dist/cli/commands/feedback.js.map +1 -1
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +5 -20
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/launch.d.ts.map +1 -1
- package/dist/cli/commands/launch.js +5 -59
- package/dist/cli/commands/launch.js.map +1 -1
- package/dist/cli/commands/login.d.ts.map +1 -1
- package/dist/cli/commands/login.js +7 -2
- package/dist/cli/commands/login.js.map +1 -1
- package/dist/cli/commands/logs.d.ts.map +1 -1
- package/dist/cli/commands/logs.js +3 -1
- package/dist/cli/commands/logs.js.map +1 -1
- package/dist/cli/commands/onboard.js +1 -1
- package/dist/cli/commands/plugin.d.ts +8 -0
- package/dist/cli/commands/plugin.d.ts.map +1 -0
- package/dist/cli/commands/plugin.js +407 -0
- package/dist/cli/commands/plugin.js.map +1 -0
- package/dist/cli/commands/project.d.ts.map +1 -1
- package/dist/cli/commands/project.js +3 -1
- package/dist/cli/commands/project.js.map +1 -1
- package/dist/cli/commands/push.d.ts.map +1 -1
- package/dist/cli/commands/push.js +128 -12
- package/dist/cli/commands/push.js.map +1 -1
- package/dist/cli/commands/register.d.ts +25 -0
- package/dist/cli/commands/register.d.ts.map +1 -1
- package/dist/cli/commands/register.js +30 -13
- package/dist/cli/commands/register.js.map +1 -1
- package/dist/cli/commands/secret.d.ts +9 -0
- package/dist/cli/commands/secret.d.ts.map +1 -1
- package/dist/cli/commands/secret.js +40 -50
- package/dist/cli/commands/secret.js.map +1 -1
- package/dist/cli/commands/storage.d.ts +10 -0
- package/dist/cli/commands/storage.d.ts.map +1 -0
- package/dist/cli/commands/storage.js +459 -0
- package/dist/cli/commands/storage.js.map +1 -0
- package/dist/cli/commands/tun.d.ts.map +1 -1
- package/dist/cli/commands/tun.js +3 -2
- package/dist/cli/commands/tun.js.map +1 -1
- package/dist/cli/deploy/bundler.d.ts +15 -0
- package/dist/cli/deploy/bundler.d.ts.map +1 -1
- package/dist/cli/deploy/bundler.js +86 -2
- package/dist/cli/deploy/bundler.js.map +1 -1
- package/dist/cli/index.js +4 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/utils/config.d.ts +12 -0
- package/dist/cli/utils/config.d.ts.map +1 -1
- package/dist/cli/utils/config.js +23 -3
- package/dist/cli/utils/config.js.map +1 -1
- package/dist/cli/utils/environment.d.ts +12 -0
- package/dist/cli/utils/environment.d.ts.map +1 -1
- package/dist/cli/utils/environment.js +40 -6
- package/dist/cli/utils/environment.js.map +1 -1
- package/dist/cli/utils/launch-io-impl.d.ts +13 -0
- package/dist/cli/utils/launch-io-impl.d.ts.map +1 -0
- package/dist/cli/utils/launch-io-impl.js +51 -0
- package/dist/cli/utils/launch-io-impl.js.map +1 -0
- package/dist/cli/utils/launch-io.d.ts +42 -0
- package/dist/cli/utils/launch-io.d.ts.map +1 -0
- package/dist/cli/utils/launch-io.js +8 -0
- package/dist/cli/utils/launch-io.js.map +1 -0
- package/dist/cli/utils/project-name.d.ts +17 -0
- package/dist/cli/utils/project-name.d.ts.map +1 -0
- package/dist/cli/utils/project-name.js +33 -0
- package/dist/cli/utils/project-name.js.map +1 -0
- package/dist/cli/utils/prompt-new-project.d.ts +12 -0
- package/dist/cli/utils/prompt-new-project.d.ts.map +1 -0
- package/dist/cli/utils/prompt-new-project.js +66 -0
- package/dist/cli/utils/prompt-new-project.js.map +1 -0
- package/dist/cli/utils/version-check.d.ts +30 -0
- package/dist/cli/utils/version-check.d.ts.map +1 -0
- package/dist/cli/utils/version-check.js +43 -0
- package/dist/cli/utils/version-check.js.map +1 -0
- package/dist/client/assets/index-BqVrS7t9.js +40 -0
- package/dist/client/assets/index-DSLUsCtO.css +1 -0
- package/dist/client/index.html +14 -0
- package/dist/client/vite.svg +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/runtime/db.d.ts +5 -0
- package/dist/runtime/db.d.ts.map +1 -1
- package/dist/runtime/db.js +6 -1
- package/dist/runtime/db.js.map +1 -1
- package/dist/runtime/discord.d.ts +171 -0
- package/dist/runtime/discord.d.ts.map +1 -0
- package/dist/runtime/discord.js +192 -0
- package/dist/runtime/discord.js.map +1 -0
- package/dist/runtime/secrets.d.ts +28 -0
- package/dist/runtime/secrets.d.ts.map +1 -1
- package/dist/runtime/secrets.js +77 -20
- package/dist/runtime/secrets.js.map +1 -1
- package/dist/runtime/storage.d.ts +29 -0
- package/dist/runtime/storage.d.ts.map +1 -0
- package/dist/runtime/storage.js +456 -0
- package/dist/runtime/storage.js.map +1 -0
- package/dist/shared/constants.d.ts +12 -0
- package/dist/shared/constants.d.ts.map +1 -0
- package/dist/shared/constants.js +12 -0
- package/dist/shared/constants.js.map +1 -0
- package/dist/shared/discord-types.d.ts +130 -0
- package/dist/shared/discord-types.d.ts.map +1 -0
- package/dist/shared/discord-types.js +8 -0
- package/dist/shared/discord-types.js.map +1 -0
- package/dist/shared/random-code.d.ts +6 -0
- package/dist/shared/random-code.d.ts.map +1 -0
- package/dist/shared/random-code.js +23 -0
- package/dist/shared/random-code.js.map +1 -0
- package/dist/types/storage.d.ts +154 -0
- package/dist/types/storage.d.ts.map +1 -0
- package/dist/types/storage.js +8 -0
- package/dist/types/storage.js.map +1 -0
- package/dist/worker-runtime/discord.d.ts +61 -0
- package/dist/worker-runtime/discord.d.ts.map +1 -0
- package/dist/worker-runtime/discord.js +181 -0
- package/dist/worker-runtime/discord.js.map +1 -0
- package/dist/worker-runtime/index.d.ts +21 -1
- package/dist/worker-runtime/index.d.ts.map +1 -1
- package/dist/worker-runtime/index.js +102 -0
- package/dist/worker-runtime/index.js.map +1 -1
- package/package.json +9 -2
- package/templates/default/CLAUDE.md +65 -11
- package/templates/default/skills/discord/SKILL.md +328 -0
- package/templates/default/skills/fling/API.md +208 -0
- package/templates/default/skills/fling/SKILL.md +51 -8
- package/dist/cli/deploy/worker-entry.d.ts +0 -14
- package/dist/cli/deploy/worker-entry.d.ts.map +0 -1
- package/dist/cli/deploy/worker-entry.js +0 -60
- package/dist/cli/deploy/worker-entry.js.map +0 -1
- package/dist/cli/deploy/wrangler-config.d.ts +0 -20
- package/dist/cli/deploy/wrangler-config.d.ts.map +0 -1
- package/dist/cli/deploy/wrangler-config.js +0 -54
- package/dist/cli/deploy/wrangler-config.js.map +0 -1
- package/dist/cli/loaders/register-wasm.d.ts +0 -12
- package/dist/cli/loaders/register-wasm.d.ts.map +0 -1
- package/dist/cli/loaders/register-wasm.js +0 -19
- package/dist/cli/loaders/register-wasm.js.map +0 -1
- package/dist/cli/loaders/wasm-hooks.d.ts +0 -61
- package/dist/cli/loaders/wasm-hooks.d.ts.map +0 -1
- package/dist/cli/loaders/wasm-hooks.js +0 -63
- package/dist/cli/loaders/wasm-hooks.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
* Fling - Personal Software Platform
|
|
3
3
|
*
|
|
4
4
|
* Main entry point for the fling runtime package.
|
|
5
|
-
* Re-exports all primitives: app, cron, db, secrets
|
|
5
|
+
* Re-exports all primitives: app, cron, db, secrets, storage
|
|
6
6
|
*/
|
|
7
7
|
export { app } from "./runtime/http.js";
|
|
8
8
|
export { cron } from "./runtime/cron.js";
|
|
9
9
|
export { db } from "./runtime/db.js";
|
|
10
10
|
export { migrate } from "./runtime/migrate.js";
|
|
11
11
|
export { secrets } from "./runtime/secrets.js";
|
|
12
|
+
export { storage } from "./runtime/storage.js";
|
|
13
|
+
export type { Storage, StorageObject, StorageObjectBody, StoragePutOptions, StorageListOptions, StorageListResult, } from "./types/storage.js";
|
|
12
14
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +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"}
|
|
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;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAG/C,YAAY,EACV,OAAO,EACP,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,oBAAoB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
* Fling - Personal Software Platform
|
|
3
3
|
*
|
|
4
4
|
* Main entry point for the fling runtime package.
|
|
5
|
-
* Re-exports all primitives: app, cron, db, secrets
|
|
5
|
+
* Re-exports all primitives: app, cron, db, secrets, storage
|
|
6
6
|
*/
|
|
7
7
|
export { app } from "./runtime/http.js";
|
|
8
8
|
export { cron } from "./runtime/cron.js";
|
|
9
9
|
export { db } from "./runtime/db.js";
|
|
10
10
|
export { migrate } from "./runtime/migrate.js";
|
|
11
11
|
export { secrets } from "./runtime/secrets.js";
|
|
12
|
+
export { storage } from "./runtime/storage.js";
|
|
12
13
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +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"}
|
|
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;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/runtime/db.d.ts
CHANGED
|
@@ -5,6 +5,11 @@
|
|
|
5
5
|
* Locally, this runs against SQLite via better-sqlite3.
|
|
6
6
|
* In production, it runs against Cloudflare D1.
|
|
7
7
|
*/
|
|
8
|
+
/**
|
|
9
|
+
* Path components for the local database file.
|
|
10
|
+
* Exported so CLI can construct the same path.
|
|
11
|
+
*/
|
|
12
|
+
export declare const DB_PATH_PARTS: readonly [".fling", "data", "local.db"];
|
|
8
13
|
/**
|
|
9
14
|
* D1-compatible prepared statement wrapper
|
|
10
15
|
*/
|
package/dist/runtime/db.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../src/runtime/db.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../src/runtime/db.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH;;;GAGG;AACH,eAAO,MAAM,aAAa,yCAA0C,CAAC;AAsBrE;;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"}
|
package/dist/runtime/db.js
CHANGED
|
@@ -8,8 +8,13 @@
|
|
|
8
8
|
import Database from "better-sqlite3";
|
|
9
9
|
import { existsSync, mkdirSync } from "node:fs";
|
|
10
10
|
import { dirname, join } from "node:path";
|
|
11
|
+
/**
|
|
12
|
+
* Path components for the local database file.
|
|
13
|
+
* Exported so CLI can construct the same path.
|
|
14
|
+
*/
|
|
15
|
+
export const DB_PATH_PARTS = [".fling", "data", "local.db"];
|
|
11
16
|
// Database path - configurable via environment
|
|
12
|
-
const DB_PATH = process.env["FLING_DB_PATH"] ?? join(process.cwd(),
|
|
17
|
+
const DB_PATH = process.env["FLING_DB_PATH"] ?? join(process.cwd(), ...DB_PATH_PARTS);
|
|
13
18
|
let database = null;
|
|
14
19
|
function getDatabase() {
|
|
15
20
|
if (!database) {
|
package/dist/runtime/db.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db.js","sourceRoot":"","sources":["../../src/runtime/db.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,+CAA+C;AAC/C,MAAM,OAAO,GACX,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"db.js","sourceRoot":"","sources":["../../src/runtime/db.ts"],"names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G,WAAW,EAAE,CAAC;QAC/B,MAAM,WAAW,GAAG,QAAQ,CAAC,WAAW,CAAC,GAAG,EAAE;YAC5C,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;QAC9C,CAAC,CAAC,CAAC;QACH,OAAO,WAAW,EAAE,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,QAAQ,EAAE,CAAC;YACb,QAAQ,CAAC,KAAK,EAAE,CAAC;YACjB,QAAQ,GAAG,IAAI,CAAC;QAClB,CAAC;IACH,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Discord integration for Fling applications (Local runtime)
|
|
3
|
+
*
|
|
4
|
+
* Provides helpers for building Discord chatops bots.
|
|
5
|
+
* This is the local development version - the worker version is in worker-runtime.
|
|
6
|
+
*
|
|
7
|
+
* Note: Discord features require the Discord plugin to be installed.
|
|
8
|
+
* Run `fling plugin install discord` to set up.
|
|
9
|
+
*/
|
|
10
|
+
import type { Context } from "hono";
|
|
11
|
+
export type { DiscordSlashCommand, DiscordCommandOption, DiscordInteraction, DiscordEmbed, SendMessageOptions, EditMessageOptions, InteractionReplyOptions, DiscordMessage, } from "../shared/discord-types.js";
|
|
12
|
+
import type { DiscordSlashCommand, DiscordInteraction, SendMessageOptions, EditMessageOptions, InteractionReplyOptions, DiscordMessage } from "../shared/discord-types.js";
|
|
13
|
+
/**
|
|
14
|
+
* Discord integration helper.
|
|
15
|
+
*
|
|
16
|
+
* Provides methods for sending messages, handling interactions,
|
|
17
|
+
* and registering slash commands.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* import { app } from "flingit";
|
|
22
|
+
* import { discord } from "flingit/plugin/discord";
|
|
23
|
+
*
|
|
24
|
+
* // Define slash commands (synced on deploy)
|
|
25
|
+
* export const commands = discord.defineCommands([
|
|
26
|
+
* { name: "deploy", description: "Deploy the current branch" },
|
|
27
|
+
* { name: "status", description: "Show deployment status" }
|
|
28
|
+
* ]);
|
|
29
|
+
*
|
|
30
|
+
* // Handle slash commands
|
|
31
|
+
* app.post("/discord", async (c) => {
|
|
32
|
+
* const interaction = await discord.verifyInteraction(c);
|
|
33
|
+
*
|
|
34
|
+
* if (interaction.data?.name === "deploy") {
|
|
35
|
+
* await discord.replyToInteraction(interaction, {
|
|
36
|
+
* content: "Starting deployment..."
|
|
37
|
+
* });
|
|
38
|
+
* }
|
|
39
|
+
* });
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare const discord: {
|
|
43
|
+
/**
|
|
44
|
+
* Define slash commands for your project.
|
|
45
|
+
* These are registered with Discord when you run `fling push`.
|
|
46
|
+
*
|
|
47
|
+
* @param commands - Array of command definitions
|
|
48
|
+
* @returns The same array (for export)
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* export const commands = discord.defineCommands([
|
|
53
|
+
* { name: "ping", description: "Check bot latency" },
|
|
54
|
+
* {
|
|
55
|
+
* name: "deploy",
|
|
56
|
+
* description: "Deploy a branch",
|
|
57
|
+
* options: [
|
|
58
|
+
* { name: "branch", type: "string", description: "Branch name", required: true }
|
|
59
|
+
* ]
|
|
60
|
+
* }
|
|
61
|
+
* ]);
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
defineCommands(commands: DiscordSlashCommand[]): DiscordSlashCommand[];
|
|
65
|
+
/**
|
|
66
|
+
* Verify and parse a Discord interaction from a request.
|
|
67
|
+
* Discord requires interaction verification within 3 seconds.
|
|
68
|
+
*
|
|
69
|
+
* @param c - Hono context from the request
|
|
70
|
+
* @returns Parsed interaction
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```typescript
|
|
74
|
+
* app.post("/discord", async (c) => {
|
|
75
|
+
* const interaction = await discord.verifyInteraction(c);
|
|
76
|
+
* // Handle interaction...
|
|
77
|
+
* });
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
verifyInteraction(_c: Context): Promise<DiscordInteraction>;
|
|
81
|
+
/**
|
|
82
|
+
* Reply to a Discord interaction.
|
|
83
|
+
* Must be called within 3 seconds of receiving the interaction.
|
|
84
|
+
*
|
|
85
|
+
* @param interaction - The interaction to reply to
|
|
86
|
+
* @param options - Reply content and options
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```typescript
|
|
90
|
+
* await discord.replyToInteraction(interaction, {
|
|
91
|
+
* content: "Command received!",
|
|
92
|
+
* ephemeral: true // Only visible to command user
|
|
93
|
+
* });
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
replyToInteraction(_interaction: DiscordInteraction, _options: InteractionReplyOptions): void;
|
|
97
|
+
/**
|
|
98
|
+
* Send a message to a Discord channel.
|
|
99
|
+
* The channel must be in a server claimed by your project.
|
|
100
|
+
*
|
|
101
|
+
* @param options - Message content and target channel
|
|
102
|
+
* @returns The sent message
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```typescript
|
|
106
|
+
* const message = await discord.sendMessage({
|
|
107
|
+
* channelId: "123456789",
|
|
108
|
+
* content: "Hello from Fling!",
|
|
109
|
+
* embeds: [{
|
|
110
|
+
* title: "Deployment Complete",
|
|
111
|
+
* description: "Version 1.2.3 is now live",
|
|
112
|
+
* color: 0x00ff00
|
|
113
|
+
* }]
|
|
114
|
+
* });
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
sendMessage(_options: SendMessageOptions): Promise<DiscordMessage>;
|
|
118
|
+
/**
|
|
119
|
+
* Edit a previously sent message.
|
|
120
|
+
*
|
|
121
|
+
* @param channelId - The channel containing the message
|
|
122
|
+
* @param messageId - The message to edit
|
|
123
|
+
* @param options - New message content
|
|
124
|
+
* @returns The edited message
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```typescript
|
|
128
|
+
* await discord.editMessage(channelId, messageId, {
|
|
129
|
+
* content: "Updated content"
|
|
130
|
+
* });
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
editMessage(_channelId: string, _messageId: string, _options: EditMessageOptions): Promise<DiscordMessage>;
|
|
134
|
+
/**
|
|
135
|
+
* Add a reaction to a message.
|
|
136
|
+
*
|
|
137
|
+
* @param channelId - The channel containing the message
|
|
138
|
+
* @param messageId - The message to react to
|
|
139
|
+
* @param emoji - The emoji to add (unicode or custom emoji format)
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```typescript
|
|
143
|
+
* await discord.addReaction(channelId, messageId, "✅");
|
|
144
|
+
* await discord.addReaction(channelId, messageId, "🚀");
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
addReaction(_channelId: string, _messageId: string, _emoji: string): Promise<void>;
|
|
148
|
+
/**
|
|
149
|
+
* Send a followup message to an interaction.
|
|
150
|
+
* Use this after the initial reply for additional messages.
|
|
151
|
+
*
|
|
152
|
+
* @param interaction - The original interaction
|
|
153
|
+
* @param options - Followup message content
|
|
154
|
+
* @returns The sent message
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* ```typescript
|
|
158
|
+
* // Initial reply
|
|
159
|
+
* await discord.replyToInteraction(interaction, { content: "Processing..." });
|
|
160
|
+
*
|
|
161
|
+
* // Do some work...
|
|
162
|
+
*
|
|
163
|
+
* // Send followup
|
|
164
|
+
* await discord.sendFollowup(interaction, {
|
|
165
|
+
* content: "Done! Here are the results..."
|
|
166
|
+
* });
|
|
167
|
+
* ```
|
|
168
|
+
*/
|
|
169
|
+
sendFollowup(_interaction: DiscordInteraction, _options: InteractionReplyOptions): Promise<DiscordMessage>;
|
|
170
|
+
};
|
|
171
|
+
//# sourceMappingURL=discord.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discord.d.ts","sourceRoot":"","sources":["../../src/runtime/discord.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAGpC,YAAY,EACV,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,EAClB,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,EAClB,uBAAuB,EACvB,cAAc,GACf,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EACV,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,uBAAuB,EACvB,cAAc,EACf,MAAM,4BAA4B,CAAC;AAgBpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,OAAO;IAClB;;;;;;;;;;;;;;;;;;;;OAoBG;6BACsB,mBAAmB,EAAE,GAAG,mBAAmB,EAAE;IAItE;;;;;;;;;;;;;;OAcG;0BACyB,OAAO,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAIjE;;;;;;;;;;;;;;OAcG;qCAEa,kBAAkB,YACtB,uBAAuB,GAChC,IAAI;IAIP;;;;;;;;;;;;;;;;;;;OAmBG;0BACyB,kBAAkB,GAAG,OAAO,CAAC,cAAc,CAAC;IAIxE;;;;;;;;;;;;;;OAcG;4BAEW,MAAM,cACN,MAAM,YACR,kBAAkB,GAC3B,OAAO,CAAC,cAAc,CAAC;IAI1B;;;;;;;;;;;;OAYG;4BAEW,MAAM,cACN,MAAM,UACV,MAAM,GACb,OAAO,CAAC,IAAI,CAAC;IAIhB;;;;;;;;;;;;;;;;;;;;OAoBG;+BAEa,kBAAkB,YACtB,uBAAuB,GAChC,OAAO,CAAC,cAAc,CAAC;CAG3B,CAAC"}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Discord integration for Fling applications (Local runtime)
|
|
3
|
+
*
|
|
4
|
+
* Provides helpers for building Discord chatops bots.
|
|
5
|
+
* This is the local development version - the worker version is in worker-runtime.
|
|
6
|
+
*
|
|
7
|
+
* Note: Discord features require the Discord plugin to be installed.
|
|
8
|
+
* Run `fling plugin install discord` to set up.
|
|
9
|
+
*/
|
|
10
|
+
// =============================================================================
|
|
11
|
+
// Discord API (Local Runtime - Stubs)
|
|
12
|
+
// =============================================================================
|
|
13
|
+
/**
|
|
14
|
+
* Local runtime warning - Discord features only work in deployed workers.
|
|
15
|
+
*/
|
|
16
|
+
function localRuntimeWarning(method) {
|
|
17
|
+
throw new Error(`discord.${method}() is only available in deployed workers. ` +
|
|
18
|
+
"Use 'fling push' to deploy, then test your Discord integration.");
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Discord integration helper.
|
|
22
|
+
*
|
|
23
|
+
* Provides methods for sending messages, handling interactions,
|
|
24
|
+
* and registering slash commands.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* import { app } from "flingit";
|
|
29
|
+
* import { discord } from "flingit/plugin/discord";
|
|
30
|
+
*
|
|
31
|
+
* // Define slash commands (synced on deploy)
|
|
32
|
+
* export const commands = discord.defineCommands([
|
|
33
|
+
* { name: "deploy", description: "Deploy the current branch" },
|
|
34
|
+
* { name: "status", description: "Show deployment status" }
|
|
35
|
+
* ]);
|
|
36
|
+
*
|
|
37
|
+
* // Handle slash commands
|
|
38
|
+
* app.post("/discord", async (c) => {
|
|
39
|
+
* const interaction = await discord.verifyInteraction(c);
|
|
40
|
+
*
|
|
41
|
+
* if (interaction.data?.name === "deploy") {
|
|
42
|
+
* await discord.replyToInteraction(interaction, {
|
|
43
|
+
* content: "Starting deployment..."
|
|
44
|
+
* });
|
|
45
|
+
* }
|
|
46
|
+
* });
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export const discord = {
|
|
50
|
+
/**
|
|
51
|
+
* Define slash commands for your project.
|
|
52
|
+
* These are registered with Discord when you run `fling push`.
|
|
53
|
+
*
|
|
54
|
+
* @param commands - Array of command definitions
|
|
55
|
+
* @returns The same array (for export)
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* export const commands = discord.defineCommands([
|
|
60
|
+
* { name: "ping", description: "Check bot latency" },
|
|
61
|
+
* {
|
|
62
|
+
* name: "deploy",
|
|
63
|
+
* description: "Deploy a branch",
|
|
64
|
+
* options: [
|
|
65
|
+
* { name: "branch", type: "string", description: "Branch name", required: true }
|
|
66
|
+
* ]
|
|
67
|
+
* }
|
|
68
|
+
* ]);
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
defineCommands(commands) {
|
|
72
|
+
return commands;
|
|
73
|
+
},
|
|
74
|
+
/**
|
|
75
|
+
* Verify and parse a Discord interaction from a request.
|
|
76
|
+
* Discord requires interaction verification within 3 seconds.
|
|
77
|
+
*
|
|
78
|
+
* @param c - Hono context from the request
|
|
79
|
+
* @returns Parsed interaction
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```typescript
|
|
83
|
+
* app.post("/discord", async (c) => {
|
|
84
|
+
* const interaction = await discord.verifyInteraction(c);
|
|
85
|
+
* // Handle interaction...
|
|
86
|
+
* });
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
async verifyInteraction(_c) {
|
|
90
|
+
localRuntimeWarning("verifyInteraction");
|
|
91
|
+
},
|
|
92
|
+
/**
|
|
93
|
+
* Reply to a Discord interaction.
|
|
94
|
+
* Must be called within 3 seconds of receiving the interaction.
|
|
95
|
+
*
|
|
96
|
+
* @param interaction - The interaction to reply to
|
|
97
|
+
* @param options - Reply content and options
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```typescript
|
|
101
|
+
* await discord.replyToInteraction(interaction, {
|
|
102
|
+
* content: "Command received!",
|
|
103
|
+
* ephemeral: true // Only visible to command user
|
|
104
|
+
* });
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
replyToInteraction(_interaction, _options) {
|
|
108
|
+
localRuntimeWarning("replyToInteraction");
|
|
109
|
+
},
|
|
110
|
+
/**
|
|
111
|
+
* Send a message to a Discord channel.
|
|
112
|
+
* The channel must be in a server claimed by your project.
|
|
113
|
+
*
|
|
114
|
+
* @param options - Message content and target channel
|
|
115
|
+
* @returns The sent message
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* ```typescript
|
|
119
|
+
* const message = await discord.sendMessage({
|
|
120
|
+
* channelId: "123456789",
|
|
121
|
+
* content: "Hello from Fling!",
|
|
122
|
+
* embeds: [{
|
|
123
|
+
* title: "Deployment Complete",
|
|
124
|
+
* description: "Version 1.2.3 is now live",
|
|
125
|
+
* color: 0x00ff00
|
|
126
|
+
* }]
|
|
127
|
+
* });
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
async sendMessage(_options) {
|
|
131
|
+
localRuntimeWarning("sendMessage");
|
|
132
|
+
},
|
|
133
|
+
/**
|
|
134
|
+
* Edit a previously sent message.
|
|
135
|
+
*
|
|
136
|
+
* @param channelId - The channel containing the message
|
|
137
|
+
* @param messageId - The message to edit
|
|
138
|
+
* @param options - New message content
|
|
139
|
+
* @returns The edited message
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```typescript
|
|
143
|
+
* await discord.editMessage(channelId, messageId, {
|
|
144
|
+
* content: "Updated content"
|
|
145
|
+
* });
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
148
|
+
async editMessage(_channelId, _messageId, _options) {
|
|
149
|
+
localRuntimeWarning("editMessage");
|
|
150
|
+
},
|
|
151
|
+
/**
|
|
152
|
+
* Add a reaction to a message.
|
|
153
|
+
*
|
|
154
|
+
* @param channelId - The channel containing the message
|
|
155
|
+
* @param messageId - The message to react to
|
|
156
|
+
* @param emoji - The emoji to add (unicode or custom emoji format)
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* ```typescript
|
|
160
|
+
* await discord.addReaction(channelId, messageId, "✅");
|
|
161
|
+
* await discord.addReaction(channelId, messageId, "🚀");
|
|
162
|
+
* ```
|
|
163
|
+
*/
|
|
164
|
+
async addReaction(_channelId, _messageId, _emoji) {
|
|
165
|
+
localRuntimeWarning("addReaction");
|
|
166
|
+
},
|
|
167
|
+
/**
|
|
168
|
+
* Send a followup message to an interaction.
|
|
169
|
+
* Use this after the initial reply for additional messages.
|
|
170
|
+
*
|
|
171
|
+
* @param interaction - The original interaction
|
|
172
|
+
* @param options - Followup message content
|
|
173
|
+
* @returns The sent message
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* ```typescript
|
|
177
|
+
* // Initial reply
|
|
178
|
+
* await discord.replyToInteraction(interaction, { content: "Processing..." });
|
|
179
|
+
*
|
|
180
|
+
* // Do some work...
|
|
181
|
+
*
|
|
182
|
+
* // Send followup
|
|
183
|
+
* await discord.sendFollowup(interaction, {
|
|
184
|
+
* content: "Done! Here are the results..."
|
|
185
|
+
* });
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
188
|
+
async sendFollowup(_interaction, _options) {
|
|
189
|
+
localRuntimeWarning("sendFollowup");
|
|
190
|
+
},
|
|
191
|
+
};
|
|
192
|
+
//# sourceMappingURL=discord.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discord.js","sourceRoot":"","sources":["../../src/runtime/discord.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAyBH,gFAAgF;AAChF,sCAAsC;AACtC,gFAAgF;AAEhF;;GAEG;AACH,SAAS,mBAAmB,CAAC,MAAc;IACzC,MAAM,IAAI,KAAK,CACb,WAAW,MAAM,4CAA4C;QAC3D,iEAAiE,CACpE,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,cAAc,CAAC,QAA+B;QAC5C,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACH,KAAK,CAAC,iBAAiB,CAAC,EAAW;QACjC,mBAAmB,CAAC,mBAAmB,CAAC,CAAC;IAC3C,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACH,kBAAkB,CAChB,YAAgC,EAChC,QAAiC;QAEjC,mBAAmB,CAAC,oBAAoB,CAAC,CAAC;IAC5C,CAAC;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,KAAK,CAAC,WAAW,CAAC,QAA4B;QAC5C,mBAAmB,CAAC,aAAa,CAAC,CAAC;IACrC,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACH,KAAK,CAAC,WAAW,CACf,UAAkB,EAClB,UAAkB,EAClB,QAA4B;QAE5B,mBAAmB,CAAC,aAAa,CAAC,CAAC;IACrC,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,WAAW,CACf,UAAkB,EAClB,UAAkB,EAClB,MAAc;QAEd,mBAAmB,CAAC,aAAa,CAAC,CAAC;IACrC,CAAC;IAED;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,KAAK,CAAC,YAAY,CAChB,YAAgC,EAChC,QAAiC;QAEjC,mBAAmB,CAAC,cAAc,CAAC,CAAC;IACtC,CAAC;CACF,CAAC"}
|
|
@@ -4,6 +4,34 @@
|
|
|
4
4
|
* Secrets are retrieved by name. If a secret is not set,
|
|
5
5
|
* Fling throws an error immediately - no default values.
|
|
6
6
|
*/
|
|
7
|
+
/**
|
|
8
|
+
* Get the secrets file path.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getSecretsPath(): string;
|
|
11
|
+
/**
|
|
12
|
+
* Set secrets path. Used for testing.
|
|
13
|
+
*/
|
|
14
|
+
export declare function setSecretsPath(path: string): void;
|
|
15
|
+
/**
|
|
16
|
+
* Reset secrets path to default behavior. Used for testing.
|
|
17
|
+
*/
|
|
18
|
+
export declare function resetSecretsPath(): void;
|
|
19
|
+
/**
|
|
20
|
+
* Parse secrets from file content.
|
|
21
|
+
* Exported for use by CLI and other tools.
|
|
22
|
+
*/
|
|
23
|
+
export declare function parseSecretsContent(content: string): Map<string, string>;
|
|
24
|
+
/**
|
|
25
|
+
* Read secrets from file without caching.
|
|
26
|
+
* Exported for use by CLI which needs fresh reads.
|
|
27
|
+
*/
|
|
28
|
+
export declare function readSecretsFile(): Map<string, string>;
|
|
29
|
+
/**
|
|
30
|
+
* Write secrets to file.
|
|
31
|
+
* Creates parent directories if needed.
|
|
32
|
+
* Exported for use by CLI.
|
|
33
|
+
*/
|
|
34
|
+
export declare function writeSecretsFile(secrets: Map<string, string>): void;
|
|
7
35
|
/**
|
|
8
36
|
* Secrets interface for retrieving credentials
|
|
9
37
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secrets.d.ts","sourceRoot":"","sources":["../../src/runtime/secrets.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"secrets.d.ts","sourceRoot":"","sources":["../../src/runtime/secrets.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH;;GAEG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAKvC;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAGjD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAGvC;AAID;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAexE;AAED;;;GAGG;AACH,wBAAgB,eAAe,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAOrD;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAanE;AAUD;;GAEG;AACH,eAAO,MAAM,OAAO;IAClB;;;;;;;;;;;;;;OAcG;cACO,MAAM,GAAG,MAAM;IAazB;;OAEG;cACO,MAAM,GAAG,OAAO;IAK1B;;OAEG;kBACW,IAAI;CAGnB,CAAC"}
|
package/dist/runtime/secrets.js
CHANGED
|
@@ -4,31 +4,88 @@
|
|
|
4
4
|
* Secrets are retrieved by name. If a secret is not set,
|
|
5
5
|
* Fling throws an error immediately - no default values.
|
|
6
6
|
*/
|
|
7
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
8
|
-
import { join } from "node:path";
|
|
9
|
-
// Secrets file path
|
|
10
|
-
|
|
7
|
+
import { existsSync, readFileSync, writeFileSync, mkdirSync } from "node:fs";
|
|
8
|
+
import { join, dirname } from "node:path";
|
|
9
|
+
// Secrets file path - configurable via environment or setter
|
|
10
|
+
let _secretsPath = null;
|
|
11
|
+
/**
|
|
12
|
+
* Get the secrets file path.
|
|
13
|
+
*/
|
|
14
|
+
export function getSecretsPath() {
|
|
15
|
+
if (_secretsPath !== null) {
|
|
16
|
+
return _secretsPath;
|
|
17
|
+
}
|
|
18
|
+
return process.env["FLING_SECRETS_PATH"] ?? join(process.cwd(), ".fling", "secrets");
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Set secrets path. Used for testing.
|
|
22
|
+
*/
|
|
23
|
+
export function setSecretsPath(path) {
|
|
24
|
+
_secretsPath = path;
|
|
25
|
+
secretsCache = null; // Invalidate cache when path changes
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Reset secrets path to default behavior. Used for testing.
|
|
29
|
+
*/
|
|
30
|
+
export function resetSecretsPath() {
|
|
31
|
+
_secretsPath = null;
|
|
32
|
+
secretsCache = null;
|
|
33
|
+
}
|
|
11
34
|
let secretsCache = null;
|
|
35
|
+
/**
|
|
36
|
+
* Parse secrets from file content.
|
|
37
|
+
* Exported for use by CLI and other tools.
|
|
38
|
+
*/
|
|
39
|
+
export function parseSecretsContent(content) {
|
|
40
|
+
const secrets = new Map();
|
|
41
|
+
for (const line of content.split("\n")) {
|
|
42
|
+
const trimmed = line.trim();
|
|
43
|
+
if (!trimmed || trimmed.startsWith("#")) {
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
const eqIndex = trimmed.indexOf("=");
|
|
47
|
+
if (eqIndex > 0) {
|
|
48
|
+
const key = trimmed.slice(0, eqIndex);
|
|
49
|
+
const value = trimmed.slice(eqIndex + 1);
|
|
50
|
+
secrets.set(key, value);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return secrets;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Read secrets from file without caching.
|
|
57
|
+
* Exported for use by CLI which needs fresh reads.
|
|
58
|
+
*/
|
|
59
|
+
export function readSecretsFile() {
|
|
60
|
+
const path = getSecretsPath();
|
|
61
|
+
if (!existsSync(path)) {
|
|
62
|
+
return new Map();
|
|
63
|
+
}
|
|
64
|
+
const content = readFileSync(path, "utf-8");
|
|
65
|
+
return parseSecretsContent(content);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Write secrets to file.
|
|
69
|
+
* Creates parent directories if needed.
|
|
70
|
+
* Exported for use by CLI.
|
|
71
|
+
*/
|
|
72
|
+
export function writeSecretsFile(secrets) {
|
|
73
|
+
const secretsPath = getSecretsPath();
|
|
74
|
+
const dir = dirname(secretsPath);
|
|
75
|
+
if (!existsSync(dir)) {
|
|
76
|
+
mkdirSync(dir, { recursive: true });
|
|
77
|
+
}
|
|
78
|
+
const lines = ["# Fling secrets", "# Format: KEY=value", ""];
|
|
79
|
+
for (const [key, value] of secrets) {
|
|
80
|
+
lines.push(`${key}=${value}`);
|
|
81
|
+
}
|
|
82
|
+
writeFileSync(secretsPath, lines.join("\n") + "\n", { mode: 0o600 });
|
|
83
|
+
}
|
|
12
84
|
function loadSecrets() {
|
|
13
85
|
if (secretsCache) {
|
|
14
86
|
return secretsCache;
|
|
15
87
|
}
|
|
16
|
-
secretsCache =
|
|
17
|
-
if (existsSync(SECRETS_PATH)) {
|
|
18
|
-
const content = readFileSync(SECRETS_PATH, "utf-8");
|
|
19
|
-
for (const line of content.split("\n")) {
|
|
20
|
-
const trimmed = line.trim();
|
|
21
|
-
if (!trimmed || trimmed.startsWith("#")) {
|
|
22
|
-
continue;
|
|
23
|
-
}
|
|
24
|
-
const eqIndex = trimmed.indexOf("=");
|
|
25
|
-
if (eqIndex > 0) {
|
|
26
|
-
const key = trimmed.slice(0, eqIndex);
|
|
27
|
-
const value = trimmed.slice(eqIndex + 1);
|
|
28
|
-
secretsCache.set(key, value);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
88
|
+
secretsCache = readSecretsFile();
|
|
32
89
|
return secretsCache;
|
|
33
90
|
}
|
|
34
91
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secrets.js","sourceRoot":"","sources":["../../src/runtime/secrets.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"secrets.js","sourceRoot":"","sources":["../../src/runtime/secrets.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE1C,6DAA6D;AAC7D,IAAI,YAAY,GAAkB,IAAI,CAAC;AAEvC;;GAEG;AACH,MAAM,UAAU,cAAc;IAC5B,IAAI,YAAY,KAAK,IAAI,EAAE,CAAC;QAC1B,OAAO,YAAY,CAAC;IACtB,CAAC;IACD,OAAO,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;AACvF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,YAAY,GAAG,IAAI,CAAC;IACpB,YAAY,GAAG,IAAI,CAAC,CAAC,qCAAqC;AAC5D,CAAC;AAED;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AAI,CAAC,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,UAAU;QACR,YAAY,GAAG,IAAI,CAAC;IACtB,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Storage primitive using local filesystem
|
|
3
|
+
*
|
|
4
|
+
* The storage API matches Cloudflare R2 for portability.
|
|
5
|
+
* Locally, this uses a flat directory with URL-encoded filenames.
|
|
6
|
+
* In production, it runs against Cloudflare R2.
|
|
7
|
+
*
|
|
8
|
+
* Storage structure:
|
|
9
|
+
* .fling/data/storage/ - Object storage root (flat directory)
|
|
10
|
+
* images%2Flogo.png.data - Key: "images/logo.png" data file
|
|
11
|
+
* images%2Flogo.png.meta - Metadata JSON sidecar
|
|
12
|
+
*
|
|
13
|
+
* Both data and metadata files use explicit suffixes to avoid conflicts
|
|
14
|
+
* (e.g., a key ending in ".meta" won't collide with metadata files).
|
|
15
|
+
*/
|
|
16
|
+
import type { Storage } from "../types/storage.js";
|
|
17
|
+
/**
|
|
18
|
+
* Set storage path. Used for testing.
|
|
19
|
+
*/
|
|
20
|
+
export declare function setStoragePath(path: string): void;
|
|
21
|
+
/**
|
|
22
|
+
* Reset storage path to default behavior. Used for testing.
|
|
23
|
+
*/
|
|
24
|
+
export declare function resetStoragePath(): void;
|
|
25
|
+
/**
|
|
26
|
+
* Local filesystem storage implementation.
|
|
27
|
+
*/
|
|
28
|
+
export declare const storage: Storage;
|
|
29
|
+
//# sourceMappingURL=storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/runtime/storage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAeH,OAAO,KAAK,EACV,OAAO,EAIR,MAAM,qBAAqB,CAAC;AAe7B;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAEjD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAEvC;AAgOD;;GAEG;AACH,eAAO,MAAM,OAAO,EAAE,OA+OrB,CAAC"}
|