@kamilio/wire 0.1.38 → 0.1.40
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/adapters/ashby.d.ts +4 -0
- package/dist/adapters/ashby.d.ts.map +1 -0
- package/dist/adapters/ashby.js +228 -0
- package/dist/adapters/ashby.js.map +1 -0
- package/dist/adapters/gdrive.d.ts.map +1 -1
- package/dist/adapters/gdrive.js +77 -3
- package/dist/adapters/gdrive.js.map +1 -1
- package/dist/adapters/root.d.ts +1 -0
- package/dist/adapters/root.d.ts.map +1 -1
- package/dist/adapters/root.js +17 -4
- package/dist/adapters/root.js.map +1 -1
- package/dist/auth.d.ts +2 -1
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +4 -2
- package/dist/auth.js.map +1 -1
- package/dist/cli.js +2 -2
- package/dist/cli.js.map +1 -1
- package/dist/executable.d.ts.map +1 -1
- package/dist/executable.js +2 -1
- package/dist/executable.js.map +1 -1
- package/node_modules/wire-core/dist/ports.d.ts +1 -1
- package/node_modules/wire-core/dist/ports.d.ts.map +1 -1
- package/node_modules/wire-core/dist/runtime/cookies.d.ts.map +1 -1
- package/node_modules/wire-core/dist/runtime/cookies.js +3 -1
- package/node_modules/wire-core/dist/runtime/cookies.js.map +1 -1
- package/node_modules/wire-core/dist/runtime/node.js +2 -2
- package/node_modules/wire-core/dist/runtime/node.js.map +1 -1
- package/node_modules/wire-core/src/ports.ts +1 -1
- package/node_modules/wire-core/src/runtime/cookies.ts +2 -1
- package/node_modules/wire-core/src/runtime/node.ts +2 -2
- package/package.json +1 -1
- package/src/adapters/ashby.ts +334 -0
- package/src/adapters/gdrive.ts +72 -4
- package/src/adapters/root.ts +18 -5
- package/src/auth.ts +7 -3
- package/src/cli.ts +2 -2
- package/src/executable.ts +2 -1
package/src/adapters/gdrive.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createHash, randomUUID } from "node:crypto";
|
|
2
2
|
import { lstat, mkdir, readFile, rename, unlink, writeFile } from "node:fs/promises";
|
|
3
|
-
import { basename, extname, join } from "node:path";
|
|
3
|
+
import { basename, dirname, extname, join } from "node:path";
|
|
4
4
|
import type { RuntimeCapabilities } from "wire-core";
|
|
5
5
|
|
|
6
6
|
const google = "application/vnd.google-apps.";
|
|
@@ -11,7 +11,7 @@ const formats: Record<string, [string, string]> = {
|
|
|
11
11
|
drawing: [".svg", "image/svg+xml"],
|
|
12
12
|
};
|
|
13
13
|
type File = { id: string; name: string; mimeType: string; version: string };
|
|
14
|
-
type Entry = { id: string; version?: string; hash?: string; noText?: true; markdownOnly?: true };
|
|
14
|
+
type Entry = { id: string; version?: string; hash?: string; noText?: true; markdownOnly?: true; images?: string[] };
|
|
15
15
|
type State = { folder: string; entries: Record<string, Entry> };
|
|
16
16
|
const digest = (data: Uint8Array) => createHash("sha256").update(data).digest("hex");
|
|
17
17
|
async function stat(path: string) {
|
|
@@ -27,6 +27,58 @@ async function save(path: string, data: string | Uint8Array) {
|
|
|
27
27
|
await rename(tmp, path);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
const imageData = /data:image\/(png|jpeg|gif|webp);base64,([a-zA-Z0-9+/]+=*)/;
|
|
31
|
+
const imageDefinition = new RegExp("^\\[(image\\d+)\\]:[ \\t]*<?(" + imageData.source + ")>?[ \\t]*\\r?$", "gm");
|
|
32
|
+
const inlineImage = new RegExp("(!\\[(?:\\\\.|[^\\]\\\\\\n])*\\])\\(<?(" + imageData.source + ")>?\\)", "g");
|
|
33
|
+
|
|
34
|
+
async function docImageDir(full: string, create: boolean) {
|
|
35
|
+
const root = join(dirname(full), "attachments"), folder = join(root, basename(full, ".md"));
|
|
36
|
+
for (const path of [root, folder]) {
|
|
37
|
+
const info = await stat(path);
|
|
38
|
+
if (info && !info.isDirectory()) throw new Error("Expected an attachment directory: " + path);
|
|
39
|
+
if (!info && create) await mkdir(path, { mode: 0o700 });
|
|
40
|
+
if (!info && !create) break;
|
|
41
|
+
}
|
|
42
|
+
return folder;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async function checkDocImage(folder: string, name: string) {
|
|
46
|
+
const hash = /^([a-f0-9]{64})\.(png|jpeg|gif|webp)$/.exec(name)?.[1];
|
|
47
|
+
if (!hash) throw new Error("Invalid attachment name: " + name);
|
|
48
|
+
const path = join(folder, name), info = await stat(path);
|
|
49
|
+
if (!info) return false;
|
|
50
|
+
if (!info.isFile() || digest(await readFile(path)) !== hash) throw new Error("Local attachment changed: " + path);
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async function extractDocImages(full: string, text: string) {
|
|
55
|
+
const files = new Map<string, Buffer>(), links = new Map<string, string>();
|
|
56
|
+
const link = (ext: string, base64: string) => {
|
|
57
|
+
const data = Buffer.from(base64, "base64");
|
|
58
|
+
if (data.toString("base64") !== base64) throw new Error("Invalid image encoding.");
|
|
59
|
+
const name = digest(data) + "." + ext;
|
|
60
|
+
files.set(name, data);
|
|
61
|
+
return "attachments/" + encodeURIComponent(basename(full, ".md")).replace(/[()]/g, c => c === "(" ? "%28" : "%29") + "/" + name;
|
|
62
|
+
};
|
|
63
|
+
for (const m of text.matchAll(imageDefinition)) links.set(m[1]!, link(m[3]!, m[4]!));
|
|
64
|
+
text = text.replace(inlineImage, (_, alt, _uri, ext, data) => alt + "(" + link(ext, data) + ")");
|
|
65
|
+
if (links.size) {
|
|
66
|
+
text = text.replace(/(!\[(?:\\.|[^\]\\\n])*\])\[(image\d+)\]/g, (all, alt, id) =>
|
|
67
|
+
links.has(id) ? alt + "(" + links.get(id) + ")" : all);
|
|
68
|
+
// Keep a relative definition for ordinary links that use the same reference.
|
|
69
|
+
text = text.replace(imageDefinition, (line, id, _uri, _ext, _data, offset) =>
|
|
70
|
+
(text.slice(0, offset) + text.slice(offset + line.length)).includes("[" + id + "]")
|
|
71
|
+
? "[" + id + "]: <" + links.get(id) + ">" : "");
|
|
72
|
+
}
|
|
73
|
+
if (files.size) {
|
|
74
|
+
const folder = await docImageDir(full, true);
|
|
75
|
+
for (const [name, data] of files) {
|
|
76
|
+
if (!(await checkDocImage(folder, name))) await writeFile(join(folder, name), data, { flag: "wx", mode: 0o600 });
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return { bytes: Buffer.from(text), images: [...files.keys()] };
|
|
80
|
+
}
|
|
81
|
+
|
|
30
82
|
type DriveRuntime = Pick<RuntimeCapabilities, "googleFormsTokens" | "http">;
|
|
31
83
|
const folderUrl = /^https:\/\/drive\.google\.com\/drive\/(?:u\/\d+\/)?folders\/([\w-]+)\/?(?:[?#].*)?$/;
|
|
32
84
|
const safeName = (name: string) => name.replace(/[/\\:\x00-\x1f]/g, "_").replace(/^\.+/, "_") || "_";
|
|
@@ -181,6 +233,20 @@ export async function scrapeDrive(runtime: DriveRuntime, cwd: string, url?: stri
|
|
|
181
233
|
throw new Error("Local file changed: " + p);
|
|
182
234
|
if (!info || entry?.version !== f.version) current = false;
|
|
183
235
|
}
|
|
236
|
+
if (current && f.mimeType === google + "document") {
|
|
237
|
+
if (original?.images?.length) {
|
|
238
|
+
const dir = await docImageDir(full, false);
|
|
239
|
+
for (const image of original.images) if (!(await checkDocImage(dir, image))) current = false;
|
|
240
|
+
} else if (!original?.images) {
|
|
241
|
+
// Upgrade prior exports on refresh, without another network request.
|
|
242
|
+
const local = await extractDocImages(full, await readFile(full, "utf8"));
|
|
243
|
+
if (local.images.length) {
|
|
244
|
+
await save(full, local.bytes);
|
|
245
|
+
original!.hash = digest(local.bytes);
|
|
246
|
+
}
|
|
247
|
+
original!.images = local.images;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
184
250
|
if (current) {
|
|
185
251
|
if (state.entries[key(path)]?.noText) images.push(path);
|
|
186
252
|
if (pdf && !original?.noText && (await stat(full)))
|
|
@@ -191,9 +257,11 @@ export async function scrapeDrive(runtime: DriveRuntime, cwd: string, url?: stri
|
|
|
191
257
|
const response = format
|
|
192
258
|
? await drive(runtime, "/" + f.id + "/export", { mimeType: format[1] })
|
|
193
259
|
: await drive(runtime, "/" + f.id, { alt: "media", supportsAllDrives: "true" });
|
|
194
|
-
const
|
|
260
|
+
const raw = new Uint8Array(await response.arrayBuffer());
|
|
261
|
+
const doc = f.mimeType === google + "document" ? await extractDocImages(full, Buffer.from(raw).toString("utf8")) : undefined;
|
|
262
|
+
const bytes = doc?.bytes ?? raw;
|
|
195
263
|
await save(full, bytes);
|
|
196
|
-
state.entries[key(path)] = { id: f.id, version: f.version, hash: digest(bytes) };
|
|
264
|
+
state.entries[key(path)] = { id: f.id, version: f.version, hash: digest(bytes), ...(doc ? { images: doc.images } : {}) };
|
|
197
265
|
if (pdf) {
|
|
198
266
|
const { pdfMarkdown } = await import("./drive-pdf.js");
|
|
199
267
|
const text = pdfMarkdown(bytes);
|
package/src/adapters/root.ts
CHANGED
|
@@ -10,9 +10,9 @@ import { formatAgenda, type readAgenda } from "./calendar.js";
|
|
|
10
10
|
|
|
11
11
|
export type WireRoot = Group;
|
|
12
12
|
export type TextInputReader = () => Promise<string>;
|
|
13
|
-
export type WireRootOptions = Readonly<{ allowPaste: boolean; previewDrive?: (url: string) => Promise<string>; scrapeDrive?: (url?: string) => Promise<string>; calendarAgenda?: (date?: string, calendarId?: string) => ReturnType<typeof readAgenda>; latticeSync?: (url: string | undefined, file?: string) => Promise<string>; latticeRequests?: (url: string) => Promise<string>; latticeTemplate?: (url: string) => Promise<string>; latticeFill?: (url: string, file: string) => Promise<string>; scrapeZoom?: () => ReturnType<typeof zoomProvider.scrape> }>;
|
|
13
|
+
export type WireRootOptions = Readonly<{ allowPaste: boolean; ashby?: (action: string, arg?: string) => Promise<string>; previewDrive?: (url: string) => Promise<string>; scrapeDrive?: (url?: string) => Promise<string>; calendarAgenda?: (date?: string, calendarId?: string) => ReturnType<typeof readAgenda>; latticeSync?: (url: string | undefined, file?: string) => Promise<string>; latticeRequests?: (url: string) => Promise<string>; latticeTemplate?: (url: string) => Promise<string>; latticeFill?: (url: string, file: string) => Promise<string>; scrapeZoom?: () => ReturnType<typeof zoomProvider.scrape> }>;
|
|
14
14
|
|
|
15
|
-
const authServices = ["asana", "chatgpt", "gmail", "google-docs", "notion", "slack", "zoom"] as const;
|
|
15
|
+
const authServices = ["ashby", "asana", "chatgpt", "gmail", "google-docs", "notion", "slack", "zoom"] as const;
|
|
16
16
|
const removedCliCommandNames = Object.freeze({
|
|
17
17
|
create: "Use `wire attach <url>` or `wire <url>`.",
|
|
18
18
|
fetch: "Use `wire download <url>`.",
|
|
@@ -207,7 +207,7 @@ function wireUserErrorMessage(message: string): boolean {
|
|
|
207
207
|
|| /^Resource (path |identifier |URL )?not found: /.test(message)
|
|
208
208
|
|| /^Ambiguous resource path /.test(message)
|
|
209
209
|
|| /^Login not saved$/.test(message)
|
|
210
|
-
|| /authentication (is missing|is missing or expired|failed|expired).*Run `wire (asana|chatgpt|gmail|google-docs|notion|slack|zoom) login`/i.test(message)
|
|
210
|
+
|| /authentication (is missing|is missing or expired|failed|expired).*Run `wire (ashby|asana|chatgpt|gmail|google-docs|notion|slack|zoom) login`/i.test(message)
|
|
211
211
|
|| /^Asana API /.test(message)
|
|
212
212
|
|| /^(GET|POST|PUT|DELETE) \/.* failed: \d+ /.test(message)
|
|
213
213
|
|| /^(Invalid Asana project heading|Asana section appears|Asana milestone appears|Asana task appears|Asana subtask appears|Unsupported Asana Markdown|Duplicate Asana identity|Missing Asana project heading|Asana project identity changed|Unknown Asana identity|Conflicting Asana edits)/.test(message)
|
|
@@ -246,7 +246,7 @@ function wireUserErrorDisplayMessage(message: string): string {
|
|
|
246
246
|
if (unsupportedSource !== null) return `unsupported source\nurl: ${lineText(unsupportedSource[1]!)}\nsupported: Asana, ChatGPT, Gmail, Google Docs/Sheets/Slides/Forms, Notion, Slack, Zoom`;
|
|
247
247
|
const existingWorkspace = /^Wire workspace already initialized with (sqlite|files) registry at ([\s\S]+)\. Existing registries are not overwritten\.$/.exec(message);
|
|
248
248
|
if (existingWorkspace !== null) return `workspace already initialized\nbackend: ${existingWorkspace[1]!}\nregistry: ${lineText(existingWorkspace[2]!)}\nkept: existing registry`;
|
|
249
|
-
const authentication = /authentication (is missing or expired|is missing|failed|expired).*Run `wire (asana|chatgpt|gmail|google-docs|notion|slack|zoom) login`/i.exec(message);
|
|
249
|
+
const authentication = /authentication (is missing or expired|is missing|failed|expired).*Run `wire (ashby|asana|chatgpt|gmail|google-docs|notion|slack|zoom) login`/i.exec(message);
|
|
250
250
|
if (authentication !== null) return `login required\nservice: ${serviceTitle(authentication[2] as AuthService)}\nrun: wire ${authentication[2]} login`;
|
|
251
251
|
const asanaApi = /^Asana API ([^\s]+) failed: HTTP (\d+)(?: ([\s\S]+))?$/.exec(message);
|
|
252
252
|
if (asanaApi !== null) return `api failed\nservice: Asana\nrequest: ${lineText(asanaApi[1]!)}\nstatus: HTTP ${asanaApi[2]!}${asanaApi[3] === undefined ? "" : `\ndetail: ${lineText(asanaApi[3]!)}`}`;
|
|
@@ -345,6 +345,7 @@ function userFacing<T>(operation: () => Promise<T>): Promise<T> {
|
|
|
345
345
|
|
|
346
346
|
function serviceTitle(service: AuthService): string {
|
|
347
347
|
return {
|
|
348
|
+
ashby: "Ashby",
|
|
348
349
|
asana: "Asana",
|
|
349
350
|
chatgpt: "ChatGPT",
|
|
350
351
|
gmail: "Gmail",
|
|
@@ -410,7 +411,7 @@ export const wirePresentation: WirePresentation = Object.freeze({
|
|
|
410
411
|
function authGroup(service: AuthService, description: string, loginDescription: string, auth: Auth, readInput: TextInputReader | undefined, options: WireRootOptions): Group {
|
|
411
412
|
const login = async (paste: boolean | undefined) => {
|
|
412
413
|
if (paste === true && !options.allowPaste) throw new UserError("Cookie paste is CLI-only.");
|
|
413
|
-
return paste === true ? auth.pasteCookies(service, await readInput!()) : service === "asana" ? auth.extractAsana() : service === "chatgpt" ? auth.extractChatgpt() : service === "gmail" ? auth.extractGmail() : service === "google-docs" ? auth.extractGoogleDocs() : service === "notion" ? auth.extractNotion() : service === "slack" ? auth.extractSlack() : auth.extractZoom();
|
|
414
|
+
return paste === true ? auth.pasteCookies(service, await readInput!()) : service === "ashby" ? auth.extractAshby() : service === "asana" ? auth.extractAsana() : service === "chatgpt" ? auth.extractChatgpt() : service === "gmail" ? auth.extractGmail() : service === "google-docs" ? auth.extractGoogleDocs() : service === "notion" ? auth.extractNotion() : service === "slack" ? auth.extractSlack() : auth.extractZoom();
|
|
414
415
|
};
|
|
415
416
|
const title = serviceTitle(service);
|
|
416
417
|
return defineGroup({ name: service, description, children: [
|
|
@@ -561,6 +562,18 @@ export function createRoot(wire: Wire, currentDirectory: string, auth?: Auth, re
|
|
|
561
562
|
render: render<JsonObject>((comment) => `Updated comment ${comment["gid"]}`),
|
|
562
563
|
})] })] : []),
|
|
563
564
|
] });
|
|
565
|
+
if (service === "ashby" && options.ashby) {
|
|
566
|
+
const run = options.ashby;
|
|
567
|
+
return defineGroup({ ...group, description: "Read your interviews and sync feedback drafts.", children: [...group.children,
|
|
568
|
+
...([["interviews","List your upcoming interviews."],["pending","List interviews awaiting your feedback."],["latest","Read your most recently submitted feedback."]] as const).map(([name,description])=>defineCommand({
|
|
569
|
+
name,description,params:S.Object({}),handler:()=>userFacing(()=>run(name)),render:render<string>(v=>v),
|
|
570
|
+
})),
|
|
571
|
+
...([["prep","Read the interview briefing and candidate background."],["template","Print your editable Markdown feedback draft."]] as const).map(([name,description])=>defineCommand({
|
|
572
|
+
name,description,positional:["url"],params:S.Object({url:S.String({description:"Interview briefing URL."})}),handler:({params})=>userFacing(()=>run(name,params.url)),render:render<string>(v=>v),
|
|
573
|
+
})),
|
|
574
|
+
defineCommand({name:"sync",description:"Save edited Markdown sections as drafts. Blank answers are skipped. Final submission is manual.",positional:["file"],params:S.Object({file:S.String({description:"Markdown file created with ashby template."})}),handler:({params})=>userFacing(()=>run("sync",params.file)),render:render<string>(v=>v)}),
|
|
575
|
+
]});
|
|
576
|
+
}
|
|
564
577
|
if (service === "zoom" && options.scrapeZoom) return defineGroup({ ...group, children: [...group.children, defineCommand({
|
|
565
578
|
name: "scrape", scope: ["cli"], description: "Sync available Zoom Hub transcripts into ./zoom without deleting existing files.", params: S.Object({}),
|
|
566
579
|
handler: () => userFacing(options.scrapeZoom!),
|
package/src/auth.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { parsePastedCookieMetadata, parsePastedCookies, type ChromeCookieExtraction, type ChromeCookieResult, type Cookie, type NodeEnvironment, type RuntimeCapabilities } from "wire-core";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import { ashbySession } from "./adapters/ashby.js";
|
|
4
|
+
|
|
5
|
+
export type AuthService = "ashby" | "asana" | "chatgpt" | "gmail" | "google-docs" | "notion" | "slack" | "zoom";
|
|
4
6
|
export type CookieAuthService = AuthService;
|
|
5
7
|
|
|
6
8
|
export interface AuthResult {
|
|
@@ -227,6 +229,7 @@ export interface Auth {
|
|
|
227
229
|
readonly status: (service: AuthService) => Promise<AuthResult>;
|
|
228
230
|
readonly pasteCookies: (service: AuthService, contents: string) => Promise<AuthResult>;
|
|
229
231
|
readonly logout: (service: AuthService) => Promise<{ readonly service: AuthService; readonly deleted: true }>;
|
|
232
|
+
readonly extractAshby: () => Promise<AuthResult>;
|
|
230
233
|
readonly extractAsana: () => Promise<AuthResult>;
|
|
231
234
|
readonly extractChatgpt: () => Promise<AuthResult>;
|
|
232
235
|
readonly extractGmail: () => Promise<AuthResult>;
|
|
@@ -239,8 +242,8 @@ export interface Auth {
|
|
|
239
242
|
export type CookieExtractor = (environment: NodeEnvironment, extraction: ChromeCookieExtraction) => Promise<ChromeCookieResult>;
|
|
240
243
|
|
|
241
244
|
export function composeAuth(runtime: RuntimeCapabilities, environment: NodeEnvironment, extractCookies: CookieExtractor): Auth {
|
|
242
|
-
const cookieDomains: Readonly<Record<AuthService, string>> = Object.freeze({ asana: ".asana.com", chatgpt: ".chatgpt.com", gmail: ".google.com", "google-docs": ".google.com", notion: ".notion.so", slack: ".slack.com", zoom: ".zoom.us" });
|
|
243
|
-
const verifyCookies = (service: AuthService, cookies: readonly Cookie[], metadata: Readonly<Record<string, string>>) => service === "asana" ? verifyAsana(runtime, cookies) : service === "chatgpt" ? verifyChatgpt(runtime, cookies) : service === "gmail" ? verifyGmailCookies(runtime, cookies) : service === "google-docs" ? verifyGoogleDocsCookies(runtime, cookies) : service === "notion" ? verifyNotion(runtime, cookies) : service === "slack" ? verifySlack(runtime, cookies, metadata) : verifyZoom(runtime, cookies);
|
|
245
|
+
const cookieDomains: Readonly<Record<AuthService, string>> = Object.freeze({ ashby: ".ashbyhq.com", asana: ".asana.com", chatgpt: ".chatgpt.com", gmail: ".google.com", "google-docs": ".google.com", notion: ".notion.so", slack: ".slack.com", zoom: ".zoom.us" });
|
|
246
|
+
const verifyCookies = (service: AuthService, cookies: readonly Cookie[], metadata: Readonly<Record<string, string>>) => service === "ashby" ? ashbySession(runtime,cookies).then(q=>q("query { sessionUser { id } }")).then(d=>d.sessionUser ? {service,identity:{user_id:d.sessionUser.id}} : null).catch(()=>null) : service === "asana" ? verifyAsana(runtime, cookies) : service === "chatgpt" ? verifyChatgpt(runtime, cookies) : service === "gmail" ? verifyGmailCookies(runtime, cookies) : service === "google-docs" ? verifyGoogleDocsCookies(runtime, cookies) : service === "notion" ? verifyNotion(runtime, cookies) : service === "slack" ? verifySlack(runtime, cookies, metadata) : verifyZoom(runtime, cookies);
|
|
244
247
|
const verifyCookieState = async (service: AuthService, cookies: readonly Cookie[], metadata: Readonly<Record<string, string>>) => {
|
|
245
248
|
if (service === "zoom") return verifyZoomCookieState(runtime, cookies, metadata);
|
|
246
249
|
return Object.freeze({ result: await verifyCookies(service, cookies, metadata), cookies, metadata, changed: false });
|
|
@@ -286,6 +289,7 @@ export function composeAuth(runtime: RuntimeCapabilities, environment: NodeEnvir
|
|
|
286
289
|
await runtime.cookies.delete(service);
|
|
287
290
|
return Object.freeze({ service, deleted: true });
|
|
288
291
|
},
|
|
292
|
+
extractAshby: () => extract("ashby", "https://app.ashbyhq.com/", ["ashbyhq.com"], values => values.length > 0),
|
|
289
293
|
extractAsana: () => extract("asana", "https://app.asana.com/", ["asana.com"], (values) => values.some((cookie) => cookie.domain === ".asana.com" || cookie.domain.endsWith(".asana.com"))),
|
|
290
294
|
extractChatgpt: () => extract("chatgpt", "https://chatgpt.com/", ["chatgpt.com", "openai.com"], (values) => values.some((cookie) => cookie.name === "oai-did") && values.some((cookie) => cookie.name === "__Secure-next-auth.session-token" || cookie.name === "__Secure-next-auth.session-token.0"), undefined, true),
|
|
291
295
|
extractGmail: () => extract("gmail", "https://mail.google.com/mail/u/0/", ["google.com"], googleReady),
|
package/src/cli.ts
CHANGED
|
@@ -120,7 +120,7 @@ const fixedCommandPositionals = Object.freeze({
|
|
|
120
120
|
"sync-all": Object.freeze({ expected: 0, name: "" }),
|
|
121
121
|
watch: Object.freeze({ expected: 1, name: "file" }),
|
|
122
122
|
});
|
|
123
|
-
const authServices = new Set(["asana", "chatgpt", "gmail", "google-docs", "notion", "slack", "zoom"]);
|
|
123
|
+
const authServices = new Set(["ashby", "asana", "chatgpt", "gmail", "google-docs", "notion", "slack", "zoom"]);
|
|
124
124
|
const slackResourceCommands = new Set(["preview", "attach", "sync"]);
|
|
125
125
|
const authCommands = new Set(["login", "logout", "status"]);
|
|
126
126
|
const removedCommandNames = Object.freeze({
|
|
@@ -299,7 +299,7 @@ function renderRemovedCommand(argv: readonly string[]): boolean {
|
|
|
299
299
|
function renderUnknownAuthCommand(argv: readonly string[]): boolean {
|
|
300
300
|
if (hasRootSeparator(argv)) return false;
|
|
301
301
|
const words = positionalWords(argv);
|
|
302
|
-
if (words === null || words.length < 2 || !authServices.has(words[0]!) || authCommands.has(words[1]!) || (words[0] === "zoom" && words[1] === "scrape") || words[0] === "asana" && (words[1] === "projects" || words[1] === "tasks" || words[1] === "comments") || (words[0] === "slack" || words[0] === "notion" || words[0] === "asana") && words[1] === "users" || words[0] === "slack" && (words[1] === "send" || words[1] === "edit" || slackResourceCommands.has(words[1]!))) return false;
|
|
302
|
+
if (words === null || words.length < 2 || !authServices.has(words[0]!) || authCommands.has(words[1]!) || (words[0] === "ashby" && ["interviews","pending","latest","prep","template","sync"].includes(words[1]!)) || (words[0] === "zoom" && words[1] === "scrape") || words[0] === "asana" && (words[1] === "projects" || words[1] === "tasks" || words[1] === "comments") || (words[0] === "slack" || words[0] === "notion" || words[0] === "asana") && words[1] === "users" || words[0] === "slack" && (words[1] === "send" || words[1] === "edit" || slackResourceCommands.has(words[1]!))) return false;
|
|
303
303
|
renderCliError(argv, `Unknown command: ${words[1]}`, `wire ${words[0]} --help`, `Unknown command: ${cliValue(words[1]!)}`);
|
|
304
304
|
return true;
|
|
305
305
|
}
|
package/src/executable.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { zoomProvider } from "provider-zoom";
|
|
|
10
10
|
import { lookupNotionUsers } from "provider-notion";
|
|
11
11
|
|
|
12
12
|
import { previewDrive, scrapeDrive } from "./adapters/gdrive.js";
|
|
13
|
+
import { ashby } from "./adapters/ashby.js";
|
|
13
14
|
import { readAgenda } from "./adapters/calendar.js";
|
|
14
15
|
import { createRoot } from "./adapters/root.js";
|
|
15
16
|
import { composeAuth } from "./auth.js";
|
|
@@ -140,7 +141,7 @@ export function createExecutableRoot(environment: NodeEnvironment, currentDirect
|
|
|
140
141
|
switchBackend: baseWire.switchBackend,
|
|
141
142
|
});
|
|
142
143
|
const wire = withWireHooks(configuredWire, { currentDirectory, home, environment: configuredEnvironment() });
|
|
143
|
-
return createRoot(wire, currentDirectory, auth, readStandardInput, { ...options, previewDrive: url => previewDrive(runtime,url), scrapeDrive: url => scrapeDrive(runtime, currentDirectory, url), calendarAgenda: (date, id) => readAgenda(processCapability, configuration.get("WIRE_REPOSITORY_ROOT"), date, id), latticeSync: (url,file) => syncLatticeDrafts(runtime,url,currentDirectory,file), latticeRequests: url => listLatticeReviewRequests(runtime,url), latticeTemplate: url => latticeReviewDraft(runtime,url), latticeFill: async (url,file) => latticeReviewDraft(runtime,url,await runtime.filesystem.readText(resolve(currentDirectory,file))), scrapeZoom: () => zoomProvider.scrape(runtime, currentDirectory) }, (destination, markdown) => sendSlackMessage(runtime, destination, markdown), (query) => lookupSlackUsers(runtime, query), (url, markdown) => editSlackMessage(runtime, url, markdown), (query) => lookupNotionUsers(runtime, query), {
|
|
144
|
+
return createRoot(wire, currentDirectory, auth, readStandardInput, { ...options, ashby: (action,arg) => ashby(runtime,action,action === "sync" ? resolve(currentDirectory,arg!) : arg), previewDrive: url => previewDrive(runtime,url), scrapeDrive: url => scrapeDrive(runtime, currentDirectory, url), calendarAgenda: (date, id) => readAgenda(processCapability, configuration.get("WIRE_REPOSITORY_ROOT"), date, id), latticeSync: (url,file) => syncLatticeDrafts(runtime,url,currentDirectory,file), latticeRequests: url => listLatticeReviewRequests(runtime,url), latticeTemplate: url => latticeReviewDraft(runtime,url), latticeFill: async (url,file) => latticeReviewDraft(runtime,url,await runtime.filesystem.readText(resolve(currentDirectory,file))), scrapeZoom: () => zoomProvider.scrape(runtime, currentDirectory) }, (destination, markdown) => sendSlackMessage(runtime, destination, markdown), (query) => lookupSlackUsers(runtime, query), (url, markdown) => editSlackMessage(runtime, url, markdown), (query) => lookupNotionUsers(runtime, query), {
|
|
144
145
|
lookup: (query) => lookupAsanaUsers(runtime, query), projects: () => listAsanaProjects(runtime), project: (project) => showAsanaProject(runtime, project), tasks: (project) => listAsanaTasks(runtime, project), show: (task) => showAsanaTask(runtime, task),
|
|
145
146
|
writes: { move: (task, project, section) => moveAsanaTask(runtime, task, project, section), create: (project, title, section, body, assignee) => createAsanaTask(runtime, project, title, section, body, assignee), edit: (task, fields) => editAsanaTask(runtime, task, fields), comment: (task, body) => addAsanaComment(runtime, task, body), editComment: (comment, body) => editAsanaComment(runtime, comment, body) },
|
|
146
147
|
}, async () => {
|