@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/form.ts
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
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
|
+
*/
|
|
11
|
+
/* @ts-types="npm:@types/react@19.3.0" */ import {
|
|
12
|
+
createElement as h,
|
|
13
|
+
type JSX,
|
|
14
|
+
type ReactNode as Kids,
|
|
15
|
+
useState,
|
|
16
|
+
} from 'react'
|
|
17
|
+
import { Button, Field as Box, Form, Section } from '@yaks/ui'
|
|
18
|
+
import { type Field, fieldsOf, KEY, loginFields } from './field.js'
|
|
19
|
+
import type { Pasted } from './paste.js'
|
|
20
|
+
|
|
21
|
+
export { type Pasted, pasted } from './paste.js'
|
|
22
|
+
export { type Field, fieldsOf, KEY, loginFields }
|
|
23
|
+
|
|
24
|
+
let labeled = (id: string, label: Kids, control: Kids, hint: Kids = '') =>
|
|
25
|
+
h(
|
|
26
|
+
Form.Field,
|
|
27
|
+
null,
|
|
28
|
+
h(Form.Label, { for: id }, label),
|
|
29
|
+
control,
|
|
30
|
+
hint ? h(Form.Hint, null, hint) : null,
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
/** The box a key is pasted in and the button that saves it, one line under
|
|
34
|
+
* its label; or, for a service that asks for several fields, a box for each
|
|
35
|
+
* under its own label, masked unless the field is shown, and the button under
|
|
36
|
+
* them. Each box shows what its field looks like, where the integration says,
|
|
37
|
+
* and a row of dots where it does not. {@link givenOf} reads what was typed. */
|
|
38
|
+
export let keyBox = (
|
|
39
|
+
id: string,
|
|
40
|
+
label: Kids,
|
|
41
|
+
send: Kids,
|
|
42
|
+
hint: Kids = '',
|
|
43
|
+
fields: Field[] = [KEY],
|
|
44
|
+
): Kids => {
|
|
45
|
+
let box = (at: string, name: string, f: Field) =>
|
|
46
|
+
h(Box, {
|
|
47
|
+
id: at,
|
|
48
|
+
name,
|
|
49
|
+
type: f.shown ? 'text' : 'password',
|
|
50
|
+
placeholder: f.example ||
|
|
51
|
+
(f.shown && f.name == 'username' ? f.label : '••••••••'),
|
|
52
|
+
autocomplete: 'off',
|
|
53
|
+
spellcheck: 'false',
|
|
54
|
+
required: true,
|
|
55
|
+
})
|
|
56
|
+
if (fields.length == 1) {
|
|
57
|
+
return labeled(
|
|
58
|
+
id,
|
|
59
|
+
fields[0].label == KEY.label ? label : fields[0].label,
|
|
60
|
+
h(Form.Line, null, box(id, 'key', fields[0]), send),
|
|
61
|
+
hint,
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
return [
|
|
65
|
+
...fields.map((f) =>
|
|
66
|
+
labeled(
|
|
67
|
+
`${id}-${f.name}`,
|
|
68
|
+
f.label,
|
|
69
|
+
box(`${id}-${f.name}`, `key.${f.name}`, f),
|
|
70
|
+
)
|
|
71
|
+
),
|
|
72
|
+
send ? h(Form.Actions, null, send) : null,
|
|
73
|
+
hint ? h(Form.Hint, null, hint) : null,
|
|
74
|
+
]
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** What a person typed into a {@link keyBox}, read from its form by name
|
|
78
|
+
* (a posted `FormData`, or the boxes themselves): the one key, or each field
|
|
79
|
+
* by name; or what the page says when one was left empty.
|
|
80
|
+
*
|
|
81
|
+
* ```ts
|
|
82
|
+
* import { assertEquals } from '@std/assert'
|
|
83
|
+
* let form = new FormData()
|
|
84
|
+
* form.set('key', ' k ')
|
|
85
|
+
* assertEquals(givenOf(form, [{ name: 'key', label: 'Key' }]), { key: 'k' })
|
|
86
|
+
* assertEquals(givenOf(new FormData(), [{ name: 'key', label: 'API key' }]), 'Enter the API key.')
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
export let givenOf = (
|
|
90
|
+
form: { get: (name: string) => unknown },
|
|
91
|
+
fields: Field[],
|
|
92
|
+
): Pasted | string => {
|
|
93
|
+
let at = (k: string) => String(form.get(k) ?? '').trim()
|
|
94
|
+
if (fields.length == 1) {
|
|
95
|
+
return at('key') ? { key: at('key') } : 'Enter the API key.'
|
|
96
|
+
}
|
|
97
|
+
let said = Object.fromEntries(
|
|
98
|
+
fields.map((f) => [f.name, at(`key.${f.name}`)]),
|
|
99
|
+
)
|
|
100
|
+
let missing = fields.find((f) => !said[f.name])
|
|
101
|
+
return missing ? `Fill in ${missing.label} first.` : { fields: said }
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** A connection a person is asked to paste a key for, as a live page draws
|
|
105
|
+
* it: what it is for, how to get the key (`howTo`, drawn by the host), the
|
|
106
|
+
* box, anything the host adds under it (`children`), and what came of
|
|
107
|
+
* saving. A connection whose last key the service refused (`broken`) asks
|
|
108
|
+
* again; once connected, only what came of saving stays, and no box. `save`
|
|
109
|
+
* keeps what was given and resolves once the write is answered; what the page
|
|
110
|
+
* says after is its own. */
|
|
111
|
+
export let KeyForm = (
|
|
112
|
+
{ id, title, fields, status, howTo, save, children }: {
|
|
113
|
+
id: string
|
|
114
|
+
title: Kids
|
|
115
|
+
fields: Field[]
|
|
116
|
+
status: string
|
|
117
|
+
howTo?: Kids
|
|
118
|
+
save: (given: Pasted) => Promise<unknown>
|
|
119
|
+
/** more the host draws inside the form, under the box */
|
|
120
|
+
children?: Kids
|
|
121
|
+
},
|
|
122
|
+
): JSX.Element | null => {
|
|
123
|
+
let [said, say] = useState('')
|
|
124
|
+
let [busy, setBusy] = useState(false)
|
|
125
|
+
let connected = status == 'connected'
|
|
126
|
+
if (connected && !said) return null
|
|
127
|
+
let submit = async (ev: Event) => {
|
|
128
|
+
ev.preventDefault()
|
|
129
|
+
let form = ev.currentTarget as HTMLFormElement
|
|
130
|
+
let given = givenOf({
|
|
131
|
+
get: (name) =>
|
|
132
|
+
form.querySelector<HTMLInputElement>(`[name="${name}"]`)?.value,
|
|
133
|
+
}, fields)
|
|
134
|
+
if (typeof given == 'string') return say(given)
|
|
135
|
+
setBusy(true)
|
|
136
|
+
say('')
|
|
137
|
+
try {
|
|
138
|
+
await save(given)
|
|
139
|
+
form.reset()
|
|
140
|
+
say('Saved. It is checked, then kept where it is used.')
|
|
141
|
+
} catch (e) {
|
|
142
|
+
say(e instanceof Error ? e.message : String(e))
|
|
143
|
+
} finally {
|
|
144
|
+
setBusy(false)
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return h(
|
|
148
|
+
Section,
|
|
149
|
+
{ 'data-key': id },
|
|
150
|
+
h(
|
|
151
|
+
Section.Title,
|
|
152
|
+
{},
|
|
153
|
+
title,
|
|
154
|
+
h(
|
|
155
|
+
Section.Note,
|
|
156
|
+
{},
|
|
157
|
+
connected ? 'connected' : status == 'broken' ? 'refused' : 'needed',
|
|
158
|
+
),
|
|
159
|
+
),
|
|
160
|
+
status == 'broken'
|
|
161
|
+
? h(Section.Sub, {}, 'The service refused the last key. Paste a new one.')
|
|
162
|
+
: null,
|
|
163
|
+
connected ? null : howTo,
|
|
164
|
+
connected ? null : h(
|
|
165
|
+
Form,
|
|
166
|
+
{ onSubmit: submit },
|
|
167
|
+
keyBox(
|
|
168
|
+
`key-${id}`,
|
|
169
|
+
'Paste the key',
|
|
170
|
+
h(Button, { type: 'submit', mod: 'go', disabled: busy }, 'Save key'),
|
|
171
|
+
'',
|
|
172
|
+
fields,
|
|
173
|
+
),
|
|
174
|
+
children,
|
|
175
|
+
),
|
|
176
|
+
said ? h(Section.Note, { role: 'status' }, said) : null,
|
|
177
|
+
)
|
|
178
|
+
}
|
package/git-config.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { command } from "@yaks/process/command";
|
|
2
|
+
let scope = 'credential.https://*.yaks.app.';
|
|
3
|
+
let helper = '!yak git credential';
|
|
4
|
+
let decode = (bytes)=>new TextDecoder().decode(bytes);
|
|
5
|
+
let config = (args)=>command('git', {
|
|
6
|
+
args: [
|
|
7
|
+
'config',
|
|
8
|
+
'--global',
|
|
9
|
+
...args
|
|
10
|
+
]
|
|
11
|
+
}).output();
|
|
12
|
+
/** Use the same space grant for clone, fetch and push. */ export let installGitCredential = async (run = config)=>{
|
|
13
|
+
let key = scope + 'helper';
|
|
14
|
+
let existing = await run([
|
|
15
|
+
'--null',
|
|
16
|
+
'--get-all',
|
|
17
|
+
key
|
|
18
|
+
]);
|
|
19
|
+
if (!existing.success && existing.code != 1) {
|
|
20
|
+
throw new Error(decode(existing.stderr).trim());
|
|
21
|
+
}
|
|
22
|
+
let helpers = decode(existing.stdout).split('\0').slice(0, -1);
|
|
23
|
+
let write = async (args)=>{
|
|
24
|
+
let result = await run(args);
|
|
25
|
+
if (!result.success) throw new Error(decode(result.stderr).trim());
|
|
26
|
+
};
|
|
27
|
+
await write([
|
|
28
|
+
'--replace-all',
|
|
29
|
+
scope + 'useHttpPath',
|
|
30
|
+
'true'
|
|
31
|
+
]);
|
|
32
|
+
if (helpers.at(-2) == '' && helpers.at(-1) == helper) return;
|
|
33
|
+
await write([
|
|
34
|
+
'--add',
|
|
35
|
+
key,
|
|
36
|
+
''
|
|
37
|
+
]);
|
|
38
|
+
await write([
|
|
39
|
+
'--add',
|
|
40
|
+
key,
|
|
41
|
+
helper
|
|
42
|
+
]);
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=git-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-config.js","sources":["./git-config.ts"],"names":[],"mappings":"AAAA,SAAS,OAAO,qCAA0C;AAE1D,IAAI,QAAQ;AACZ,IAAI,SAAS;AACb,IAAI,SAAS,CAAC,QAAsB,IAAI,cAAc,MAAM,CAAC;AAE7D,IAAI,SAAS,CAAC,OACZ,QAAQ,OAAO;IAAE,MAAM;MAAC;MAAU;SAAe;KAAK;EAAC,GAAG,MAAM;AAElE,wDAAwD,GACxD,OAAO,IAAI,uBAAuB,OAAO,MAAM,MAAM;EACnD,IAAI,MAAM,QAAQ;EAClB,IAAI,WAAW,MAAM,IAAI;IAAC;IAAU;IAAa;GAAI;EACrD,IAAI,CAAC,SAAS,OAAO,IAAI,SAAS,IAAI,IAAI,GAAG;IAC3C,MAAM,IAAI,MAAM,OAAO,SAAS,MAAM,EAAE,IAAI;EAC9C;EACA,IAAI,UAAU,OAAO,SAAS,MAAM,EAAE,KAAK,CAAC,MAAM,KAAK,CAAC,GAAG,CAAC;EAC5D,IAAI,QAAQ,OAAO;IACjB,IAAI,SAAS,MAAM,IAAI;IACvB,IAAI,CAAC,OAAO,OAAO,EAAE,MAAM,IAAI,MAAM,OAAO,OAAO,MAAM,EAAE,IAAI;EACjE;EACA,MAAM,MAAM;IAAC;IAAiB,QAAQ;IAAe;GAAO;EAC5D,IAAI,QAAQ,EAAE,CAAC,CAAC,MAAM,MAAM,QAAQ,EAAE,CAAC,CAAC,MAAM,QAAQ;EACtD,MAAM,MAAM;IAAC;IAAS;IAAK;GAAG;EAC9B,MAAM,MAAM;IAAC;IAAS;IAAK;GAAO;AACpC,EAAC"}
|
package/git-config.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { command } from '@yaks/process/command'
|
|
2
|
+
|
|
3
|
+
let scope = 'credential.https://*.yaks.app.'
|
|
4
|
+
let helper = '!yak git credential'
|
|
5
|
+
let decode = (bytes: Uint8Array) => new TextDecoder().decode(bytes)
|
|
6
|
+
|
|
7
|
+
let config = (args: string[]) =>
|
|
8
|
+
command('git', { args: ['config', '--global', ...args] }).output()
|
|
9
|
+
|
|
10
|
+
/** Use the same space grant for clone, fetch and push. */
|
|
11
|
+
export let installGitCredential = async (run = config): Promise<void> => {
|
|
12
|
+
let key = scope + 'helper'
|
|
13
|
+
let existing = await run(['--null', '--get-all', key])
|
|
14
|
+
if (!existing.success && existing.code != 1) {
|
|
15
|
+
throw new Error(decode(existing.stderr).trim())
|
|
16
|
+
}
|
|
17
|
+
let helpers = decode(existing.stdout).split('\0').slice(0, -1)
|
|
18
|
+
let write = async (args: string[]) => {
|
|
19
|
+
let result = await run(args)
|
|
20
|
+
if (!result.success) throw new Error(decode(result.stderr).trim())
|
|
21
|
+
}
|
|
22
|
+
await write(['--replace-all', scope + 'useHttpPath', 'true'])
|
|
23
|
+
if (helpers.at(-2) == '' && helpers.at(-1) == helper) return
|
|
24
|
+
await write(['--add', key, ''])
|
|
25
|
+
await write(['--add', key, helper])
|
|
26
|
+
}
|
package/given.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// What follows a key given for a connection (`connection_given`, ./vocab.json):
|
|
2
|
+
// once its new credential is sealed in the vault, its integration's `check` is
|
|
3
|
+
// called, the key goes to each place the connection's `keep` names, through
|
|
4
|
+
// the keeper the host lends under that name (@yaks/host/keepers), and the
|
|
5
|
+
// tasks that ask for it are completed. This package names no keeper: where a
|
|
6
|
+
// key goes is the ask's data, and how it gets there is the host's.
|
|
7
|
+
//
|
|
8
|
+
// A key the service refuses is the person's to give again: the connection is
|
|
9
|
+
// marked `broken`, so the task's paste box shows once more, and the run ends
|
|
10
|
+
// without failing. A keeper that cannot keep it fails the run, which the pool
|
|
11
|
+
// retries and reports, and the task stays open.
|
|
12
|
+
import { line } from "@yaks/query";
|
|
13
|
+
import { reveal } from "@yaks/secrets";
|
|
14
|
+
import { call } from "./connections.js";
|
|
15
|
+
import { known } from "./integrations.js";
|
|
16
|
+
import { ASKS, CONNECTION } from "./identity.js";
|
|
17
|
+
let comp = (b, name)=>b?.[name] ?? {};
|
|
18
|
+
/** The keeper `place` names, or why it cannot keep the key now. */ let keeperOf = (host, place)=>{
|
|
19
|
+
let keeper = host.keepers?.[place.via];
|
|
20
|
+
if (!keeper) throw new Error(`nothing lends the keeper ${place.via}`);
|
|
21
|
+
let waiting = keeper.waiting?.();
|
|
22
|
+
if (waiting) throw new Error(`the keeper ${place.via} is ${waiting}`);
|
|
23
|
+
return keeper;
|
|
24
|
+
};
|
|
25
|
+
/** Whether the service takes the key, by the integration's check; a key with
|
|
26
|
+
* no check is taken as given. */ let works = async (host, eid, check)=>{
|
|
27
|
+
if (!check) return true;
|
|
28
|
+
let [method, url] = check.split(' ');
|
|
29
|
+
let res = await call({
|
|
30
|
+
graph: host.graph,
|
|
31
|
+
vault: host.vault,
|
|
32
|
+
fetch: host.fetch
|
|
33
|
+
}, eid, new Request(url, {
|
|
34
|
+
method
|
|
35
|
+
}));
|
|
36
|
+
await res.body?.cancel();
|
|
37
|
+
if (res.ok) return true;
|
|
38
|
+
if (res.status == 401 || res.status == 403) return false;
|
|
39
|
+
throw new Error(`${check} answered ${res.status}`);
|
|
40
|
+
};
|
|
41
|
+
/** The handler: check, keep, then complete the asks. */ export let given = (host)=>async (event, _tx, write)=>{
|
|
42
|
+
let eid = event.entity.eid;
|
|
43
|
+
let read = host.graph.read;
|
|
44
|
+
let [b] = await read(line`.entity.eid=${eid}&.${CONNECTION}&*`);
|
|
45
|
+
let c = comp(b, CONNECTION);
|
|
46
|
+
if (c.status != 'connected') return;
|
|
47
|
+
let keep = c.keep ?? [];
|
|
48
|
+
let asks = await read(line`.edge.to=${eid}&.${ASKS}&.edge`);
|
|
49
|
+
if (!keep.length && !asks.length) return;
|
|
50
|
+
let i = await known(read, String(c.integration));
|
|
51
|
+
if (!await works(host, eid, i?.check)) {
|
|
52
|
+
await write([
|
|
53
|
+
{
|
|
54
|
+
entity: {
|
|
55
|
+
eid
|
|
56
|
+
},
|
|
57
|
+
[CONNECTION]: {
|
|
58
|
+
status: 'broken'
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
]);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (keep.length) {
|
|
65
|
+
let name = String(comp(b, 'secret').name);
|
|
66
|
+
let value = await reveal(host.vault, name, {
|
|
67
|
+
env: ()=>undefined
|
|
68
|
+
});
|
|
69
|
+
if (!value) throw new Error(`${name} holds no key to keep`);
|
|
70
|
+
for (let place of keep)await keeperOf(host, place).keep(place.at, value);
|
|
71
|
+
}
|
|
72
|
+
let tasks = asks.map((l)=>String(comp(l, 'edge').from));
|
|
73
|
+
let open = tasks.length ? await read(line`.entity.eid=${tasks}&.task&!completed&!cancelled`) : [];
|
|
74
|
+
if (open.length) {
|
|
75
|
+
await write(open.map((t)=>({
|
|
76
|
+
entity: {
|
|
77
|
+
eid: t.entity.eid
|
|
78
|
+
},
|
|
79
|
+
completed: {}
|
|
80
|
+
})));
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
//# sourceMappingURL=given.js.map
|
package/given.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"given.js","sources":["./given.ts"],"names":[],"mappings":"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"}
|
package/given.ts
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// What follows a key given for a connection (`connection_given`, ./vocab.json):
|
|
2
|
+
// once its new credential is sealed in the vault, its integration's `check` is
|
|
3
|
+
// called, the key goes to each place the connection's `keep` names, through
|
|
4
|
+
// the keeper the host lends under that name (@yaks/host/keepers), and the
|
|
5
|
+
// tasks that ask for it are completed. This package names no keeper: where a
|
|
6
|
+
// key goes is the ask's data, and how it gets there is the host's.
|
|
7
|
+
//
|
|
8
|
+
// A key the service refuses is the person's to give again: the connection is
|
|
9
|
+
// marked `broken`, so the task's paste box shows once more, and the run ends
|
|
10
|
+
// without failing. A keeper that cannot keep it fails the run, which the pool
|
|
11
|
+
// retries and reports, and the task stays open.
|
|
12
|
+
|
|
13
|
+
import type { Handler } from 'jsr:@yaks/effects@0.2.36'
|
|
14
|
+
import type { Bundle, Comp, Eid } from 'jsr:@yaks/graph@0.2.36'
|
|
15
|
+
import type { Keeper, Place } from 'jsr:@yaks/host@0.2.36/keepers'
|
|
16
|
+
import { line } from '@yaks/query'
|
|
17
|
+
import { reveal, type Vault } from '@yaks/secrets'
|
|
18
|
+
import { call, type Ctx } from './connections.js'
|
|
19
|
+
import { known } from './integrations.js'
|
|
20
|
+
import { ASKS, CONNECTION } from './identity.js'
|
|
21
|
+
|
|
22
|
+
/** What it needs of the host: its graph, its vault, and the keepers it lends. */
|
|
23
|
+
export type Host = {
|
|
24
|
+
graph: Ctx['graph']
|
|
25
|
+
vault: Vault
|
|
26
|
+
keepers?: Readonly<Record<string, Keeper>>
|
|
27
|
+
fetch?: typeof fetch
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
let comp = (b: Bundle | undefined, name: string): Comp =>
|
|
31
|
+
(b?.[name] ?? {}) as Comp
|
|
32
|
+
|
|
33
|
+
/** The keeper `place` names, or why it cannot keep the key now. */
|
|
34
|
+
let keeperOf = (host: Host, place: Place): Keeper => {
|
|
35
|
+
let keeper = host.keepers?.[place.via]
|
|
36
|
+
if (!keeper) throw new Error(`nothing lends the keeper ${place.via}`)
|
|
37
|
+
let waiting = keeper.waiting?.()
|
|
38
|
+
if (waiting) throw new Error(`the keeper ${place.via} is ${waiting}`)
|
|
39
|
+
return keeper
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Whether the service takes the key, by the integration's check; a key with
|
|
43
|
+
* no check is taken as given. */
|
|
44
|
+
let works = async (host: Host, eid: Eid, check?: string): Promise<boolean> => {
|
|
45
|
+
if (!check) return true
|
|
46
|
+
let [method, url] = check.split(' ')
|
|
47
|
+
let res = await call(
|
|
48
|
+
{ graph: host.graph, vault: host.vault, fetch: host.fetch },
|
|
49
|
+
eid,
|
|
50
|
+
new Request(url, { method }),
|
|
51
|
+
)
|
|
52
|
+
await res.body?.cancel()
|
|
53
|
+
if (res.ok) return true
|
|
54
|
+
if (res.status == 401 || res.status == 403) return false
|
|
55
|
+
throw new Error(`${check} answered ${res.status}`)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** The handler: check, keep, then complete the asks. */
|
|
59
|
+
export let given = (host: Host): Handler => async (event, _tx, write) => {
|
|
60
|
+
let eid = event.entity.eid
|
|
61
|
+
let read = host.graph.read
|
|
62
|
+
let [b] = await read(line`.entity.eid=${eid}&.${CONNECTION}&*`)
|
|
63
|
+
let c = comp(b, CONNECTION)
|
|
64
|
+
if (c.status != 'connected') return
|
|
65
|
+
let keep = (c.keep ?? []) as Place[]
|
|
66
|
+
let asks = await read(line`.edge.to=${eid}&.${ASKS}&.edge`)
|
|
67
|
+
if (!keep.length && !asks.length) return
|
|
68
|
+
let i = await known(read, String(c.integration))
|
|
69
|
+
if (!await works(host, eid, i?.check)) {
|
|
70
|
+
await write([{ entity: { eid }, [CONNECTION]: { status: 'broken' } }])
|
|
71
|
+
return
|
|
72
|
+
}
|
|
73
|
+
if (keep.length) {
|
|
74
|
+
let name = String(comp(b, 'secret').name)
|
|
75
|
+
let value = await reveal(host.vault, name, { env: () => undefined })
|
|
76
|
+
if (!value) throw new Error(`${name} holds no key to keep`)
|
|
77
|
+
for (let place of keep) await keeperOf(host, place).keep(place.at, value)
|
|
78
|
+
}
|
|
79
|
+
let tasks = asks.map((l) => String(comp(l, 'edge').from))
|
|
80
|
+
let open = tasks.length
|
|
81
|
+
? await read(line`.entity.eid=${tasks}&.task&!completed&!cancelled`)
|
|
82
|
+
: []
|
|
83
|
+
if (open.length) {
|
|
84
|
+
await write(
|
|
85
|
+
open.map((t) => ({ entity: { eid: t.entity.eid }, completed: {} })),
|
|
86
|
+
)
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "gmail-mailbox",
|
|
3
|
+
"visitors": "never",
|
|
4
|
+
"title": "Gmail mailbox",
|
|
5
|
+
"tagline": "Send and receive new mail for a space through a dedicated Gmail account.",
|
|
6
|
+
"site": "https://mail.google.com",
|
|
7
|
+
"image": "https://app.nango.dev/images/template-logos/google-mail.svg",
|
|
8
|
+
"authorize": "https://accounts.google.com/o/oauth2/v2/auth",
|
|
9
|
+
"token": "https://oauth2.googleapis.com/token",
|
|
10
|
+
"client": "google",
|
|
11
|
+
"broker": {
|
|
12
|
+
"name": "nango",
|
|
13
|
+
"integration": "gmail-mailbox",
|
|
14
|
+
"scoped": true
|
|
15
|
+
},
|
|
16
|
+
"scopes": [
|
|
17
|
+
"https://www.googleapis.com/auth/gmail.modify",
|
|
18
|
+
"https://www.googleapis.com/auth/gmail.send"
|
|
19
|
+
],
|
|
20
|
+
"params": {
|
|
21
|
+
"access_type": "offline",
|
|
22
|
+
"prompt": "consent"
|
|
23
|
+
},
|
|
24
|
+
"hosts": [
|
|
25
|
+
"gmail.googleapis.com"
|
|
26
|
+
],
|
|
27
|
+
"userinfo": "https://gmail.googleapis.com/gmail/v1/users/me/profile",
|
|
28
|
+
"account": "emailAddress"
|
|
29
|
+
}
|
package/gmail.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "gmail",
|
|
3
|
+
"visitors": "never",
|
|
4
|
+
"title": "Gmail",
|
|
5
|
+
"tagline": "Your Gmail account: its mail read, sent, drafted and labelled.",
|
|
6
|
+
"site": "https://mail.google.com",
|
|
7
|
+
"image": "https://app.nango.dev/images/template-logos/google-mail.svg",
|
|
8
|
+
"authorize": "https://accounts.google.com/o/oauth2/v2/auth",
|
|
9
|
+
"token": "https://oauth2.googleapis.com/token",
|
|
10
|
+
"client": "google",
|
|
11
|
+
"broker": {
|
|
12
|
+
"name": "nango",
|
|
13
|
+
"integration": "google-mail"
|
|
14
|
+
},
|
|
15
|
+
"scopes": [
|
|
16
|
+
"https://mail.google.com/"
|
|
17
|
+
],
|
|
18
|
+
"params": {
|
|
19
|
+
"access_type": "offline",
|
|
20
|
+
"prompt": "consent"
|
|
21
|
+
},
|
|
22
|
+
"hosts": [
|
|
23
|
+
"gmail.googleapis.com"
|
|
24
|
+
],
|
|
25
|
+
"api": {
|
|
26
|
+
"base": "https://gmail.googleapis.com/gmail/v1",
|
|
27
|
+
"docs": "https://developers.google.com/workspace/gmail/api/reference/rest"
|
|
28
|
+
},
|
|
29
|
+
"userinfo": "https://gmail.googleapis.com/gmail/v1/users/me/profile",
|
|
30
|
+
"account": "emailAddress"
|
|
31
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "google-calendar",
|
|
3
|
+
"visitors": "never",
|
|
4
|
+
"title": "Google Calendar",
|
|
5
|
+
"tagline": "Your Google calendars, and the events on them.",
|
|
6
|
+
"site": "https://calendar.google.com",
|
|
7
|
+
"logo": "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"#4285F4\"><path d=\"M18.316 5.684H24v12.632h-5.684V5.684zM5.684 24h12.632v-5.684H5.684V24zM18.316 5.684V0H1.895A1.894 1.894 0 0 0 0 1.895v16.421h5.684V5.684h12.632zm-7.207 6.25v-.065c.272-.144.5-.349.687-.617s.279-.595.279-.982c0-.379-.099-.72-.3-1.025a2.05 2.05 0 0 0-.832-.714 2.703 2.703 0 0 0-1.197-.257c-.6 0-1.094.156-1.481.467-.386.311-.65.671-.793 1.078l1.085.452c.086-.249.224-.461.413-.633.189-.172.445-.257.767-.257.33 0 .602.088.816.264a.86.86 0 0 1 .322.703c0 .33-.12.589-.36.778-.24.19-.535.284-.886.284h-.567v1.085h.633c.407 0 .748.109 1.02.327.272.218.407.499.407.843 0 .336-.129.614-.387.832s-.565.327-.924.327c-.351 0-.651-.103-.897-.311-.248-.208-.422-.502-.521-.881l-1.096.452c.178.616.505 1.082.977 1.401.472.319.984.478 1.538.477a2.84 2.84 0 0 0 1.293-.291c.382-.193.684-.458.902-.794.218-.336.327-.72.327-1.149 0-.429-.115-.797-.344-1.105a2.067 2.067 0 0 0-.881-.689zm2.093-1.931l.602.913L15 10.045v5.744h1.187V8.446h-.827l-2.158 1.557zM22.105 0h-3.289v5.184H24V1.895A1.894 1.894 0 0 0 22.105 0zm-3.289 23.5l4.684-4.684h-4.684V23.5zM0 22.105C0 23.152.848 24 1.895 24h3.289v-5.184H0v3.289z\"/></svg>",
|
|
8
|
+
"authorize": "https://accounts.google.com/o/oauth2/v2/auth",
|
|
9
|
+
"token": "https://oauth2.googleapis.com/token",
|
|
10
|
+
"client": "google",
|
|
11
|
+
"broker": {
|
|
12
|
+
"name": "nango",
|
|
13
|
+
"integration": "google-calendar"
|
|
14
|
+
},
|
|
15
|
+
"scopes": [
|
|
16
|
+
"https://www.googleapis.com/auth/calendar"
|
|
17
|
+
],
|
|
18
|
+
"params": {
|
|
19
|
+
"access_type": "offline",
|
|
20
|
+
"prompt": "consent"
|
|
21
|
+
},
|
|
22
|
+
"hosts": [
|
|
23
|
+
"www.googleapis.com"
|
|
24
|
+
],
|
|
25
|
+
"api": {
|
|
26
|
+
"base": "https://www.googleapis.com/calendar/v3",
|
|
27
|
+
"docs": "https://developers.google.com/workspace/calendar/api/v3/reference"
|
|
28
|
+
},
|
|
29
|
+
"userinfo": "https://www.googleapis.com/calendar/v3/users/me/calendarList/primary?fields=id",
|
|
30
|
+
"account": "id"
|
|
31
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "google-drive",
|
|
3
|
+
"visitors": "never",
|
|
4
|
+
"title": "Google Drive",
|
|
5
|
+
"tagline": "Your Google Drive: its files and folders found, read, made and shared.",
|
|
6
|
+
"site": "https://drive.google.com",
|
|
7
|
+
"image": "https://app.nango.dev/images/template-logos/google-drive.svg",
|
|
8
|
+
"authorize": "https://accounts.google.com/o/oauth2/v2/auth",
|
|
9
|
+
"token": "https://oauth2.googleapis.com/token",
|
|
10
|
+
"client": "google",
|
|
11
|
+
"broker": {
|
|
12
|
+
"name": "nango",
|
|
13
|
+
"integration": "google-drive"
|
|
14
|
+
},
|
|
15
|
+
"scopes": [
|
|
16
|
+
"https://www.googleapis.com/auth/drive"
|
|
17
|
+
],
|
|
18
|
+
"params": {
|
|
19
|
+
"access_type": "offline",
|
|
20
|
+
"prompt": "consent"
|
|
21
|
+
},
|
|
22
|
+
"hosts": [
|
|
23
|
+
"www.googleapis.com"
|
|
24
|
+
],
|
|
25
|
+
"api": {
|
|
26
|
+
"base": "https://www.googleapis.com/drive/v3",
|
|
27
|
+
"docs": "https://developers.google.com/workspace/drive/api/reference/rest/v3"
|
|
28
|
+
},
|
|
29
|
+
"userinfo": "https://www.googleapis.com/drive/v3/about?fields=user",
|
|
30
|
+
"account": "user.emailAddress"
|
|
31
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "google-search-console",
|
|
3
|
+
"visitors": "never",
|
|
4
|
+
"title": "Google Search Console",
|
|
5
|
+
"tagline": "Your sites in Google Search: their queries, clicks and sitemaps.",
|
|
6
|
+
"site": "https://search.google.com/search-console",
|
|
7
|
+
"logo": "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\" fill=\"#458CF5\"><path d=\"M8.548 1.156L6.832 2.872v1.682h1.716zm0 3.398v.035H6.832v-.035H3.386L0 7.844v3.577h2.826V8.94c0-.525.429-.954.954-.954h16.476c.525 0 .954.43.954.954v2.48h2.754V7.844l-3.386-3.29H17.3v.035h-1.717v-.035zm7.035 0H17.3V2.872l-1.717-1.716zM8.679 1.188V2.84h6.773V1.188zm11.471 7.07a.834.834 0 00-.132.01l-.543.002c-5.216.014-10.432-.008-15.648.01-.435-.063-.794.436-.716.883v2.264h17.812c-.016-.888.045-1.782-.034-2.666-.104-.342-.427-.502-.739-.502zm-15.422.634a.689.698 0 01.689.698.689.698 0 01-.689.697.689.698 0 01-.688-.697.689.698 0 01.688-.698zm2.134 0a.689.698 0 01.689.698.689.698 0 01-.689.697.689.698 0 01-.688-.697.689.698 0 01.688-.698zM.036 11.645v9.156c0 1.05.858 1.908 1.907 1.908h.883V11.645zm21.174 0v11.064h.882c1.05 0 1.908-.858 1.908-1.908v-9.156zM4.057 13.133v6.85h6.137v-6.85zm13.243.021v3.777l-1.708.977-1.708-.977v-3.758a4.006 4.006 0 000 7.23v2.441h3.457v-2.442a4.006 4.006 0 00-.041-7.248zm-13.243 8.26v1.43h7.925v-1.43z\"/></svg>",
|
|
8
|
+
"authorize": "https://accounts.google.com/o/oauth2/v2/auth",
|
|
9
|
+
"token": "https://oauth2.googleapis.com/token",
|
|
10
|
+
"client": "google",
|
|
11
|
+
"scopes": [
|
|
12
|
+
"openid",
|
|
13
|
+
"email",
|
|
14
|
+
"https://www.googleapis.com/auth/webmasters"
|
|
15
|
+
],
|
|
16
|
+
"params": {
|
|
17
|
+
"access_type": "offline",
|
|
18
|
+
"prompt": "consent"
|
|
19
|
+
},
|
|
20
|
+
"hosts": [
|
|
21
|
+
"searchconsole.googleapis.com"
|
|
22
|
+
],
|
|
23
|
+
"api": {
|
|
24
|
+
"base": "https://searchconsole.googleapis.com",
|
|
25
|
+
"docs": "https://developers.google.com/webmaster-tools/v1/api_reference_index"
|
|
26
|
+
},
|
|
27
|
+
"testing": true,
|
|
28
|
+
"userinfo": "https://openidconnect.googleapis.com/v1/userinfo"
|
|
29
|
+
}
|
package/graph.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// The `graph` export (`@yaks/connections/graph`): what a direct tool call is
|
|
2
|
+
// answered with beside its own answer. A call whose answer names a connection
|
|
3
|
+
// is answered with the integration it goes through too, so whoever asked for
|
|
4
|
+
// one (an agent calling connection_need) reads how to get its key without
|
|
5
|
+
// asking again. A host composes it like any plugin's graph facet; nothing
|
|
6
|
+
// calls it by hand.
|
|
7
|
+
//
|
|
8
|
+
// Every process composing this package loads this module as it starts, so it
|
|
9
|
+
// needs only the names (./identity.ts), never the connection actions.
|
|
10
|
+
import { line } from "@yaks/query";
|
|
11
|
+
import { CONNECTION, INTEGRATION, integrationEid, USES } from "./identity.js";
|
|
12
|
+
/** The integrations the connections among `bundles` go through, as the graph
|
|
13
|
+
* holds them, but for any `bundles` already carry: what a person and their
|
|
14
|
+
* agent read beside a connection, how to get its key among it. A `uses` link
|
|
15
|
+
* whose connection is not among them is read to find which. */ export let through = async (read, bundles)=>{
|
|
16
|
+
let names = new Set();
|
|
17
|
+
let ask = [];
|
|
18
|
+
for (let b of bundles){
|
|
19
|
+
let c = b[CONNECTION];
|
|
20
|
+
if (typeof c?.integration == 'string') names.add(c.integration);
|
|
21
|
+
else if (b[USES]) ask.push(String(b.edge?.to));
|
|
22
|
+
}
|
|
23
|
+
if (ask.length) {
|
|
24
|
+
for (let b of (await read(line`.entity.eid=${ask}&.${CONNECTION}`))){
|
|
25
|
+
names.add(String(b[CONNECTION].integration));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
let have = new Set(bundles.filter((b)=>b[INTEGRATION]).map((b)=>b.entity.eid));
|
|
29
|
+
let wanted = [
|
|
30
|
+
...names
|
|
31
|
+
].map(integrationEid).filter((e)=>!have.has(e));
|
|
32
|
+
return wanted.length ? await read(line`.entity.eid=${wanted}&.${INTEGRATION}`) : [];
|
|
33
|
+
};
|
|
34
|
+
/** Beside a direct call's answer: the integrations its connections go
|
|
35
|
+
* through, but for those it already carries. */ export let reply = (host)=>(_call, answer)=>through(host.graph.read, answer);
|
|
36
|
+
//# sourceMappingURL=graph.js.map
|
package/graph.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph.js","sources":["./graph.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,8EAA8E;AAC9E,6EAA6E;AAC7E,0EAA0E;AAC1E,0EAA0E;AAC1E,oBAAoB;AACpB,EAAE;AACF,6EAA6E;AAC7E,sEAAsE;AAEtE,SAAS,IAAI,2BAAgC;AAI7C,SAAS,UAAU,EAAE,WAAW,EAAE,cAAc,EAAE,IAAI,wBAAuB;AAK7E;;;6DAG6D,GAC7D,OAAO,IAAI,UAAU,OACnB,MACA;EAEA,IAAI,QAAQ,IAAI;EAChB,IAAI,MAAa,EAAE;EACnB,KAAK,IAAI,KAAK,QAAS;IACrB,IAAI,IAAI,CAAC,CAAC,WAAW;IACrB,IAAI,OAAO,GAAG,eAAe,UAAU,MAAM,GAAG,CAAC,EAAE,WAAW;SACzD,IAAI,CAAC,CAAC,KAAK,EAAE,IAAI,IAAI,CAAC,OAAQ,EAAE,IAAI,EAAuB;EAClE;EACA,IAAI,IAAI,MAAM,EAAE;IACd,KAAK,IAAI,KAAK,CAAA,MAAM,KAAK,IAAI,CAAC,YAAY,EAAE,IAAI,EAAE,EAAE,WAAW,CAAC,CAAA,EAAG;MACjE,MAAM,GAAG,CAAC,OAAO,AAAC,CAAC,CAAC,WAAW,CAAU,WAAW;IACtD;EACF;EACA,IAAI,OAAO,IAAI,IACb,QAAQ,MAAM,CAAC,CAAC,IAAM,CAAC,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC,IAAM,EAAE,MAAM,CAAC,GAAG;EAE/D,IAAI,SAAS;OAAI;GAAM,CAAC,GAAG,CAAC,gBAAgB,MAAM,CAAC,CAAC,IAAM,CAAC,KAAK,GAAG,CAAC;EACpE,OAAO,OAAO,MAAM,GAChB,MAAM,KAAK,IAAI,CAAC,YAAY,EAAE,OAAO,EAAE,EAAE,YAAY,CAAC,IACtD,EAAE;AACR,EAAC;AAED;8CAC8C,GAC9C,OAAO,IAAI,QAAQ,CAAC,OAAsB,CAAC,OAAO,SAChD,QAAQ,KAAK,KAAK,CAAC,IAAI,EAAE,QAAO"}
|