@yaks/connections 0.0.0-stage → 0.2.36
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/LICENSE +202 -0
- package/README.md +609 -2
- package/_dist/authorize.d.ts +38 -0
- package/_dist/authorize.d.ts.map +1 -0
- package/_dist/authorize_cli.d.ts +12 -0
- package/_dist/authorize_cli.d.ts.map +1 -0
- package/_dist/brokers.d.ts +66 -0
- package/_dist/brokers.d.ts.map +1 -0
- package/_dist/catalog.d.ts +33 -0
- package/_dist/catalog.d.ts.map +1 -0
- package/_dist/cli.d.ts +3 -0
- package/_dist/cli.d.ts.map +1 -0
- package/_dist/clients.d.ts +18 -0
- package/_dist/clients.d.ts.map +1 -0
- package/_dist/connections.d.ts +296 -0
- package/_dist/connections.d.ts.map +1 -0
- package/_dist/effects.d.ts +15 -0
- package/_dist/effects.d.ts.map +1 -0
- package/_dist/field.d.ts +17 -0
- package/_dist/field.d.ts.map +1 -0
- package/_dist/form.d.ts +49 -0
- package/_dist/form.d.ts.map +1 -0
- package/_dist/given.d.ts +10 -0
- package/_dist/given.d.ts.map +1 -0
- package/_dist/graph.d.ts +15 -0
- package/_dist/graph.d.ts.map +1 -0
- package/_dist/history.d.ts +4 -0
- package/_dist/history.d.ts.map +1 -0
- package/_dist/identity.d.ts +9 -0
- package/_dist/identity.d.ts.map +1 -0
- package/_dist/integrations.d.ts +196 -0
- package/_dist/integrations.d.ts.map +1 -0
- package/_dist/loopback.d.ts +7 -0
- package/_dist/loopback.d.ts.map +1 -0
- package/_dist/mcp-retirement.d.ts +33 -0
- package/_dist/mcp-retirement.d.ts.map +1 -0
- package/_dist/mcp.d.ts +179 -0
- package/_dist/mcp.d.ts.map +1 -0
- package/_dist/mod.d.ts +70 -0
- package/_dist/mod.d.ts.map +1 -0
- package/_dist/paste.d.ts +13 -0
- package/_dist/paste.d.ts.map +1 -0
- package/_dist/requests.d.ts +30 -0
- package/_dist/requests.d.ts.map +1 -0
- package/_dist/services.d.ts +25 -0
- package/_dist/services.d.ts.map +1 -0
- package/_dist/sign-in.d.ts +9 -0
- package/_dist/sign-in.d.ts.map +1 -0
- package/_dist/signin-mail.d.ts +12 -0
- package/_dist/signin-mail.d.ts.map +1 -0
- package/_dist/signin.d.ts +19 -0
- package/_dist/signin.d.ts.map +1 -0
- package/_dist/sources.d.ts +61 -0
- package/_dist/sources.d.ts.map +1 -0
- package/_dist/tools.d.ts +3 -0
- package/_dist/tools.d.ts.map +1 -0
- package/_dist/views.d.ts +3 -0
- package/_dist/views.d.ts.map +1 -0
- package/_dist/vocab.d.ts +6 -0
- package/_dist/vocab.d.ts.map +1 -0
- package/_dist/yaks-app.d.ts +29 -0
- package/_dist/yaks-app.d.ts.map +1 -0
- package/anthropic.json +12 -0
- package/auth_command.js +69 -0
- package/auth_command.js.map +1 -0
- package/auth_command.ts +74 -0
- package/authorize.js +89 -0
- package/authorize.js.map +1 -0
- package/authorize.ts +138 -0
- package/authorize_cli.js +167 -0
- package/authorize_cli.js.map +1 -0
- package/authorize_cli.ts +211 -0
- package/brokers.js +318 -0
- package/brokers.js.map +1 -0
- package/brokers.ts +423 -0
- package/canva.json +32 -0
- package/catalog.js +178 -0
- package/catalog.js.map +1 -0
- package/catalog.ts +216 -0
- package/cli.js +30 -0
- package/cli.js.map +1 -0
- package/cli.ts +26 -0
- package/clients.js +34 -0
- package/clients.js.map +1 -0
- package/clients.ts +65 -0
- package/connections.js +1961 -0
- package/connections.js.map +1 -0
- package/connections.ts +2561 -0
- package/deno.json +1 -0
- package/discord-account.json +22 -0
- package/discord-bot.json +20 -0
- package/discord.json +26 -0
- package/effects.js +168 -0
- package/effects.js.map +1 -0
- package/effects.ts +160 -0
- package/elevenlabs.json +18 -0
- package/facebook.json +18 -0
- package/field.js +19 -0
- package/field.js.map +1 -0
- package/field.ts +31 -0
- package/form.js +112 -0
- package/form.js.map +1 -0
- package/form.ts +178 -0
- package/git-config.js +44 -0
- package/git-config.js.map +1 -0
- package/git-config.ts +26 -0
- package/given.js +83 -0
- package/given.js.map +1 -0
- package/given.ts +88 -0
- package/gmail-mailbox.json +29 -0
- package/gmail.json +31 -0
- package/google-calendar.json +31 -0
- package/google-drive.json +31 -0
- package/google-search-console.json +29 -0
- package/graph.js +36 -0
- package/graph.js.map +1 -0
- package/graph.ts +52 -0
- package/history.js +31 -0
- package/history.js.map +1 -0
- package/history.ts +32 -0
- package/identity.js +15 -0
- package/identity.js.map +1 -0
- package/identity.ts +18 -0
- package/integrations.js +493 -0
- package/integrations.js.map +1 -0
- package/integrations.ts +725 -0
- package/loopback.js +72 -0
- package/loopback.js.map +1 -0
- package/loopback.ts +89 -0
- package/lulu.json +32 -0
- package/mcp-retirement.js +133 -0
- package/mcp-retirement.js.map +1 -0
- package/mcp-retirement.ts +200 -0
- package/mcp-signin.js +14 -0
- package/mcp-signin.js.map +1 -0
- package/mcp-signin.ts +13 -0
- package/mcp.js +1036 -0
- package/mcp.js.map +1 -0
- package/mcp.ts +1283 -0
- package/mod.js +70 -0
- package/mod.js.map +1 -0
- package/mod.ts +216 -0
- package/openai-api.json +12 -0
- package/openai.json +25 -0
- package/openrouter.json +14 -0
- package/package.json +89 -4
- package/paste.js +36 -0
- package/paste.js.map +1 -0
- package/paste.ts +55 -0
- package/requests.js +137 -0
- package/requests.js.map +1 -0
- package/requests.ts +200 -0
- package/services.js +84 -0
- package/services.js.map +1 -0
- package/services.ts +111 -0
- package/sign-in.js +36 -0
- package/sign-in.js.map +1 -0
- package/sign-in.ts +53 -0
- package/signin-mail.js +29 -0
- package/signin-mail.js.map +1 -0
- package/signin-mail.ts +56 -0
- package/signin.js +68 -0
- package/signin.js.map +1 -0
- package/signin.ts +109 -0
- package/slack.json +90 -0
- package/sources.js +178 -0
- package/sources.js.map +1 -0
- package/sources.ts +237 -0
- package/tools.js +39 -0
- package/tools.js.map +1 -0
- package/tools.ts +46 -0
- package/views.js +85 -0
- package/views.js.map +1 -0
- package/views.ts +89 -0
- package/visitor-defaults.json +8 -0
- package/vocab.js +17 -0
- package/vocab.js.map +1 -0
- package/vocab.json +863 -0
- package/vocab.ts +18 -0
- package/voipms.json +32 -0
- package/yaks-app.js +159 -0
- package/yaks-app.js.map +1 -0
- package/yaks-app.ts +177 -0
- package/youtube.json +26 -0
package/deno.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"publish":{"exclude":["**/*_test.ts"]},"name":"@yaks/connections","version":"0.2.36","license":"Apache-2.0","description":"Integrations and connections: the outside services a space can reach, the link between a space or a person and one, and the credential behind it, kept as a secret.","exports":{".":"./mod.ts","./identity":"./identity.ts","./integrations":"./integrations.ts","./vocab":"./vocab.ts","./tools":"./tools.ts","./graph":"./graph.ts","./effects":"./effects.ts","./cli":"./cli.ts","./authorize-cli":"./authorize_cli.ts","./views":"./views.ts","./form":"./form.ts","./paste":"./paste.ts","./yaks-app":"./yaks-app.ts","./mcp":"./mcp.ts","./mcp-retirement":"./mcp-retirement.ts"},"imports":{"@yaks/connections":"./mod.ts","@yaks/connections/identity":"./identity.ts","@yaks/connections/integrations":"./integrations.ts","@yaks/connections/vocab":"./vocab.ts","@yaks/connections/tools":"./tools.ts","@yaks/connections/graph":"./graph.ts","@yaks/connections/effects":"./effects.ts","@yaks/connections/cli":"./cli.ts","@yaks/connections/authorize-cli":"./authorize_cli.ts","@yaks/connections/views":"./views.ts","@yaks/connections/form":"./form.ts","@yaks/connections/paste":"./paste.ts","@yaks/connections/yaks-app":"./yaks-app.ts","@yaks/connections/mcp":"./mcp.ts","@yaks/connections/mcp-retirement":"./mcp-retirement.ts"}}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "discord-account",
|
|
3
|
+
"visitors": "never",
|
|
4
|
+
"title": "Your Discord account",
|
|
5
|
+
"tagline": "You as a Discord user, so your Operator knows it is you when you talk to it on Discord.",
|
|
6
|
+
"site": "https://discord.com",
|
|
7
|
+
"logo": "<svg fill=\"#5865F2\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189Z\"/></svg>",
|
|
8
|
+
"authorize": "https://discord.com/oauth2/authorize",
|
|
9
|
+
"token": "https://discord.com/api/oauth2/token",
|
|
10
|
+
"client": "discord",
|
|
11
|
+
"scopes": [
|
|
12
|
+
"identify"
|
|
13
|
+
],
|
|
14
|
+
"userinfo": "https://discord.com/api/users/@me",
|
|
15
|
+
"account": "id",
|
|
16
|
+
"account_title": "global_name",
|
|
17
|
+
"personal": true,
|
|
18
|
+
"hosts": [
|
|
19
|
+
"discord.com"
|
|
20
|
+
],
|
|
21
|
+
"testing": true
|
|
22
|
+
}
|
package/discord-bot.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "discord-bot",
|
|
3
|
+
"visitors": "never",
|
|
4
|
+
"title": "Your own Discord bot",
|
|
5
|
+
"tagline": "A Discord app you made, with its own name and picture, for your Operator and your apps to talk through.",
|
|
6
|
+
"site": "https://discord.com/developers/applications",
|
|
7
|
+
"logo": "<svg fill=\"#5865F2\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189Z\"/></svg>",
|
|
8
|
+
"chat": "discord",
|
|
9
|
+
"hosts": [
|
|
10
|
+
"discord.com"
|
|
11
|
+
],
|
|
12
|
+
"fields": [
|
|
13
|
+
{
|
|
14
|
+
"name": "key",
|
|
15
|
+
"label": "Bot token"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"testing": true,
|
|
19
|
+
"instructions": "1. Open the [Discord Developer Portal](https://discord.com/developers/applications) and choose your application, or press **New Application**.\n2. Under **Bot**, turn on all three **Privileged Gateway Intents** (Presence, Server Members and Message Content), then press **Reset Token** and copy the token.\n3. Paste the token here.\n4. Under **OAuth2 → URL Generator**, tick `bot`, then View Channels, Read Message History, Send Messages, Send Messages in Threads, Embed Links, Attach Files, Add Reactions, Use External Emojis, Use External Stickers, Send Polls, Create Public Threads, Create Private Threads, Manage Threads, Manage Messages, Pin Messages, Create Events, Manage Events, Change Nickname, Connect, Speak and Use Voice Activity, and open the link it makes to add your bot to your server. A server you added it to before keeps the permissions it was given then until you add it again."
|
|
20
|
+
}
|
package/discord.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "discord",
|
|
3
|
+
"visitors": "never",
|
|
4
|
+
"title": "Discord server",
|
|
5
|
+
"tagline": "Your Operator in your Discord server, where people mention it or talk to it in a channel you choose.",
|
|
6
|
+
"site": "https://discord.com",
|
|
7
|
+
"logo": "<svg fill=\"#5865F2\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189Z\"/></svg>",
|
|
8
|
+
"authorize": "https://discord.com/oauth2/authorize",
|
|
9
|
+
"token": "https://discord.com/api/oauth2/token",
|
|
10
|
+
"client": "discord",
|
|
11
|
+
"scopes": [
|
|
12
|
+
"bot",
|
|
13
|
+
"identify"
|
|
14
|
+
],
|
|
15
|
+
"params": {
|
|
16
|
+
"permissions": "2832883223227456"
|
|
17
|
+
},
|
|
18
|
+
"account": "guild.id",
|
|
19
|
+
"account_title": "guild.name",
|
|
20
|
+
"links": "discord-account",
|
|
21
|
+
"chat": "discord",
|
|
22
|
+
"hosts": [
|
|
23
|
+
"discord.com"
|
|
24
|
+
],
|
|
25
|
+
"testing": true
|
|
26
|
+
}
|
package/effects.js
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
// What a host does about @yaks/connections when it works the effects: the
|
|
2
|
+
// `@yaks/connections/effects` entry point.
|
|
3
|
+
//
|
|
4
|
+
// `integration_install` (./vocab.json) is a start-up effect (`start: true`).
|
|
5
|
+
// The process that starts working them installs the integrations this package
|
|
6
|
+
// builds, trusted, since `built` is server-owned (./integrations.ts
|
|
7
|
+
// `install`). A graph already holding them as shipped is read once and
|
|
8
|
+
// written nothing, so a new build's integrations land when its server starts.
|
|
9
|
+
//
|
|
10
|
+
// `connection_given` hands a key just given to the places its connection's
|
|
11
|
+
// `keep` names, checks it, and completes the tasks asking for it (./given.ts).
|
|
12
|
+
//
|
|
13
|
+
// `connection_hold_lapse` is owed with every grant held for the account that
|
|
14
|
+
// approved it (./connections.ts `settle`). It waits, deferred, until the hold
|
|
15
|
+
// is a day old (`HOLD`), then forgets the grant at the broker (`lapse`).
|
|
16
|
+
// `connection_holds` owes it at start-up for each hold already standing, so
|
|
17
|
+
// one written before it was declared lapses too.
|
|
18
|
+
//
|
|
19
|
+
// `connection_gone` is owed with every connection's death, a disconnect's or
|
|
20
|
+
// its owner's, and forgets at the broker what it held there (`ended`): the row
|
|
21
|
+
// is gone when it runs, so it asks the broker by the connection's eid.
|
|
22
|
+
// `connection_owner_gone` finds connections already disconnected when their
|
|
23
|
+
// owner is erased. `credential_purged` carries the grant locator across
|
|
24
|
+
// permanent deletion of the vault version.
|
|
25
|
+
import { effectInvocation } from "@yaks/effects";
|
|
26
|
+
import { mint } from "@yaks/graph";
|
|
27
|
+
import { purgeEntities } from "@yaks/graph/trash";
|
|
28
|
+
import { line } from "@yaks/query";
|
|
29
|
+
import { install } from "./integrations.js";
|
|
30
|
+
import { given } from "./given.js";
|
|
31
|
+
import { ended, forgetPurged, grantOf, lapse } from "./connections.js";
|
|
32
|
+
import { connectionHistory } from "./history.js";
|
|
33
|
+
import { APPROVING, CONNECTION } from "./identity.js";
|
|
34
|
+
// How long a broker that did not answer a forgetting waits before it is asked
|
|
35
|
+
// again, in ms.
|
|
36
|
+
let AGAIN = 3_600_000;
|
|
37
|
+
// A broker's failure, to be tried again after `AGAIN`.
|
|
38
|
+
let again = (e)=>{
|
|
39
|
+
throw Object.assign(e instanceof Error ? e : new Error(String(e)), {
|
|
40
|
+
retry: {
|
|
41
|
+
after: AGAIN
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
/** Record broker cleanup before permanently removing a saved version. */ export let purgingCredential = (connection, version, saved, broker)=>{
|
|
46
|
+
let grant = grantOf(saved?.value);
|
|
47
|
+
return grant && grant.broker == broker ? [
|
|
48
|
+
{
|
|
49
|
+
entity: {
|
|
50
|
+
eid: mint()
|
|
51
|
+
},
|
|
52
|
+
credential_purge: {
|
|
53
|
+
connection,
|
|
54
|
+
version,
|
|
55
|
+
...grant
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
] : [];
|
|
59
|
+
};
|
|
60
|
+
let disconnected = async (host, owner)=>{
|
|
61
|
+
let trash = host.graph.storage.trash;
|
|
62
|
+
if (!trash) return [];
|
|
63
|
+
let ids = [
|
|
64
|
+
...new Set((await host.vault.trash()).map((one)=>one.eid))
|
|
65
|
+
];
|
|
66
|
+
let rows = [];
|
|
67
|
+
for(let at = 0; at < ids.length; at += 50){
|
|
68
|
+
let page = ids.slice(at, at + 50);
|
|
69
|
+
let live = new Set((await host.graph.get(page, [
|
|
70
|
+
CONNECTION
|
|
71
|
+
])).filter((b)=>b[CONNECTION]).map((b)=>b.entity.eid));
|
|
72
|
+
for (let row of (await connectionHistory(trash, page.filter((eid)=>!live.has(eid)))).values()){
|
|
73
|
+
let connection = row[CONNECTION];
|
|
74
|
+
if (connection.owner == owner && connection.broker) rows.push(row);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return rows;
|
|
78
|
+
};
|
|
79
|
+
/** The built integrations installed, whenever a process starts working the
|
|
80
|
+
* effects, a given key kept, checked and its asks completed, a grant held
|
|
81
|
+
* for its approver forgotten once its day is out, and what a connection held
|
|
82
|
+
* at the broker forgotten once it dies. */ export let effects = (host)=>({
|
|
83
|
+
integration_install: async ()=>{
|
|
84
|
+
let bundles = await install(host.graph.read);
|
|
85
|
+
if (bundles.length) await host.graph.apply(bundles, {
|
|
86
|
+
trusted: true
|
|
87
|
+
});
|
|
88
|
+
},
|
|
89
|
+
connection_given: given(host),
|
|
90
|
+
connection_hold_lapse: async (event, _tx, write, attempt)=>{
|
|
91
|
+
let c = {
|
|
92
|
+
...host,
|
|
93
|
+
graph: {
|
|
94
|
+
read: host.graph.read,
|
|
95
|
+
apply: write
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
let left = await lapse(c, event.entity.eid).catch(again);
|
|
99
|
+
if (left) await attempt?.defer?.(left, 'held for its approver');
|
|
100
|
+
},
|
|
101
|
+
connection_gone: async (event, _tx, write)=>{
|
|
102
|
+
let was = event.before?.[CONNECTION];
|
|
103
|
+
if (!was) return;
|
|
104
|
+
let c = {
|
|
105
|
+
...host,
|
|
106
|
+
graph: {
|
|
107
|
+
read: host.graph.read,
|
|
108
|
+
apply: write
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
await ended(c, event.entity.eid, was).catch(again);
|
|
112
|
+
},
|
|
113
|
+
connection_owner_gone: async (event, _tx, write)=>{
|
|
114
|
+
let c = {
|
|
115
|
+
...host,
|
|
116
|
+
graph: {
|
|
117
|
+
read: host.graph.read,
|
|
118
|
+
apply: write
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
for (let row of (await disconnected(host, event.entity.eid).catch(again))){
|
|
122
|
+
await ended(c, row.entity.eid, row[CONNECTION]).catch(again);
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
credential_purged: async ({ entity }, tx, write)=>{
|
|
126
|
+
let [row] = await tx.get([
|
|
127
|
+
entity.eid
|
|
128
|
+
], [
|
|
129
|
+
'credential_purge'
|
|
130
|
+
]);
|
|
131
|
+
let purge = row?.credential_purge;
|
|
132
|
+
if (!purge) return;
|
|
133
|
+
let { connection, version } = purge;
|
|
134
|
+
await host.vault.lock(connection, async ()=>{
|
|
135
|
+
await host.vault.purge(version);
|
|
136
|
+
let c = {
|
|
137
|
+
...host,
|
|
138
|
+
graph: {
|
|
139
|
+
read: host.graph.read,
|
|
140
|
+
apply: write
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
await forgetPurged(c, connection, purge);
|
|
144
|
+
if (!await host.vault.read(connection) && !(await host.vault.trash()).some((s)=>s.eid == connection) && !(await tx.get([
|
|
145
|
+
connection
|
|
146
|
+
], [
|
|
147
|
+
CONNECTION
|
|
148
|
+
])).some((b)=>b[CONNECTION])) {
|
|
149
|
+
await purgeEntities(host.graph, [
|
|
150
|
+
connection
|
|
151
|
+
]);
|
|
152
|
+
}
|
|
153
|
+
}).catch(again);
|
|
154
|
+
await write([
|
|
155
|
+
{
|
|
156
|
+
entity,
|
|
157
|
+
tombstone: {}
|
|
158
|
+
}
|
|
159
|
+
]);
|
|
160
|
+
},
|
|
161
|
+
connection_holds: async (_event, _tx, write)=>{
|
|
162
|
+
let holds = await host.graph.read(line`.${CONNECTION}&.${APPROVING}`);
|
|
163
|
+
if (holds.length) {
|
|
164
|
+
await write(holds.map((b)=>effectInvocation('connection_hold_lapse', b.entity.eid)));
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
//# sourceMappingURL=effects.js.map
|
package/effects.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"effects.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K,KAAK,CAAC,KAAK,EAAE,EAAE,IAAI,CAAC,CAAC,IAAM,EAAE,GAAG,IAAI,eACjD,CAAC,CAAC,MAAM,GAAG,GAAG,CAAC;UAAC;SAAW,EAAE;UAAC;SAAW,CAAC,EAAE,IAAI,CAAC,CAAC,IAAM,CAAC,CAAC,WAAW,GACrE;UACA,MAAM,cAAc,KAAK,KAAK,EAAE;YAAC;WAAW;QAC9C;MACF,GAAG,KAAK,CAAC;MACT,MAAM,MAAM;QAAC;UAAE;UAAQ,WAAW,CAAC;QAAE;OAAE;IACzC;IACA,kBAAkB,OAAO,QAAQ,KAAK;MACpC,IAAI,QAAQ,MAAM,KAAK,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,WAAW,EAAE,EAAE,UAAU,CAAC;MACpE,IAAI,MAAM,MAAM,EAAE;QAChB,MAAM,MACJ,MAAM,GAAG,CAAC,CAAC,IACT,iBAAiB,yBAAyB,EAAE,MAAM,CAAC,GAAG;MAG5D;IACF;EACF,CAAC,EAAC"}
|
package/effects.ts
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
// What a host does about @yaks/connections when it works the effects: the
|
|
2
|
+
// `@yaks/connections/effects` entry point.
|
|
3
|
+
//
|
|
4
|
+
// `integration_install` (./vocab.json) is a start-up effect (`start: true`).
|
|
5
|
+
// The process that starts working them installs the integrations this package
|
|
6
|
+
// builds, trusted, since `built` is server-owned (./integrations.ts
|
|
7
|
+
// `install`). A graph already holding them as shipped is read once and
|
|
8
|
+
// written nothing, so a new build's integrations land when its server starts.
|
|
9
|
+
//
|
|
10
|
+
// `connection_given` hands a key just given to the places its connection's
|
|
11
|
+
// `keep` names, checks it, and completes the tasks asking for it (./given.ts).
|
|
12
|
+
//
|
|
13
|
+
// `connection_hold_lapse` is owed with every grant held for the account that
|
|
14
|
+
// approved it (./connections.ts `settle`). It waits, deferred, until the hold
|
|
15
|
+
// is a day old (`HOLD`), then forgets the grant at the broker (`lapse`).
|
|
16
|
+
// `connection_holds` owes it at start-up for each hold already standing, so
|
|
17
|
+
// one written before it was declared lapses too.
|
|
18
|
+
//
|
|
19
|
+
// `connection_gone` is owed with every connection's death, a disconnect's or
|
|
20
|
+
// its owner's, and forgets at the broker what it held there (`ended`): the row
|
|
21
|
+
// is gone when it runs, so it asks the broker by the connection's eid.
|
|
22
|
+
// `connection_owner_gone` finds connections already disconnected when their
|
|
23
|
+
// owner is erased. `credential_purged` carries the grant locator across
|
|
24
|
+
// permanent deletion of the vault version.
|
|
25
|
+
|
|
26
|
+
import { effectInvocation, type Handlers } from '@yaks/effects'
|
|
27
|
+
import { type Bundle, type Comp, type Graph, mint } from '@yaks/graph'
|
|
28
|
+
import { purgeEntities } from '@yaks/graph/trash'
|
|
29
|
+
import type { Sealed } from 'jsr:@yaks/secrets@0.2.36'
|
|
30
|
+
import { line } from '@yaks/query'
|
|
31
|
+
import { install } from './integrations.js'
|
|
32
|
+
import { given, type Host as Giving } from './given.js'
|
|
33
|
+
import { ended, forgetPurged, grantOf, lapse } from './connections.js'
|
|
34
|
+
import { connectionHistory } from './history.js'
|
|
35
|
+
import { APPROVING, CONNECTION } from './identity.js'
|
|
36
|
+
|
|
37
|
+
/** What the handlers are given: the graph, its vault, the keepers the host
|
|
38
|
+
* lends, and its clock. */
|
|
39
|
+
export type Host = Giving & { graph: Graph; now?: () => number }
|
|
40
|
+
|
|
41
|
+
// How long a broker that did not answer a forgetting waits before it is asked
|
|
42
|
+
// again, in ms.
|
|
43
|
+
let AGAIN = 3_600_000
|
|
44
|
+
|
|
45
|
+
// A broker's failure, to be tried again after `AGAIN`.
|
|
46
|
+
let again = (e: unknown) => {
|
|
47
|
+
throw Object.assign(e instanceof Error ? e : new Error(String(e)), {
|
|
48
|
+
retry: { after: AGAIN },
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
type CredentialPurge = {
|
|
53
|
+
connection: string
|
|
54
|
+
version: string
|
|
55
|
+
broker: string
|
|
56
|
+
integration: string
|
|
57
|
+
id: string
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Record broker cleanup before permanently removing a saved version. */
|
|
61
|
+
export let purgingCredential = (
|
|
62
|
+
connection: string,
|
|
63
|
+
version: string,
|
|
64
|
+
saved: Sealed | undefined,
|
|
65
|
+
broker: unknown,
|
|
66
|
+
): Bundle[] => {
|
|
67
|
+
let grant = grantOf(saved?.value)
|
|
68
|
+
return grant && grant.broker == broker
|
|
69
|
+
? [{
|
|
70
|
+
entity: { eid: mint() },
|
|
71
|
+
credential_purge: {
|
|
72
|
+
connection,
|
|
73
|
+
version,
|
|
74
|
+
...grant,
|
|
75
|
+
} satisfies CredentialPurge,
|
|
76
|
+
}]
|
|
77
|
+
: []
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
let disconnected = async (host: Host, owner: string) => {
|
|
81
|
+
let trash = host.graph.storage.trash
|
|
82
|
+
if (!trash) return []
|
|
83
|
+
let ids = [...new Set((await host.vault.trash()).map((one) => one.eid))]
|
|
84
|
+
let rows: Bundle[] = []
|
|
85
|
+
for (let at = 0; at < ids.length; at += 50) {
|
|
86
|
+
let page = ids.slice(at, at + 50)
|
|
87
|
+
let live = new Set(
|
|
88
|
+
(await host.graph.get(page, [CONNECTION])).filter((b) => b[CONNECTION])
|
|
89
|
+
.map((b) => b.entity.eid),
|
|
90
|
+
)
|
|
91
|
+
for (
|
|
92
|
+
let row of (await connectionHistory(
|
|
93
|
+
trash,
|
|
94
|
+
page.filter((eid) => !live.has(eid)),
|
|
95
|
+
)).values()
|
|
96
|
+
) {
|
|
97
|
+
let connection = row[CONNECTION] as Comp
|
|
98
|
+
if (connection.owner == owner && connection.broker) rows.push(row)
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return rows
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** The built integrations installed, whenever a process starts working the
|
|
105
|
+
* effects, a given key kept, checked and its asks completed, a grant held
|
|
106
|
+
* for its approver forgotten once its day is out, and what a connection held
|
|
107
|
+
* at the broker forgotten once it dies. */
|
|
108
|
+
export let effects = (host: Host): Handlers => ({
|
|
109
|
+
integration_install: async () => {
|
|
110
|
+
let bundles = await install(host.graph.read)
|
|
111
|
+
if (bundles.length) await host.graph.apply(bundles, { trusted: true })
|
|
112
|
+
},
|
|
113
|
+
connection_given: given(host),
|
|
114
|
+
connection_hold_lapse: async (event, _tx, write, attempt) => {
|
|
115
|
+
let c = { ...host, graph: { read: host.graph.read, apply: write } }
|
|
116
|
+
let left = await lapse(c, event.entity.eid).catch(again)
|
|
117
|
+
if (left) await attempt?.defer?.(left, 'held for its approver')
|
|
118
|
+
},
|
|
119
|
+
connection_gone: async (event, _tx, write) => {
|
|
120
|
+
let was = event.before?.[CONNECTION] as Comp | undefined
|
|
121
|
+
if (!was) return
|
|
122
|
+
let c = { ...host, graph: { read: host.graph.read, apply: write } }
|
|
123
|
+
await ended(c, event.entity.eid, was).catch(again)
|
|
124
|
+
},
|
|
125
|
+
connection_owner_gone: async (event, _tx, write) => {
|
|
126
|
+
let c = { ...host, graph: { read: host.graph.read, apply: write } }
|
|
127
|
+
for (let row of await disconnected(host, event.entity.eid).catch(again)) {
|
|
128
|
+
await ended(c, row.entity.eid, row[CONNECTION] as Comp).catch(again)
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
credential_purged: async ({ entity }, tx, write) => {
|
|
132
|
+
let [row] = await tx.get([entity.eid], ['credential_purge'])
|
|
133
|
+
let purge = row?.credential_purge as CredentialPurge | undefined
|
|
134
|
+
if (!purge) return
|
|
135
|
+
let { connection, version } = purge
|
|
136
|
+
await host.vault.lock(connection, async () => {
|
|
137
|
+
await host.vault.purge(version)
|
|
138
|
+
let c = { ...host, graph: { read: host.graph.read, apply: write } }
|
|
139
|
+
await forgetPurged(c, connection, purge)
|
|
140
|
+
if (
|
|
141
|
+
!await host.vault.read(connection) &&
|
|
142
|
+
!(await host.vault.trash()).some((s) => s.eid == connection) &&
|
|
143
|
+
!(await tx.get([connection], [CONNECTION])).some((b) => b[CONNECTION])
|
|
144
|
+
) {
|
|
145
|
+
await purgeEntities(host.graph, [connection])
|
|
146
|
+
}
|
|
147
|
+
}).catch(again)
|
|
148
|
+
await write([{ entity, tombstone: {} }])
|
|
149
|
+
},
|
|
150
|
+
connection_holds: async (_event, _tx, write) => {
|
|
151
|
+
let holds = await host.graph.read(line`.${CONNECTION}&.${APPROVING}`)
|
|
152
|
+
if (holds.length) {
|
|
153
|
+
await write(
|
|
154
|
+
holds.map((b) =>
|
|
155
|
+
effectInvocation('connection_hold_lapse', b.entity.eid)
|
|
156
|
+
),
|
|
157
|
+
)
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
})
|
package/elevenlabs.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "elevenlabs",
|
|
3
|
+
"visitors": "off",
|
|
4
|
+
"title": "ElevenLabs",
|
|
5
|
+
"tagline": "Lifelike voices: speech from text, voices designed from a description, and clones of your own.",
|
|
6
|
+
"site": "https://elevenlabs.io",
|
|
7
|
+
"logo": "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><rect width=\"24\" height=\"24\" rx=\"5\" fill=\"#000\"/><rect x=\"8\" y=\"5\" width=\"2.6\" height=\"14\" fill=\"#fff\"/><rect x=\"13.4\" y=\"5\" width=\"2.6\" height=\"14\" fill=\"#fff\"/></svg>",
|
|
8
|
+
"hosts": [
|
|
9
|
+
"api.elevenlabs.io"
|
|
10
|
+
],
|
|
11
|
+
"api": {
|
|
12
|
+
"base": "https://api.elevenlabs.io",
|
|
13
|
+
"docs": "https://elevenlabs.io/docs/api-reference"
|
|
14
|
+
},
|
|
15
|
+
"instructions": "1. Sign in at [elevenlabs.io](https://elevenlabs.io) and open [Developers → API Keys](https://elevenlabs.io/app/developers/api-keys).\n2. Choose **Create Key**, name it yaks.app, and allow what your apps and Operator will do: **Text to Speech**, **Voices** (read, and write to design or clone voices) and **Speech to Text**.\n3. Copy the key and paste it here.\n\nSpeech, voices and designs made with it are charged to your ElevenLabs account. Cloning a voice needs a plan that allows it. An app sends the key in the `xi-api-key` header.",
|
|
16
|
+
"example": "sk_••••••••",
|
|
17
|
+
"mcp": "https://api.elevenlabs.io/v1/mcp"
|
|
18
|
+
}
|
package/facebook.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "facebook",
|
|
3
|
+
"visitors": "never",
|
|
4
|
+
"title": "Facebook",
|
|
5
|
+
"tagline": "Connect a Facebook Page you manage.",
|
|
6
|
+
"site": "https://www.facebook.com/",
|
|
7
|
+
"image": "https://app.nango.dev/images/template-logos/facebook.svg",
|
|
8
|
+
"docs": "https://developers.facebook.com/docs/graph-api/reference/page/published_posts/",
|
|
9
|
+
"broker": {
|
|
10
|
+
"name": "nango",
|
|
11
|
+
"integration": "facebook",
|
|
12
|
+
"managed": true
|
|
13
|
+
},
|
|
14
|
+
"scopes": ["email", "pages_show_list", "pages_read_engagement"],
|
|
15
|
+
"hosts": ["graph.facebook.com"],
|
|
16
|
+
"categories": ["marketing", "social"],
|
|
17
|
+
"userinfo": "https://graph.facebook.com/v27.0/me?fields=email"
|
|
18
|
+
}
|
package/field.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// What a person gives to connect a pasted-key integration, apart from the
|
|
2
|
+
// integrations themselves, so a page drawing the box a key is pasted in
|
|
3
|
+
// (./form.ts) loads none of their seed data.
|
|
4
|
+
/** One thing a person gives to connect a pasted-key integration: what an app
|
|
5
|
+
* reads it by, what the page asks for it by, whether it is typed in the open,
|
|
6
|
+
* as a username or a region is, and what it looks like. */ /** The one field of an integration that declares none: its key. */ export let KEY = {
|
|
7
|
+
name: 'key',
|
|
8
|
+
label: 'Key'
|
|
9
|
+
};
|
|
10
|
+
/** The field names shared by site sign-ins and their vault credentials. */ export let loginFields = (fields)=>fields.length == 2 && fields.some((f)=>f.name == 'username') && fields.some((f)=>f.name == 'password');
|
|
11
|
+
/** What a person gives to connect a pasted-key integration, in the order the
|
|
12
|
+
* page asks for it: the fields it declares, or its one key, shaped as the
|
|
13
|
+
* integration says. */ export let fieldsOf = (i)=>i?.fields?.length ? i.fields : [
|
|
14
|
+
i?.example ? {
|
|
15
|
+
...KEY,
|
|
16
|
+
example: i.example
|
|
17
|
+
} : KEY
|
|
18
|
+
];
|
|
19
|
+
//# sourceMappingURL=field.js.map
|
package/field.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field.js","sources":["./field.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,wEAAwE;AACxE,6CAA6C;AAE7C;;yDAEyD,GAQzD,iEAAiE,GACjE,OAAO,IAAI,MAAa;EAAE,MAAM;EAAO,OAAO;AAAM,EAAC;AAErD,yEAAyE,GACzE,OAAO,IAAI,cAAc,CAAC,SACxB,OAAO,MAAM,IAAI,KAAK,OAAO,IAAI,CAAC,CAAC,IAAM,EAAE,IAAI,IAAI,eACnD,OAAO,IAAI,CAAC,CAAC,IAAM,EAAE,IAAI,IAAI,YAAW;AAE1C;;qBAEqB,GACrB,OAAO,IAAI,WAAW,CACpB,IAEA,GAAG,QAAQ,SACP,EAAE,MAAM,GACR;IAAC,GAAG,UAAU;MAAE,GAAG,GAAG;MAAE,SAAS,EAAE,OAAO;IAAC,IAAI;GAAI,CAAA"}
|
package/field.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// What a person gives to connect a pasted-key integration, apart from the
|
|
2
|
+
// integrations themselves, so a page drawing the box a key is pasted in
|
|
3
|
+
// (./form.ts) loads none of their seed data.
|
|
4
|
+
|
|
5
|
+
/** One thing a person gives to connect a pasted-key integration: what an app
|
|
6
|
+
* reads it by, what the page asks for it by, whether it is typed in the open,
|
|
7
|
+
* as a username or a region is, and what it looks like. */
|
|
8
|
+
export type Field = {
|
|
9
|
+
name: string
|
|
10
|
+
label: string
|
|
11
|
+
shown?: boolean
|
|
12
|
+
example?: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** The one field of an integration that declares none: its key. */
|
|
16
|
+
export let KEY: Field = { name: 'key', label: 'Key' }
|
|
17
|
+
|
|
18
|
+
/** The field names shared by site sign-ins and their vault credentials. */
|
|
19
|
+
export let loginFields = (fields: Field[]): boolean =>
|
|
20
|
+
fields.length == 2 && fields.some((f) => f.name == 'username') &&
|
|
21
|
+
fields.some((f) => f.name == 'password')
|
|
22
|
+
|
|
23
|
+
/** What a person gives to connect a pasted-key integration, in the order the
|
|
24
|
+
* page asks for it: the fields it declares, or its one key, shaped as the
|
|
25
|
+
* integration says. */
|
|
26
|
+
export let fieldsOf = (
|
|
27
|
+
i?: { fields?: Field[]; example?: string },
|
|
28
|
+
): Field[] =>
|
|
29
|
+
i?.fields?.length
|
|
30
|
+
? i.fields
|
|
31
|
+
: [i?.example ? { ...KEY, example: i.example } : KEY]
|
package/form.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The box a key is pasted in, wherever a person is asked for one: a task
|
|
3
|
+
* asking for a connection (`asks`), a connections page, a sign-in page. It is
|
|
4
|
+
* plain markup for a server's page and a component for a live one, shared by
|
|
5
|
+
* every host; what saving does is the host's (`save`), and a page writes
|
|
6
|
+
* {@link pasted} through the graph, which seals the value out of the write.
|
|
7
|
+
* The key is never prefilled, drawn back, or kept in the page's state.
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/ /* @ts-types="npm:@types/react@19.3.0" */ import { createElement as h, useState } from "react";
|
|
11
|
+
import { Button, Field as Box, Form, Section } from "@yaks/ui";
|
|
12
|
+
import { fieldsOf, KEY, loginFields } from "./field.js";
|
|
13
|
+
export { pasted } from "./paste.js";
|
|
14
|
+
export { fieldsOf, KEY, loginFields };
|
|
15
|
+
let labeled = (id, label, control, hint = '')=>/*#__PURE__*/ h(Form.Field, null, /*#__PURE__*/ h(Form.Label, {
|
|
16
|
+
for: id
|
|
17
|
+
}, label), control, hint ? /*#__PURE__*/ h(Form.Hint, null, hint) : null);
|
|
18
|
+
/** The box a key is pasted in and the button that saves it, one line under
|
|
19
|
+
* its label; or, for a service that asks for several fields, a box for each
|
|
20
|
+
* under its own label, masked unless the field is shown, and the button under
|
|
21
|
+
* them. Each box shows what its field looks like, where the integration says,
|
|
22
|
+
* and a row of dots where it does not. {@link givenOf} reads what was typed. */ export let keyBox = (id, label, send, hint = '', fields = [
|
|
23
|
+
KEY
|
|
24
|
+
])=>{
|
|
25
|
+
let box = (at, name, f)=>/*#__PURE__*/ h(Box, {
|
|
26
|
+
id: at,
|
|
27
|
+
name,
|
|
28
|
+
type: f.shown ? 'text' : 'password',
|
|
29
|
+
placeholder: f.example || (f.shown && f.name == 'username' ? f.label : '••••••••'),
|
|
30
|
+
autocomplete: 'off',
|
|
31
|
+
spellcheck: 'false',
|
|
32
|
+
required: true
|
|
33
|
+
});
|
|
34
|
+
if (fields.length == 1) {
|
|
35
|
+
return labeled(id, fields[0].label == KEY.label ? label : fields[0].label, /*#__PURE__*/ h(Form.Line, null, box(id, 'key', fields[0]), send), hint);
|
|
36
|
+
}
|
|
37
|
+
return [
|
|
38
|
+
...fields.map((f)=>labeled(`${id}-${f.name}`, f.label, box(`${id}-${f.name}`, `key.${f.name}`, f))),
|
|
39
|
+
send ? /*#__PURE__*/ h(Form.Actions, null, send) : null,
|
|
40
|
+
hint ? /*#__PURE__*/ h(Form.Hint, null, hint) : null
|
|
41
|
+
];
|
|
42
|
+
};
|
|
43
|
+
/** What a person typed into a {@link keyBox}, read from its form by name
|
|
44
|
+
* (a posted `FormData`, or the boxes themselves): the one key, or each field
|
|
45
|
+
* by name; or what the page says when one was left empty.
|
|
46
|
+
*
|
|
47
|
+
* ```ts
|
|
48
|
+
* import { assertEquals } from '@std/assert'
|
|
49
|
+
* let form = new FormData()
|
|
50
|
+
* form.set('key', ' k ')
|
|
51
|
+
* assertEquals(givenOf(form, [{ name: 'key', label: 'Key' }]), { key: 'k' })
|
|
52
|
+
* assertEquals(givenOf(new FormData(), [{ name: 'key', label: 'API key' }]), 'Enter the API key.')
|
|
53
|
+
* ```
|
|
54
|
+
*/ export let givenOf = (form, fields)=>{
|
|
55
|
+
let at = (k)=>String(form.get(k) ?? '').trim();
|
|
56
|
+
if (fields.length == 1) {
|
|
57
|
+
return at('key') ? {
|
|
58
|
+
key: at('key')
|
|
59
|
+
} : 'Enter the API key.';
|
|
60
|
+
}
|
|
61
|
+
let said = Object.fromEntries(fields.map((f)=>[
|
|
62
|
+
f.name,
|
|
63
|
+
at(`key.${f.name}`)
|
|
64
|
+
]));
|
|
65
|
+
let missing = fields.find((f)=>!said[f.name]);
|
|
66
|
+
return missing ? `Fill in ${missing.label} first.` : {
|
|
67
|
+
fields: said
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
/** A connection a person is asked to paste a key for, as a live page draws
|
|
71
|
+
* it: what it is for, how to get the key (`howTo`, drawn by the host), the
|
|
72
|
+
* box, anything the host adds under it (`children`), and what came of
|
|
73
|
+
* saving. A connection whose last key the service refused (`broken`) asks
|
|
74
|
+
* again; once connected, only what came of saving stays, and no box. `save`
|
|
75
|
+
* keeps what was given and resolves once the write is answered; what the page
|
|
76
|
+
* says after is its own. */ export let KeyForm = ({ id, title, fields, status, howTo, save, children })=>{
|
|
77
|
+
let [said, say] = useState('');
|
|
78
|
+
let [busy, setBusy] = useState(false);
|
|
79
|
+
let connected = status == 'connected';
|
|
80
|
+
if (connected && !said) return null;
|
|
81
|
+
let submit = async (ev)=>{
|
|
82
|
+
ev.preventDefault();
|
|
83
|
+
let form = ev.currentTarget;
|
|
84
|
+
let given = givenOf({
|
|
85
|
+
get: (name)=>form.querySelector(`[name="${name}"]`)?.value
|
|
86
|
+
}, fields);
|
|
87
|
+
if (typeof given == 'string') return say(given);
|
|
88
|
+
setBusy(true);
|
|
89
|
+
say('');
|
|
90
|
+
try {
|
|
91
|
+
await save(given);
|
|
92
|
+
form.reset();
|
|
93
|
+
say('Saved. It is checked, then kept where it is used.');
|
|
94
|
+
} catch (e) {
|
|
95
|
+
say(e instanceof Error ? e.message : String(e));
|
|
96
|
+
} finally{
|
|
97
|
+
setBusy(false);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
return /*#__PURE__*/ h(Section, {
|
|
101
|
+
'data-key': id
|
|
102
|
+
}, /*#__PURE__*/ h(Section.Title, {}, title, /*#__PURE__*/ h(Section.Note, {}, connected ? 'connected' : status == 'broken' ? 'refused' : 'needed')), status == 'broken' ? /*#__PURE__*/ h(Section.Sub, {}, 'The service refused the last key. Paste a new one.') : null, connected ? null : howTo, connected ? null : /*#__PURE__*/ h(Form, {
|
|
103
|
+
onSubmit: submit
|
|
104
|
+
}, keyBox(`key-${id}`, 'Paste the key', /*#__PURE__*/ h(Button, {
|
|
105
|
+
type: 'submit',
|
|
106
|
+
mod: 'go',
|
|
107
|
+
disabled: busy
|
|
108
|
+
}, 'Save key'), '', fields), children), said ? /*#__PURE__*/ h(Section.Note, {
|
|
109
|
+
role: 'status'
|
|
110
|
+
}, said) : null);
|
|
111
|
+
};
|
|
112
|
+
//# sourceMappingURL=form.js.map
|
package/form.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form.js","sources":["./form.ts"],"names":[],"mappings":"AAAA;;;;;;;;;CASC,GACD,uCAAuC,GAAG,SACxC,iBAAiB,CAAC,EAGlB,QAAQ,gBACe;AACzB,SAAS,MAAM,EAAE,SAAS,GAAG,EAAE,IAAI,EAAE,OAAO,wBAA6B;AACzE,SAAqB,QAAQ,EAAE,GAAG,EAAE,WAAW,qBAAoB;AAGnE,SAAsB,MAAM,qBAAoB;AAChD,SAAqB,QAAQ,EAAE,GAAG,EAAE,WAAW,GAAE;AAEjD,IAAI,UAAU,CAAC,IAAY,OAAa,SAAe,OAAa,EAAE,iBACpE,EACE,KAAK,KAAK,EACV,oBACA,EAAE,KAAK,KAAK,EAAE;IAAE,KAAK;EAAG,GAAG,QAC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