@hasna/connectors 1.3.30 → 1.3.32
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 +1 -1
- package/README.md +9 -0
- package/bin/index.js +461 -1702
- package/bin/mcp.js +583 -1768
- package/bin/serve.js +647 -1875
- package/connectors/{imessage → connect-github}/bin/index.js +892 -390
- package/connectors/connect-github/dist/index.js +520 -0
- package/connectors/{cloudflare → connect-yousign}/bun.lock +3 -3
- package/connectors/connect-yousign/node_modules/@types/bun/LICENSE +21 -0
- package/connectors/connect-yousign/node_modules/@types/bun/README.md +20 -0
- package/connectors/connect-yousign/node_modules/@types/bun/index.d.ts +1 -0
- package/connectors/connect-yousign/node_modules/@types/bun/package.json +53 -0
- package/connectors/connect-yousign/node_modules/@types/node/LICENSE +21 -0
- package/connectors/connect-yousign/node_modules/@types/node/README.md +15 -0
- package/connectors/connect-yousign/node_modules/@types/node/assert/strict.d.ts +105 -0
- package/connectors/connect-yousign/node_modules/@types/node/assert.d.ts +955 -0
- package/connectors/connect-yousign/node_modules/@types/node/async_hooks.d.ts +623 -0
- package/connectors/connect-yousign/node_modules/@types/node/buffer.buffer.d.ts +466 -0
- package/connectors/connect-yousign/node_modules/@types/node/buffer.d.ts +1810 -0
- package/connectors/connect-yousign/node_modules/@types/node/child_process.d.ts +1433 -0
- package/connectors/connect-yousign/node_modules/@types/node/cluster.d.ts +486 -0
- package/connectors/connect-yousign/node_modules/@types/node/compatibility/iterators.d.ts +21 -0
- package/connectors/connect-yousign/node_modules/@types/node/console.d.ts +151 -0
- package/connectors/connect-yousign/node_modules/@types/node/constants.d.ts +20 -0
- package/connectors/connect-yousign/node_modules/@types/node/crypto.d.ts +4065 -0
- package/connectors/connect-yousign/node_modules/@types/node/dgram.d.ts +564 -0
- package/connectors/connect-yousign/node_modules/@types/node/diagnostics_channel.d.ts +576 -0
- package/connectors/connect-yousign/node_modules/@types/node/dns/promises.d.ts +503 -0
- package/connectors/connect-yousign/node_modules/@types/node/dns.d.ts +922 -0
- package/connectors/connect-yousign/node_modules/@types/node/domain.d.ts +166 -0
- package/connectors/connect-yousign/node_modules/@types/node/events.d.ts +1047 -0
- package/connectors/connect-yousign/node_modules/@types/node/fs/promises.d.ts +1329 -0
- package/connectors/connect-yousign/node_modules/@types/node/fs.d.ts +4678 -0
- package/connectors/connect-yousign/node_modules/@types/node/globals.d.ts +150 -0
- package/connectors/connect-yousign/node_modules/@types/node/globals.typedarray.d.ts +101 -0
- package/connectors/connect-yousign/node_modules/@types/node/http.d.ts +2188 -0
- package/connectors/connect-yousign/node_modules/@types/node/http2.d.ts +2480 -0
- package/connectors/connect-yousign/node_modules/@types/node/https.d.ts +405 -0
- package/connectors/connect-yousign/node_modules/@types/node/index.d.ts +115 -0
- package/connectors/connect-yousign/node_modules/@types/node/inspector/promises.d.ts +41 -0
- package/connectors/connect-yousign/node_modules/@types/node/inspector.d.ts +269 -0
- package/connectors/connect-yousign/node_modules/@types/node/inspector.generated.d.ts +4401 -0
- package/connectors/connect-yousign/node_modules/@types/node/module.d.ts +757 -0
- package/connectors/connect-yousign/node_modules/@types/node/net.d.ts +933 -0
- package/connectors/connect-yousign/node_modules/@types/node/os.d.ts +507 -0
- package/connectors/connect-yousign/node_modules/@types/node/package.json +155 -0
- package/connectors/connect-yousign/node_modules/@types/node/path/posix.d.ts +8 -0
- package/connectors/connect-yousign/node_modules/@types/node/path/win32.d.ts +8 -0
- package/connectors/connect-yousign/node_modules/@types/node/path.d.ts +187 -0
- package/connectors/connect-yousign/node_modules/@types/node/perf_hooks.d.ts +643 -0
- package/connectors/connect-yousign/node_modules/@types/node/process.d.ts +2175 -0
- package/connectors/connect-yousign/node_modules/@types/node/punycode.d.ts +117 -0
- package/connectors/connect-yousign/node_modules/@types/node/querystring.d.ts +152 -0
- package/connectors/connect-yousign/node_modules/@types/node/quic.d.ts +910 -0
- package/connectors/connect-yousign/node_modules/@types/node/readline/promises.d.ts +161 -0
- package/connectors/connect-yousign/node_modules/@types/node/readline.d.ts +542 -0
- package/connectors/connect-yousign/node_modules/@types/node/repl.d.ts +415 -0
- package/connectors/connect-yousign/node_modules/@types/node/sea.d.ts +162 -0
- package/connectors/connect-yousign/node_modules/@types/node/sqlite.d.ts +1065 -0
- package/connectors/connect-yousign/node_modules/@types/node/stream/consumers.d.ts +38 -0
- package/connectors/connect-yousign/node_modules/@types/node/stream/promises.d.ts +211 -0
- package/connectors/connect-yousign/node_modules/@types/node/stream/web.d.ts +296 -0
- package/connectors/connect-yousign/node_modules/@types/node/stream.d.ts +1770 -0
- package/connectors/connect-yousign/node_modules/@types/node/string_decoder.d.ts +67 -0
- package/connectors/connect-yousign/node_modules/@types/node/test/reporters.d.ts +96 -0
- package/connectors/connect-yousign/node_modules/@types/node/test.d.ts +2275 -0
- package/connectors/connect-yousign/node_modules/@types/node/timers/promises.d.ts +108 -0
- package/connectors/connect-yousign/node_modules/@types/node/timers.d.ts +159 -0
- package/connectors/connect-yousign/node_modules/@types/node/tls.d.ts +1203 -0
- package/connectors/connect-yousign/node_modules/@types/node/trace_events.d.ts +197 -0
- package/connectors/connect-yousign/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +462 -0
- package/connectors/connect-yousign/node_modules/@types/node/ts5.6/compatibility/float16array.d.ts +71 -0
- package/connectors/connect-yousign/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +36 -0
- package/connectors/connect-yousign/node_modules/@types/node/ts5.6/index.d.ts +117 -0
- package/connectors/connect-yousign/node_modules/@types/node/ts5.7/compatibility/float16array.d.ts +72 -0
- package/connectors/connect-yousign/node_modules/@types/node/ts5.7/index.d.ts +117 -0
- package/connectors/connect-yousign/node_modules/@types/node/tty.d.ts +250 -0
- package/connectors/connect-yousign/node_modules/@types/node/url.d.ts +541 -0
- package/connectors/connect-yousign/node_modules/@types/node/util/types.d.ts +558 -0
- package/connectors/connect-yousign/node_modules/@types/node/util.d.ts +1687 -0
- package/connectors/connect-yousign/node_modules/@types/node/v8.d.ts +988 -0
- package/connectors/connect-yousign/node_modules/@types/node/vm.d.ts +1208 -0
- package/connectors/connect-yousign/node_modules/@types/node/wasi.d.ts +202 -0
- package/connectors/connect-yousign/node_modules/@types/node/web-globals/abortcontroller.d.ts +59 -0
- package/connectors/connect-yousign/node_modules/@types/node/web-globals/blob.d.ts +23 -0
- package/connectors/connect-yousign/node_modules/@types/node/web-globals/console.d.ts +9 -0
- package/connectors/connect-yousign/node_modules/@types/node/web-globals/crypto.d.ts +39 -0
- package/connectors/connect-yousign/node_modules/@types/node/web-globals/domexception.d.ts +68 -0
- package/connectors/connect-yousign/node_modules/@types/node/web-globals/encoding.d.ts +11 -0
- package/connectors/connect-yousign/node_modules/@types/node/web-globals/events.d.ts +106 -0
- package/connectors/connect-yousign/node_modules/@types/node/web-globals/fetch.d.ts +69 -0
- package/connectors/connect-yousign/node_modules/@types/node/web-globals/importmeta.d.ts +13 -0
- package/connectors/connect-yousign/node_modules/@types/node/web-globals/messaging.d.ts +23 -0
- package/connectors/connect-yousign/node_modules/@types/node/web-globals/navigator.d.ts +25 -0
- package/connectors/connect-yousign/node_modules/@types/node/web-globals/performance.d.ts +45 -0
- package/connectors/connect-yousign/node_modules/@types/node/web-globals/storage.d.ts +24 -0
- package/connectors/connect-yousign/node_modules/@types/node/web-globals/streams.d.ts +115 -0
- package/connectors/connect-yousign/node_modules/@types/node/web-globals/timers.d.ts +44 -0
- package/connectors/connect-yousign/node_modules/@types/node/web-globals/url.d.ts +24 -0
- package/connectors/connect-yousign/node_modules/@types/node/worker_threads.d.ts +717 -0
- package/connectors/connect-yousign/node_modules/@types/node/zlib.d.ts +682 -0
- package/connectors/connect-yousign/node_modules/bun-types/CLAUDE.md +105 -0
- package/connectors/connect-yousign/node_modules/bun-types/README.md +33 -0
- package/connectors/connect-yousign/node_modules/bun-types/bun.d.ts +8481 -0
- package/connectors/connect-yousign/node_modules/bun-types/bun.ns.d.ts +5 -0
- package/connectors/connect-yousign/node_modules/bun-types/bundle.d.ts +74 -0
- package/connectors/connect-yousign/node_modules/bun-types/deprecated.d.ts +184 -0
- package/connectors/connect-yousign/node_modules/bun-types/devserver.d.ts +187 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/README.md +28 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/bundler/bytecode.mdx +447 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/bundler/css.mdx +1024 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/bundler/esbuild.mdx +304 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/bundler/executables.mdx +1318 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/bundler/fullstack.mdx +1086 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/bundler/hot-reloading.mdx +229 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/bundler/html-static.mdx +498 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/bundler/index.mdx +1840 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/bundler/loaders.mdx +451 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/bundler/macros.mdx +328 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/bundler/minifier.mdx +1286 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/bundler/plugins.mdx +477 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/bundler/standalone-html.mdx +314 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/feedback.mdx +75 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/binary/arraybuffer-to-array.mdx +29 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/binary/arraybuffer-to-blob.mdx +26 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/binary/arraybuffer-to-buffer.mdx +27 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/binary/arraybuffer-to-string.mdx +17 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/binary/arraybuffer-to-typedarray.mdx +41 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/binary/blob-to-arraybuffer.mdx +16 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/binary/blob-to-dataview.mdx +16 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/binary/blob-to-stream.mdx +16 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/binary/blob-to-string.mdx +17 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/binary/blob-to-typedarray.mdx +16 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/binary/buffer-to-arraybuffer.mdx +16 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/binary/buffer-to-blob.mdx +16 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/binary/buffer-to-readablestream.mdx +43 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/binary/buffer-to-string.mdx +27 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/binary/buffer-to-typedarray.mdx +16 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/binary/dataview-to-string.mdx +17 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/binary/typedarray-to-arraybuffer.mdx +27 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/binary/typedarray-to-blob.mdx +18 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/binary/typedarray-to-buffer.mdx +16 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/binary/typedarray-to-dataview.mdx +16 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/binary/typedarray-to-readablestream.mdx +43 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/binary/typedarray-to-string.mdx +18 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/deployment/aws-lambda.mdx +204 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/deployment/digital-ocean.mdx +161 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/deployment/google-cloud-run.mdx +194 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/deployment/railway.mdx +145 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/deployment/render.mdx +82 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/deployment/vercel.mdx +97 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/astro.mdx +82 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/discordjs.mdx +80 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/docker.mdx +151 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/drizzle.mdx +195 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/elysia.mdx +31 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/express.mdx +43 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/gel.mdx +261 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/hono.mdx +47 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/mongoose.mdx +92 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/neon-drizzle.mdx +234 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/neon-serverless-postgres.mdx +60 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/nextjs.mdx +103 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/nuxt.mdx +96 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/pm2.mdx +55 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/prisma-postgres.mdx +169 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/prisma.mdx +164 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/qwik.mdx +114 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/react.mdx +52 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/remix.mdx +97 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/sentry.mdx +54 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/solidstart.mdx +62 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/ssr-react.mdx +49 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/stric.mdx +54 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/sveltekit.mdx +138 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/systemd.mdx +114 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/tanstack-start.mdx +791 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/upstash.mdx +87 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/vite.mdx +77 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/html-rewriter/extract-links.mdx +71 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/html-rewriter/extract-social-meta.mdx +97 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/http/cluster.mdx +69 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/http/fetch-unix.mdx +35 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/http/fetch.mdx +26 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/http/file-uploads.mdx +97 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/http/hot.mdx +28 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/http/proxy.mdx +50 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/http/server.mdx +48 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/http/simple.mdx +20 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/http/stream-file.mdx +50 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/http/stream-iterator.mdx +49 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/http/stream-node-streams-in-bun.mdx +22 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/http/tls.mdx +32 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/index.mdx +10 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/install/add-dev.mdx +28 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/install/add-git.mdx +40 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/install/add-optional.mdx +27 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/install/add-peer.mdx +45 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/install/add-tarball.mdx +35 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/install/add.mdx +44 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/install/azure-artifacts.mdx +76 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/install/cicd.mdx +43 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/install/custom-registry.mdx +32 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/install/from-npm-install-to-bun-install.mdx +230 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/install/git-diff-bun-lockfile.mdx +48 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/install/jfrog-artifactory.mdx +28 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/install/npm-alias.mdx +25 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/install/registry-scope.mdx +40 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/install/trusted.mdx +52 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/install/workspaces.mdx +70 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/install/yarnlock.mdx +51 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/process/argv.mdx +66 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/process/ctrl-c.mdx +18 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/process/ipc.mdx +69 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/process/nanoseconds.mdx +15 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/process/os-signals.mdx +31 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/process/spawn-stderr.mdx +34 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/process/spawn-stdout.mdx +28 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/process/spawn.mdx +43 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/process/stdin.mdx +62 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/read-file/arraybuffer.mdx +30 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/read-file/buffer.mdx +21 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/read-file/exists.mdx +18 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/read-file/json.mdx +19 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/read-file/mime.mdx +22 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/read-file/stream.mdx +28 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/read-file/string.mdx +24 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/read-file/uint8array.mdx +23 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/read-file/watch.mdx +66 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/runtime/build-time-constants.mdx +295 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/runtime/cicd.mdx +45 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/runtime/codesign-macos-executable.mdx +61 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/runtime/define-constant.mdx +149 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/runtime/delete-directory.mdx +39 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/runtime/delete-file.mdx +21 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/runtime/heap-snapshot.mdx +28 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/runtime/import-html.mdx +15 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/runtime/import-json.mdx +46 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/runtime/import-json5.mdx +74 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/runtime/import-toml.mdx +32 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/runtime/import-yaml.mdx +104 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/runtime/read-env.mdx +37 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/runtime/set-env.mdx +51 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/runtime/shell.mdx +42 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/runtime/timezone.mdx +38 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/runtime/tsconfig-paths.mdx +31 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/runtime/typescript.mdx +51 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/runtime/vscode-debugger.mdx +47 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/runtime/web-debugger.mdx +103 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/streams/node-readable-to-arraybuffer.mdx +13 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/streams/node-readable-to-blob.mdx +13 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/streams/node-readable-to-json.mdx +14 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/streams/node-readable-to-string.mdx +14 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/streams/node-readable-to-uint8array.mdx +13 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/streams/to-array.mdx +16 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/streams/to-arraybuffer.mdx +16 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/streams/to-blob.mdx +16 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/streams/to-buffer.mdx +17 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/streams/to-json.mdx +16 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/streams/to-string.mdx +16 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/streams/to-typedarray.mdx +24 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/test/bail.mdx +24 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/test/concurrent-test-glob.mdx +146 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/test/coverage-threshold.mdx +67 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/test/coverage.mdx +49 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/test/happy-dom.mdx +73 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/test/migrate-from-jest.mdx +125 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/test/mock-clock.mdx +50 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/test/mock-functions.mdx +70 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/test/rerun-each.mdx +16 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/test/run-tests.mdx +116 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/test/skip-tests.mdx +43 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/test/snapshot.mdx +102 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/test/spy-on.mdx +49 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/test/svelte-test.mdx +113 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/test/testing-library.mdx +93 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/test/timeout.mdx +17 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/test/todo-tests.mdx +74 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/test/update-snapshots.mdx +49 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/test/watch-mode.mdx +24 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/util/base64.mdx +17 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/util/deep-equals.mdx +41 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/util/deflate.mdx +20 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/util/detect-bun.mdx +28 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/util/entrypoint.mdx +19 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/util/escape-html.mdx +24 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/util/file-url-to-path.mdx +16 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/util/gzip.mdx +20 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/util/hash-a-password.mdx +56 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/util/import-meta-dir.mdx +15 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/util/import-meta-file.mdx +15 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/util/import-meta-path.mdx +15 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/util/javascript-uuid.mdx +25 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/util/main.mdx +43 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/util/path-to-file-url.mdx +16 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/util/sleep.mdx +24 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/util/upgrade.mdx +93 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/util/version.mdx +23 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/util/which-path-to-executable-bin.mdx +17 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/websocket/compression.mdx +33 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/websocket/context.mdx +79 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/websocket/pubsub.mdx +43 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/websocket/simple.mdx +38 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/write-file/append.mdx +54 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/write-file/basic.mdx +46 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/write-file/blob.mdx +30 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/write-file/cat.mdx +19 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/write-file/file-cp.mdx +18 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/write-file/filesink.mdx +54 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/write-file/response.mdx +19 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/write-file/stdout.mdx +23 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/write-file/stream.mdx +19 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/write-file/unlink.mdx +18 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/index.mdx +133 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/installation.mdx +372 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/pm/bunx.mdx +91 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/pm/catalogs.mdx +292 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/pm/cli/add.mdx +179 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/pm/cli/audit.mdx +60 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/pm/cli/info.mdx +70 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/pm/cli/install.mdx +591 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/pm/cli/link.mdx +61 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/pm/cli/outdated.mdx +197 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/pm/cli/patch.mdx +69 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/pm/cli/pm.mdx +323 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/pm/cli/publish.mdx +131 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/pm/cli/remove.mdx +16 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/pm/cli/update.mdx +140 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/pm/cli/why.mdx +84 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/pm/filter.mdx +127 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/pm/global-cache.mdx +72 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/pm/isolated-installs.mdx +220 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/pm/lifecycle.mdx +64 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/pm/lockfile.mdx +64 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/pm/npmrc.mdx +245 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/pm/overrides.mdx +83 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/pm/scopes-registries.mdx +35 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/pm/security-scanner-api.mdx +95 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/pm/workspaces.mdx +115 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/project/benchmarking.mdx +296 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/project/bindgen.mdx +223 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/project/building-windows.mdx +143 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/project/contributing.mdx +366 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/project/feedback.mdx +20 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/project/license.mdx +78 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/project/roadmap.mdx +8 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/quickstart.mdx +251 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/archive.mdx +452 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/auto-install.mdx +97 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/binary-data.mdx +846 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/bun-apis.mdx +59 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/bunfig.mdx +754 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/c-compiler.mdx +204 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/child-process.mdx +659 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/color.mdx +267 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/console.mdx +67 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/cookies.mdx +454 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/debugger.mdx +335 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/environment-variables.mdx +231 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/ffi.mdx +567 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/file-io.mdx +306 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/file-system-router.mdx +118 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/file-types.mdx +482 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/glob.mdx +181 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/globals.mdx +72 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/hashing.mdx +315 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/html-rewriter.mdx +333 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/http/cookies.mdx +79 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/http/error-handling.mdx +40 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/http/metrics.mdx +36 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/http/routing.mdx +289 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/http/server.mdx +645 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/http/tls.mdx +101 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/http/websockets.mdx +414 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/index.mdx +223 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/json5.mdx +271 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/jsonl.mdx +188 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/jsx.mdx +115 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/markdown.mdx +344 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/module-resolution.mdx +374 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/networking/dns.mdx +111 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/networking/fetch.mdx +484 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/networking/tcp.mdx +239 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/networking/udp.mdx +180 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/node-api.mdx +19 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/nodejs-compat.mdx +468 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/plugins.mdx +419 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/redis.mdx +583 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/repl.mdx +176 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/s3.mdx +881 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/secrets.mdx +340 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/semver.mdx +57 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/shell.mdx +637 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/sql.mdx +1404 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/sqlite.mdx +721 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/streams.mdx +232 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/templating/create.mdx +269 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/templating/init.mdx +58 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/transpiler.mdx +288 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/typescript.mdx +58 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/utils.mdx +1010 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/watch-mode.mdx +161 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/web-apis.mdx +29 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/workers.mdx +314 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/yaml.mdx +469 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/snippets/cli/add.mdx +166 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/snippets/cli/build.mdx +197 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/snippets/cli/bunx.mdx +49 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/snippets/cli/feedback.mdx +17 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/snippets/cli/init.mdx +84 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/snippets/cli/install.mdx +173 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/snippets/cli/link.mdx +163 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/snippets/cli/outdated.mdx +140 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/snippets/cli/patch.mdx +171 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/snippets/cli/publish.mdx +198 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/snippets/cli/remove.mdx +146 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/snippets/cli/run.mdx +305 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/snippets/cli/test.mdx +105 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/snippets/cli/update.mdx +144 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/test/code-coverage.mdx +409 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/test/configuration.mdx +520 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/test/dates-times.mdx +129 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/test/discovery.mdx +90 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/test/dom.mdx +226 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/test/index.mdx +409 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/test/lifecycle.mdx +366 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/test/mocks.mdx +637 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/test/reporters.mdx +126 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/test/runtime-behavior.mdx +342 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/test/snapshots.mdx +434 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/test/writing-tests.mdx +672 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/typescript.mdx +54 -0
- package/connectors/connect-yousign/node_modules/bun-types/extensions.d.ts +40 -0
- package/connectors/connect-yousign/node_modules/bun-types/fetch.d.ts +79 -0
- package/connectors/connect-yousign/node_modules/bun-types/ffi.d.ts +1154 -0
- package/connectors/connect-yousign/node_modules/bun-types/globals.d.ts +2067 -0
- package/connectors/connect-yousign/node_modules/bun-types/html-rewriter.d.ts +186 -0
- package/connectors/connect-yousign/node_modules/bun-types/index.d.ts +32 -0
- package/connectors/connect-yousign/node_modules/bun-types/jsc.d.ts +233 -0
- package/connectors/connect-yousign/node_modules/bun-types/jsx.d.ts +11 -0
- package/connectors/connect-yousign/node_modules/bun-types/overrides.d.ts +376 -0
- package/connectors/connect-yousign/node_modules/bun-types/package.json +37 -0
- package/connectors/connect-yousign/node_modules/bun-types/redis.d.ts +3352 -0
- package/connectors/connect-yousign/node_modules/bun-types/s3.d.ts +1335 -0
- package/connectors/connect-yousign/node_modules/bun-types/security.d.ts +101 -0
- package/connectors/connect-yousign/node_modules/bun-types/serve.d.ts +1296 -0
- package/connectors/connect-yousign/node_modules/bun-types/shell.d.ts +380 -0
- package/connectors/connect-yousign/node_modules/bun-types/sql.d.ts +887 -0
- package/connectors/connect-yousign/node_modules/bun-types/sqlite.d.ts +1322 -0
- package/connectors/connect-yousign/node_modules/bun-types/test-globals.d.ts +22 -0
- package/connectors/connect-yousign/node_modules/bun-types/test.d.ts +2392 -0
- package/connectors/connect-yousign/node_modules/bun-types/vendor/expect-type/branding.d.ts +283 -0
- package/connectors/connect-yousign/node_modules/bun-types/vendor/expect-type/index.d.ts +1207 -0
- package/connectors/connect-yousign/node_modules/bun-types/vendor/expect-type/messages.d.ts +395 -0
- package/connectors/connect-yousign/node_modules/bun-types/vendor/expect-type/overloads.d.ts +669 -0
- package/connectors/connect-yousign/node_modules/bun-types/vendor/expect-type/utils.d.ts +431 -0
- package/connectors/connect-yousign/node_modules/bun-types/wasm.d.ts +193 -0
- package/connectors/connect-yousign/node_modules/chalk/license +9 -0
- package/connectors/connect-yousign/node_modules/chalk/package.json +83 -0
- package/connectors/connect-yousign/node_modules/chalk/readme.md +297 -0
- package/connectors/connect-yousign/node_modules/chalk/source/index.d.ts +325 -0
- package/connectors/connect-yousign/node_modules/chalk/source/index.js +225 -0
- package/connectors/connect-yousign/node_modules/chalk/source/utilities.js +33 -0
- package/connectors/connect-yousign/node_modules/chalk/source/vendor/ansi-styles/index.d.ts +236 -0
- package/connectors/connect-yousign/node_modules/chalk/source/vendor/ansi-styles/index.js +223 -0
- package/connectors/connect-yousign/node_modules/chalk/source/vendor/supports-color/browser.d.ts +1 -0
- package/connectors/connect-yousign/node_modules/chalk/source/vendor/supports-color/browser.js +34 -0
- package/connectors/connect-yousign/node_modules/chalk/source/vendor/supports-color/index.d.ts +55 -0
- package/connectors/connect-yousign/node_modules/chalk/source/vendor/supports-color/index.js +190 -0
- package/connectors/connect-yousign/node_modules/commander/LICENSE +22 -0
- package/connectors/connect-yousign/node_modules/commander/Readme.md +1157 -0
- package/connectors/connect-yousign/node_modules/commander/esm.mjs +16 -0
- package/connectors/connect-yousign/node_modules/commander/index.js +24 -0
- package/connectors/connect-yousign/node_modules/commander/lib/argument.js +149 -0
- package/connectors/connect-yousign/node_modules/commander/lib/command.js +2509 -0
- package/connectors/connect-yousign/node_modules/commander/lib/error.js +39 -0
- package/connectors/connect-yousign/node_modules/commander/lib/help.js +520 -0
- package/connectors/connect-yousign/node_modules/commander/lib/option.js +330 -0
- package/connectors/connect-yousign/node_modules/commander/lib/suggestSimilar.js +101 -0
- package/connectors/connect-yousign/node_modules/commander/package-support.json +16 -0
- package/connectors/connect-yousign/node_modules/commander/package.json +84 -0
- package/connectors/connect-yousign/node_modules/commander/typings/esm.d.mts +3 -0
- package/connectors/connect-yousign/node_modules/commander/typings/index.d.ts +969 -0
- package/connectors/connect-yousign/node_modules/typescript/LICENSE.txt +55 -0
- package/connectors/connect-yousign/node_modules/typescript/README.md +50 -0
- package/connectors/connect-yousign/node_modules/typescript/SECURITY.md +41 -0
- package/connectors/connect-yousign/node_modules/typescript/ThirdPartyNoticeText.txt +193 -0
- package/connectors/connect-yousign/node_modules/typescript/bin/tsc +2 -0
- package/connectors/connect-yousign/node_modules/typescript/bin/tsserver +2 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/_tsc.js +133818 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/_tsserver.js +659 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/_typingsInstaller.js +222 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/cs/diagnosticMessages.generated.json +2122 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/de/diagnosticMessages.generated.json +2122 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/es/diagnosticMessages.generated.json +2122 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/fr/diagnosticMessages.generated.json +2122 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/it/diagnosticMessages.generated.json +2122 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/ja/diagnosticMessages.generated.json +2122 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/ko/diagnosticMessages.generated.json +2122 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.d.ts +22 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.decorators.d.ts +384 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.decorators.legacy.d.ts +22 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.dom.asynciterable.d.ts +41 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.dom.d.ts +39429 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.dom.iterable.d.ts +571 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2015.collection.d.ts +147 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2015.core.d.ts +597 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2015.d.ts +28 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2015.generator.d.ts +77 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2015.iterable.d.ts +605 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2015.promise.d.ts +81 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2015.proxy.d.ts +128 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2015.reflect.d.ts +144 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2015.symbol.d.ts +46 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts +326 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2016.array.include.d.ts +116 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2016.d.ts +21 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2016.full.d.ts +23 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2016.intl.d.ts +31 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts +21 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2017.d.ts +26 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2017.date.d.ts +31 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2017.full.d.ts +23 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2017.intl.d.ts +44 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2017.object.d.ts +49 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts +135 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2017.string.d.ts +45 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts +53 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts +77 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts +53 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2018.d.ts +24 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2018.full.d.ts +24 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2018.intl.d.ts +83 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2018.promise.d.ts +30 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2018.regexp.d.ts +37 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2019.array.d.ts +79 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2019.d.ts +24 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2019.full.d.ts +24 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2019.intl.d.ts +23 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2019.object.d.ts +33 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2019.string.d.ts +37 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2019.symbol.d.ts +24 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2020.bigint.d.ts +765 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2020.d.ts +27 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2020.date.d.ts +42 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2020.full.d.ts +24 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2020.intl.d.ts +474 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2020.number.d.ts +28 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2020.promise.d.ts +47 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts +99 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2020.string.d.ts +44 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts +41 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2021.d.ts +23 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2021.full.d.ts +24 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2021.intl.d.ts +166 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2021.promise.d.ts +48 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2021.string.d.ts +33 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2021.weakref.d.ts +78 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2022.array.d.ts +121 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2022.d.ts +25 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2022.error.d.ts +75 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2022.full.d.ts +24 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2022.intl.d.ts +145 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2022.object.d.ts +26 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2022.regexp.d.ts +39 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2022.string.d.ts +25 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2023.array.d.ts +924 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2023.collection.d.ts +21 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2023.d.ts +22 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2023.full.d.ts +24 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2023.intl.d.ts +56 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2024.arraybuffer.d.ts +65 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2024.collection.d.ts +29 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2024.d.ts +26 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2024.full.d.ts +24 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2024.object.d.ts +29 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2024.promise.d.ts +35 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2024.regexp.d.ts +25 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2024.sharedmemory.d.ts +68 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2024.string.d.ts +29 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es5.d.ts +4601 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es6.d.ts +23 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.esnext.array.d.ts +35 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.esnext.collection.d.ts +96 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.esnext.d.ts +29 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.esnext.decorators.d.ts +28 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.esnext.disposable.d.ts +193 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.esnext.error.d.ts +24 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.esnext.float16.d.ts +445 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.esnext.full.d.ts +24 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.esnext.intl.d.ts +21 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.esnext.iterator.d.ts +148 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.esnext.promise.d.ts +34 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.esnext.sharedmemory.d.ts +25 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.scripthost.d.ts +322 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.webworker.asynciterable.d.ts +41 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.webworker.d.ts +13150 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.webworker.importscripts.d.ts +23 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.webworker.iterable.d.ts +340 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/pl/diagnosticMessages.generated.json +2122 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/pt-br/diagnosticMessages.generated.json +2122 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/ru/diagnosticMessages.generated.json +2122 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/tr/diagnosticMessages.generated.json +2122 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/tsc.js +8 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/tsserver.js +8 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/tsserverlibrary.d.ts +17 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/tsserverlibrary.js +21 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/typesMap.json +497 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/typescript.d.ts +11437 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/typescript.js +200276 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/typingsInstaller.js +8 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/watchGuard.js +53 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/zh-cn/diagnosticMessages.generated.json +2122 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/zh-tw/diagnosticMessages.generated.json +2122 -0
- package/connectors/connect-yousign/node_modules/typescript/package.json +120 -0
- package/connectors/connect-yousign/node_modules/undici-types/LICENSE +21 -0
- package/connectors/connect-yousign/node_modules/undici-types/README.md +6 -0
- package/connectors/connect-yousign/node_modules/undici-types/agent.d.ts +32 -0
- package/connectors/connect-yousign/node_modules/undici-types/api.d.ts +43 -0
- package/connectors/connect-yousign/node_modules/undici-types/balanced-pool.d.ts +30 -0
- package/connectors/connect-yousign/node_modules/undici-types/cache-interceptor.d.ts +173 -0
- package/connectors/connect-yousign/node_modules/undici-types/cache.d.ts +36 -0
- package/connectors/connect-yousign/node_modules/undici-types/client-stats.d.ts +15 -0
- package/connectors/connect-yousign/node_modules/undici-types/client.d.ts +108 -0
- package/connectors/connect-yousign/node_modules/undici-types/connector.d.ts +34 -0
- package/connectors/connect-yousign/node_modules/undici-types/content-type.d.ts +21 -0
- package/connectors/connect-yousign/node_modules/undici-types/cookies.d.ts +30 -0
- package/connectors/connect-yousign/node_modules/undici-types/diagnostics-channel.d.ts +74 -0
- package/connectors/connect-yousign/node_modules/undici-types/dispatcher.d.ts +276 -0
- package/connectors/connect-yousign/node_modules/undici-types/env-http-proxy-agent.d.ts +22 -0
- package/connectors/connect-yousign/node_modules/undici-types/errors.d.ts +161 -0
- package/connectors/connect-yousign/node_modules/undici-types/eventsource.d.ts +66 -0
- package/connectors/connect-yousign/node_modules/undici-types/fetch.d.ts +211 -0
- package/connectors/connect-yousign/node_modules/undici-types/formdata.d.ts +108 -0
- package/connectors/connect-yousign/node_modules/undici-types/global-dispatcher.d.ts +9 -0
- package/connectors/connect-yousign/node_modules/undici-types/global-origin.d.ts +7 -0
- package/connectors/connect-yousign/node_modules/undici-types/h2c-client.d.ts +73 -0
- package/connectors/connect-yousign/node_modules/undici-types/handlers.d.ts +15 -0
- package/connectors/connect-yousign/node_modules/undici-types/header.d.ts +160 -0
- package/connectors/connect-yousign/node_modules/undici-types/index.d.ts +88 -0
- package/connectors/connect-yousign/node_modules/undici-types/interceptors.d.ts +73 -0
- package/connectors/connect-yousign/node_modules/undici-types/mock-agent.d.ts +68 -0
- package/connectors/connect-yousign/node_modules/undici-types/mock-call-history.d.ts +111 -0
- package/connectors/connect-yousign/node_modules/undici-types/mock-client.d.ts +27 -0
- package/connectors/connect-yousign/node_modules/undici-types/mock-errors.d.ts +12 -0
- package/connectors/connect-yousign/node_modules/undici-types/mock-interceptor.d.ts +94 -0
- package/connectors/connect-yousign/node_modules/undici-types/mock-pool.d.ts +27 -0
- package/connectors/connect-yousign/node_modules/undici-types/package.json +55 -0
- package/connectors/connect-yousign/node_modules/undici-types/patch.d.ts +29 -0
- package/connectors/connect-yousign/node_modules/undici-types/pool-stats.d.ts +19 -0
- package/connectors/connect-yousign/node_modules/undici-types/pool.d.ts +41 -0
- package/connectors/connect-yousign/node_modules/undici-types/proxy-agent.d.ts +29 -0
- package/connectors/connect-yousign/node_modules/undici-types/readable.d.ts +68 -0
- package/connectors/connect-yousign/node_modules/undici-types/retry-agent.d.ts +8 -0
- package/connectors/connect-yousign/node_modules/undici-types/retry-handler.d.ts +125 -0
- package/connectors/connect-yousign/node_modules/undici-types/round-robin-pool.d.ts +41 -0
- package/connectors/connect-yousign/node_modules/undici-types/snapshot-agent.d.ts +109 -0
- package/connectors/connect-yousign/node_modules/undici-types/util.d.ts +18 -0
- package/connectors/connect-yousign/node_modules/undici-types/utility.d.ts +7 -0
- package/connectors/connect-yousign/node_modules/undici-types/webidl.d.ts +341 -0
- package/connectors/connect-yousign/node_modules/undici-types/websocket.d.ts +186 -0
- package/dashboard/dist/assets/index-CSlS3oNV.css +1 -0
- package/dashboard/dist/assets/index-NCasN7x4.js +284 -0
- package/dashboard/dist/index.html +2 -2
- package/dist/cli/commands/auth.d.ts +0 -3
- package/dist/index.d.ts +1 -2
- package/dist/index.js +167 -1399
- package/dist/lib/lock.d.ts +1 -1
- package/dist/lib/runner.d.ts +0 -31
- package/dist/lib/workflow-runner.d.ts +0 -7
- package/dist/server/auth.d.ts +3 -4
- package/package.json +1 -1
- package/connectors/gmail/bin/index.js +0 -7027
- package/connectors/googledrive/bin/index.js +0 -5958
- package/connectors/imessage/bin/.gitkeep +0 -2
- package/connectors/imessage/bun.lock +0 -32
- package/dashboard/dist/assets/index-ClBXkNbL.css +0 -1
- package/dashboard/dist/assets/index-DvfmyAO4.js +0 -284
- package/dist/core/builtins.test.d.ts +0 -1
- package/dist/core/connectors/gmail.d.ts +0 -5
- package/dist/core/connectors/googledrive.d.ts +0 -6
- package/dist/core/connectors/internal-operations.test.d.ts +0 -1
- package/dist/core/connectors/internal-runtime.test.d.ts +0 -1
- package/dist/core/errors.test.d.ts +0 -1
- package/dist/lib/connector-resolver.d.ts +0 -37
- package/dist/lib/connector-resolver.test.d.ts +0 -1
- package/dist/lib/manifest.d.ts +0 -50
- package/dist/lib/manifest.test.d.ts +0 -1
- package/dist/lib/runner-auth.test.d.ts +0 -1
- package/dist/lib/test-endpoints.test.d.ts +0 -1
- package/dist/server/auth-exchange.test.d.ts +0 -1
- package/dist/server/auth-refresh.test.d.ts +0 -1
- /package/dist/{cli/auth-no-browser.test.d.ts → server/server.test.d.ts} +0 -0
package/bin/index.js
CHANGED
|
@@ -1909,7 +1909,7 @@ var package_default;
|
|
|
1909
1909
|
var init_package = __esm(() => {
|
|
1910
1910
|
package_default = {
|
|
1911
1911
|
name: "@hasna/connectors",
|
|
1912
|
-
version: "1.3.
|
|
1912
|
+
version: "1.3.24",
|
|
1913
1913
|
description: "Open source connector library - Install API connectors with a single command",
|
|
1914
1914
|
type: "module",
|
|
1915
1915
|
bin: {
|
|
@@ -1997,7 +1997,7 @@ var init_package = __esm(() => {
|
|
|
1997
1997
|
});
|
|
1998
1998
|
|
|
1999
1999
|
// src/core/errors.ts
|
|
2000
|
-
var ConnectorDefinitionError
|
|
2000
|
+
var ConnectorDefinitionError;
|
|
2001
2001
|
var init_errors = __esm(() => {
|
|
2002
2002
|
ConnectorDefinitionError = class ConnectorDefinitionError extends Error {
|
|
2003
2003
|
code;
|
|
@@ -2007,16 +2007,6 @@ var init_errors = __esm(() => {
|
|
|
2007
2007
|
this.code = code;
|
|
2008
2008
|
}
|
|
2009
2009
|
};
|
|
2010
|
-
ConnectorOperationNotFoundError = class ConnectorOperationNotFoundError extends Error {
|
|
2011
|
-
connectorName;
|
|
2012
|
-
operationName;
|
|
2013
|
-
constructor(connectorName, operationName) {
|
|
2014
|
-
super(`Operation '${operationName}' not found on connector '${connectorName}'`);
|
|
2015
|
-
this.name = "ConnectorOperationNotFoundError";
|
|
2016
|
-
this.connectorName = connectorName;
|
|
2017
|
-
this.operationName = operationName;
|
|
2018
|
-
}
|
|
2019
|
-
};
|
|
2020
2010
|
});
|
|
2021
2011
|
|
|
2022
2012
|
// src/core/connector.ts
|
|
@@ -2058,34 +2048,11 @@ function defineConnector(definition) {
|
|
|
2058
2048
|
operations: normalizedOperations
|
|
2059
2049
|
};
|
|
2060
2050
|
}
|
|
2061
|
-
function listConnectorOperations(connector) {
|
|
2062
|
-
return Object.values(connector.operations).sort((a, b) => a.name.localeCompare(b.name));
|
|
2063
|
-
}
|
|
2064
|
-
function getConnectorOperation(connector, name) {
|
|
2065
|
-
return listConnectorOperations(connector).find((operation) => operation.name === name);
|
|
2066
|
-
}
|
|
2067
|
-
async function executeConnectorOperation(connector, args) {
|
|
2068
|
-
const operation = getConnectorOperation(connector, args.operation);
|
|
2069
|
-
if (!operation) {
|
|
2070
|
-
throw new ConnectorOperationNotFoundError(connector.meta.name, args.operation);
|
|
2071
|
-
}
|
|
2072
|
-
const context = connector.createContext ? await connector.createContext({
|
|
2073
|
-
credentials: args.credentials,
|
|
2074
|
-
profile: args.profile
|
|
2075
|
-
}) : undefined;
|
|
2076
|
-
const parsedInput = operation.inputSchema ? operation.inputSchema.parse(args.input ?? {}) : args.input ?? {};
|
|
2077
|
-
return operation.execute({
|
|
2078
|
-
connector,
|
|
2079
|
-
context,
|
|
2080
|
-
profile: args.profile,
|
|
2081
|
-
credentials: args.credentials
|
|
2082
|
-
}, parsedInput);
|
|
2083
|
-
}
|
|
2084
2051
|
var CONNECTOR_NAME_RE, OPERATION_NAME_RE;
|
|
2085
2052
|
var init_connector = __esm(() => {
|
|
2086
2053
|
init_errors();
|
|
2087
2054
|
CONNECTOR_NAME_RE = /^[a-z0-9-]+$/;
|
|
2088
|
-
OPERATION_NAME_RE = /^[
|
|
2055
|
+
OPERATION_NAME_RE = /^[a-z0-9:_-]+$/;
|
|
2089
2056
|
});
|
|
2090
2057
|
|
|
2091
2058
|
// src/core/registry.ts
|
|
@@ -6087,10 +6054,10 @@ import { dirname, join } from "path";
|
|
|
6087
6054
|
import { fileURLToPath, pathToFileURL } from "url";
|
|
6088
6055
|
function resolveGithubConnectorDir() {
|
|
6089
6056
|
const candidates = [
|
|
6090
|
-
join(__dirname2, "..", "..", "..", "connectors", "github"),
|
|
6091
|
-
join(__dirname2, "..", "..", "connectors", "github"),
|
|
6092
|
-
join(__dirname2, "..", "connectors", "github"),
|
|
6093
|
-
join(process.cwd(), "connectors", "github")
|
|
6057
|
+
join(__dirname2, "..", "..", "..", "connectors", "connect-github"),
|
|
6058
|
+
join(__dirname2, "..", "..", "connectors", "connect-github"),
|
|
6059
|
+
join(__dirname2, "..", "connectors", "connect-github"),
|
|
6060
|
+
join(process.cwd(), "connectors", "connect-github")
|
|
6094
6061
|
];
|
|
6095
6062
|
for (const candidate of candidates) {
|
|
6096
6063
|
if (existsSync(candidate)) {
|
|
@@ -6946,806 +6913,6 @@ Commands:
|
|
|
6946
6913
|
});
|
|
6947
6914
|
});
|
|
6948
6915
|
|
|
6949
|
-
// src/core/connectors/gmail.ts
|
|
6950
|
-
import { existsSync as existsSync2, mkdirSync, readFileSync, readdirSync, writeFileSync } from "fs";
|
|
6951
|
-
import { homedir } from "os";
|
|
6952
|
-
import { basename, join as join2 } from "path";
|
|
6953
|
-
async function modifyMessage(profile, messageId, addLabelIds, removeLabelIds) {
|
|
6954
|
-
return requestJson(profile, `/users/me/messages/${encodeURIComponent(messageId)}/modify`, {}, {
|
|
6955
|
-
method: "POST",
|
|
6956
|
-
body: {
|
|
6957
|
-
addLabelIds: addLabelIds ?? [],
|
|
6958
|
-
removeLabelIds: removeLabelIds ?? []
|
|
6959
|
-
}
|
|
6960
|
-
});
|
|
6961
|
-
}
|
|
6962
|
-
async function replyToMessage(profile, messageId, input) {
|
|
6963
|
-
const original = await requestJson(profile, `/users/me/messages/${encodeURIComponent(messageId)}`, { format: "full" });
|
|
6964
|
-
const headers = headersToObject(original.payload?.headers ?? []);
|
|
6965
|
-
const subject = normalizeReplySubject(headers.Subject ?? headers.subject ?? "");
|
|
6966
|
-
const to = headers.From ?? headers.from ?? "";
|
|
6967
|
-
const messageIdHeader = headers["Message-ID"] ?? headers["Message-Id"] ?? headers["message-id"] ?? "";
|
|
6968
|
-
const references = [headers.References ?? headers.references, messageIdHeader].filter(Boolean).join(" ");
|
|
6969
|
-
const raw = buildRawEmail({
|
|
6970
|
-
to,
|
|
6971
|
-
cc: normalizeStringArray(input.cc),
|
|
6972
|
-
bcc: normalizeStringArray(input.bcc),
|
|
6973
|
-
subject,
|
|
6974
|
-
body: input.body,
|
|
6975
|
-
isHtml: Boolean(input.html ?? input.isHtml),
|
|
6976
|
-
inReplyTo: messageIdHeader,
|
|
6977
|
-
references
|
|
6978
|
-
});
|
|
6979
|
-
return requestJson(profile, "/users/me/messages/send", {}, {
|
|
6980
|
-
method: "POST",
|
|
6981
|
-
body: {
|
|
6982
|
-
raw: Buffer.from(raw).toString("base64url"),
|
|
6983
|
-
threadId: original.threadId
|
|
6984
|
-
}
|
|
6985
|
-
});
|
|
6986
|
-
}
|
|
6987
|
-
async function downloadAttachments(profile, input) {
|
|
6988
|
-
const messageId = getMessageId(input);
|
|
6989
|
-
const outputDir = input.dir ?? input.outputDir ?? join2(configDirs()[0], "attachments", messageId);
|
|
6990
|
-
mkdirSync(outputDir, { recursive: true });
|
|
6991
|
-
const attachments = input.attachmentId && input.filename ? [{
|
|
6992
|
-
attachmentId: input.attachmentId,
|
|
6993
|
-
filename: input.filename,
|
|
6994
|
-
mimeType: input.mimeType ?? "application/octet-stream",
|
|
6995
|
-
size: 0
|
|
6996
|
-
}] : collectAttachments((await requestJson(profile, `/users/me/messages/${encodeURIComponent(messageId)}`, { format: "full" })).payload);
|
|
6997
|
-
const downloaded = [];
|
|
6998
|
-
for (const attachment of attachments) {
|
|
6999
|
-
const data = await requestJson(profile, `/users/me/messages/${encodeURIComponent(messageId)}/attachments/${encodeURIComponent(attachment.attachmentId)}`, {});
|
|
7000
|
-
const filename = safeFilename(attachment.filename);
|
|
7001
|
-
const path = join2(outputDir, filename);
|
|
7002
|
-
const buffer = Buffer.from(data.data, "base64url");
|
|
7003
|
-
writeFileSync(path, buffer);
|
|
7004
|
-
downloaded.push({
|
|
7005
|
-
filename,
|
|
7006
|
-
path,
|
|
7007
|
-
size: buffer.length,
|
|
7008
|
-
mimeType: attachment.mimeType
|
|
7009
|
-
});
|
|
7010
|
-
}
|
|
7011
|
-
return downloaded;
|
|
7012
|
-
}
|
|
7013
|
-
async function requestJson(profile, path, params, options = {}) {
|
|
7014
|
-
const token = await getValidAccessToken(profile);
|
|
7015
|
-
const url = new URL(`${GMAIL_API_BASE}${path}`);
|
|
7016
|
-
for (const [key, value] of Object.entries(params)) {
|
|
7017
|
-
if (value !== undefined && value !== null && value !== "")
|
|
7018
|
-
url.searchParams.append(key, String(value));
|
|
7019
|
-
}
|
|
7020
|
-
let lastError;
|
|
7021
|
-
for (let attempt = 0;attempt <= MAX_GMAIL_RETRIES; attempt++) {
|
|
7022
|
-
let response;
|
|
7023
|
-
try {
|
|
7024
|
-
response = await fetch(url, {
|
|
7025
|
-
method: options.method ?? "GET",
|
|
7026
|
-
headers: {
|
|
7027
|
-
Authorization: `Bearer ${token}`,
|
|
7028
|
-
Accept: "application/json",
|
|
7029
|
-
...options.body ? { "Content-Type": "application/json" } : {}
|
|
7030
|
-
},
|
|
7031
|
-
body: options.body ? JSON.stringify(options.body) : undefined
|
|
7032
|
-
});
|
|
7033
|
-
} catch (error2) {
|
|
7034
|
-
lastError = error2 instanceof Error ? error2.message : String(error2);
|
|
7035
|
-
if (attempt >= MAX_GMAIL_RETRIES)
|
|
7036
|
-
throw error2;
|
|
7037
|
-
await sleep(gmailBackoffDelayMs(attempt));
|
|
7038
|
-
continue;
|
|
7039
|
-
}
|
|
7040
|
-
const text = await response.text();
|
|
7041
|
-
const data = text ? JSON.parse(text) : {};
|
|
7042
|
-
if (response.ok)
|
|
7043
|
-
return data;
|
|
7044
|
-
const error = data;
|
|
7045
|
-
lastError = error.error?.message ?? response.statusText;
|
|
7046
|
-
if (!isRetryableGmailResponse(response.status, error) || attempt >= MAX_GMAIL_RETRIES) {
|
|
7047
|
-
throw new Error(`Gmail request failed (${response.status}): ${lastError}`);
|
|
7048
|
-
}
|
|
7049
|
-
await sleep(gmailBackoffDelayMs(attempt, response.headers.get("retry-after")));
|
|
7050
|
-
}
|
|
7051
|
-
throw new Error(`Gmail request failed: ${lastError ?? "unknown error"}`);
|
|
7052
|
-
}
|
|
7053
|
-
function isRetryableGmailResponse(status, error) {
|
|
7054
|
-
if ([429, 500, 502, 503, 504].includes(status))
|
|
7055
|
-
return true;
|
|
7056
|
-
const reasons = error.error?.errors?.map((entry) => entry.reason) ?? [];
|
|
7057
|
-
return reasons.some((reason) => reason === "rateLimitExceeded" || reason === "userRateLimitExceeded");
|
|
7058
|
-
}
|
|
7059
|
-
function gmailBackoffDelayMs(attempt, retryAfter = null) {
|
|
7060
|
-
if (retryAfter) {
|
|
7061
|
-
const seconds = Number(retryAfter);
|
|
7062
|
-
if (Number.isFinite(seconds) && seconds >= 0)
|
|
7063
|
-
return seconds * 1000;
|
|
7064
|
-
}
|
|
7065
|
-
const base = Number(process.env.CONNECTORS_GMAIL_RETRY_BASE_MS ?? "1000");
|
|
7066
|
-
const baseMs = Number.isFinite(base) && base >= 0 ? base : 1000;
|
|
7067
|
-
const jitterMs = Math.floor(Math.random() * 1000);
|
|
7068
|
-
return Math.min(2 ** attempt * baseMs + jitterMs, 64000);
|
|
7069
|
-
}
|
|
7070
|
-
function sleep(ms) {
|
|
7071
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
7072
|
-
}
|
|
7073
|
-
async function getValidAccessToken(profile) {
|
|
7074
|
-
if (process.env.GMAIL_ACCESS_TOKEN)
|
|
7075
|
-
return process.env.GMAIL_ACCESS_TOKEN;
|
|
7076
|
-
const tokens = loadTokens(profile);
|
|
7077
|
-
if (!tokens?.accessToken && !tokens?.refreshToken) {
|
|
7078
|
-
throw new Error(`Gmail profile "${profile}" is not authenticated. Run: connectors auth gmail`);
|
|
7079
|
-
}
|
|
7080
|
-
if (tokens.accessToken && (!tokens.expiresAt || Date.now() < tokens.expiresAt - REFRESH_BUFFER_MS))
|
|
7081
|
-
return tokens.accessToken;
|
|
7082
|
-
if (!tokens.refreshToken)
|
|
7083
|
-
return tokens.accessToken ?? "";
|
|
7084
|
-
return (await refreshAccessToken(profile, tokens)).accessToken ?? "";
|
|
7085
|
-
}
|
|
7086
|
-
async function refreshAccessToken(profile, currentTokens) {
|
|
7087
|
-
const credentials = loadCredentials(profile);
|
|
7088
|
-
if (!credentials.clientId || !credentials.clientSecret)
|
|
7089
|
-
throw new Error("Gmail OAuth credentials are not configured. Run: connectors auth gmail");
|
|
7090
|
-
if (!currentTokens.refreshToken)
|
|
7091
|
-
throw new Error(`Gmail profile "${profile}" has no refresh token. Run: connectors auth gmail`);
|
|
7092
|
-
const response = await fetch(TOKEN_URL, {
|
|
7093
|
-
method: "POST",
|
|
7094
|
-
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
7095
|
-
body: new URLSearchParams({
|
|
7096
|
-
client_id: credentials.clientId,
|
|
7097
|
-
client_secret: credentials.clientSecret,
|
|
7098
|
-
refresh_token: currentTokens.refreshToken,
|
|
7099
|
-
grant_type: "refresh_token"
|
|
7100
|
-
})
|
|
7101
|
-
});
|
|
7102
|
-
const data = await response.json().catch(() => ({}));
|
|
7103
|
-
if (!response.ok || !data.access_token)
|
|
7104
|
-
throw new Error(`Gmail token refresh failed: ${data.error_description || data.error || response.statusText}`);
|
|
7105
|
-
const tokens = {
|
|
7106
|
-
accessToken: data.access_token,
|
|
7107
|
-
refreshToken: currentTokens.refreshToken,
|
|
7108
|
-
expiresAt: Date.now() + (data.expires_in ?? 3600) * 1000,
|
|
7109
|
-
tokenType: data.token_type ?? currentTokens.tokenType,
|
|
7110
|
-
scope: data.scope ?? currentTokens.scope
|
|
7111
|
-
};
|
|
7112
|
-
saveTokens(profile, tokens);
|
|
7113
|
-
return tokens;
|
|
7114
|
-
}
|
|
7115
|
-
function listProfiles() {
|
|
7116
|
-
const profiles = new Set;
|
|
7117
|
-
for (const baseDir of configDirs()) {
|
|
7118
|
-
const profilesDir = join2(baseDir, "profiles");
|
|
7119
|
-
if (!existsSync2(profilesDir))
|
|
7120
|
-
continue;
|
|
7121
|
-
for (const entry of readdirSync(profilesDir, { withFileTypes: true })) {
|
|
7122
|
-
if (entry.isDirectory())
|
|
7123
|
-
profiles.add(entry.name);
|
|
7124
|
-
if (entry.isFile() && entry.name.endsWith(".json"))
|
|
7125
|
-
profiles.add(basename(entry.name, ".json"));
|
|
7126
|
-
}
|
|
7127
|
-
}
|
|
7128
|
-
return Array.from(profiles).sort((a, b) => a.localeCompare(b));
|
|
7129
|
-
}
|
|
7130
|
-
function loadCredentials(profile) {
|
|
7131
|
-
const envClientId = process.env.GMAIL_CLIENT_ID ?? process.env.GOOGLE_CLIENT_ID;
|
|
7132
|
-
const envClientSecret = process.env.GMAIL_CLIENT_SECRET ?? process.env.GOOGLE_CLIENT_SECRET;
|
|
7133
|
-
if (envClientId && envClientSecret)
|
|
7134
|
-
return { clientId: envClientId, clientSecret: envClientSecret };
|
|
7135
|
-
for (const baseDir of configDirs()) {
|
|
7136
|
-
const credentials = {
|
|
7137
|
-
...readJson(join2(baseDir, "credentials.json")),
|
|
7138
|
-
...readJson(join2(baseDir, "profiles", profile, "config.json"))
|
|
7139
|
-
};
|
|
7140
|
-
if (credentials.clientId || credentials.clientSecret)
|
|
7141
|
-
return credentials;
|
|
7142
|
-
}
|
|
7143
|
-
return {};
|
|
7144
|
-
}
|
|
7145
|
-
function loadTokens(profile) {
|
|
7146
|
-
for (const baseDir of configDirs()) {
|
|
7147
|
-
const fromProfile = readJson(join2(baseDir, "profiles", profile, "tokens.json"));
|
|
7148
|
-
if (fromProfile)
|
|
7149
|
-
return fromProfile;
|
|
7150
|
-
const flat = readJson(join2(baseDir, "profiles", `${profile}.json`));
|
|
7151
|
-
if (flat)
|
|
7152
|
-
return flat.tokens ?? (flat.accessToken || flat.refreshToken ? flat : null);
|
|
7153
|
-
}
|
|
7154
|
-
return null;
|
|
7155
|
-
}
|
|
7156
|
-
function saveTokens(profile, tokens) {
|
|
7157
|
-
const baseDir = configDirs().find((dir) => existsSync2(dir)) ?? configDirs()[0];
|
|
7158
|
-
const profileDir = join2(baseDir, "profiles", profile);
|
|
7159
|
-
mkdirSync(profileDir, { recursive: true });
|
|
7160
|
-
writeFileSync(join2(profileDir, "tokens.json"), JSON.stringify(tokens, null, 2), { mode: 384 });
|
|
7161
|
-
}
|
|
7162
|
-
function configDirs() {
|
|
7163
|
-
const explicit = process.env.HASNA_GMAIL_CONNECTOR_DIR ?? process.env.GMAIL_CONNECTOR_DIR;
|
|
7164
|
-
if (explicit)
|
|
7165
|
-
return [explicit];
|
|
7166
|
-
const baseDir = process.env.HASNA_CONNECTORS_DIR ?? join2(homedir(), ".hasna", "connectors");
|
|
7167
|
-
return [join2(baseDir, "gmail"), join2(baseDir, "connect-gmail")];
|
|
7168
|
-
}
|
|
7169
|
-
function readJson(path) {
|
|
7170
|
-
if (!existsSync2(path))
|
|
7171
|
-
return null;
|
|
7172
|
-
try {
|
|
7173
|
-
return JSON.parse(readFileSync(path, "utf8"));
|
|
7174
|
-
} catch {
|
|
7175
|
-
return null;
|
|
7176
|
-
}
|
|
7177
|
-
}
|
|
7178
|
-
function getMessageId(input) {
|
|
7179
|
-
const id = input.messageId ?? (input.args?.[0] != null ? String(input.args[0]) : undefined);
|
|
7180
|
-
if (!id)
|
|
7181
|
-
throw new Error("Gmail messageId is required");
|
|
7182
|
-
return id;
|
|
7183
|
-
}
|
|
7184
|
-
function headersToObject(headers) {
|
|
7185
|
-
const out = {};
|
|
7186
|
-
for (const header of headers)
|
|
7187
|
-
out[header.name] = header.value;
|
|
7188
|
-
return out;
|
|
7189
|
-
}
|
|
7190
|
-
function extractBody(message, preferHtml = false) {
|
|
7191
|
-
if (!message.payload)
|
|
7192
|
-
return "";
|
|
7193
|
-
const targetType = preferHtml ? "text/html" : "text/plain";
|
|
7194
|
-
const parts = [];
|
|
7195
|
-
collectTextParts(message.payload, parts);
|
|
7196
|
-
return parts.find((part) => part.mimeType === targetType)?.data ?? parts.find((part) => part.mimeType.startsWith("text/"))?.data ?? "";
|
|
7197
|
-
}
|
|
7198
|
-
function collectTextParts(part, results) {
|
|
7199
|
-
const mimeType = (part.mimeType ?? "").split(";")[0].trim().toLowerCase();
|
|
7200
|
-
if (part.body?.data && mimeType.startsWith("text/")) {
|
|
7201
|
-
results.push({ mimeType, data: Buffer.from(part.body.data, "base64url").toString("utf8") });
|
|
7202
|
-
}
|
|
7203
|
-
for (const child of part.parts ?? [])
|
|
7204
|
-
collectTextParts(child, results);
|
|
7205
|
-
}
|
|
7206
|
-
function collectAttachments(part, attachments = []) {
|
|
7207
|
-
if (!part)
|
|
7208
|
-
return attachments;
|
|
7209
|
-
if (part.body?.attachmentId && part.filename) {
|
|
7210
|
-
attachments.push({
|
|
7211
|
-
attachmentId: part.body.attachmentId,
|
|
7212
|
-
filename: part.filename,
|
|
7213
|
-
mimeType: part.mimeType ?? "application/octet-stream",
|
|
7214
|
-
size: part.body.size ?? 0,
|
|
7215
|
-
partId: part.partId
|
|
7216
|
-
});
|
|
7217
|
-
}
|
|
7218
|
-
for (const child of part.parts ?? [])
|
|
7219
|
-
collectAttachments(child, attachments);
|
|
7220
|
-
return attachments;
|
|
7221
|
-
}
|
|
7222
|
-
function normalizeStringArray(value) {
|
|
7223
|
-
if (!value)
|
|
7224
|
-
return [];
|
|
7225
|
-
return Array.isArray(value) ? value : value.split(",").map((item) => item.trim()).filter(Boolean);
|
|
7226
|
-
}
|
|
7227
|
-
function normalizeReplySubject(subject) {
|
|
7228
|
-
return subject.toLowerCase().startsWith("re:") ? subject : `Re: ${subject}`;
|
|
7229
|
-
}
|
|
7230
|
-
function buildRawEmail(input) {
|
|
7231
|
-
const headers = [
|
|
7232
|
-
`To: ${input.to}`,
|
|
7233
|
-
input.cc.length ? `Cc: ${input.cc.join(", ")}` : "",
|
|
7234
|
-
input.bcc.length ? `Bcc: ${input.bcc.join(", ")}` : "",
|
|
7235
|
-
`Subject: ${input.subject}`,
|
|
7236
|
-
input.inReplyTo ? `In-Reply-To: ${input.inReplyTo}` : "",
|
|
7237
|
-
input.references ? `References: ${input.references}` : "",
|
|
7238
|
-
"MIME-Version: 1.0",
|
|
7239
|
-
`Content-Type: ${input.isHtml ? "text/html" : "text/plain"}; charset=UTF-8`
|
|
7240
|
-
].filter(Boolean);
|
|
7241
|
-
return `${headers.join(`\r
|
|
7242
|
-
`)}\r
|
|
7243
|
-
\r
|
|
7244
|
-
${input.body}`;
|
|
7245
|
-
}
|
|
7246
|
-
function safeFilename(filename) {
|
|
7247
|
-
return basename(filename.replace(/[\u00A0\u2000-\u200B\u202F\u205F\u3000]/g, " ")).replace(/[\/\\]/g, "_");
|
|
7248
|
-
}
|
|
7249
|
-
var GMAIL_API_BASE = "https://gmail.googleapis.com/gmail/v1", TOKEN_URL = "https://oauth2.googleapis.com/token", REFRESH_BUFFER_MS, MAX_GMAIL_RETRIES = 5, listMessagesSchema, messageIdSchema, readMessageSchema, attachmentListSchema, attachmentDownloadSchema, historyListSchema, replySchema, gmailConnector;
|
|
7250
|
-
var init_gmail = __esm(() => {
|
|
7251
|
-
init_zod();
|
|
7252
|
-
init_connector();
|
|
7253
|
-
REFRESH_BUFFER_MS = 5 * 60 * 1000;
|
|
7254
|
-
listMessagesSchema = exports_external.object({
|
|
7255
|
-
max: exports_external.coerce.number().int().positive().max(500).optional(),
|
|
7256
|
-
maxResults: exports_external.coerce.number().int().positive().max(500).optional(),
|
|
7257
|
-
pageToken: exports_external.string().optional(),
|
|
7258
|
-
query: exports_external.string().optional(),
|
|
7259
|
-
q: exports_external.string().optional(),
|
|
7260
|
-
label: exports_external.string().optional(),
|
|
7261
|
-
labelIds: exports_external.union([exports_external.string(), exports_external.array(exports_external.string())]).optional(),
|
|
7262
|
-
includeSpamTrash: exports_external.boolean().optional()
|
|
7263
|
-
});
|
|
7264
|
-
messageIdSchema = exports_external.object({
|
|
7265
|
-
args: exports_external.array(exports_external.union([exports_external.string(), exports_external.number(), exports_external.boolean()])).optional(),
|
|
7266
|
-
messageId: exports_external.string().optional()
|
|
7267
|
-
});
|
|
7268
|
-
readMessageSchema = messageIdSchema.extend({
|
|
7269
|
-
body: exports_external.boolean().optional(),
|
|
7270
|
-
html: exports_external.boolean().optional(),
|
|
7271
|
-
format: exports_external.enum(["full", "metadata", "minimal", "raw"]).optional()
|
|
7272
|
-
});
|
|
7273
|
-
attachmentListSchema = messageIdSchema;
|
|
7274
|
-
attachmentDownloadSchema = messageIdSchema.extend({
|
|
7275
|
-
attachmentId: exports_external.string().optional(),
|
|
7276
|
-
filename: exports_external.string().optional(),
|
|
7277
|
-
mimeType: exports_external.string().optional(),
|
|
7278
|
-
dir: exports_external.string().optional(),
|
|
7279
|
-
outputDir: exports_external.string().optional()
|
|
7280
|
-
});
|
|
7281
|
-
historyListSchema = exports_external.object({
|
|
7282
|
-
startHistoryId: exports_external.string(),
|
|
7283
|
-
historyTypes: exports_external.union([exports_external.string(), exports_external.array(exports_external.string())]).optional(),
|
|
7284
|
-
labelId: exports_external.string().optional(),
|
|
7285
|
-
maxResults: exports_external.coerce.number().int().positive().max(500).optional(),
|
|
7286
|
-
pageToken: exports_external.string().optional()
|
|
7287
|
-
});
|
|
7288
|
-
replySchema = messageIdSchema.extend({
|
|
7289
|
-
body: exports_external.string(),
|
|
7290
|
-
html: exports_external.boolean().optional(),
|
|
7291
|
-
isHtml: exports_external.boolean().optional(),
|
|
7292
|
-
cc: exports_external.union([exports_external.string(), exports_external.array(exports_external.string())]).optional(),
|
|
7293
|
-
bcc: exports_external.union([exports_external.string(), exports_external.array(exports_external.string())]).optional()
|
|
7294
|
-
});
|
|
7295
|
-
gmailConnector = defineConnector({
|
|
7296
|
-
meta: {
|
|
7297
|
-
name: "gmail",
|
|
7298
|
-
displayName: "Gmail",
|
|
7299
|
-
description: "Profile-aware Gmail mailbox operations for sync, labels, attachments, history, and replies.",
|
|
7300
|
-
category: "communication",
|
|
7301
|
-
tags: ["google", "gmail", "email", "mailbox"]
|
|
7302
|
-
},
|
|
7303
|
-
auth: {
|
|
7304
|
-
type: "oauth2",
|
|
7305
|
-
supportsProfiles: true,
|
|
7306
|
-
fields: [
|
|
7307
|
-
{ key: "clientId", env: "GMAIL_CLIENT_ID", label: "OAuth client ID" },
|
|
7308
|
-
{ key: "clientSecret", env: "GMAIL_CLIENT_SECRET", label: "OAuth client secret", secret: true }
|
|
7309
|
-
]
|
|
7310
|
-
},
|
|
7311
|
-
createContext: ({ profile }) => ({ profile: profile || "default" }),
|
|
7312
|
-
operations: {
|
|
7313
|
-
"profiles.list": {
|
|
7314
|
-
summary: "List configured Gmail profiles.",
|
|
7315
|
-
execute: () => ({ profiles: listProfiles() })
|
|
7316
|
-
},
|
|
7317
|
-
"profile.get": {
|
|
7318
|
-
summary: "Get the authenticated Gmail profile.",
|
|
7319
|
-
execute: async ({ context }) => requestJson(context.profile, "/users/me/profile", {})
|
|
7320
|
-
},
|
|
7321
|
-
"messages.list": {
|
|
7322
|
-
summary: "List Gmail messages.",
|
|
7323
|
-
inputSchema: listMessagesSchema,
|
|
7324
|
-
execute: async ({ context }, input) => {
|
|
7325
|
-
const labelIds = normalizeStringArray(input.labelIds ?? input.label);
|
|
7326
|
-
return requestJson(context.profile, "/users/me/messages", {
|
|
7327
|
-
maxResults: input.maxResults ?? input.max ?? 50,
|
|
7328
|
-
pageToken: input.pageToken,
|
|
7329
|
-
q: input.q ?? input.query,
|
|
7330
|
-
labelIds: labelIds.length > 0 ? labelIds.join(",") : undefined,
|
|
7331
|
-
includeSpamTrash: input.includeSpamTrash
|
|
7332
|
-
});
|
|
7333
|
-
}
|
|
7334
|
-
},
|
|
7335
|
-
"messages.read": {
|
|
7336
|
-
summary: "Read a Gmail message with optional extracted body.",
|
|
7337
|
-
inputSchema: readMessageSchema,
|
|
7338
|
-
execute: async ({ context }, input) => {
|
|
7339
|
-
const messageId = getMessageId(input);
|
|
7340
|
-
const message = await requestJson(context.profile, `/users/me/messages/${encodeURIComponent(messageId)}`, { format: input.format ?? "full" });
|
|
7341
|
-
const headers = headersToObject(message.payload?.headers ?? []);
|
|
7342
|
-
return {
|
|
7343
|
-
...message,
|
|
7344
|
-
from: headers.From ?? headers.from ?? "",
|
|
7345
|
-
to: headers.To ?? headers.to ?? "",
|
|
7346
|
-
cc: headers.Cc ?? headers.cc ?? "",
|
|
7347
|
-
subject: headers.Subject ?? headers.subject ?? "",
|
|
7348
|
-
date: headers.Date ?? headers.date ?? "",
|
|
7349
|
-
body: input.body ? extractBody(message, Boolean(input.html)) : undefined,
|
|
7350
|
-
size: message.sizeEstimate
|
|
7351
|
-
};
|
|
7352
|
-
}
|
|
7353
|
-
},
|
|
7354
|
-
"messages.getRaw": {
|
|
7355
|
-
summary: "Read raw base64url Gmail message content.",
|
|
7356
|
-
inputSchema: messageIdSchema,
|
|
7357
|
-
execute: async ({ context }, input) => {
|
|
7358
|
-
const messageId = getMessageId(input);
|
|
7359
|
-
return requestJson(context.profile, `/users/me/messages/${encodeURIComponent(messageId)}`, { format: "raw" });
|
|
7360
|
-
}
|
|
7361
|
-
},
|
|
7362
|
-
"messages.mark-read": {
|
|
7363
|
-
summary: "Mark a message as read.",
|
|
7364
|
-
inputSchema: messageIdSchema,
|
|
7365
|
-
execute: async ({ context }, input) => modifyMessage(context.profile, getMessageId(input), undefined, ["UNREAD"])
|
|
7366
|
-
},
|
|
7367
|
-
"messages.mark-unread": {
|
|
7368
|
-
summary: "Mark a message as unread.",
|
|
7369
|
-
inputSchema: messageIdSchema,
|
|
7370
|
-
execute: async ({ context }, input) => modifyMessage(context.profile, getMessageId(input), ["UNREAD"], undefined)
|
|
7371
|
-
},
|
|
7372
|
-
"messages.archive": {
|
|
7373
|
-
summary: "Archive a message by removing the INBOX label.",
|
|
7374
|
-
inputSchema: messageIdSchema,
|
|
7375
|
-
execute: async ({ context }, input) => modifyMessage(context.profile, getMessageId(input), undefined, ["INBOX"])
|
|
7376
|
-
},
|
|
7377
|
-
"messages.star": {
|
|
7378
|
-
summary: "Star a message.",
|
|
7379
|
-
inputSchema: messageIdSchema,
|
|
7380
|
-
execute: async ({ context }, input) => modifyMessage(context.profile, getMessageId(input), ["STARRED"], undefined)
|
|
7381
|
-
},
|
|
7382
|
-
"messages.reply": {
|
|
7383
|
-
summary: "Reply to a Gmail message in the same thread.",
|
|
7384
|
-
inputSchema: replySchema,
|
|
7385
|
-
execute: async ({ context }, input) => replyToMessage(context.profile, getMessageId(input), input)
|
|
7386
|
-
},
|
|
7387
|
-
"attachments.list": {
|
|
7388
|
-
summary: "List Gmail message attachments.",
|
|
7389
|
-
inputSchema: attachmentListSchema,
|
|
7390
|
-
execute: async ({ context }, input) => {
|
|
7391
|
-
const message = await requestJson(context.profile, `/users/me/messages/${encodeURIComponent(getMessageId(input))}`, { format: "full" });
|
|
7392
|
-
return collectAttachments(message.payload);
|
|
7393
|
-
}
|
|
7394
|
-
},
|
|
7395
|
-
"attachments.download": {
|
|
7396
|
-
summary: "Download one or all Gmail message attachments to disk.",
|
|
7397
|
-
inputSchema: attachmentDownloadSchema,
|
|
7398
|
-
execute: async ({ context }, input) => downloadAttachments(context.profile, input)
|
|
7399
|
-
},
|
|
7400
|
-
"labels.list": {
|
|
7401
|
-
summary: "List Gmail labels.",
|
|
7402
|
-
execute: async ({ context }) => requestJson(context.profile, "/users/me/labels", {})
|
|
7403
|
-
},
|
|
7404
|
-
"history.list": {
|
|
7405
|
-
summary: "List Gmail mailbox history from a history id.",
|
|
7406
|
-
inputSchema: historyListSchema,
|
|
7407
|
-
execute: async ({ context }, input) => requestJson(context.profile, "/users/me/history", {
|
|
7408
|
-
startHistoryId: input.startHistoryId,
|
|
7409
|
-
historyTypes: normalizeStringArray(input.historyTypes).join(",") || undefined,
|
|
7410
|
-
labelId: input.labelId,
|
|
7411
|
-
maxResults: input.maxResults,
|
|
7412
|
-
pageToken: input.pageToken
|
|
7413
|
-
})
|
|
7414
|
-
}
|
|
7415
|
-
}
|
|
7416
|
-
});
|
|
7417
|
-
});
|
|
7418
|
-
|
|
7419
|
-
// src/core/connectors/googledrive.ts
|
|
7420
|
-
import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync2, readdirSync as readdirSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
7421
|
-
import { homedir as homedir2 } from "os";
|
|
7422
|
-
import { basename as basename2, join as join3 } from "path";
|
|
7423
|
-
async function requestJson2(profile, path, params) {
|
|
7424
|
-
const response = await request(profile, path, params);
|
|
7425
|
-
const text = await response.text();
|
|
7426
|
-
return text ? JSON.parse(text) : {};
|
|
7427
|
-
}
|
|
7428
|
-
async function requestBinary(profile, path, params) {
|
|
7429
|
-
return (await request(profile, path, params)).arrayBuffer();
|
|
7430
|
-
}
|
|
7431
|
-
async function request(profile, path, params) {
|
|
7432
|
-
const token = await getValidAccessToken2(profile);
|
|
7433
|
-
const url = new URL(`${DRIVE_API_BASE}${path}`);
|
|
7434
|
-
for (const [key, value] of Object.entries(params)) {
|
|
7435
|
-
if (value !== undefined && value !== null && value !== "")
|
|
7436
|
-
url.searchParams.set(key, String(value));
|
|
7437
|
-
}
|
|
7438
|
-
const response = await fetch(url, { headers: { Authorization: `Bearer ${token}`, Accept: "application/json" } });
|
|
7439
|
-
if (!response.ok) {
|
|
7440
|
-
const body = await response.text().catch(() => "");
|
|
7441
|
-
throw new Error(`Google Drive request failed (${response.status}): ${extractGoogleError(body) || response.statusText}`);
|
|
7442
|
-
}
|
|
7443
|
-
return response;
|
|
7444
|
-
}
|
|
7445
|
-
async function getValidAccessToken2(profile) {
|
|
7446
|
-
if (process.env.GOOGLE_ACCESS_TOKEN)
|
|
7447
|
-
return process.env.GOOGLE_ACCESS_TOKEN;
|
|
7448
|
-
const tokens = loadTokens2(profile);
|
|
7449
|
-
if (!tokens?.accessToken && !tokens?.refreshToken) {
|
|
7450
|
-
throw new Error(`Google Drive profile "${profile}" is not authenticated. Run: connectors auth googledrive`);
|
|
7451
|
-
}
|
|
7452
|
-
if (tokens.accessToken && (!tokens.expiresAt || Date.now() < tokens.expiresAt - REFRESH_BUFFER_MS2))
|
|
7453
|
-
return tokens.accessToken;
|
|
7454
|
-
if (!tokens.refreshToken)
|
|
7455
|
-
return tokens.accessToken ?? "";
|
|
7456
|
-
return (await refreshAccessToken2(profile, tokens)).accessToken ?? "";
|
|
7457
|
-
}
|
|
7458
|
-
async function refreshAccessToken2(profile, currentTokens) {
|
|
7459
|
-
const credentials = loadCredentials2(profile);
|
|
7460
|
-
if (!credentials.clientId || !credentials.clientSecret)
|
|
7461
|
-
throw new Error("Google Drive OAuth credentials are not configured. Run: connectors auth googledrive");
|
|
7462
|
-
if (!currentTokens.refreshToken)
|
|
7463
|
-
throw new Error(`Google Drive profile "${profile}" has no refresh token. Run: connectors auth googledrive`);
|
|
7464
|
-
const response = await fetch(TOKEN_URL2, {
|
|
7465
|
-
method: "POST",
|
|
7466
|
-
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
7467
|
-
body: new URLSearchParams({
|
|
7468
|
-
client_id: credentials.clientId,
|
|
7469
|
-
client_secret: credentials.clientSecret,
|
|
7470
|
-
refresh_token: currentTokens.refreshToken,
|
|
7471
|
-
grant_type: "refresh_token"
|
|
7472
|
-
})
|
|
7473
|
-
});
|
|
7474
|
-
const data = await response.json().catch(() => ({}));
|
|
7475
|
-
if (!response.ok || !data.access_token)
|
|
7476
|
-
throw new Error(`Google Drive token refresh failed: ${data.error_description || data.error || response.statusText}`);
|
|
7477
|
-
const tokens = {
|
|
7478
|
-
accessToken: data.access_token,
|
|
7479
|
-
refreshToken: currentTokens.refreshToken,
|
|
7480
|
-
expiresAt: Date.now() + (data.expires_in ?? 3600) * 1000,
|
|
7481
|
-
tokenType: data.token_type ?? currentTokens.tokenType,
|
|
7482
|
-
scope: data.scope ?? currentTokens.scope
|
|
7483
|
-
};
|
|
7484
|
-
saveTokens2(profile, tokens);
|
|
7485
|
-
return tokens;
|
|
7486
|
-
}
|
|
7487
|
-
function listProfiles2() {
|
|
7488
|
-
const profiles = new Set;
|
|
7489
|
-
for (const baseDir of configDirs2()) {
|
|
7490
|
-
const profilesDir = join3(baseDir, "profiles");
|
|
7491
|
-
if (!existsSync3(profilesDir))
|
|
7492
|
-
continue;
|
|
7493
|
-
for (const entry of readdirSync2(profilesDir, { withFileTypes: true })) {
|
|
7494
|
-
if (entry.isDirectory())
|
|
7495
|
-
profiles.add(entry.name);
|
|
7496
|
-
if (entry.isFile() && entry.name.endsWith(".json"))
|
|
7497
|
-
profiles.add(basename2(entry.name, ".json"));
|
|
7498
|
-
}
|
|
7499
|
-
}
|
|
7500
|
-
return Array.from(profiles).sort((a, b) => a.localeCompare(b));
|
|
7501
|
-
}
|
|
7502
|
-
function listProfileStatuses(profile) {
|
|
7503
|
-
const profiles = profile ? [profile] : listProfiles2();
|
|
7504
|
-
const uniqueProfiles = profiles.length ? profiles : ["default"];
|
|
7505
|
-
const now = Date.now();
|
|
7506
|
-
return uniqueProfiles.map((name) => {
|
|
7507
|
-
const tokens = loadTokens2(name);
|
|
7508
|
-
const credentials = loadCredentials2(name);
|
|
7509
|
-
const hasAccessToken = Boolean(tokens?.accessToken || process.env.GOOGLE_ACCESS_TOKEN);
|
|
7510
|
-
const hasRefreshToken = Boolean(tokens?.refreshToken);
|
|
7511
|
-
const hasOAuthCredentials = Boolean(credentials.clientId && credentials.clientSecret);
|
|
7512
|
-
const expiresAt = tokens?.expiresAt ?? null;
|
|
7513
|
-
const expired = Boolean(expiresAt && now >= expiresAt - REFRESH_BUFFER_MS2);
|
|
7514
|
-
const authenticated = Boolean(process.env.GOOGLE_ACCESS_TOKEN || hasRefreshToken || hasAccessToken && !expired);
|
|
7515
|
-
const configured = authenticated || hasOAuthCredentials;
|
|
7516
|
-
const authRequired = !authenticated || expired && !hasRefreshToken;
|
|
7517
|
-
return {
|
|
7518
|
-
profile: name,
|
|
7519
|
-
configured,
|
|
7520
|
-
authenticated,
|
|
7521
|
-
expired,
|
|
7522
|
-
expiresAt,
|
|
7523
|
-
hasAccessToken,
|
|
7524
|
-
hasRefreshToken,
|
|
7525
|
-
hasOAuthCredentials,
|
|
7526
|
-
authRequired,
|
|
7527
|
-
message: authRequired ? `Google Drive profile "${name}" needs authentication. Run: connectors auth googledrive` : expired ? `Google Drive profile "${name}" access token is expired but can refresh.` : `Google Drive profile "${name}" is authenticated.`
|
|
7528
|
-
};
|
|
7529
|
-
});
|
|
7530
|
-
}
|
|
7531
|
-
function loadCredentials2(profile) {
|
|
7532
|
-
const envClientId = process.env.GOOGLE_CLIENT_ID;
|
|
7533
|
-
const envClientSecret = process.env.GOOGLE_CLIENT_SECRET;
|
|
7534
|
-
if (envClientId && envClientSecret)
|
|
7535
|
-
return { clientId: envClientId, clientSecret: envClientSecret };
|
|
7536
|
-
for (const baseDir of configDirs2()) {
|
|
7537
|
-
const credentials = {
|
|
7538
|
-
...readJson2(join3(baseDir, "credentials.json")),
|
|
7539
|
-
...readJson2(join3(baseDir, "profiles", profile, "config.json"))
|
|
7540
|
-
};
|
|
7541
|
-
if (credentials.clientId || credentials.clientSecret)
|
|
7542
|
-
return credentials;
|
|
7543
|
-
}
|
|
7544
|
-
return {};
|
|
7545
|
-
}
|
|
7546
|
-
function loadTokens2(profile) {
|
|
7547
|
-
for (const baseDir of configDirs2()) {
|
|
7548
|
-
const fromProfile = readJson2(join3(baseDir, "profiles", profile, "tokens.json"));
|
|
7549
|
-
if (fromProfile)
|
|
7550
|
-
return fromProfile;
|
|
7551
|
-
const flat = readJson2(join3(baseDir, "profiles", `${profile}.json`));
|
|
7552
|
-
if (flat)
|
|
7553
|
-
return flat.tokens ?? (flat.accessToken || flat.refreshToken ? flat : null);
|
|
7554
|
-
}
|
|
7555
|
-
return null;
|
|
7556
|
-
}
|
|
7557
|
-
function saveTokens2(profile, tokens) {
|
|
7558
|
-
const baseDir = configDirs2().find((dir) => existsSync3(dir)) ?? configDirs2()[0];
|
|
7559
|
-
const profileDir = join3(baseDir, "profiles", profile);
|
|
7560
|
-
mkdirSync2(profileDir, { recursive: true });
|
|
7561
|
-
writeFileSync2(join3(profileDir, "tokens.json"), JSON.stringify(tokens, null, 2), { mode: 384 });
|
|
7562
|
-
}
|
|
7563
|
-
function configDirs2() {
|
|
7564
|
-
const explicit = process.env.HASNA_GOOGLE_DRIVE_CONNECTOR_DIR ?? process.env.GOOGLE_DRIVE_CONNECTOR_DIR;
|
|
7565
|
-
if (explicit)
|
|
7566
|
-
return [explicit];
|
|
7567
|
-
const baseDir = process.env.HASNA_CONNECTORS_DIR ?? join3(homedir2(), ".hasna", "connectors");
|
|
7568
|
-
return [join3(baseDir, "googledrive"), join3(baseDir, "connect-googledrive")];
|
|
7569
|
-
}
|
|
7570
|
-
function readJson2(path) {
|
|
7571
|
-
if (!existsSync3(path))
|
|
7572
|
-
return null;
|
|
7573
|
-
try {
|
|
7574
|
-
return JSON.parse(readFileSync2(path, "utf8"));
|
|
7575
|
-
} catch {
|
|
7576
|
-
return null;
|
|
7577
|
-
}
|
|
7578
|
-
}
|
|
7579
|
-
function defaultExportMimeType(googleMimeType) {
|
|
7580
|
-
if (googleMimeType.endsWith(".document"))
|
|
7581
|
-
return DEFAULT_EXPORT_FORMATS.document;
|
|
7582
|
-
if (googleMimeType.endsWith(".spreadsheet"))
|
|
7583
|
-
return DEFAULT_EXPORT_FORMATS.spreadsheet;
|
|
7584
|
-
if (googleMimeType.endsWith(".presentation"))
|
|
7585
|
-
return DEFAULT_EXPORT_FORMATS.presentation;
|
|
7586
|
-
if (googleMimeType.endsWith(".drawing"))
|
|
7587
|
-
return DEFAULT_EXPORT_FORMATS.drawing;
|
|
7588
|
-
throw new Error(`Cannot export Google Workspace file type: ${googleMimeType}`);
|
|
7589
|
-
}
|
|
7590
|
-
function extensionForMimeType(mimeType) {
|
|
7591
|
-
return EXPORT_EXTENSIONS[mimeType] ?? "";
|
|
7592
|
-
}
|
|
7593
|
-
function extractGoogleError(body) {
|
|
7594
|
-
if (!body)
|
|
7595
|
-
return "";
|
|
7596
|
-
try {
|
|
7597
|
-
const parsed = JSON.parse(body);
|
|
7598
|
-
return parsed.error?.message ?? body;
|
|
7599
|
-
} catch {
|
|
7600
|
-
return body;
|
|
7601
|
-
}
|
|
7602
|
-
}
|
|
7603
|
-
var DRIVE_API_BASE = "https://www.googleapis.com/drive/v3", TOKEN_URL2 = "https://oauth2.googleapis.com/token", REFRESH_BUFFER_MS2, DEFAULT_FILE_FIELDS, DEFAULT_EXPORT_FORMATS, EXPORT_EXTENSIONS, listFilesSchema, listDrivesSchema, fileIdSchema, downloadSchema, profilesStatusSchema, googleDriveConnector;
|
|
7604
|
-
var init_googledrive = __esm(() => {
|
|
7605
|
-
init_zod();
|
|
7606
|
-
init_connector();
|
|
7607
|
-
REFRESH_BUFFER_MS2 = 5 * 60 * 1000;
|
|
7608
|
-
DEFAULT_FILE_FIELDS = [
|
|
7609
|
-
"id",
|
|
7610
|
-
"name",
|
|
7611
|
-
"mimeType",
|
|
7612
|
-
"parents",
|
|
7613
|
-
"version",
|
|
7614
|
-
"md5Checksum",
|
|
7615
|
-
"size",
|
|
7616
|
-
"modifiedTime",
|
|
7617
|
-
"createdTime",
|
|
7618
|
-
"trashed",
|
|
7619
|
-
"webViewLink",
|
|
7620
|
-
"webContentLink"
|
|
7621
|
-
].join(",");
|
|
7622
|
-
DEFAULT_EXPORT_FORMATS = {
|
|
7623
|
-
document: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
7624
|
-
spreadsheet: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
7625
|
-
presentation: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
7626
|
-
drawing: "image/png"
|
|
7627
|
-
};
|
|
7628
|
-
EXPORT_EXTENSIONS = {
|
|
7629
|
-
"application/vnd.openxmlformats-officedocument.wordprocessingml.document": ".docx",
|
|
7630
|
-
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": ".xlsx",
|
|
7631
|
-
"application/vnd.openxmlformats-officedocument.presentationml.presentation": ".pptx",
|
|
7632
|
-
"application/pdf": ".pdf",
|
|
7633
|
-
"text/plain": ".txt",
|
|
7634
|
-
"text/csv": ".csv",
|
|
7635
|
-
"image/png": ".png",
|
|
7636
|
-
"image/jpeg": ".jpg",
|
|
7637
|
-
"image/svg+xml": ".svg"
|
|
7638
|
-
};
|
|
7639
|
-
listFilesSchema = exports_external.object({
|
|
7640
|
-
pageSize: exports_external.coerce.number().int().positive().max(1000).optional(),
|
|
7641
|
-
pageToken: exports_external.string().optional(),
|
|
7642
|
-
q: exports_external.string().optional(),
|
|
7643
|
-
fields: exports_external.string().optional(),
|
|
7644
|
-
orderBy: exports_external.string().optional(),
|
|
7645
|
-
corpora: exports_external.enum(["user", "drive", "allDrives"]).optional(),
|
|
7646
|
-
driveId: exports_external.string().optional(),
|
|
7647
|
-
supportsAllDrives: exports_external.boolean().optional(),
|
|
7648
|
-
includeItemsFromAllDrives: exports_external.boolean().optional()
|
|
7649
|
-
});
|
|
7650
|
-
listDrivesSchema = exports_external.object({
|
|
7651
|
-
pageSize: exports_external.coerce.number().int().positive().max(100).optional(),
|
|
7652
|
-
pageToken: exports_external.string().optional(),
|
|
7653
|
-
q: exports_external.string().optional()
|
|
7654
|
-
});
|
|
7655
|
-
fileIdSchema = exports_external.object({
|
|
7656
|
-
fileId: exports_external.string(),
|
|
7657
|
-
fields: exports_external.string().optional()
|
|
7658
|
-
});
|
|
7659
|
-
downloadSchema = exports_external.object({
|
|
7660
|
-
fileId: exports_external.string(),
|
|
7661
|
-
file: exports_external.object({
|
|
7662
|
-
id: exports_external.string(),
|
|
7663
|
-
name: exports_external.string(),
|
|
7664
|
-
mimeType: exports_external.string()
|
|
7665
|
-
}).optional(),
|
|
7666
|
-
exportMimeType: exports_external.string().optional()
|
|
7667
|
-
});
|
|
7668
|
-
profilesStatusSchema = exports_external.object({
|
|
7669
|
-
profile: exports_external.string().optional()
|
|
7670
|
-
});
|
|
7671
|
-
googleDriveConnector = defineConnector({
|
|
7672
|
-
meta: {
|
|
7673
|
-
name: "googledrive",
|
|
7674
|
-
displayName: "Google Drive",
|
|
7675
|
-
description: "Profile-aware Google Drive discovery and file download operations.",
|
|
7676
|
-
category: "storage",
|
|
7677
|
-
tags: ["google", "drive", "files", "storage"]
|
|
7678
|
-
},
|
|
7679
|
-
auth: {
|
|
7680
|
-
type: "oauth2",
|
|
7681
|
-
supportsProfiles: true,
|
|
7682
|
-
fields: [
|
|
7683
|
-
{ key: "clientId", env: "GOOGLE_CLIENT_ID", label: "OAuth client ID" },
|
|
7684
|
-
{ key: "clientSecret", env: "GOOGLE_CLIENT_SECRET", label: "OAuth client secret", secret: true }
|
|
7685
|
-
]
|
|
7686
|
-
},
|
|
7687
|
-
createContext: ({ profile }) => ({ profile: profile || "default" }),
|
|
7688
|
-
operations: {
|
|
7689
|
-
"profiles.list": {
|
|
7690
|
-
summary: "List configured Google Drive profiles.",
|
|
7691
|
-
execute: () => ({ profiles: listProfiles2() })
|
|
7692
|
-
},
|
|
7693
|
-
"profiles.status": {
|
|
7694
|
-
summary: "List Google Drive profile authentication status.",
|
|
7695
|
-
inputSchema: profilesStatusSchema,
|
|
7696
|
-
execute: (_ctx, input) => ({ profiles: listProfileStatuses(input.profile) })
|
|
7697
|
-
},
|
|
7698
|
-
"files.list": {
|
|
7699
|
-
summary: "List Google Drive files.",
|
|
7700
|
-
inputSchema: listFilesSchema,
|
|
7701
|
-
execute: async ({ context }, input) => requestJson2(context.profile, "/files", {
|
|
7702
|
-
pageSize: input.pageSize ?? 1000,
|
|
7703
|
-
pageToken: input.pageToken,
|
|
7704
|
-
q: input.q,
|
|
7705
|
-
fields: input.fields ?? `nextPageToken,files(${DEFAULT_FILE_FIELDS})`,
|
|
7706
|
-
orderBy: input.orderBy ?? "modifiedTime desc",
|
|
7707
|
-
corpora: input.corpora,
|
|
7708
|
-
driveId: input.driveId,
|
|
7709
|
-
supportsAllDrives: input.supportsAllDrives ?? true,
|
|
7710
|
-
includeItemsFromAllDrives: input.includeItemsFromAllDrives ?? false
|
|
7711
|
-
})
|
|
7712
|
-
},
|
|
7713
|
-
"files.get": {
|
|
7714
|
-
summary: "Get Google Drive file metadata.",
|
|
7715
|
-
inputSchema: fileIdSchema,
|
|
7716
|
-
execute: async ({ context }, input) => requestJson2(context.profile, `/files/${encodeURIComponent(input.fileId)}`, {
|
|
7717
|
-
fields: input.fields ?? DEFAULT_FILE_FIELDS,
|
|
7718
|
-
supportsAllDrives: true
|
|
7719
|
-
})
|
|
7720
|
-
},
|
|
7721
|
-
"files.download": {
|
|
7722
|
-
summary: "Download or export a Google Drive file as base64 content.",
|
|
7723
|
-
inputSchema: downloadSchema,
|
|
7724
|
-
execute: async ({ context }, input) => {
|
|
7725
|
-
const file = input.file ?? await requestJson2(context.profile, `/files/${encodeURIComponent(input.fileId)}`, { fields: DEFAULT_FILE_FIELDS, supportsAllDrives: true });
|
|
7726
|
-
const exportMimeType = file.mimeType.startsWith("application/vnd.google-apps.") ? input.exportMimeType ?? defaultExportMimeType(file.mimeType) : undefined;
|
|
7727
|
-
const data = await requestBinary(context.profile, exportMimeType ? `/files/${encodeURIComponent(file.id)}/export` : `/files/${encodeURIComponent(file.id)}`, exportMimeType ? { mimeType: exportMimeType, supportsAllDrives: true } : { alt: "media", supportsAllDrives: true });
|
|
7728
|
-
const mimeType = exportMimeType ?? file.mimeType ?? "application/octet-stream";
|
|
7729
|
-
return {
|
|
7730
|
-
dataBase64: Buffer.from(data).toString("base64"),
|
|
7731
|
-
filename: exportMimeType ? `${file.name}${extensionForMimeType(exportMimeType)}` : file.name,
|
|
7732
|
-
mimeType
|
|
7733
|
-
};
|
|
7734
|
-
}
|
|
7735
|
-
},
|
|
7736
|
-
"drives.list": {
|
|
7737
|
-
summary: "List Google shared drives.",
|
|
7738
|
-
inputSchema: listDrivesSchema,
|
|
7739
|
-
execute: async ({ context }, input) => requestJson2(context.profile, "/drives", {
|
|
7740
|
-
pageSize: input.pageSize ?? 100,
|
|
7741
|
-
pageToken: input.pageToken,
|
|
7742
|
-
q: input.q
|
|
7743
|
-
})
|
|
7744
|
-
}
|
|
7745
|
-
}
|
|
7746
|
-
});
|
|
7747
|
-
});
|
|
7748
|
-
|
|
7749
6916
|
// node_modules/@hasna/cloud/dist/index.js
|
|
7750
6917
|
var exports_dist = {};
|
|
7751
6918
|
__export(exports_dist, {
|
|
@@ -7819,27 +6986,27 @@ __export(exports_dist, {
|
|
|
7819
6986
|
import { createRequire } from "module";
|
|
7820
6987
|
import { Database } from "bun:sqlite";
|
|
7821
6988
|
import {
|
|
7822
|
-
existsSync as
|
|
7823
|
-
mkdirSync
|
|
7824
|
-
readdirSync
|
|
6989
|
+
existsSync as existsSync2,
|
|
6990
|
+
mkdirSync,
|
|
6991
|
+
readdirSync,
|
|
7825
6992
|
copyFileSync
|
|
7826
6993
|
} from "fs";
|
|
7827
|
-
import { homedir
|
|
7828
|
-
import { join as
|
|
7829
|
-
import { existsSync as existsSync22, mkdirSync as
|
|
7830
|
-
import { homedir as
|
|
6994
|
+
import { homedir } from "os";
|
|
6995
|
+
import { join as join2, relative } from "path";
|
|
6996
|
+
import { existsSync as existsSync22, mkdirSync as mkdirSync2, readFileSync, writeFileSync } from "fs";
|
|
6997
|
+
import { homedir as homedir2 } from "os";
|
|
7831
6998
|
import { join as join22 } from "path";
|
|
7832
|
-
import { readdirSync as
|
|
7833
|
-
import { join as
|
|
7834
|
-
import { homedir as
|
|
6999
|
+
import { readdirSync as readdirSync2, existsSync as existsSync3 } from "fs";
|
|
7000
|
+
import { join as join3 } from "path";
|
|
7001
|
+
import { homedir as homedir3 } from "os";
|
|
7835
7002
|
import { hostname } from "os";
|
|
7836
|
-
import { existsSync as
|
|
7003
|
+
import { existsSync as existsSync4, readFileSync as readFileSync2 } from "fs";
|
|
7837
7004
|
import { homedir as homedir4 } from "os";
|
|
7838
|
-
import { join as
|
|
7839
|
-
import { existsSync as existsSync5, readdirSync as
|
|
7005
|
+
import { join as join4 } from "path";
|
|
7006
|
+
import { existsSync as existsSync5, readdirSync as readdirSync3 } from "fs";
|
|
7840
7007
|
import { join as join5 } from "path";
|
|
7841
7008
|
import { join as join6, dirname as dirname2 } from "path";
|
|
7842
|
-
import { existsSync as existsSync6, writeFileSync as
|
|
7009
|
+
import { existsSync as existsSync6, writeFileSync as writeFileSync2, unlinkSync, mkdirSync as mkdirSync3 } from "fs";
|
|
7843
7010
|
import { homedir as homedir5, platform } from "os";
|
|
7844
7011
|
function __accessProp2(key) {
|
|
7845
7012
|
return this[key];
|
|
@@ -8722,33 +7889,33 @@ function custom2(check, _params = {}, fatal) {
|
|
|
8722
7889
|
return ZodAny2.create();
|
|
8723
7890
|
}
|
|
8724
7891
|
function getDataDir(serviceName) {
|
|
8725
|
-
const dir =
|
|
8726
|
-
|
|
7892
|
+
const dir = join2(HASNA_DIR, serviceName);
|
|
7893
|
+
mkdirSync(dir, { recursive: true });
|
|
8727
7894
|
return dir;
|
|
8728
7895
|
}
|
|
8729
7896
|
function getDbPath(serviceName) {
|
|
8730
7897
|
const dir = getDataDir(serviceName);
|
|
8731
|
-
return
|
|
7898
|
+
return join2(dir, `${serviceName}.db`);
|
|
8732
7899
|
}
|
|
8733
7900
|
function migrateDotfile(serviceName) {
|
|
8734
|
-
const legacyDir =
|
|
8735
|
-
const newDir =
|
|
8736
|
-
if (!
|
|
7901
|
+
const legacyDir = join2(homedir(), `.${serviceName}`);
|
|
7902
|
+
const newDir = join2(HASNA_DIR, serviceName);
|
|
7903
|
+
if (!existsSync2(legacyDir))
|
|
8737
7904
|
return [];
|
|
8738
|
-
if (
|
|
7905
|
+
if (existsSync2(newDir))
|
|
8739
7906
|
return [];
|
|
8740
|
-
|
|
7907
|
+
mkdirSync(newDir, { recursive: true });
|
|
8741
7908
|
const migrated = [];
|
|
8742
7909
|
copyDirRecursive(legacyDir, newDir, legacyDir, migrated);
|
|
8743
7910
|
return migrated;
|
|
8744
7911
|
}
|
|
8745
7912
|
function copyDirRecursive(src, dest, root, migrated) {
|
|
8746
|
-
const entries =
|
|
7913
|
+
const entries = readdirSync(src, { withFileTypes: true });
|
|
8747
7914
|
for (const entry of entries) {
|
|
8748
|
-
const srcPath =
|
|
8749
|
-
const destPath =
|
|
7915
|
+
const srcPath = join2(src, entry.name);
|
|
7916
|
+
const destPath = join2(dest, entry.name);
|
|
8750
7917
|
if (entry.isDirectory()) {
|
|
8751
|
-
|
|
7918
|
+
mkdirSync(destPath, { recursive: true });
|
|
8752
7919
|
copyDirRecursive(srcPath, destPath, root, migrated);
|
|
8753
7920
|
} else {
|
|
8754
7921
|
copyFileSync(srcPath, destPath);
|
|
@@ -8757,10 +7924,10 @@ function copyDirRecursive(src, dest, root, migrated) {
|
|
|
8757
7924
|
}
|
|
8758
7925
|
}
|
|
8759
7926
|
function hasLegacyDotfile(serviceName) {
|
|
8760
|
-
return
|
|
7927
|
+
return existsSync2(join2(homedir(), `.${serviceName}`));
|
|
8761
7928
|
}
|
|
8762
7929
|
function getHasnaDir() {
|
|
8763
|
-
|
|
7930
|
+
mkdirSync(HASNA_DIR, { recursive: true });
|
|
8764
7931
|
return HASNA_DIR;
|
|
8765
7932
|
}
|
|
8766
7933
|
function getConfigDir() {
|
|
@@ -8774,15 +7941,15 @@ function getCloudConfig() {
|
|
|
8774
7941
|
return CloudConfigSchema.parse({});
|
|
8775
7942
|
}
|
|
8776
7943
|
try {
|
|
8777
|
-
const raw =
|
|
7944
|
+
const raw = readFileSync(CONFIG_PATH, "utf-8");
|
|
8778
7945
|
return CloudConfigSchema.parse(JSON.parse(raw));
|
|
8779
7946
|
} catch {
|
|
8780
7947
|
return CloudConfigSchema.parse({});
|
|
8781
7948
|
}
|
|
8782
7949
|
}
|
|
8783
7950
|
function saveCloudConfig(config) {
|
|
8784
|
-
|
|
8785
|
-
|
|
7951
|
+
mkdirSync2(CONFIG_DIR, { recursive: true });
|
|
7952
|
+
writeFileSync(CONFIG_PATH, JSON.stringify(config, null, 2) + `
|
|
8786
7953
|
`, "utf-8");
|
|
8787
7954
|
}
|
|
8788
7955
|
function getConnectionString(dbName) {
|
|
@@ -8812,11 +7979,11 @@ function isSyncExcludedTable(table) {
|
|
|
8812
7979
|
return SYNC_EXCLUDED_TABLE_PATTERNS.some((p) => p.test(table));
|
|
8813
7980
|
}
|
|
8814
7981
|
function discoverServices() {
|
|
8815
|
-
const dataDir =
|
|
8816
|
-
if (!
|
|
7982
|
+
const dataDir = join3(homedir3(), ".hasna");
|
|
7983
|
+
if (!existsSync3(dataDir))
|
|
8817
7984
|
return [];
|
|
8818
7985
|
try {
|
|
8819
|
-
const entries =
|
|
7986
|
+
const entries = readdirSync2(dataDir, { withFileTypes: true });
|
|
8820
7987
|
return entries.filter((e) => {
|
|
8821
7988
|
if (!e.isDirectory())
|
|
8822
7989
|
return false;
|
|
@@ -8834,24 +8001,24 @@ function discoverSyncableServices() {
|
|
|
8834
8001
|
return local.filter((s) => pgSet.has(s));
|
|
8835
8002
|
}
|
|
8836
8003
|
function getServiceDbPath(service) {
|
|
8837
|
-
const dataDir =
|
|
8838
|
-
if (!
|
|
8004
|
+
const dataDir = join3(homedir3(), ".hasna", service);
|
|
8005
|
+
if (!existsSync3(dataDir))
|
|
8839
8006
|
return null;
|
|
8840
8007
|
const candidates = [
|
|
8841
|
-
|
|
8842
|
-
|
|
8843
|
-
|
|
8008
|
+
join3(dataDir, `${service}.db`),
|
|
8009
|
+
join3(dataDir, "data.db"),
|
|
8010
|
+
join3(dataDir, "database.db")
|
|
8844
8011
|
];
|
|
8845
8012
|
try {
|
|
8846
|
-
const files =
|
|
8013
|
+
const files = readdirSync2(dataDir);
|
|
8847
8014
|
for (const f of files) {
|
|
8848
8015
|
if (f.endsWith(".db") && !f.endsWith("-wal") && !f.endsWith("-shm")) {
|
|
8849
|
-
candidates.push(
|
|
8016
|
+
candidates.push(join3(dataDir, f));
|
|
8850
8017
|
}
|
|
8851
8018
|
}
|
|
8852
8019
|
} catch {}
|
|
8853
8020
|
for (const p of candidates) {
|
|
8854
|
-
if (
|
|
8021
|
+
if (existsSync3(p))
|
|
8855
8022
|
return p;
|
|
8856
8023
|
}
|
|
8857
8024
|
return null;
|
|
@@ -9158,9 +8325,9 @@ async function syncTransfer(source, target, options, _direction) {
|
|
|
9158
8325
|
const batch = rows.slice(offset, offset + batchSize);
|
|
9159
8326
|
try {
|
|
9160
8327
|
if (isAsyncAdapter(target)) {
|
|
9161
|
-
await batchUpsertPg(target, table, columns, updateCols, pkColumns, batch);
|
|
8328
|
+
await batchUpsertPg(target, table, columns, updateCols, pkColumns, batch, columns.includes(conflictColumn) ? conflictColumn : undefined);
|
|
9162
8329
|
} else {
|
|
9163
|
-
batchUpsertSqlite(target, table, columns, updateCols, pkColumns, batch);
|
|
8330
|
+
batchUpsertSqlite(target, table, columns, updateCols, pkColumns, batch, columns.includes(conflictColumn) ? conflictColumn : undefined);
|
|
9164
8331
|
}
|
|
9165
8332
|
result.rowsWritten += batch.length;
|
|
9166
8333
|
} catch (err) {
|
|
@@ -9207,7 +8374,7 @@ async function syncTransfer(source, target, options, _direction) {
|
|
|
9207
8374
|
}
|
|
9208
8375
|
return results;
|
|
9209
8376
|
}
|
|
9210
|
-
async function batchUpsertPg(target, table, columns, updateCols, primaryKeys, batch) {
|
|
8377
|
+
async function batchUpsertPg(target, table, columns, updateCols, primaryKeys, batch, conflictColumn) {
|
|
9211
8378
|
if (batch.length === 0)
|
|
9212
8379
|
return;
|
|
9213
8380
|
const colList = columns.map((c) => `"${c}"`).join(", ");
|
|
@@ -9217,20 +8384,22 @@ async function batchUpsertPg(target, table, columns, updateCols, primaryKeys, ba
|
|
|
9217
8384
|
}).join(", ");
|
|
9218
8385
|
const pkList = primaryKeys.map((c) => `"${c}"`).join(", ");
|
|
9219
8386
|
const setClause = updateCols.length > 0 ? updateCols.map((c) => `"${c}" = EXCLUDED."${c}"`).join(", ") : `"${primaryKeys[0]}" = EXCLUDED."${primaryKeys[0]}"`;
|
|
8387
|
+
const whereClause = conflictColumn && updateCols.includes(conflictColumn) ? ` WHERE "${table}"."${conflictColumn}" IS NULL OR EXCLUDED."${conflictColumn}" >= "${table}"."${conflictColumn}"` : "";
|
|
9220
8388
|
const sql = `INSERT INTO "${table}" (${colList}) VALUES ${valuePlaceholders}
|
|
9221
|
-
ON CONFLICT (${pkList}) DO UPDATE SET ${setClause}`;
|
|
8389
|
+
ON CONFLICT (${pkList}) DO UPDATE SET ${setClause}${whereClause}`;
|
|
9222
8390
|
const params = batch.flatMap((row) => columns.map((c) => row[c] ?? null));
|
|
9223
8391
|
await target.run(sql, ...params);
|
|
9224
8392
|
}
|
|
9225
|
-
function batchUpsertSqlite(target, table, columns, updateCols, primaryKeys, batch) {
|
|
8393
|
+
function batchUpsertSqlite(target, table, columns, updateCols, primaryKeys, batch, conflictColumn) {
|
|
9226
8394
|
if (batch.length === 0)
|
|
9227
8395
|
return;
|
|
9228
8396
|
const colList = columns.map((c) => `"${c}"`).join(", ");
|
|
9229
8397
|
const valuePlaceholders = batch.map(() => `(${columns.map(() => "?").join(", ")})`).join(", ");
|
|
9230
8398
|
const pkList = primaryKeys.map((c) => `"${c}"`).join(", ");
|
|
9231
8399
|
const setClause = updateCols.length > 0 ? updateCols.map((c) => `"${c}" = EXCLUDED."${c}"`).join(", ") : `"${primaryKeys[0]}" = EXCLUDED."${primaryKeys[0]}"`;
|
|
8400
|
+
const whereClause = conflictColumn && updateCols.includes(conflictColumn) ? ` WHERE "${table}"."${conflictColumn}" IS NULL OR EXCLUDED."${conflictColumn}" >= "${table}"."${conflictColumn}"` : "";
|
|
9232
8401
|
const sql = `INSERT INTO "${table}" (${colList}) VALUES ${valuePlaceholders}
|
|
9233
|
-
ON CONFLICT (${pkList}) DO UPDATE SET ${setClause}`;
|
|
8402
|
+
ON CONFLICT (${pkList}) DO UPDATE SET ${setClause}${whereClause}`;
|
|
9234
8403
|
const params = batch.flatMap((row) => columns.map((c) => coerceForSqlite(row[c])));
|
|
9235
8404
|
target.run(sql, ...params);
|
|
9236
8405
|
}
|
|
@@ -9770,10 +8939,10 @@ function resetAllSyncMeta(db) {
|
|
|
9770
8939
|
}
|
|
9771
8940
|
function getAutoSyncConfig() {
|
|
9772
8941
|
try {
|
|
9773
|
-
if (!
|
|
8942
|
+
if (!existsSync4(AUTO_SYNC_CONFIG_PATH)) {
|
|
9774
8943
|
return { ...DEFAULT_AUTO_SYNC_CONFIG };
|
|
9775
8944
|
}
|
|
9776
|
-
const raw = JSON.parse(
|
|
8945
|
+
const raw = JSON.parse(readFileSync2(AUTO_SYNC_CONFIG_PATH, "utf-8"));
|
|
9777
8946
|
return {
|
|
9778
8947
|
auto_sync_on_start: typeof raw.auto_sync_on_start === "boolean" ? raw.auto_sync_on_start : DEFAULT_AUTO_SYNC_CONFIG.auto_sync_on_start,
|
|
9779
8948
|
auto_sync_on_stop: typeof raw.auto_sync_on_stop === "boolean" ? raw.auto_sync_on_stop : DEFAULT_AUTO_SYNC_CONFIG.auto_sync_on_stop
|
|
@@ -9888,7 +9057,7 @@ function discoverSyncableServices2() {
|
|
|
9888
9057
|
const hasnaDir = getHasnaDir();
|
|
9889
9058
|
const services = [];
|
|
9890
9059
|
try {
|
|
9891
|
-
const entries =
|
|
9060
|
+
const entries = readdirSync3(hasnaDir, { withFileTypes: true });
|
|
9892
9061
|
for (const entry of entries) {
|
|
9893
9062
|
if (!entry.isDirectory())
|
|
9894
9063
|
continue;
|
|
@@ -10058,11 +9227,11 @@ function createLaunchdPlist(intervalMinutes) {
|
|
|
10058
9227
|
async function registerLaunchd(intervalMinutes) {
|
|
10059
9228
|
const plistPath = getLaunchdPlistPath();
|
|
10060
9229
|
const plistDir = dirname2(plistPath);
|
|
10061
|
-
|
|
9230
|
+
mkdirSync3(plistDir, { recursive: true });
|
|
10062
9231
|
try {
|
|
10063
9232
|
await Bun.spawn(["launchctl", "unload", plistPath]).exited;
|
|
10064
9233
|
} catch {}
|
|
10065
|
-
|
|
9234
|
+
writeFileSync2(plistPath, createLaunchdPlist(intervalMinutes));
|
|
10066
9235
|
await Bun.spawn(["launchctl", "load", plistPath]).exited;
|
|
10067
9236
|
}
|
|
10068
9237
|
async function removeLaunchd() {
|
|
@@ -10109,9 +9278,9 @@ WantedBy=timers.target
|
|
|
10109
9278
|
}
|
|
10110
9279
|
async function registerSystemd(intervalMinutes) {
|
|
10111
9280
|
const dir = getSystemdDir();
|
|
10112
|
-
|
|
10113
|
-
|
|
10114
|
-
|
|
9281
|
+
mkdirSync3(dir, { recursive: true });
|
|
9282
|
+
writeFileSync2(join6(dir, `${SERVICE_NAME}.service`), createSystemdService());
|
|
9283
|
+
writeFileSync2(join6(dir, `${SERVICE_NAME}.timer`), createSystemdTimer(intervalMinutes));
|
|
10115
9284
|
await Bun.spawn(["systemctl", "--user", "daemon-reload"]).exited;
|
|
10116
9285
|
await Bun.spawn(["systemctl", "--user", "enable", "--now", `${SERVICE_NAME}.timer`]).exited;
|
|
10117
9286
|
}
|
|
@@ -10134,7 +9303,7 @@ async function registerSyncSchedule(intervalMinutes) {
|
|
|
10134
9303
|
if (intervalMinutes <= 0) {
|
|
10135
9304
|
throw new Error("Interval must be a positive number of minutes.");
|
|
10136
9305
|
}
|
|
10137
|
-
|
|
9306
|
+
mkdirSync3(CONFIG_DIR2, { recursive: true });
|
|
10138
9307
|
if (platform() === "darwin") {
|
|
10139
9308
|
await registerLaunchd(intervalMinutes);
|
|
10140
9309
|
} else {
|
|
@@ -10300,7 +9469,7 @@ async function ensureAllPgDatabases() {
|
|
|
10300
9469
|
}
|
|
10301
9470
|
return results;
|
|
10302
9471
|
}
|
|
10303
|
-
function registerCloudTools(server, serviceName) {
|
|
9472
|
+
function registerCloudTools(server, serviceName, opts = {}) {
|
|
10304
9473
|
server.tool(`${serviceName}_cloud_status`, "Show cloud configuration and connection health", {}, async () => {
|
|
10305
9474
|
const config = getCloudConfig();
|
|
10306
9475
|
const lines = [
|
|
@@ -10333,8 +9502,13 @@ function registerCloudTools(server, serviceName) {
|
|
|
10333
9502
|
isError: true
|
|
10334
9503
|
};
|
|
10335
9504
|
}
|
|
10336
|
-
const local = new SqliteAdapter(getDbPath(serviceName));
|
|
9505
|
+
const local = new SqliteAdapter(opts.dbPath ?? getDbPath(serviceName));
|
|
10337
9506
|
const cloud = new PgAdapterAsync(getConnectionString(serviceName));
|
|
9507
|
+
if (opts.migrations?.length) {
|
|
9508
|
+
for (const sql of opts.migrations) {
|
|
9509
|
+
await cloud.run(sql);
|
|
9510
|
+
}
|
|
9511
|
+
}
|
|
10338
9512
|
const tableList = tablesStr ? tablesStr.split(",").map((t) => t.trim()) : listSqliteTables(local);
|
|
10339
9513
|
const results = await syncPush(local, cloud, { tables: tableList });
|
|
10340
9514
|
local.close();
|
|
@@ -10356,7 +9530,7 @@ function registerCloudTools(server, serviceName) {
|
|
|
10356
9530
|
isError: true
|
|
10357
9531
|
};
|
|
10358
9532
|
}
|
|
10359
|
-
const local = new SqliteAdapter(getDbPath(serviceName));
|
|
9533
|
+
const local = new SqliteAdapter(opts.dbPath ?? getDbPath(serviceName));
|
|
10360
9534
|
const cloud = new PgAdapterAsync(getConnectionString(serviceName));
|
|
10361
9535
|
let tableList;
|
|
10362
9536
|
if (tablesStr) {
|
|
@@ -18708,7 +17882,7 @@ See https://www.postgresql.org/docs/current/libpq-ssl.html for libpq SSL mode de
|
|
|
18708
17882
|
init_external2();
|
|
18709
17883
|
});
|
|
18710
17884
|
init_dotfile = __esm2(() => {
|
|
18711
|
-
HASNA_DIR =
|
|
17885
|
+
HASNA_DIR = join2(homedir(), ".hasna");
|
|
18712
17886
|
});
|
|
18713
17887
|
exports_config = {};
|
|
18714
17888
|
__export2(exports_config, {
|
|
@@ -18739,7 +17913,7 @@ See https://www.postgresql.org/docs/current/libpq-ssl.html for libpq SSL mode de
|
|
|
18739
17913
|
schedule_minutes: exports_external2.number().default(0)
|
|
18740
17914
|
}).default({})
|
|
18741
17915
|
});
|
|
18742
|
-
CONFIG_DIR = join22(
|
|
17916
|
+
CONFIG_DIR = join22(homedir2(), ".hasna", "cloud");
|
|
18743
17917
|
CONFIG_PATH = join22(CONFIG_DIR, "config.json");
|
|
18744
17918
|
});
|
|
18745
17919
|
exports_discover = {};
|
|
@@ -18804,7 +17978,7 @@ See https://www.postgresql.org/docs/current/libpq-ssl.html for libpq SSL mode de
|
|
|
18804
17978
|
init_adapter();
|
|
18805
17979
|
init_config();
|
|
18806
17980
|
init_discover();
|
|
18807
|
-
AUTO_SYNC_CONFIG_PATH =
|
|
17981
|
+
AUTO_SYNC_CONFIG_PATH = join4(homedir4(), ".hasna", "cloud", "config.json");
|
|
18808
17982
|
DEFAULT_AUTO_SYNC_CONFIG = {
|
|
18809
17983
|
auto_sync_on_start: true,
|
|
18810
17984
|
auto_sync_on_stop: true
|
|
@@ -19013,115 +18187,17 @@ var init_database = __esm(() => {
|
|
|
19013
18187
|
DB_PATH = join7(DB_DIR, "connectors.db");
|
|
19014
18188
|
});
|
|
19015
18189
|
|
|
19016
|
-
// src/lib/connector-resolver.ts
|
|
19017
|
-
import { existsSync as existsSync9, readdirSync as readdirSync5, statSync as statSync2 } from "fs";
|
|
19018
|
-
import { join as join9 } from "path";
|
|
19019
|
-
function normalizeConnectorName(name) {
|
|
19020
|
-
const trimmed = name.trim().toLowerCase();
|
|
19021
|
-
return trimmed.startsWith(LEGACY_CONNECTOR_PREFIX) ? trimmed.slice(LEGACY_CONNECTOR_PREFIX.length) : trimmed;
|
|
19022
|
-
}
|
|
19023
|
-
function legacyConnectorName(name) {
|
|
19024
|
-
return `${LEGACY_CONNECTOR_PREFIX}${normalizeConnectorName(name)}`;
|
|
19025
|
-
}
|
|
19026
|
-
function resolveConnectorName(name) {
|
|
19027
|
-
const canonicalName = normalizeConnectorName(name);
|
|
19028
|
-
const legacyName = legacyConnectorName(canonicalName);
|
|
19029
|
-
return {
|
|
19030
|
-
input: name,
|
|
19031
|
-
canonicalName,
|
|
19032
|
-
legacyName,
|
|
19033
|
-
aliases: canonicalName === legacyName ? [canonicalName] : [canonicalName, legacyName],
|
|
19034
|
-
isLegacyInput: name.trim().toLowerCase().startsWith(LEGACY_CONNECTOR_PREFIX)
|
|
19035
|
-
};
|
|
19036
|
-
}
|
|
19037
|
-
function isValidConnectorName(name) {
|
|
19038
|
-
const trimmed = name.trim();
|
|
19039
|
-
if (trimmed !== trimmed.toLowerCase())
|
|
19040
|
-
return false;
|
|
19041
|
-
return CONNECTOR_NAME_RE2.test(normalizeConnectorName(trimmed));
|
|
19042
|
-
}
|
|
19043
|
-
function connectorPackageDirNames(name) {
|
|
19044
|
-
const { canonicalName, legacyName } = resolveConnectorName(name);
|
|
19045
|
-
if (!canonicalName)
|
|
19046
|
-
return [legacyName];
|
|
19047
|
-
return canonicalName === legacyName ? [canonicalName] : [canonicalName, legacyName];
|
|
19048
|
-
}
|
|
19049
|
-
function resolveConnectorPackagePath(connectorsDir, name) {
|
|
19050
|
-
const resolution = resolveConnectorName(name);
|
|
19051
|
-
const dirNames = connectorPackageDirNames(name);
|
|
19052
|
-
const checkedPaths = dirNames.map((dirName) => join9(connectorsDir, dirName));
|
|
19053
|
-
const existingPath = checkedPaths.find((path) => existsSync9(path)) ?? null;
|
|
19054
|
-
const existingDirName = existingPath ? dirNames[checkedPaths.indexOf(existingPath)] : null;
|
|
19055
|
-
return {
|
|
19056
|
-
...resolution,
|
|
19057
|
-
connectorsDir,
|
|
19058
|
-
preferredDirName: dirNames[0],
|
|
19059
|
-
preferredPath: checkedPaths[0],
|
|
19060
|
-
existingPath,
|
|
19061
|
-
existingDirName,
|
|
19062
|
-
checkedPaths
|
|
19063
|
-
};
|
|
19064
|
-
}
|
|
19065
|
-
function getConnectorPackagePath(connectorsDir, name) {
|
|
19066
|
-
const resolved = resolveConnectorPackagePath(connectorsDir, name);
|
|
19067
|
-
return resolved.existingPath ?? resolved.preferredPath;
|
|
19068
|
-
}
|
|
19069
|
-
function resolveConnectorConfigPaths(name, connectorsHome = getConnectorsHome()) {
|
|
19070
|
-
const resolution = resolveConnectorName(name);
|
|
19071
|
-
const preferredDirName = resolution.canonicalName || resolution.legacyName;
|
|
19072
|
-
const preferredPath = join9(connectorsHome, preferredDirName);
|
|
19073
|
-
const legacyPath = join9(connectorsHome, resolution.legacyName);
|
|
19074
|
-
const paths = preferredPath === legacyPath ? [preferredPath] : [preferredPath, legacyPath];
|
|
19075
|
-
const existingPaths = paths.filter((path) => existsSync9(path));
|
|
19076
|
-
return {
|
|
19077
|
-
...resolution,
|
|
19078
|
-
connectorsHome,
|
|
19079
|
-
preferredDirName,
|
|
19080
|
-
preferredPath,
|
|
19081
|
-
legacyPath,
|
|
19082
|
-
existingPaths,
|
|
19083
|
-
readPaths: paths
|
|
19084
|
-
};
|
|
19085
|
-
}
|
|
19086
|
-
function getConnectorConfigDir(name, connectorsHome = getConnectorsHome()) {
|
|
19087
|
-
return resolveConnectorConfigPaths(name, connectorsHome).preferredPath;
|
|
19088
|
-
}
|
|
19089
|
-
function getConnectorConfigReadDirs(name, connectorsHome = getConnectorsHome()) {
|
|
19090
|
-
return resolveConnectorConfigPaths(name, connectorsHome).readPaths;
|
|
19091
|
-
}
|
|
19092
|
-
function listConfiguredConnectorNames(connectorsHome = getConnectorsHome()) {
|
|
19093
|
-
if (!existsSync9(connectorsHome))
|
|
19094
|
-
return [];
|
|
19095
|
-
const names = new Set;
|
|
19096
|
-
for (const entry of readdirSync5(connectorsHome)) {
|
|
19097
|
-
const fullPath = join9(connectorsHome, entry);
|
|
19098
|
-
try {
|
|
19099
|
-
if (!statSync2(fullPath).isDirectory())
|
|
19100
|
-
continue;
|
|
19101
|
-
if (!isValidConnectorName(entry))
|
|
19102
|
-
continue;
|
|
19103
|
-
names.add(normalizeConnectorName(entry));
|
|
19104
|
-
} catch {}
|
|
19105
|
-
}
|
|
19106
|
-
return [...names].sort();
|
|
19107
|
-
}
|
|
19108
|
-
var LEGACY_CONNECTOR_PREFIX = "connect-", CONNECTOR_NAME_RE2;
|
|
19109
|
-
var init_connector_resolver = __esm(() => {
|
|
19110
|
-
init_database();
|
|
19111
|
-
CONNECTOR_NAME_RE2 = /^[a-z0-9-]+$/;
|
|
19112
|
-
});
|
|
19113
|
-
|
|
19114
18190
|
// src/core/connectors/imessage.ts
|
|
19115
18191
|
import {
|
|
19116
|
-
existsSync as
|
|
19117
|
-
mkdirSync as
|
|
19118
|
-
readFileSync as
|
|
18192
|
+
existsSync as existsSync9,
|
|
18193
|
+
mkdirSync as mkdirSync6,
|
|
18194
|
+
readFileSync as readFileSync3,
|
|
19119
18195
|
readdirSync as readdirSync6,
|
|
19120
18196
|
rmSync,
|
|
19121
|
-
statSync as
|
|
19122
|
-
writeFileSync as
|
|
18197
|
+
statSync as statSync2,
|
|
18198
|
+
writeFileSync as writeFileSync3
|
|
19123
18199
|
} from "fs";
|
|
19124
|
-
import { join as
|
|
18200
|
+
import { join as join9 } from "path";
|
|
19125
18201
|
function buildRootHelp(specs) {
|
|
19126
18202
|
const lines = [
|
|
19127
18203
|
"Usage: connect-imessage [options] [command]",
|
|
@@ -19166,44 +18242,36 @@ function buildCommandHelp(spec) {
|
|
|
19166
18242
|
`);
|
|
19167
18243
|
}
|
|
19168
18244
|
function getConfigDir2() {
|
|
19169
|
-
return
|
|
19170
|
-
}
|
|
19171
|
-
function getConfigReadDirs() {
|
|
19172
|
-
return getConnectorConfigReadDirs(CONNECTOR_NAME);
|
|
18245
|
+
return join9(getConnectorsHome(), CONNECTOR_DIRNAME);
|
|
19173
18246
|
}
|
|
19174
18247
|
function getProfilesDir() {
|
|
19175
|
-
return
|
|
18248
|
+
return join9(getConfigDir2(), "profiles");
|
|
19176
18249
|
}
|
|
19177
18250
|
function getCurrentProfile() {
|
|
19178
|
-
|
|
19179
|
-
|
|
19180
|
-
|
|
19181
|
-
|
|
19182
|
-
|
|
19183
|
-
|
|
19184
|
-
|
|
19185
|
-
|
|
19186
|
-
}
|
|
18251
|
+
const currentProfileFile = join9(getConfigDir2(), "current_profile");
|
|
18252
|
+
if (!existsSync9(currentProfileFile)) {
|
|
18253
|
+
return "default";
|
|
18254
|
+
}
|
|
18255
|
+
try {
|
|
18256
|
+
return readFileSync3(currentProfileFile, "utf-8").trim() || "default";
|
|
18257
|
+
} catch {
|
|
18258
|
+
return "default";
|
|
19187
18259
|
}
|
|
19188
|
-
return "default";
|
|
19189
18260
|
}
|
|
19190
18261
|
function setCurrentProfile(profile) {
|
|
19191
18262
|
const configDir = getConfigDir2();
|
|
19192
|
-
|
|
19193
|
-
|
|
18263
|
+
mkdirSync6(configDir, { recursive: true });
|
|
18264
|
+
writeFileSync3(join9(configDir, "current_profile"), profile);
|
|
19194
18265
|
}
|
|
19195
18266
|
function getFlatProfilePath(profile) {
|
|
19196
|
-
return
|
|
18267
|
+
return join9(getProfilesDir(), `${profile}.json`);
|
|
19197
18268
|
}
|
|
19198
|
-
function
|
|
19199
|
-
return
|
|
19200
|
-
}
|
|
19201
|
-
function getDirectoryProfileReadPaths(profile) {
|
|
19202
|
-
return getConfigReadDirs().map((dir) => join10(dir, "profiles", profile, "config.json"));
|
|
18269
|
+
function getDirectoryProfilePath(profile) {
|
|
18270
|
+
return join9(getProfilesDir(), profile, "config.json");
|
|
19203
18271
|
}
|
|
19204
18272
|
function loadJsonFile(path) {
|
|
19205
18273
|
try {
|
|
19206
|
-
return JSON.parse(
|
|
18274
|
+
return JSON.parse(readFileSync3(path, "utf-8"));
|
|
19207
18275
|
} catch {
|
|
19208
18276
|
return {};
|
|
19209
18277
|
}
|
|
@@ -19219,8 +18287,8 @@ function sanitizeProfileConfig(config) {
|
|
|
19219
18287
|
};
|
|
19220
18288
|
}
|
|
19221
18289
|
function loadProfile(profile = getCurrentProfile()) {
|
|
19222
|
-
const flatConfig =
|
|
19223
|
-
const directoryConfig =
|
|
18290
|
+
const flatConfig = existsSync9(getFlatProfilePath(profile)) ? loadJsonFile(getFlatProfilePath(profile)) : {};
|
|
18291
|
+
const directoryConfig = existsSync9(getDirectoryProfilePath(profile)) ? loadJsonFile(getDirectoryProfilePath(profile)) : {};
|
|
19224
18292
|
return sanitizeProfileConfig({
|
|
19225
18293
|
...flatConfig,
|
|
19226
18294
|
...directoryConfig
|
|
@@ -19228,34 +18296,33 @@ function loadProfile(profile = getCurrentProfile()) {
|
|
|
19228
18296
|
}
|
|
19229
18297
|
function writeProfile(profile, config) {
|
|
19230
18298
|
const profilesDir = getProfilesDir();
|
|
19231
|
-
|
|
19232
|
-
|
|
18299
|
+
mkdirSync6(profilesDir, { recursive: true });
|
|
18300
|
+
writeFileSync3(getFlatProfilePath(profile), JSON.stringify(config, null, 2) + `
|
|
19233
18301
|
`);
|
|
19234
18302
|
}
|
|
19235
18303
|
function profileExists(profile) {
|
|
19236
18304
|
if (profile === "default") {
|
|
19237
18305
|
return true;
|
|
19238
18306
|
}
|
|
19239
|
-
return
|
|
18307
|
+
return existsSync9(getFlatProfilePath(profile)) || existsSync9(join9(getProfilesDir(), profile));
|
|
19240
18308
|
}
|
|
19241
|
-
function
|
|
18309
|
+
function listProfiles() {
|
|
18310
|
+
const profilesDir = getProfilesDir();
|
|
19242
18311
|
const seen = new Set(["default"]);
|
|
19243
|
-
|
|
19244
|
-
|
|
19245
|
-
if (!existsSync10(profilesDir))
|
|
19246
|
-
continue;
|
|
19247
|
-
try {
|
|
19248
|
-
for (const entry of readdirSync6(profilesDir)) {
|
|
19249
|
-
const fullPath = join10(profilesDir, entry);
|
|
19250
|
-
const stat = statSync3(fullPath);
|
|
19251
|
-
if (stat.isDirectory()) {
|
|
19252
|
-
seen.add(entry);
|
|
19253
|
-
} else if (entry.endsWith(".json")) {
|
|
19254
|
-
seen.add(entry.replace(/\.json$/, ""));
|
|
19255
|
-
}
|
|
19256
|
-
}
|
|
19257
|
-
} catch {}
|
|
18312
|
+
if (!existsSync9(profilesDir)) {
|
|
18313
|
+
return [...seen];
|
|
19258
18314
|
}
|
|
18315
|
+
try {
|
|
18316
|
+
for (const entry of readdirSync6(profilesDir)) {
|
|
18317
|
+
const fullPath = join9(profilesDir, entry);
|
|
18318
|
+
const stat = statSync2(fullPath);
|
|
18319
|
+
if (stat.isDirectory()) {
|
|
18320
|
+
seen.add(entry);
|
|
18321
|
+
} else if (entry.endsWith(".json")) {
|
|
18322
|
+
seen.add(entry.replace(/\.json$/, ""));
|
|
18323
|
+
}
|
|
18324
|
+
}
|
|
18325
|
+
} catch {}
|
|
19259
18326
|
return [...seen].sort();
|
|
19260
18327
|
}
|
|
19261
18328
|
function createProfile(profile, config = {}) {
|
|
@@ -19268,11 +18335,11 @@ function createProfile(profile, config = {}) {
|
|
|
19268
18335
|
}
|
|
19269
18336
|
function clearProfile(profile = getCurrentProfile()) {
|
|
19270
18337
|
const flatPath = getFlatProfilePath(profile);
|
|
19271
|
-
const directoryPath =
|
|
19272
|
-
if (
|
|
18338
|
+
const directoryPath = join9(getProfilesDir(), profile);
|
|
18339
|
+
if (existsSync9(flatPath)) {
|
|
19273
18340
|
rmSync(flatPath);
|
|
19274
18341
|
}
|
|
19275
|
-
if (
|
|
18342
|
+
if (existsSync9(directoryPath)) {
|
|
19276
18343
|
rmSync(directoryPath, { recursive: true, force: true });
|
|
19277
18344
|
}
|
|
19278
18345
|
}
|
|
@@ -19568,7 +18635,7 @@ async function sendMessage(context, input) {
|
|
|
19568
18635
|
direction: "outbound"
|
|
19569
18636
|
});
|
|
19570
18637
|
}
|
|
19571
|
-
async function
|
|
18638
|
+
async function replyToMessage(context, input) {
|
|
19572
18639
|
const payload = await bridgeRequest(context, "/messages/reply", {
|
|
19573
18640
|
method: "POST",
|
|
19574
18641
|
body: {
|
|
@@ -19682,7 +18749,7 @@ async function runProfileCommand2(args, context) {
|
|
|
19682
18749
|
switch (subcommand) {
|
|
19683
18750
|
case "list": {
|
|
19684
18751
|
const current = getCurrentProfile();
|
|
19685
|
-
const profiles =
|
|
18752
|
+
const profiles = listProfiles();
|
|
19686
18753
|
return successOutput({ current, profiles }, context.format, () => profiles.map((profile) => `${profile}${profile === current ? " (active)" : ""}`).join(`
|
|
19687
18754
|
`));
|
|
19688
18755
|
}
|
|
@@ -19856,7 +18923,7 @@ async function runMessageCommand(args, context) {
|
|
|
19856
18923
|
if (!conversationId || !text) {
|
|
19857
18924
|
return failure2("Usage: connect-imessage message reply --conversation <id> --text <text>");
|
|
19858
18925
|
}
|
|
19859
|
-
return successOutput(await
|
|
18926
|
+
return successOutput(await replyToMessage(resolved, {
|
|
19860
18927
|
conversationId,
|
|
19861
18928
|
text,
|
|
19862
18929
|
replyToMessageId: asString2(options.replyTo),
|
|
@@ -19875,7 +18942,7 @@ function createOperationContext(args) {
|
|
|
19875
18942
|
deviceId: extractCredentialString(args.credentials, "deviceId")
|
|
19876
18943
|
});
|
|
19877
18944
|
}
|
|
19878
|
-
var
|
|
18945
|
+
var CONNECTOR_DIRNAME = "connect-imessage", COMMAND_SPECS, ROOT_HELP2, COMMAND_HELP2, COMMAND_DESCRIPTORS, IMESSAGE_DOCS = `# CLAUDE.md
|
|
19879
18946
|
|
|
19880
18947
|
## Project Overview
|
|
19881
18948
|
|
|
@@ -19905,12 +18972,12 @@ API Key authentication is optional and depends on the bridge deployment. A bridg
|
|
|
19905
18972
|
|
|
19906
18973
|
## Data Storage
|
|
19907
18974
|
|
|
19908
|
-
Connector state is stored under \`~/.hasna/connectors/imessage/\`. Profiles are read from both \`profiles/<name>.json\` and \`profiles/<name>/config.json\` so the connector stays compatible with the shared dashboard auth helpers while remaining fully internal to the one-product repo.
|
|
18975
|
+
Connector state is stored under \`~/.hasna/connectors/connect-imessage/\`. Profiles are read from both \`profiles/<name>.json\` and \`profiles/<name>/config.json\` so the connector stays compatible with the shared dashboard auth helpers while remaining fully internal to the one-product repo.
|
|
19909
18976
|
`, commandInputSchema, conversationListInputSchema, conversationGetInputSchema, messageListInputSchema, messageSendInputSchema, messageReplyInputSchema, imessageConnector;
|
|
19910
18977
|
var init_imessage = __esm(() => {
|
|
19911
18978
|
init_package();
|
|
19912
18979
|
init_zod();
|
|
19913
|
-
|
|
18980
|
+
init_database();
|
|
19914
18981
|
init_connector();
|
|
19915
18982
|
COMMAND_SPECS = [
|
|
19916
18983
|
{
|
|
@@ -20134,7 +19201,7 @@ var init_imessage = __esm(() => {
|
|
|
20134
19201
|
summary: "Reply to an existing conversation through the bridge",
|
|
20135
19202
|
inputSchema: messageReplyInputSchema,
|
|
20136
19203
|
async execute({ context }, input) {
|
|
20137
|
-
return
|
|
19204
|
+
return replyToMessage(context, input);
|
|
20138
19205
|
}
|
|
20139
19206
|
}
|
|
20140
19207
|
},
|
|
@@ -20198,18 +19265,18 @@ var init_imessage = __esm(() => {
|
|
|
20198
19265
|
});
|
|
20199
19266
|
|
|
20200
19267
|
// src/core/connectors/stripe.ts
|
|
20201
|
-
import { existsSync as
|
|
20202
|
-
import { dirname as dirname4, join as
|
|
19268
|
+
import { existsSync as existsSync10 } from "fs";
|
|
19269
|
+
import { dirname as dirname4, join as join10 } from "path";
|
|
20203
19270
|
import { fileURLToPath as fileURLToPath2, pathToFileURL as pathToFileURL2 } from "url";
|
|
20204
19271
|
function resolveStripeConnectorDir() {
|
|
20205
19272
|
const candidates = [
|
|
20206
|
-
|
|
20207
|
-
|
|
20208
|
-
|
|
20209
|
-
|
|
19273
|
+
join10(__dirname3, "..", "..", "..", "connectors", "connect-stripe"),
|
|
19274
|
+
join10(__dirname3, "..", "..", "connectors", "connect-stripe"),
|
|
19275
|
+
join10(__dirname3, "..", "connectors", "connect-stripe"),
|
|
19276
|
+
join10(process.cwd(), "connectors", "connect-stripe")
|
|
20210
19277
|
];
|
|
20211
19278
|
for (const candidate of candidates) {
|
|
20212
|
-
if (
|
|
19279
|
+
if (existsSync10(candidate)) {
|
|
20213
19280
|
return candidate;
|
|
20214
19281
|
}
|
|
20215
19282
|
}
|
|
@@ -20257,10 +19324,10 @@ function buildCommandHelp2(spec) {
|
|
|
20257
19324
|
`);
|
|
20258
19325
|
}
|
|
20259
19326
|
async function loadStripeApiModule() {
|
|
20260
|
-
return await import(pathToFileURL2(
|
|
19327
|
+
return await import(pathToFileURL2(join10(CONNECTOR_DIR2, "src", "api", "index.ts")).href);
|
|
20261
19328
|
}
|
|
20262
19329
|
async function loadStripeConfigModule() {
|
|
20263
|
-
return await import(pathToFileURL2(
|
|
19330
|
+
return await import(pathToFileURL2(join10(CONNECTOR_DIR2, "src", "utils", "config.ts")).href);
|
|
20264
19331
|
}
|
|
20265
19332
|
function extractGlobalArgs3(args) {
|
|
20266
19333
|
const remaining = [];
|
|
@@ -21078,14 +20145,10 @@ var INTERNAL_CONNECTOR_DEFINITIONS, INTERNAL_CONNECTOR_REGISTRY;
|
|
|
21078
20145
|
var init_builtins = __esm(() => {
|
|
21079
20146
|
init_registry();
|
|
21080
20147
|
init_github();
|
|
21081
|
-
init_gmail();
|
|
21082
|
-
init_googledrive();
|
|
21083
20148
|
init_imessage();
|
|
21084
20149
|
init_stripe();
|
|
21085
20150
|
INTERNAL_CONNECTOR_DEFINITIONS = [
|
|
21086
|
-
gmailConnector,
|
|
21087
20151
|
githubConnector,
|
|
21088
|
-
googleDriveConnector,
|
|
21089
20152
|
imessageConnector,
|
|
21090
20153
|
stripeConnector
|
|
21091
20154
|
];
|
|
@@ -27225,8 +26288,8 @@ __export(exports_registry, {
|
|
|
27225
26288
|
CONNECTORS: () => CONNECTORS,
|
|
27226
26289
|
CATEGORIES: () => CATEGORIES
|
|
27227
26290
|
});
|
|
27228
|
-
import { existsSync as
|
|
27229
|
-
import { join as
|
|
26291
|
+
import { existsSync as existsSync11, readFileSync as readFileSync5 } from "fs";
|
|
26292
|
+
import { join as join11, dirname as dirname5 } from "path";
|
|
27230
26293
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
27231
26294
|
function getConnectorsByCategory(category) {
|
|
27232
26295
|
return CONNECTORS.filter((c) => c.category === category);
|
|
@@ -27379,10 +26442,7 @@ function searchConnectors(query, context) {
|
|
|
27379
26442
|
return results.slice(0, limit);
|
|
27380
26443
|
}
|
|
27381
26444
|
function getConnector(name) {
|
|
27382
|
-
|
|
27383
|
-
return;
|
|
27384
|
-
const normalizedName = normalizeConnectorName(name);
|
|
27385
|
-
return CONNECTORS.find((c) => c.name === normalizedName);
|
|
26445
|
+
return CONNECTORS.find((c) => c.name === name);
|
|
27386
26446
|
}
|
|
27387
26447
|
function loadConnectorVersions() {
|
|
27388
26448
|
if (versionsLoaded)
|
|
@@ -27390,16 +26450,16 @@ function loadConnectorVersions() {
|
|
|
27390
26450
|
versionsLoaded = true;
|
|
27391
26451
|
const thisDir = dirname5(fileURLToPath3(import.meta.url));
|
|
27392
26452
|
const candidates = [
|
|
27393
|
-
|
|
27394
|
-
|
|
26453
|
+
join11(thisDir, "..", "connectors"),
|
|
26454
|
+
join11(thisDir, "..", "..", "connectors")
|
|
27395
26455
|
];
|
|
27396
|
-
const connectorsDir = candidates.find((d) =>
|
|
26456
|
+
const connectorsDir = candidates.find((d) => existsSync11(d));
|
|
27397
26457
|
if (!connectorsDir)
|
|
27398
26458
|
return;
|
|
27399
26459
|
for (const connector of CONNECTORS) {
|
|
27400
26460
|
try {
|
|
27401
|
-
const pkgPath =
|
|
27402
|
-
if (
|
|
26461
|
+
const pkgPath = join11(connectorsDir, `connect-${connector.name}`, "package.json");
|
|
26462
|
+
if (existsSync11(pkgPath)) {
|
|
27403
26463
|
const pkg = JSON.parse(readFileSync5(pkgPath, "utf-8"));
|
|
27404
26464
|
connector.version = pkg.version || "0.0.0";
|
|
27405
26465
|
continue;
|
|
@@ -27415,7 +26475,6 @@ var CATEGORIES, CONNECTORS, versionsLoaded = false;
|
|
|
27415
26475
|
var init_registry2 = __esm(() => {
|
|
27416
26476
|
init_builtins();
|
|
27417
26477
|
init_synonyms();
|
|
27418
|
-
init_connector_resolver();
|
|
27419
26478
|
init_ai_ml();
|
|
27420
26479
|
init_advertising();
|
|
27421
26480
|
init_business_tools();
|
|
@@ -29124,30 +28183,33 @@ __export(exports_installer, {
|
|
|
29124
28183
|
getConnectorDocs: () => getConnectorDocs,
|
|
29125
28184
|
connectorExists: () => connectorExists
|
|
29126
28185
|
});
|
|
29127
|
-
import { existsSync as
|
|
29128
|
-
import { join as
|
|
28186
|
+
import { existsSync as existsSync12, mkdirSync as mkdirSync7, readFileSync as readFileSync6, writeFileSync as writeFileSync5, readdirSync as readdirSync7, statSync as statSync3, rmSync as rmSync2 } from "fs";
|
|
28187
|
+
import { join as join12, dirname as dirname6 } from "path";
|
|
29129
28188
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
29130
28189
|
function resolveConnectorsDir() {
|
|
29131
|
-
const fromBin =
|
|
29132
|
-
if (
|
|
28190
|
+
const fromBin = join12(__dirname4, "..", "connectors");
|
|
28191
|
+
if (existsSync12(fromBin))
|
|
29133
28192
|
return fromBin;
|
|
29134
|
-
const fromSrc =
|
|
29135
|
-
if (
|
|
28193
|
+
const fromSrc = join12(__dirname4, "..", "..", "connectors");
|
|
28194
|
+
if (existsSync12(fromSrc))
|
|
29136
28195
|
return fromSrc;
|
|
29137
28196
|
return fromBin;
|
|
29138
28197
|
}
|
|
28198
|
+
function normalizeConnectorName(name) {
|
|
28199
|
+
return name.startsWith("connect-") ? name.slice("connect-".length) : name;
|
|
28200
|
+
}
|
|
29139
28201
|
function getProjectConnectorsDir(targetDir) {
|
|
29140
|
-
return
|
|
28202
|
+
return join12(targetDir, PROJECT_CONNECTORS_DIRNAME);
|
|
29141
28203
|
}
|
|
29142
28204
|
function getEnablementManifestPath(targetDir) {
|
|
29143
|
-
return
|
|
28205
|
+
return join12(getProjectConnectorsDir(targetDir), ENABLEMENT_MANIFEST_FILENAME);
|
|
29144
28206
|
}
|
|
29145
28207
|
function getLegacyInstallPath(targetDir, name) {
|
|
29146
|
-
return
|
|
28208
|
+
return join12(getProjectConnectorsDir(targetDir), `connect-${normalizeConnectorName(name)}`);
|
|
29147
28209
|
}
|
|
29148
28210
|
function loadEnablementManifest(targetDir) {
|
|
29149
28211
|
const manifestPath = getEnablementManifestPath(targetDir);
|
|
29150
|
-
if (!
|
|
28212
|
+
if (!existsSync12(manifestPath)) {
|
|
29151
28213
|
return null;
|
|
29152
28214
|
}
|
|
29153
28215
|
try {
|
|
@@ -29167,12 +28229,12 @@ function loadEnablementManifest(targetDir) {
|
|
|
29167
28229
|
}
|
|
29168
28230
|
function getLegacyInstalledConnectors(targetDir) {
|
|
29169
28231
|
const connectorsDir = getProjectConnectorsDir(targetDir);
|
|
29170
|
-
if (!
|
|
28232
|
+
if (!existsSync12(connectorsDir)) {
|
|
29171
28233
|
return [];
|
|
29172
28234
|
}
|
|
29173
28235
|
return readdirSync7(connectorsDir).filter((entry) => {
|
|
29174
|
-
const fullPath =
|
|
29175
|
-
return entry.startsWith("connect-") &&
|
|
28236
|
+
const fullPath = join12(connectorsDir, entry);
|
|
28237
|
+
return entry.startsWith("connect-") && statSync3(fullPath).isDirectory();
|
|
29176
28238
|
}).map((entry) => entry.replace("connect-", "")).sort();
|
|
29177
28239
|
}
|
|
29178
28240
|
function getEnabledConnectors(targetDir) {
|
|
@@ -29180,7 +28242,7 @@ function getEnabledConnectors(targetDir) {
|
|
|
29180
28242
|
return [...new Set([...manifestConnectors, ...getLegacyInstalledConnectors(targetDir)])].sort();
|
|
29181
28243
|
}
|
|
29182
28244
|
function updateConnectorsIndex(connectorsDir, connectors18) {
|
|
29183
|
-
const indexPath =
|
|
28245
|
+
const indexPath = join12(connectorsDir, ENABLEMENT_INDEX_FILENAME);
|
|
29184
28246
|
const connectorList = connectors18.map((connector) => ` "${connector}",`).join(`
|
|
29185
28247
|
`);
|
|
29186
28248
|
const content = `/**
|
|
@@ -29200,7 +28262,7 @@ export type EnabledConnectorName = typeof enabledConnectors[number];
|
|
|
29200
28262
|
}
|
|
29201
28263
|
function writeEnablementManifest(targetDir, connectors18) {
|
|
29202
28264
|
const connectorsDir = getProjectConnectorsDir(targetDir);
|
|
29203
|
-
|
|
28265
|
+
mkdirSync7(connectorsDir, { recursive: true });
|
|
29204
28266
|
const manifest = {
|
|
29205
28267
|
version: 1,
|
|
29206
28268
|
mode: "internal",
|
|
@@ -29212,11 +28274,12 @@ function writeEnablementManifest(targetDir, connectors18) {
|
|
|
29212
28274
|
updateConnectorsIndex(connectorsDir, manifest.connectors);
|
|
29213
28275
|
}
|
|
29214
28276
|
function getConnectorPath(name) {
|
|
29215
|
-
|
|
28277
|
+
const connectorName = name.startsWith("connect-") ? name : `connect-${name}`;
|
|
28278
|
+
return join12(CONNECTORS_DIR, connectorName);
|
|
29216
28279
|
}
|
|
29217
28280
|
function connectorExists(name) {
|
|
29218
28281
|
const normalizedName = normalizeConnectorName(name);
|
|
29219
|
-
return hasInternalConnectorDefinition(normalizedName) ||
|
|
28282
|
+
return hasInternalConnectorDefinition(normalizedName) || existsSync12(getConnectorPath(normalizedName));
|
|
29220
28283
|
}
|
|
29221
28284
|
function installConnector(name, options = {}) {
|
|
29222
28285
|
const { targetDir = process.cwd(), overwrite = false } = options;
|
|
@@ -29249,7 +28312,7 @@ function installConnector(name, options = {}) {
|
|
|
29249
28312
|
try {
|
|
29250
28313
|
const nextEnabled = [...new Set([...installed, normalizedName])].sort();
|
|
29251
28314
|
writeEnablementManifest(targetDir, nextEnabled);
|
|
29252
|
-
if (overwrite &&
|
|
28315
|
+
if (overwrite && existsSync12(legacyInstallPath)) {
|
|
29253
28316
|
rmSync2(legacyInstallPath, { recursive: true });
|
|
29254
28317
|
}
|
|
29255
28318
|
return {
|
|
@@ -29284,8 +28347,8 @@ function parseConnectorDocs(raw) {
|
|
|
29284
28347
|
function getConnectorDocs(name) {
|
|
29285
28348
|
const normalizedName = normalizeConnectorName(name);
|
|
29286
28349
|
const connectorPath = getConnectorPath(normalizedName);
|
|
29287
|
-
const claudeMdPath =
|
|
29288
|
-
if (
|
|
28350
|
+
const claudeMdPath = join12(connectorPath, "CLAUDE.md");
|
|
28351
|
+
if (existsSync12(claudeMdPath)) {
|
|
29289
28352
|
return parseConnectorDocs(readFileSync6(claudeMdPath, "utf-8"));
|
|
29290
28353
|
}
|
|
29291
28354
|
const internalDocs = getInternalConnectorDefinition(normalizedName)?.docsMarkdown;
|
|
@@ -29330,7 +28393,7 @@ function removeConnector(name, targetDir = process.cwd()) {
|
|
|
29330
28393
|
const nextEnabled = installed.filter((connector) => connector !== normalizedName);
|
|
29331
28394
|
writeEnablementManifest(targetDir, nextEnabled);
|
|
29332
28395
|
const legacyInstallPath = getLegacyInstallPath(targetDir, normalizedName);
|
|
29333
|
-
if (
|
|
28396
|
+
if (existsSync12(legacyInstallPath)) {
|
|
29334
28397
|
rmSync2(legacyInstallPath, { recursive: true });
|
|
29335
28398
|
}
|
|
29336
28399
|
return true;
|
|
@@ -29338,29 +28401,29 @@ function removeConnector(name, targetDir = process.cwd()) {
|
|
|
29338
28401
|
var __dirname4, CONNECTORS_DIR, PROJECT_CONNECTORS_DIRNAME = ".connectors", ENABLEMENT_MANIFEST_FILENAME = "manifest.json", ENABLEMENT_INDEX_FILENAME = "index.ts";
|
|
29339
28402
|
var init_installer = __esm(() => {
|
|
29340
28403
|
init_builtins();
|
|
29341
|
-
init_connector_resolver();
|
|
29342
28404
|
__dirname4 = dirname6(fileURLToPath4(import.meta.url));
|
|
29343
28405
|
CONNECTORS_DIR = resolveConnectorsDir();
|
|
29344
28406
|
});
|
|
29345
28407
|
|
|
29346
28408
|
// src/lib/lock.ts
|
|
29347
|
-
import { openSync, closeSync, unlinkSync as unlinkSync2, existsSync as
|
|
29348
|
-
import {
|
|
28409
|
+
import { openSync, closeSync, unlinkSync as unlinkSync2, existsSync as existsSync13, statSync as statSync5 } from "fs";
|
|
28410
|
+
import { join as join14 } from "path";
|
|
28411
|
+
import { mkdirSync as mkdirSync8 } from "fs";
|
|
29349
28412
|
function lockPath(connector) {
|
|
29350
|
-
const dir =
|
|
29351
|
-
|
|
29352
|
-
return
|
|
28413
|
+
const dir = join14(getConnectorsHome(), `connect-${connector}`);
|
|
28414
|
+
mkdirSync8(dir, { recursive: true });
|
|
28415
|
+
return join14(dir, ".write.lock");
|
|
29353
28416
|
}
|
|
29354
28417
|
function isStale(path) {
|
|
29355
28418
|
try {
|
|
29356
|
-
const stat =
|
|
28419
|
+
const stat = statSync5(path);
|
|
29357
28420
|
return Date.now() - stat.mtimeMs > STALE_LOCK_MS;
|
|
29358
28421
|
} catch {
|
|
29359
28422
|
return false;
|
|
29360
28423
|
}
|
|
29361
28424
|
}
|
|
29362
28425
|
function tryAcquire(path) {
|
|
29363
|
-
if (
|
|
28426
|
+
if (existsSync13(path) && isStale(path)) {
|
|
29364
28427
|
try {
|
|
29365
28428
|
unlinkSync2(path);
|
|
29366
28429
|
} catch {}
|
|
@@ -29381,7 +28444,6 @@ function release(path) {
|
|
|
29381
28444
|
} catch {}
|
|
29382
28445
|
}
|
|
29383
28446
|
async function withWriteLock(connector, fn) {
|
|
29384
|
-
connector = normalizeConnectorName(connector);
|
|
29385
28447
|
const path = lockPath(connector);
|
|
29386
28448
|
const deadline = Date.now() + LOCK_TIMEOUT_MS;
|
|
29387
28449
|
while (Date.now() < deadline) {
|
|
@@ -29398,7 +28460,7 @@ async function withWriteLock(connector, fn) {
|
|
|
29398
28460
|
}
|
|
29399
28461
|
var LOCK_TIMEOUT_MS = 5000, LOCK_RETRY_MS = 100, STALE_LOCK_MS = 30000, LockTimeoutError;
|
|
29400
28462
|
var init_lock = __esm(() => {
|
|
29401
|
-
|
|
28463
|
+
init_database();
|
|
29402
28464
|
LockTimeoutError = class LockTimeoutError extends Error {
|
|
29403
28465
|
connector;
|
|
29404
28466
|
constructor(connector) {
|
|
@@ -29410,11 +28472,10 @@ var init_lock = __esm(() => {
|
|
|
29410
28472
|
});
|
|
29411
28473
|
|
|
29412
28474
|
// src/server/auth.ts
|
|
29413
|
-
import { existsSync as
|
|
28475
|
+
import { existsSync as existsSync14, readFileSync as readFileSync7, writeFileSync as writeFileSync6, mkdirSync as mkdirSync9, readdirSync as readdirSync9, rmSync as rmSync3, statSync as statSync6 } from "fs";
|
|
29414
28476
|
import { randomBytes } from "crypto";
|
|
29415
28477
|
import { join as join15 } from "path";
|
|
29416
28478
|
function getAuthType(name) {
|
|
29417
|
-
name = normalizeConnectorName(name);
|
|
29418
28479
|
const docs = getConnectorDocs(name);
|
|
29419
28480
|
if (!docs?.auth)
|
|
29420
28481
|
return "apikey";
|
|
@@ -29425,65 +28486,53 @@ function getAuthType(name) {
|
|
|
29425
28486
|
return "bearer";
|
|
29426
28487
|
return "apikey";
|
|
29427
28488
|
}
|
|
29428
|
-
function
|
|
29429
|
-
|
|
29430
|
-
return
|
|
29431
|
-
}
|
|
29432
|
-
function getConnectorConfigReadDirs2(name) {
|
|
29433
|
-
name = normalizeConnectorName(name);
|
|
29434
|
-
return getConnectorConfigReadDirs(name);
|
|
28489
|
+
function getConnectorConfigDir(name) {
|
|
28490
|
+
const connectorName = name.startsWith("connect-") ? name : `connect-${name}`;
|
|
28491
|
+
return join15(getConnectorsHome(), connectorName);
|
|
29435
28492
|
}
|
|
29436
28493
|
function getCurrentProfile2(name) {
|
|
29437
|
-
|
|
29438
|
-
|
|
29439
|
-
|
|
29440
|
-
|
|
29441
|
-
|
|
29442
|
-
|
|
29443
|
-
|
|
29444
|
-
return "default";
|
|
29445
|
-
}
|
|
28494
|
+
const configDir = getConnectorConfigDir(name);
|
|
28495
|
+
const currentProfileFile = join15(configDir, "current_profile");
|
|
28496
|
+
if (existsSync14(currentProfileFile)) {
|
|
28497
|
+
try {
|
|
28498
|
+
return readFileSync7(currentProfileFile, "utf-8").trim() || "default";
|
|
28499
|
+
} catch {
|
|
28500
|
+
return "default";
|
|
29446
28501
|
}
|
|
29447
28502
|
}
|
|
29448
28503
|
return "default";
|
|
29449
28504
|
}
|
|
29450
|
-
function
|
|
28505
|
+
function loadProfileConfig(name) {
|
|
28506
|
+
const configDir = getConnectorConfigDir(name);
|
|
28507
|
+
const profile = getCurrentProfile2(name);
|
|
29451
28508
|
let flatConfig = {};
|
|
29452
28509
|
let dirConfig = {};
|
|
29453
28510
|
const profileFile = join15(configDir, "profiles", `${profile}.json`);
|
|
29454
|
-
if (
|
|
28511
|
+
if (existsSync14(profileFile)) {
|
|
29455
28512
|
try {
|
|
29456
28513
|
flatConfig = JSON.parse(readFileSync7(profileFile, "utf-8"));
|
|
29457
28514
|
} catch {}
|
|
29458
28515
|
}
|
|
29459
28516
|
const profileDirConfig = join15(configDir, "profiles", profile, "config.json");
|
|
29460
|
-
if (
|
|
28517
|
+
if (existsSync14(profileDirConfig)) {
|
|
29461
28518
|
try {
|
|
29462
28519
|
dirConfig = JSON.parse(readFileSync7(profileDirConfig, "utf-8"));
|
|
29463
28520
|
} catch {}
|
|
29464
28521
|
}
|
|
29465
|
-
|
|
29466
|
-
}
|
|
29467
|
-
function loadProfileConfig(name) {
|
|
29468
|
-
name = normalizeConnectorName(name);
|
|
29469
|
-
const profile = getCurrentProfile2(name);
|
|
29470
|
-
const merged = {};
|
|
29471
|
-
for (const configDir of [...getConnectorConfigReadDirs2(name)].reverse()) {
|
|
29472
|
-
Object.assign(merged, loadProfileConfigFromDir(configDir, profile));
|
|
28522
|
+
if (Object.keys(flatConfig).length === 0 && Object.keys(dirConfig).length === 0) {
|
|
28523
|
+
return {};
|
|
29473
28524
|
}
|
|
29474
|
-
return
|
|
28525
|
+
return { ...flatConfig, ...dirConfig };
|
|
29475
28526
|
}
|
|
29476
|
-
function
|
|
29477
|
-
|
|
28527
|
+
function loadTokens(name) {
|
|
28528
|
+
const configDir = getConnectorConfigDir(name);
|
|
29478
28529
|
const profile = getCurrentProfile2(name);
|
|
29479
|
-
|
|
29480
|
-
|
|
29481
|
-
|
|
29482
|
-
|
|
29483
|
-
|
|
29484
|
-
|
|
29485
|
-
return null;
|
|
29486
|
-
}
|
|
28530
|
+
const tokensFile = join15(configDir, "profiles", profile, "tokens.json");
|
|
28531
|
+
if (existsSync14(tokensFile)) {
|
|
28532
|
+
try {
|
|
28533
|
+
return JSON.parse(readFileSync7(tokensFile, "utf-8"));
|
|
28534
|
+
} catch {
|
|
28535
|
+
return null;
|
|
29487
28536
|
}
|
|
29488
28537
|
}
|
|
29489
28538
|
const profileConfig = loadProfileConfig(name);
|
|
@@ -29498,50 +28547,28 @@ function loadTokens3(name) {
|
|
|
29498
28547
|
}
|
|
29499
28548
|
return null;
|
|
29500
28549
|
}
|
|
29501
|
-
function isStoredOAuthEnvVarSet(variable, oauthConfig, tokens, profileConfig) {
|
|
29502
|
-
if (variable.endsWith("_CLIENT_ID")) {
|
|
29503
|
-
return Boolean(oauthConfig.clientId || profileConfig.clientId);
|
|
29504
|
-
}
|
|
29505
|
-
if (variable.endsWith("_CLIENT_SECRET")) {
|
|
29506
|
-
return Boolean(oauthConfig.clientSecret || profileConfig.clientSecret);
|
|
29507
|
-
}
|
|
29508
|
-
if (variable.endsWith("_ACCESS_TOKEN")) {
|
|
29509
|
-
return Boolean(tokens?.accessToken || profileConfig.accessToken);
|
|
29510
|
-
}
|
|
29511
|
-
if (variable.endsWith("_REFRESH_TOKEN")) {
|
|
29512
|
-
return Boolean(tokens?.refreshToken || profileConfig.refreshToken);
|
|
29513
|
-
}
|
|
29514
|
-
if (variable.endsWith("_TOKEN_EXPIRES_AT")) {
|
|
29515
|
-
return Boolean(tokens?.expiresAt || profileConfig.expiresAt);
|
|
29516
|
-
}
|
|
29517
|
-
return false;
|
|
29518
|
-
}
|
|
29519
28550
|
function getAuthStatus(name) {
|
|
29520
|
-
name = normalizeConnectorName(name);
|
|
29521
28551
|
const authType = getAuthType(name);
|
|
29522
28552
|
const docs = getConnectorDocs(name);
|
|
29523
|
-
const oauthConfig = authType === "oauth" ? getOAuthConfig(name) : {};
|
|
29524
|
-
const tokens = authType === "oauth" ? loadTokens3(name) : null;
|
|
29525
|
-
const profileConfig = authType === "oauth" ? loadProfileConfig(name) : {};
|
|
29526
28553
|
const envVars = (docs?.envVars || []).map((v) => ({
|
|
29527
28554
|
variable: v.variable,
|
|
29528
28555
|
description: v.description,
|
|
29529
|
-
set: !!process.env[v.variable]
|
|
28556
|
+
set: !!process.env[v.variable]
|
|
29530
28557
|
}));
|
|
29531
28558
|
const envVarTotalCount = envVars.length;
|
|
29532
28559
|
const envVarSetCount = envVars.filter((v) => v.set).length;
|
|
29533
28560
|
if (authType === "oauth") {
|
|
29534
|
-
const
|
|
29535
|
-
const
|
|
29536
|
-
const
|
|
29537
|
-
const
|
|
28561
|
+
const tokens = loadTokens(name);
|
|
28562
|
+
const config2 = loadProfileConfig(name);
|
|
28563
|
+
const hasTokens = !!tokens?.accessToken || !!config2.accessToken;
|
|
28564
|
+
const hasRefreshToken = !!tokens?.refreshToken || !!config2.refreshToken;
|
|
28565
|
+
const tokenExpiry = tokens?.expiresAt || config2.expiresAt;
|
|
29538
28566
|
const hasEnvVar2 = envVars.some((v) => v.set);
|
|
29539
28567
|
return {
|
|
29540
28568
|
type: "oauth",
|
|
29541
|
-
configured: hasTokens || hasRefreshToken ||
|
|
28569
|
+
configured: hasTokens || hasRefreshToken || hasEnvVar2,
|
|
29542
28570
|
tokenExpiry,
|
|
29543
28571
|
hasRefreshToken,
|
|
29544
|
-
hasOAuthCredentials,
|
|
29545
28572
|
envVars,
|
|
29546
28573
|
envVarSetCount,
|
|
29547
28574
|
envVarTotalCount
|
|
@@ -29559,24 +28586,21 @@ function getAuthStatus(name) {
|
|
|
29559
28586
|
};
|
|
29560
28587
|
}
|
|
29561
28588
|
function getEnvVars(name) {
|
|
29562
|
-
name = normalizeConnectorName(name);
|
|
29563
28589
|
const docs = getConnectorDocs(name);
|
|
29564
28590
|
return docs?.envVars || [];
|
|
29565
28591
|
}
|
|
29566
28592
|
async function saveApiKey(name, key, field) {
|
|
29567
|
-
name = normalizeConnectorName(name);
|
|
29568
28593
|
return withWriteLock(name, () => _saveApiKey(name, key, field));
|
|
29569
28594
|
}
|
|
29570
28595
|
function _saveApiKey(name, key, field) {
|
|
29571
|
-
|
|
29572
|
-
const configDir = getConnectorConfigDir2(name);
|
|
28596
|
+
const configDir = getConnectorConfigDir(name);
|
|
29573
28597
|
const profile = getCurrentProfile2(name);
|
|
29574
28598
|
const keyField = field || guessKeyField(name);
|
|
29575
28599
|
if (keyField === "clientId" || keyField === "clientSecret") {
|
|
29576
28600
|
const credentialsFile = join15(configDir, "credentials.json");
|
|
29577
|
-
|
|
28601
|
+
mkdirSync9(configDir, { recursive: true });
|
|
29578
28602
|
let creds = {};
|
|
29579
|
-
if (
|
|
28603
|
+
if (existsSync14(credentialsFile)) {
|
|
29580
28604
|
try {
|
|
29581
28605
|
creds = JSON.parse(readFileSync7(credentialsFile, "utf-8"));
|
|
29582
28606
|
} catch {}
|
|
@@ -29587,7 +28611,7 @@ function _saveApiKey(name, key, field) {
|
|
|
29587
28611
|
}
|
|
29588
28612
|
const profileFile = join15(configDir, "profiles", `${profile}.json`);
|
|
29589
28613
|
const profileDir = join15(configDir, "profiles", profile);
|
|
29590
|
-
if (
|
|
28614
|
+
if (existsSync14(profileFile)) {
|
|
29591
28615
|
let config = {};
|
|
29592
28616
|
try {
|
|
29593
28617
|
config = JSON.parse(readFileSync7(profileFile, "utf-8"));
|
|
@@ -29596,10 +28620,10 @@ function _saveApiKey(name, key, field) {
|
|
|
29596
28620
|
writeFileSync6(profileFile, JSON.stringify(config, null, 2));
|
|
29597
28621
|
return;
|
|
29598
28622
|
}
|
|
29599
|
-
if (
|
|
28623
|
+
if (existsSync14(profileDir)) {
|
|
29600
28624
|
const configFile = join15(profileDir, "config.json");
|
|
29601
28625
|
let config = {};
|
|
29602
|
-
if (
|
|
28626
|
+
if (existsSync14(configFile)) {
|
|
29603
28627
|
try {
|
|
29604
28628
|
config = JSON.parse(readFileSync7(configFile, "utf-8"));
|
|
29605
28629
|
} catch {}
|
|
@@ -29608,11 +28632,10 @@ function _saveApiKey(name, key, field) {
|
|
|
29608
28632
|
writeFileSync6(configFile, JSON.stringify(config, null, 2));
|
|
29609
28633
|
return;
|
|
29610
28634
|
}
|
|
29611
|
-
|
|
28635
|
+
mkdirSync9(profileDir, { recursive: true });
|
|
29612
28636
|
writeFileSync6(join15(profileDir, "config.json"), JSON.stringify({ [keyField]: key }, null, 2));
|
|
29613
28637
|
}
|
|
29614
28638
|
function guessKeyField(name) {
|
|
29615
|
-
name = normalizeConnectorName(name);
|
|
29616
28639
|
const docs = getConnectorDocs(name);
|
|
29617
28640
|
if (!docs?.envVars.length)
|
|
29618
28641
|
return "apiKey";
|
|
@@ -29627,15 +28650,13 @@ function guessKeyField(name) {
|
|
|
29627
28650
|
return "apiKey";
|
|
29628
28651
|
}
|
|
29629
28652
|
function getOAuthConfig(name) {
|
|
29630
|
-
|
|
29631
|
-
|
|
29632
|
-
|
|
29633
|
-
|
|
29634
|
-
|
|
29635
|
-
|
|
29636
|
-
|
|
29637
|
-
} catch {}
|
|
29638
|
-
}
|
|
28653
|
+
const configDir = getConnectorConfigDir(name);
|
|
28654
|
+
const credentialsFile = join15(configDir, "credentials.json");
|
|
28655
|
+
if (existsSync14(credentialsFile)) {
|
|
28656
|
+
try {
|
|
28657
|
+
const creds = JSON.parse(readFileSync7(credentialsFile, "utf-8"));
|
|
28658
|
+
return { clientId: creds.clientId, clientSecret: creds.clientSecret };
|
|
28659
|
+
} catch {}
|
|
29639
28660
|
}
|
|
29640
28661
|
const config = loadProfileConfig(name);
|
|
29641
28662
|
return {
|
|
@@ -29644,7 +28665,6 @@ function getOAuthConfig(name) {
|
|
|
29644
28665
|
};
|
|
29645
28666
|
}
|
|
29646
28667
|
function getOAuthStartUrl(name, redirectUri) {
|
|
29647
|
-
name = normalizeConnectorName(name);
|
|
29648
28668
|
const oauthConfig = getOAuthConfig(name);
|
|
29649
28669
|
if (!oauthConfig.clientId)
|
|
29650
28670
|
return null;
|
|
@@ -29670,7 +28690,6 @@ function getOAuthStartUrl(name, redirectUri) {
|
|
|
29670
28690
|
return `${GOOGLE_AUTH_URL}?${params.toString()}`;
|
|
29671
28691
|
}
|
|
29672
28692
|
function validateOAuthState(state, expectedConnector) {
|
|
29673
|
-
expectedConnector = normalizeConnectorName(expectedConnector);
|
|
29674
28693
|
if (!state)
|
|
29675
28694
|
return false;
|
|
29676
28695
|
const entry = oauthStateStore.get(state);
|
|
@@ -29680,7 +28699,6 @@ function validateOAuthState(state, expectedConnector) {
|
|
|
29680
28699
|
return Date.now() - entry.createdAt < 10 * 60 * 1000;
|
|
29681
28700
|
}
|
|
29682
28701
|
async function exchangeOAuthCode(name, code, redirectUri) {
|
|
29683
|
-
name = normalizeConnectorName(name);
|
|
29684
28702
|
const oauthConfig = getOAuthConfig(name);
|
|
29685
28703
|
if (!oauthConfig.clientId || !oauthConfig.clientSecret) {
|
|
29686
28704
|
throw new Error("OAuth credentials not configured for " + name);
|
|
@@ -29713,22 +28731,19 @@ async function exchangeOAuthCode(name, code, redirectUri) {
|
|
|
29713
28731
|
return tokens;
|
|
29714
28732
|
}
|
|
29715
28733
|
function saveOAuthTokens(name, tokens) {
|
|
29716
|
-
|
|
29717
|
-
const configDir = getConnectorConfigDir2(name);
|
|
28734
|
+
const configDir = getConnectorConfigDir(name);
|
|
29718
28735
|
const profile = getCurrentProfile2(name);
|
|
29719
28736
|
const profileDir = join15(configDir, "profiles", profile);
|
|
29720
|
-
|
|
28737
|
+
mkdirSync9(profileDir, { recursive: true });
|
|
29721
28738
|
const tokensFile = join15(profileDir, "tokens.json");
|
|
29722
28739
|
writeFileSync6(tokensFile, JSON.stringify(tokens, null, 2), { mode: 384 });
|
|
29723
28740
|
}
|
|
29724
28741
|
async function refreshOAuthToken(name) {
|
|
29725
|
-
name = normalizeConnectorName(name);
|
|
29726
28742
|
return withWriteLock(name, () => _refreshOAuthToken(name));
|
|
29727
28743
|
}
|
|
29728
28744
|
async function _refreshOAuthToken(name) {
|
|
29729
|
-
name = normalizeConnectorName(name);
|
|
29730
28745
|
const oauthConfig = getOAuthConfig(name);
|
|
29731
|
-
const currentTokens =
|
|
28746
|
+
const currentTokens = loadTokens(name);
|
|
29732
28747
|
if (!oauthConfig.clientId || !oauthConfig.clientSecret) {
|
|
29733
28748
|
throw new Error("OAuth credentials not configured for " + name);
|
|
29734
28749
|
}
|
|
@@ -29761,43 +28776,39 @@ async function _refreshOAuthToken(name) {
|
|
|
29761
28776
|
saveOAuthTokens(name, tokens);
|
|
29762
28777
|
return tokens;
|
|
29763
28778
|
}
|
|
29764
|
-
function
|
|
29765
|
-
|
|
28779
|
+
function listProfiles2(name) {
|
|
28780
|
+
const configDir = getConnectorConfigDir(name);
|
|
28781
|
+
const profilesDir = join15(configDir, "profiles");
|
|
28782
|
+
if (!existsSync14(profilesDir))
|
|
28783
|
+
return ["default"];
|
|
29766
28784
|
const seen = new Set;
|
|
29767
|
-
|
|
29768
|
-
const
|
|
29769
|
-
|
|
29770
|
-
|
|
29771
|
-
|
|
29772
|
-
|
|
29773
|
-
|
|
29774
|
-
|
|
29775
|
-
|
|
29776
|
-
if (stat.isDirectory()) {
|
|
29777
|
-
seen.add(entry);
|
|
29778
|
-
} else if (entry.endsWith(".json")) {
|
|
29779
|
-
seen.add(entry.replace(/\.json$/, ""));
|
|
29780
|
-
}
|
|
28785
|
+
try {
|
|
28786
|
+
const entries = readdirSync9(profilesDir);
|
|
28787
|
+
for (const entry of entries) {
|
|
28788
|
+
const fullPath = join15(profilesDir, entry);
|
|
28789
|
+
const stat = statSync6(fullPath);
|
|
28790
|
+
if (stat.isDirectory()) {
|
|
28791
|
+
seen.add(entry);
|
|
28792
|
+
} else if (entry.endsWith(".json")) {
|
|
28793
|
+
seen.add(entry.replace(/\.json$/, ""));
|
|
29781
28794
|
}
|
|
29782
|
-
}
|
|
29783
|
-
}
|
|
28795
|
+
}
|
|
28796
|
+
} catch {}
|
|
29784
28797
|
seen.add("default");
|
|
29785
28798
|
return Array.from(seen).sort();
|
|
29786
28799
|
}
|
|
29787
28800
|
function switchProfile(name, profile) {
|
|
29788
|
-
|
|
29789
|
-
|
|
29790
|
-
mkdirSync8(configDir, { recursive: true });
|
|
28801
|
+
const configDir = getConnectorConfigDir(name);
|
|
28802
|
+
mkdirSync9(configDir, { recursive: true });
|
|
29791
28803
|
writeFileSync6(join15(configDir, "current_profile"), profile);
|
|
29792
28804
|
}
|
|
29793
28805
|
function deleteProfile2(name, profile) {
|
|
29794
|
-
name = normalizeConnectorName(name);
|
|
29795
28806
|
if (profile === "default")
|
|
29796
28807
|
return false;
|
|
29797
|
-
const configDir =
|
|
28808
|
+
const configDir = getConnectorConfigDir(name);
|
|
29798
28809
|
const profilesDir = join15(configDir, "profiles");
|
|
29799
28810
|
const profileFile = join15(profilesDir, `${profile}.json`);
|
|
29800
|
-
if (
|
|
28811
|
+
if (existsSync14(profileFile)) {
|
|
29801
28812
|
rmSync3(profileFile);
|
|
29802
28813
|
if (getCurrentProfile2(name) === profile) {
|
|
29803
28814
|
switchProfile(name, "default");
|
|
@@ -29805,7 +28816,7 @@ function deleteProfile2(name, profile) {
|
|
|
29805
28816
|
return true;
|
|
29806
28817
|
}
|
|
29807
28818
|
const profileDir = join15(profilesDir, profile);
|
|
29808
|
-
if (
|
|
28819
|
+
if (existsSync14(profileDir)) {
|
|
29809
28820
|
rmSync3(profileDir, { recursive: true });
|
|
29810
28821
|
if (getCurrentProfile2(name) === profile) {
|
|
29811
28822
|
switchProfile(name, "default");
|
|
@@ -29818,7 +28829,7 @@ var FETCH_TIMEOUT = 1e4, oauthStateStore, GOOGLE_AUTH_URL = "https://accounts.go
|
|
|
29818
28829
|
var init_auth = __esm(() => {
|
|
29819
28830
|
init_installer();
|
|
29820
28831
|
init_lock();
|
|
29821
|
-
|
|
28832
|
+
init_database();
|
|
29822
28833
|
oauthStateStore = new Map;
|
|
29823
28834
|
GOOGLE_SCOPES = {
|
|
29824
28835
|
gmail: [
|
|
@@ -30068,14 +29079,14 @@ var init_rate = __esm(() => {
|
|
|
30068
29079
|
});
|
|
30069
29080
|
|
|
30070
29081
|
// src/lib/llm.ts
|
|
30071
|
-
import { existsSync as
|
|
29082
|
+
import { existsSync as existsSync15, readFileSync as readFileSync8, writeFileSync as writeFileSync7, mkdirSync as mkdirSync10 } from "fs";
|
|
30072
29083
|
import { join as join16 } from "path";
|
|
30073
29084
|
function getLlmConfigPath() {
|
|
30074
29085
|
return join16(getConnectorsHome(), "llm.json");
|
|
30075
29086
|
}
|
|
30076
29087
|
function getLlmConfig() {
|
|
30077
29088
|
const path = getLlmConfigPath();
|
|
30078
|
-
if (!
|
|
29089
|
+
if (!existsSync15(path))
|
|
30079
29090
|
return null;
|
|
30080
29091
|
try {
|
|
30081
29092
|
return JSON.parse(readFileSync8(path, "utf-8"));
|
|
@@ -30085,7 +29096,7 @@ function getLlmConfig() {
|
|
|
30085
29096
|
}
|
|
30086
29097
|
function saveLlmConfig(config) {
|
|
30087
29098
|
const dir = getConnectorsHome();
|
|
30088
|
-
|
|
29099
|
+
mkdirSync10(dir, { recursive: true });
|
|
30089
29100
|
writeFileSync7(getLlmConfigPath(), JSON.stringify(config, null, 2));
|
|
30090
29101
|
}
|
|
30091
29102
|
function setLlmStrip(enabled) {
|
|
@@ -30469,7 +29480,7 @@ var init_scheduler = __esm(() => {
|
|
|
30469
29480
|
});
|
|
30470
29481
|
|
|
30471
29482
|
// src/lib/workflow-runner.ts
|
|
30472
|
-
import { spawn as
|
|
29483
|
+
import { spawn as spawn2 } from "child_process";
|
|
30473
29484
|
async function runStep(step, previousOutput) {
|
|
30474
29485
|
return new Promise((resolve) => {
|
|
30475
29486
|
const args = [...step.args ?? []];
|
|
@@ -30477,7 +29488,7 @@ async function runStep(step, previousOutput) {
|
|
|
30477
29488
|
args.push("--input", previousOutput.trim().slice(0, 4096));
|
|
30478
29489
|
}
|
|
30479
29490
|
const cmdArgs = ["run", step.connector, step.command, ...args, "--format", "json"];
|
|
30480
|
-
const proc =
|
|
29491
|
+
const proc = spawn2("connectors", cmdArgs, { shell: false });
|
|
30481
29492
|
let output = "";
|
|
30482
29493
|
proc.stdout.on("data", (d) => {
|
|
30483
29494
|
output += d.toString();
|
|
@@ -30517,23 +29528,21 @@ async function runWorkflow(workflow) {
|
|
|
30517
29528
|
final_output: results[results.length - 1]?.output ?? ""
|
|
30518
29529
|
};
|
|
30519
29530
|
}
|
|
30520
|
-
var spawnImpl;
|
|
30521
29531
|
var init_workflow_runner = __esm(() => {
|
|
30522
29532
|
init_strip();
|
|
30523
|
-
spawnImpl = nodeSpawn;
|
|
30524
29533
|
});
|
|
30525
29534
|
|
|
30526
29535
|
// src/lib/runner.ts
|
|
30527
|
-
import { existsSync as
|
|
29536
|
+
import { existsSync as existsSync16, readdirSync as readdirSync10 } from "fs";
|
|
30528
29537
|
import { join as join17, dirname as dirname7 } from "path";
|
|
30529
29538
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
30530
|
-
import { spawn as
|
|
29539
|
+
import { spawn as spawn3 } from "child_process";
|
|
30531
29540
|
function resolveConnectorsDir2() {
|
|
30532
29541
|
const fromBin = join17(__dirname5, "..", "connectors");
|
|
30533
|
-
if (
|
|
29542
|
+
if (existsSync16(fromBin))
|
|
30534
29543
|
return fromBin;
|
|
30535
29544
|
const fromSrc = join17(__dirname5, "..", "..", "connectors");
|
|
30536
|
-
if (
|
|
29545
|
+
if (existsSync16(fromSrc))
|
|
30537
29546
|
return fromSrc;
|
|
30538
29547
|
return fromBin;
|
|
30539
29548
|
}
|
|
@@ -30554,9 +29563,8 @@ function getInternalCommandRuntime(name) {
|
|
|
30554
29563
|
}
|
|
30555
29564
|
function buildEnvWithCredentials(connectorName, baseEnv) {
|
|
30556
29565
|
const env = { ...baseEnv };
|
|
30557
|
-
const
|
|
30558
|
-
|
|
30559
|
-
normalizedConnectorName.toUpperCase().replace(/-/g, "_")
|
|
29566
|
+
const prefixes = ENV_VAR_NAME_OVERRIDES[connectorName] || [
|
|
29567
|
+
connectorName.toUpperCase().replace(/-/g, "_")
|
|
30560
29568
|
];
|
|
30561
29569
|
for (const prefix of prefixes) {
|
|
30562
29570
|
const canonicalKey = `${prefix}_API_KEY`;
|
|
@@ -30577,32 +29585,13 @@ function buildEnvWithCredentials(connectorName, baseEnv) {
|
|
|
30577
29585
|
}
|
|
30578
29586
|
}
|
|
30579
29587
|
}
|
|
30580
|
-
if (getAuthType(normalizedConnectorName) === "oauth") {
|
|
30581
|
-
const oauthConfig = getOAuthConfig(normalizedConnectorName);
|
|
30582
|
-
const tokens = loadTokens3(normalizedConnectorName);
|
|
30583
|
-
for (const { variable } of getEnvVars(normalizedConnectorName)) {
|
|
30584
|
-
if (env[variable])
|
|
30585
|
-
continue;
|
|
30586
|
-
if (variable.endsWith("_CLIENT_ID") && oauthConfig.clientId) {
|
|
30587
|
-
env[variable] = oauthConfig.clientId;
|
|
30588
|
-
} else if (variable.endsWith("_CLIENT_SECRET") && oauthConfig.clientSecret) {
|
|
30589
|
-
env[variable] = oauthConfig.clientSecret;
|
|
30590
|
-
} else if (variable.endsWith("_ACCESS_TOKEN") && tokens?.accessToken) {
|
|
30591
|
-
env[variable] = tokens.accessToken;
|
|
30592
|
-
} else if (variable.endsWith("_REFRESH_TOKEN") && tokens?.refreshToken) {
|
|
30593
|
-
env[variable] = tokens.refreshToken;
|
|
30594
|
-
} else if (variable.endsWith("_TOKEN_EXPIRES_AT") && tokens?.expiresAt) {
|
|
30595
|
-
env[variable] = String(tokens.expiresAt);
|
|
30596
|
-
}
|
|
30597
|
-
}
|
|
30598
|
-
}
|
|
30599
29588
|
return env;
|
|
30600
29589
|
}
|
|
30601
29590
|
function getConnectorCliPath(name) {
|
|
30602
|
-
const safeName =
|
|
30603
|
-
const connectorDir =
|
|
29591
|
+
const safeName = name.replace(/[^a-z0-9-]/g, "");
|
|
29592
|
+
const connectorDir = join17(CONNECTORS_DIR2, `connect-${safeName}`);
|
|
30604
29593
|
const cliPath = join17(connectorDir, "src", "cli", "index.ts");
|
|
30605
|
-
if (
|
|
29594
|
+
if (existsSync16(cliPath))
|
|
30606
29595
|
return cliPath;
|
|
30607
29596
|
return null;
|
|
30608
29597
|
}
|
|
@@ -30640,7 +29629,7 @@ function parseCommanderHelpOperations(helpText) {
|
|
|
30640
29629
|
inCommands = false;
|
|
30641
29630
|
continue;
|
|
30642
29631
|
}
|
|
30643
|
-
const row = line.match(/^ {2}(
|
|
29632
|
+
const row = line.match(/^ {2}(\S.*?)(?: {2,}(.+))?$/);
|
|
30644
29633
|
if (!row)
|
|
30645
29634
|
continue;
|
|
30646
29635
|
const usage = row[1].trim();
|
|
@@ -30657,9 +29646,8 @@ function parseCommanderHelpOperations(helpText) {
|
|
|
30657
29646
|
return operations;
|
|
30658
29647
|
}
|
|
30659
29648
|
function runConnectorCommand2(name, args, timeoutMs = 30000) {
|
|
30660
|
-
const connectorName = normalizeConnectorName(name);
|
|
30661
29649
|
getConnectorsHome();
|
|
30662
|
-
const internalRuntime = getInternalCommandRuntime(
|
|
29650
|
+
const internalRuntime = getInternalCommandRuntime(name);
|
|
30663
29651
|
if (internalRuntime?.run) {
|
|
30664
29652
|
return Promise.resolve(internalRuntime.run(args)).then((result) => {
|
|
30665
29653
|
if (result) {
|
|
@@ -30673,133 +29661,25 @@ function runConnectorCommand2(name, args, timeoutMs = 30000) {
|
|
|
30673
29661
|
success: result.success ?? exitCode === 0
|
|
30674
29662
|
};
|
|
30675
29663
|
}
|
|
30676
|
-
return runLegacyConnectorCommand(
|
|
29664
|
+
return runLegacyConnectorCommand(name, args, timeoutMs);
|
|
30677
29665
|
});
|
|
30678
29666
|
}
|
|
30679
|
-
return runLegacyConnectorCommand(
|
|
30680
|
-
}
|
|
30681
|
-
async function runConnectorOperation(args) {
|
|
30682
|
-
const connectorName = normalizeConnectorName(args.connector);
|
|
30683
|
-
const internal = getInternalConnectorDefinition(connectorName);
|
|
30684
|
-
if (internal?.operations[args.operation]) {
|
|
30685
|
-
try {
|
|
30686
|
-
const operationData = await executeConnectorOperation(internal, {
|
|
30687
|
-
operation: args.operation,
|
|
30688
|
-
input: args.input,
|
|
30689
|
-
profile: args.profile
|
|
30690
|
-
});
|
|
30691
|
-
const commandResult = normalizeOperationReturn(operationData);
|
|
30692
|
-
return {
|
|
30693
|
-
connector: connectorName,
|
|
30694
|
-
operation: args.operation,
|
|
30695
|
-
profile: args.profile,
|
|
30696
|
-
...commandResult
|
|
30697
|
-
};
|
|
30698
|
-
} catch (error) {
|
|
30699
|
-
return {
|
|
30700
|
-
connector: connectorName,
|
|
30701
|
-
operation: args.operation,
|
|
30702
|
-
profile: args.profile,
|
|
30703
|
-
stdout: "",
|
|
30704
|
-
stderr: error.message,
|
|
30705
|
-
exitCode: 1,
|
|
30706
|
-
success: false
|
|
30707
|
-
};
|
|
30708
|
-
}
|
|
30709
|
-
}
|
|
30710
|
-
const commandArgs = buildConnectorOperationArgs(args);
|
|
30711
|
-
const result = await runConnectorCommand2(connectorName, commandArgs, args.timeoutMs ?? 30000);
|
|
30712
|
-
const response = {
|
|
30713
|
-
...result,
|
|
30714
|
-
connector: connectorName,
|
|
30715
|
-
operation: args.operation,
|
|
30716
|
-
profile: args.profile
|
|
30717
|
-
};
|
|
30718
|
-
if (args.parseJson !== false && result.stdout) {
|
|
30719
|
-
try {
|
|
30720
|
-
response.data = JSON.parse(result.stdout);
|
|
30721
|
-
} catch {}
|
|
30722
|
-
}
|
|
30723
|
-
return response;
|
|
30724
|
-
}
|
|
30725
|
-
function normalizeOperationReturn(value) {
|
|
30726
|
-
if (isRunResult(value)) {
|
|
30727
|
-
const result = value;
|
|
30728
|
-
const response = {
|
|
30729
|
-
...result
|
|
30730
|
-
};
|
|
30731
|
-
if (result.stdout) {
|
|
30732
|
-
try {
|
|
30733
|
-
response.data = JSON.parse(result.stdout);
|
|
30734
|
-
} catch {}
|
|
30735
|
-
}
|
|
30736
|
-
return response;
|
|
30737
|
-
}
|
|
30738
|
-
return {
|
|
30739
|
-
data: value,
|
|
30740
|
-
stdout: JSON.stringify(value),
|
|
30741
|
-
stderr: "",
|
|
30742
|
-
exitCode: 0,
|
|
30743
|
-
success: true
|
|
30744
|
-
};
|
|
30745
|
-
}
|
|
30746
|
-
function isRunResult(value) {
|
|
30747
|
-
if (!value || typeof value !== "object")
|
|
30748
|
-
return false;
|
|
30749
|
-
const candidate = value;
|
|
30750
|
-
return typeof candidate.stdout === "string" && typeof candidate.stderr === "string" && typeof candidate.exitCode === "number" && typeof candidate.success === "boolean";
|
|
30751
|
-
}
|
|
30752
|
-
function buildConnectorOperationArgs(args) {
|
|
30753
|
-
const commandArgs = [];
|
|
30754
|
-
if (args.profile) {
|
|
30755
|
-
commandArgs.push("--profile", args.profile);
|
|
30756
|
-
}
|
|
30757
|
-
commandArgs.push(...args.operation.split(".").filter(Boolean));
|
|
30758
|
-
for (const positional of args.input?.args ?? []) {
|
|
30759
|
-
commandArgs.push(String(positional));
|
|
30760
|
-
}
|
|
30761
|
-
let hasFormat = false;
|
|
30762
|
-
for (const [key, value] of Object.entries(args.input ?? {})) {
|
|
30763
|
-
if (key === "args")
|
|
30764
|
-
continue;
|
|
30765
|
-
if (value === undefined || value === null)
|
|
30766
|
-
continue;
|
|
30767
|
-
const flag = `--${key.replace(/_/g, "-").replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`)}`;
|
|
30768
|
-
if (flag === "--format" || flag === "--json")
|
|
30769
|
-
hasFormat = true;
|
|
30770
|
-
if (typeof value === "boolean") {
|
|
30771
|
-
if (value)
|
|
30772
|
-
commandArgs.push(flag);
|
|
30773
|
-
continue;
|
|
30774
|
-
}
|
|
30775
|
-
if (Array.isArray(value)) {
|
|
30776
|
-
for (const item of value) {
|
|
30777
|
-
commandArgs.push(flag, String(item));
|
|
30778
|
-
}
|
|
30779
|
-
continue;
|
|
30780
|
-
}
|
|
30781
|
-
commandArgs.push(flag, String(value));
|
|
30782
|
-
}
|
|
30783
|
-
if (args.parseJson !== false && !hasFormat) {
|
|
30784
|
-
commandArgs.push("--format", "json");
|
|
30785
|
-
}
|
|
30786
|
-
return commandArgs;
|
|
29667
|
+
return runLegacyConnectorCommand(name, args, timeoutMs);
|
|
30787
29668
|
}
|
|
30788
29669
|
function runLegacyConnectorCommand(name, args, timeoutMs = 30000) {
|
|
30789
|
-
const
|
|
30790
|
-
const cliPath = getConnectorCliPath(connectorName);
|
|
29670
|
+
const cliPath = getConnectorCliPath(name);
|
|
30791
29671
|
if (!cliPath) {
|
|
30792
29672
|
return Promise.resolve({
|
|
30793
29673
|
stdout: "",
|
|
30794
|
-
stderr: `Connector '${
|
|
29674
|
+
stderr: `Connector '${name}' not found or has no CLI.`,
|
|
30795
29675
|
exitCode: 1,
|
|
30796
29676
|
success: false
|
|
30797
29677
|
});
|
|
30798
29678
|
}
|
|
30799
29679
|
return new Promise((resolve) => {
|
|
30800
|
-
const proc =
|
|
29680
|
+
const proc = spawn3("bun", ["run", cliPath, ...args], {
|
|
30801
29681
|
timeout: timeoutMs,
|
|
30802
|
-
env: buildEnvWithCredentials(
|
|
29682
|
+
env: buildEnvWithCredentials(name, process.env),
|
|
30803
29683
|
stdio: ["pipe", "pipe", "pipe"]
|
|
30804
29684
|
});
|
|
30805
29685
|
let stdout = "";
|
|
@@ -30829,8 +29709,7 @@ function runLegacyConnectorCommand(name, args, timeoutMs = 30000) {
|
|
|
30829
29709
|
});
|
|
30830
29710
|
}
|
|
30831
29711
|
async function getConnectorOperations(name) {
|
|
30832
|
-
const
|
|
30833
|
-
const internalRuntime = getInternalCommandRuntime(connectorName);
|
|
29712
|
+
const internalRuntime = getInternalCommandRuntime(name);
|
|
30834
29713
|
if (internalRuntime?.commands.length) {
|
|
30835
29714
|
const operations2 = internalRuntime.commands.map((command) => ({
|
|
30836
29715
|
name: command.name,
|
|
@@ -30842,15 +29721,15 @@ async function getConnectorOperations(name) {
|
|
|
30842
29721
|
return {
|
|
30843
29722
|
commands: operations2.map((operation) => operation.name),
|
|
30844
29723
|
operations: operations2,
|
|
30845
|
-
helpText: internalRuntime.helpText ?? buildInternalHelpText(
|
|
29724
|
+
helpText: internalRuntime.helpText ?? buildInternalHelpText(name, internalRuntime.commands),
|
|
30846
29725
|
hasCli: true
|
|
30847
29726
|
};
|
|
30848
29727
|
}
|
|
30849
|
-
const cliPath = getConnectorCliPath(
|
|
29728
|
+
const cliPath = getConnectorCliPath(name);
|
|
30850
29729
|
if (!cliPath) {
|
|
30851
29730
|
return { commands: [], operations: [], helpText: "", hasCli: false };
|
|
30852
29731
|
}
|
|
30853
|
-
const result = await runConnectorCommand2(
|
|
29732
|
+
const result = await runConnectorCommand2(name, ["--help"]);
|
|
30854
29733
|
const helpText = result.stdout || result.stderr;
|
|
30855
29734
|
const operations = parseCommanderHelpOperations(helpText);
|
|
30856
29735
|
return {
|
|
@@ -30861,8 +29740,7 @@ async function getConnectorOperations(name) {
|
|
|
30861
29740
|
};
|
|
30862
29741
|
}
|
|
30863
29742
|
async function getConnectorCommandHelp(name, command) {
|
|
30864
|
-
const
|
|
30865
|
-
const internalRuntime = getInternalCommandRuntime(connectorName);
|
|
29743
|
+
const internalRuntime = getInternalCommandRuntime(name);
|
|
30866
29744
|
if (internalRuntime?.getHelp) {
|
|
30867
29745
|
const help = await internalRuntime.getHelp(command);
|
|
30868
29746
|
if (help) {
|
|
@@ -30873,16 +29751,13 @@ async function getConnectorCommandHelp(name, command) {
|
|
|
30873
29751
|
if (runtimeCommand?.helpText) {
|
|
30874
29752
|
return runtimeCommand.helpText;
|
|
30875
29753
|
}
|
|
30876
|
-
const result = await runConnectorCommand2(
|
|
29754
|
+
const result = await runConnectorCommand2(name, [command, "--help"]);
|
|
30877
29755
|
return result.stdout || result.stderr;
|
|
30878
29756
|
}
|
|
30879
29757
|
var __dirname5, CONNECTORS_DIR2, ENV_VAR_NAME_OVERRIDES;
|
|
30880
29758
|
var init_runner = __esm(() => {
|
|
30881
29759
|
init_builtins();
|
|
30882
|
-
init_connector();
|
|
30883
29760
|
init_database();
|
|
30884
|
-
init_auth();
|
|
30885
|
-
init_connector_resolver();
|
|
30886
29761
|
__dirname5 = dirname7(fileURLToPath5(import.meta.url));
|
|
30887
29762
|
CONNECTORS_DIR2 = resolveConnectorsDir2();
|
|
30888
29763
|
ENV_VAR_NAME_OVERRIDES = {
|
|
@@ -30894,88 +29769,13 @@ var init_runner = __esm(() => {
|
|
|
30894
29769
|
};
|
|
30895
29770
|
});
|
|
30896
29771
|
|
|
30897
|
-
// src/lib/manifest.ts
|
|
30898
|
-
function buildAliases(name) {
|
|
30899
|
-
const canonicalName = normalizeConnectorName(name);
|
|
30900
|
-
const legacyName = legacyConnectorName(canonicalName);
|
|
30901
|
-
return canonicalName === legacyName ? [canonicalName] : [canonicalName, legacyName];
|
|
30902
|
-
}
|
|
30903
|
-
async function loadOperations(name, includeOperations) {
|
|
30904
|
-
if (!includeOperations || !hasConnectorCommandSurface(name))
|
|
30905
|
-
return;
|
|
30906
|
-
return (await getConnectorOperations(name)).operations;
|
|
30907
|
-
}
|
|
30908
|
-
async function getConnectorCapability(name, options = {}) {
|
|
30909
|
-
const connectorName = normalizeConnectorName(name);
|
|
30910
|
-
const meta = getConnector(connectorName);
|
|
30911
|
-
if (!meta)
|
|
30912
|
-
return null;
|
|
30913
|
-
const docs = getConnectorDocs(connectorName);
|
|
30914
|
-
const configPaths = resolveConnectorConfigPaths(connectorName);
|
|
30915
|
-
const operations = await loadOperations(connectorName, options.includeOperations);
|
|
30916
|
-
return {
|
|
30917
|
-
...meta,
|
|
30918
|
-
id: connectorName,
|
|
30919
|
-
aliases: buildAliases(connectorName),
|
|
30920
|
-
runtime: {
|
|
30921
|
-
packageName: "@hasna/connectors",
|
|
30922
|
-
connectorId: connectorName,
|
|
30923
|
-
legacyConnectorId: legacyConnectorName(connectorName),
|
|
30924
|
-
packagePath: getConnectorPath(connectorName),
|
|
30925
|
-
configDirName: configPaths.preferredDirName,
|
|
30926
|
-
legacyConfigDirName: configPaths.legacyName,
|
|
30927
|
-
internal: Boolean(getInternalConnectorDefinition(connectorName)),
|
|
30928
|
-
packageDirectory: connectorExists(connectorName),
|
|
30929
|
-
commandSurface: hasConnectorCommandSurface(connectorName)
|
|
30930
|
-
},
|
|
30931
|
-
auth: {
|
|
30932
|
-
type: getAuthType(connectorName),
|
|
30933
|
-
summary: docs?.auth ?? null,
|
|
30934
|
-
envVars: docs?.envVars ?? []
|
|
30935
|
-
},
|
|
30936
|
-
docs: {
|
|
30937
|
-
overview: docs?.overview ?? "",
|
|
30938
|
-
cliCommands: docs?.cliCommands ?? "",
|
|
30939
|
-
dataStorage: docs?.dataStorage ?? null
|
|
30940
|
-
},
|
|
30941
|
-
...operations ? { operations } : {}
|
|
30942
|
-
};
|
|
30943
|
-
}
|
|
30944
|
-
async function getConnectorCapabilityManifest(options = {}) {
|
|
30945
|
-
const names = options.connectorNames ? [...new Set(options.connectorNames.map((name) => normalizeConnectorName(name)))].sort() : CONNECTORS.map((connector) => connector.name);
|
|
30946
|
-
const connectors18 = [];
|
|
30947
|
-
for (const name of names) {
|
|
30948
|
-
const capability = await getConnectorCapability(name, options);
|
|
30949
|
-
if (capability)
|
|
30950
|
-
connectors18.push(capability);
|
|
30951
|
-
}
|
|
30952
|
-
return {
|
|
30953
|
-
version: 1,
|
|
30954
|
-
packageName: "@hasna/connectors",
|
|
30955
|
-
packageVersion: package_default.version,
|
|
30956
|
-
generatedAt: new Date().toISOString(),
|
|
30957
|
-
categories: CATEGORIES,
|
|
30958
|
-
connectorCount: connectors18.length,
|
|
30959
|
-
connectors: connectors18
|
|
30960
|
-
};
|
|
30961
|
-
}
|
|
30962
|
-
var init_manifest = __esm(() => {
|
|
30963
|
-
init_package();
|
|
30964
|
-
init_registry2();
|
|
30965
|
-
init_installer();
|
|
30966
|
-
init_runner();
|
|
30967
|
-
init_auth();
|
|
30968
|
-
init_connector_resolver();
|
|
30969
|
-
init_builtins();
|
|
30970
|
-
});
|
|
30971
|
-
|
|
30972
29772
|
// src/server/serve.ts
|
|
30973
29773
|
var exports_serve = {};
|
|
30974
29774
|
__export(exports_serve, {
|
|
30975
29775
|
startServer: () => startServer
|
|
30976
29776
|
});
|
|
30977
|
-
import { existsSync as
|
|
30978
|
-
import { join as join18, dirname as dirname8, extname, basename
|
|
29777
|
+
import { existsSync as existsSync17, readdirSync as readdirSync11, readFileSync as readFileSync9, writeFileSync as writeFileSync8, mkdirSync as mkdirSync11 } from "fs";
|
|
29778
|
+
import { join as join18, dirname as dirname8, extname, basename } from "path";
|
|
30979
29779
|
import { fileURLToPath as fileURLToPath6 } from "url";
|
|
30980
29780
|
function logActivity(action, connector, detail) {
|
|
30981
29781
|
activityLog.unshift({ action, connector, timestamp: Date.now(), detail });
|
|
@@ -30997,7 +29797,7 @@ function resolveDashboardDir() {
|
|
|
30997
29797
|
}
|
|
30998
29798
|
candidates.push(join18(process.cwd(), "dashboard", "dist"));
|
|
30999
29799
|
for (const candidate of candidates) {
|
|
31000
|
-
if (
|
|
29800
|
+
if (existsSync17(candidate))
|
|
31001
29801
|
return candidate;
|
|
31002
29802
|
}
|
|
31003
29803
|
return join18(process.cwd(), "dashboard", "dist");
|
|
@@ -31030,6 +29830,9 @@ function htmlResponse(content, status = 200) {
|
|
|
31030
29830
|
headers: { "Content-Type": "text/html; charset=utf-8", ...SECURITY_HEADERS }
|
|
31031
29831
|
});
|
|
31032
29832
|
}
|
|
29833
|
+
function isValidConnectorName(name) {
|
|
29834
|
+
return /^[a-z0-9-]+$/.test(name);
|
|
29835
|
+
}
|
|
31033
29836
|
function getAllConnectorsWithAuth() {
|
|
31034
29837
|
const installed = new Set(getInstalledConnectors());
|
|
31035
29838
|
return CONNECTORS.map((meta) => {
|
|
@@ -31082,7 +29885,7 @@ function oauthPage(type, title, message, hint, extra) {
|
|
|
31082
29885
|
</body></html>`;
|
|
31083
29886
|
}
|
|
31084
29887
|
function serveStaticFile(filePath) {
|
|
31085
|
-
if (!
|
|
29888
|
+
if (!existsSync17(filePath))
|
|
31086
29889
|
return null;
|
|
31087
29890
|
const ext = extname(filePath);
|
|
31088
29891
|
const contentType = MIME_TYPES[ext] || "application/octet-stream";
|
|
@@ -31119,7 +29922,7 @@ async function startServer(requestedPort, options) {
|
|
|
31119
29922
|
const strict = options?.strict ?? false;
|
|
31120
29923
|
loadConnectorVersions();
|
|
31121
29924
|
const dashboardDir = resolveDashboardDir();
|
|
31122
|
-
const dashboardExists =
|
|
29925
|
+
const dashboardExists = existsSync17(dashboardDir);
|
|
31123
29926
|
if (!dashboardExists) {
|
|
31124
29927
|
console.error(`
|
|
31125
29928
|
Dashboard not found at: ${dashboardDir}`);
|
|
@@ -31162,15 +29965,6 @@ Dashboard not found at: ${dashboardDir}`);
|
|
|
31162
29965
|
}
|
|
31163
29966
|
return jsonStripped(data, 200, port);
|
|
31164
29967
|
}
|
|
31165
|
-
if (path === "/api/connectors/manifest" && method === "GET") {
|
|
31166
|
-
const connectorNames = url2.searchParams.get("connectors")?.split(",").map((name) => name.trim()).filter(Boolean);
|
|
31167
|
-
const includeOperations = url2.searchParams.get("includeOperations") === "true";
|
|
31168
|
-
const manifest = await getConnectorCapabilityManifest({
|
|
31169
|
-
includeOperations,
|
|
31170
|
-
...connectorNames ? { connectorNames } : {}
|
|
31171
|
-
});
|
|
31172
|
-
return json(manifest, 200, port);
|
|
31173
|
-
}
|
|
31174
29968
|
const singleMatch = path.match(/^\/api\/connectors\/([^/]+)$/);
|
|
31175
29969
|
if (singleMatch && method === "GET") {
|
|
31176
29970
|
const name = singleMatch[1];
|
|
@@ -31244,20 +30038,6 @@ Dashboard not found at: ${dashboardDir}`);
|
|
|
31244
30038
|
return json({ error: "Request body too large" }, 413, port);
|
|
31245
30039
|
}
|
|
31246
30040
|
const body = await req.json();
|
|
31247
|
-
if (typeof body.operation === "string" && body.operation.trim()) {
|
|
31248
|
-
const result2 = await runConnectorOperation({
|
|
31249
|
-
connector: name,
|
|
31250
|
-
operation: body.operation,
|
|
31251
|
-
input: body.input,
|
|
31252
|
-
profile: body.profile,
|
|
31253
|
-
timeoutMs: body.timeout ?? 30000,
|
|
31254
|
-
parseJson: body.parseJson
|
|
31255
|
-
});
|
|
31256
|
-
if (!result2.success) {
|
|
31257
|
-
return json({ displayName: meta.displayName, ...result2 }, 400, port);
|
|
31258
|
-
}
|
|
31259
|
-
return json({ displayName: meta.displayName, ...result2 }, 200, port);
|
|
31260
|
-
}
|
|
31261
30041
|
const args = Array.isArray(body.args) ? body.args.filter((value) => typeof value === "string") : [];
|
|
31262
30042
|
if (args.length === 0) {
|
|
31263
30043
|
return json({ error: "Missing connector command arguments" }, 400, port);
|
|
@@ -31544,16 +30324,14 @@ ${result.stderr}`;
|
|
|
31544
30324
|
if (!isValidConnectorName(name))
|
|
31545
30325
|
return json({ error: "Invalid connector name" }, 400, port);
|
|
31546
30326
|
try {
|
|
31547
|
-
const profiles =
|
|
30327
|
+
const profiles = listProfiles2(name);
|
|
30328
|
+
const configDir = join18(getConnectorsHome(), name.startsWith("connect-") ? name : `connect-${name}`);
|
|
30329
|
+
const currentProfileFile = join18(configDir, "current_profile");
|
|
31548
30330
|
let current = "default";
|
|
31549
|
-
|
|
31550
|
-
|
|
31551
|
-
|
|
31552
|
-
|
|
31553
|
-
current = readFileSync9(currentProfileFile, "utf-8").trim() || "default";
|
|
31554
|
-
} catch {}
|
|
31555
|
-
break;
|
|
31556
|
-
}
|
|
30331
|
+
if (existsSync17(currentProfileFile)) {
|
|
30332
|
+
try {
|
|
30333
|
+
current = readFileSync9(currentProfileFile, "utf-8").trim() || "default";
|
|
30334
|
+
} catch {}
|
|
31557
30335
|
}
|
|
31558
30336
|
return json({ current, profiles }, 200, port);
|
|
31559
30337
|
} catch (e) {
|
|
@@ -31601,31 +30379,33 @@ ${result.stderr}`;
|
|
|
31601
30379
|
try {
|
|
31602
30380
|
const connectDir = getConnectorsHome();
|
|
31603
30381
|
const result = {};
|
|
31604
|
-
if (
|
|
31605
|
-
|
|
30382
|
+
if (existsSync17(connectDir)) {
|
|
30383
|
+
const entries = readdirSync11(connectDir, { withFileTypes: true });
|
|
30384
|
+
for (const entry of entries) {
|
|
30385
|
+
if (!entry.isDirectory() || !entry.name.startsWith("connect-"))
|
|
30386
|
+
continue;
|
|
30387
|
+
const connectorName = entry.name.replace(/^connect-/, "");
|
|
30388
|
+
const profilesDir = join18(connectDir, entry.name, "profiles");
|
|
30389
|
+
if (!existsSync17(profilesDir))
|
|
30390
|
+
continue;
|
|
31606
30391
|
const profiles = {};
|
|
31607
|
-
|
|
31608
|
-
|
|
31609
|
-
if (
|
|
31610
|
-
|
|
31611
|
-
|
|
31612
|
-
|
|
31613
|
-
|
|
31614
|
-
|
|
30392
|
+
const profileEntries = readdirSync11(profilesDir, { withFileTypes: true });
|
|
30393
|
+
for (const pEntry of profileEntries) {
|
|
30394
|
+
if (pEntry.isFile() && pEntry.name.endsWith(".json")) {
|
|
30395
|
+
const profileName = basename(pEntry.name, ".json");
|
|
30396
|
+
try {
|
|
30397
|
+
const config = JSON.parse(readFileSync9(join18(profilesDir, pEntry.name), "utf-8"));
|
|
30398
|
+
profiles[profileName] = config;
|
|
30399
|
+
} catch {}
|
|
30400
|
+
}
|
|
30401
|
+
if (pEntry.isDirectory()) {
|
|
30402
|
+
const configPath = join18(profilesDir, pEntry.name, "config.json");
|
|
30403
|
+
if (existsSync17(configPath)) {
|
|
31615
30404
|
try {
|
|
31616
|
-
const config = JSON.parse(readFileSync9(
|
|
31617
|
-
profiles[
|
|
30405
|
+
const config = JSON.parse(readFileSync9(configPath, "utf-8"));
|
|
30406
|
+
profiles[pEntry.name] = config;
|
|
31618
30407
|
} catch {}
|
|
31619
30408
|
}
|
|
31620
|
-
if (pEntry.isDirectory()) {
|
|
31621
|
-
const configPath = join18(profilesDir, pEntry.name, "config.json");
|
|
31622
|
-
if (existsSync18(configPath)) {
|
|
31623
|
-
try {
|
|
31624
|
-
const config = JSON.parse(readFileSync9(configPath, "utf-8"));
|
|
31625
|
-
profiles[pEntry.name] = config;
|
|
31626
|
-
} catch {}
|
|
31627
|
-
}
|
|
31628
|
-
}
|
|
31629
30409
|
}
|
|
31630
30410
|
}
|
|
31631
30411
|
if (Object.keys(profiles).length > 0) {
|
|
@@ -31663,12 +30443,12 @@ ${result.stderr}`;
|
|
|
31663
30443
|
continue;
|
|
31664
30444
|
if (!data.profiles || typeof data.profiles !== "object")
|
|
31665
30445
|
continue;
|
|
31666
|
-
const connectorDir =
|
|
30446
|
+
const connectorDir = join18(connectDir, `connect-${connectorName}`);
|
|
31667
30447
|
const profilesDir = join18(connectorDir, "profiles");
|
|
31668
30448
|
for (const [profileName, config] of Object.entries(data.profiles)) {
|
|
31669
30449
|
if (!config || typeof config !== "object")
|
|
31670
30450
|
continue;
|
|
31671
|
-
|
|
30451
|
+
mkdirSync11(profilesDir, { recursive: true });
|
|
31672
30452
|
const profileFile = join18(profilesDir, `${profileName}.json`);
|
|
31673
30453
|
writeFileSync8(profileFile, JSON.stringify(config, null, 2));
|
|
31674
30454
|
imported++;
|
|
@@ -31686,7 +30466,7 @@ ${result.stderr}`;
|
|
|
31686
30466
|
const redirectUri = `http://localhost:${port}/oauth/${name}/callback`;
|
|
31687
30467
|
const authUrl = getOAuthStartUrl(name, redirectUri);
|
|
31688
30468
|
if (!authUrl) {
|
|
31689
|
-
return htmlResponse(oauthPage("warning", "OAuth Not Available", `No OAuth client credentials found for <span class="connector">${name}</span>.`, `Run <code>connectors auth ${name}</code> or add credentials at <code>~/.hasna/connectors
|
|
30469
|
+
return htmlResponse(oauthPage("warning", "OAuth Not Available", `No OAuth client credentials found for <span class="connector">${name}</span>.`, `Run <code>connectors auth ${name}</code> or add credentials at <code>~/.hasna/connectors/connect-${name}/credentials.json</code>`));
|
|
31690
30470
|
}
|
|
31691
30471
|
return Response.redirect(authUrl, 302);
|
|
31692
30472
|
}
|
|
@@ -31770,9 +30550,7 @@ var init_serve = __esm(() => {
|
|
|
31770
30550
|
init_database();
|
|
31771
30551
|
init_registry2();
|
|
31772
30552
|
init_installer();
|
|
31773
|
-
init_connector_resolver();
|
|
31774
30553
|
init_runner();
|
|
31775
|
-
init_manifest();
|
|
31776
30554
|
init_auth();
|
|
31777
30555
|
activityLog = [];
|
|
31778
30556
|
MIME_TYPES = {
|
|
@@ -33292,8 +32070,8 @@ init_registry2();
|
|
|
33292
32070
|
init_installer();
|
|
33293
32071
|
import { render } from "ink";
|
|
33294
32072
|
import chalk2 from "chalk";
|
|
33295
|
-
import { readdirSync as readdirSync8, statSync as
|
|
33296
|
-
import { join as
|
|
32073
|
+
import { readdirSync as readdirSync8, statSync as statSync4 } from "fs";
|
|
32074
|
+
import { join as join13, relative as relative2 } from "path";
|
|
33297
32075
|
import { createInterface } from "readline";
|
|
33298
32076
|
import { jsxDEV as jsxDEV7 } from "react/jsx-dev-runtime";
|
|
33299
32077
|
var isTTY = process.stdout.isTTY ?? false;
|
|
@@ -33308,8 +32086,8 @@ var PRESETS = {
|
|
|
33308
32086
|
function listFilesRecursive(dir, base = dir) {
|
|
33309
32087
|
const files = [];
|
|
33310
32088
|
for (const entry of readdirSync8(dir)) {
|
|
33311
|
-
const fullPath =
|
|
33312
|
-
if (
|
|
32089
|
+
const fullPath = join13(dir, entry);
|
|
32090
|
+
if (statSync4(fullPath).isDirectory()) {
|
|
33313
32091
|
files.push(...listFilesRecursive(fullPath, base));
|
|
33314
32092
|
} else {
|
|
33315
32093
|
files.push(relative2(base, fullPath));
|
|
@@ -33358,9 +32136,9 @@ function registerCommands(program2) {
|
|
|
33358
32136
|
}
|
|
33359
32137
|
if (options.dryRun) {
|
|
33360
32138
|
const installed = getInstalledConnectors();
|
|
33361
|
-
const connectorsDir =
|
|
33362
|
-
const manifestPath =
|
|
33363
|
-
const indexPath =
|
|
32139
|
+
const connectorsDir = join13(process.cwd(), ".connectors");
|
|
32140
|
+
const manifestPath = join13(connectorsDir, "manifest.json");
|
|
32141
|
+
const indexPath = join13(connectorsDir, "index.ts");
|
|
33364
32142
|
const actions = [];
|
|
33365
32143
|
for (const name of connectors18) {
|
|
33366
32144
|
if (!/^[a-z0-9-]+$/.test(name)) {
|
|
@@ -33376,6 +32154,7 @@ function registerCommands(program2) {
|
|
|
33376
32154
|
actions.push({ connector: name, action: "error", reason: `Connector '${name}' source files not found` });
|
|
33377
32155
|
continue;
|
|
33378
32156
|
}
|
|
32157
|
+
const connectorDirName = name.startsWith("connect-") ? name : `connect-${name}`;
|
|
33379
32158
|
const sourcePath = getConnectorPath(name);
|
|
33380
32159
|
const alreadyInstalled = installed.includes(name);
|
|
33381
32160
|
const files = listFilesRecursive(sourcePath);
|
|
@@ -33977,9 +32756,8 @@ init_registry2();
|
|
|
33977
32756
|
init_installer();
|
|
33978
32757
|
init_auth();
|
|
33979
32758
|
init_database();
|
|
33980
|
-
init_connector_resolver();
|
|
33981
32759
|
import chalk4 from "chalk";
|
|
33982
|
-
import { existsSync as
|
|
32760
|
+
import { existsSync as existsSync18, readdirSync as readdirSync12, statSync as statSync7, readFileSync as readFileSync10 } from "fs";
|
|
33983
32761
|
import { join as join19 } from "path";
|
|
33984
32762
|
function registerCommands3(program2) {
|
|
33985
32763
|
program2.command("status").option("--json", "Output as JSON", false).description("Show auth status of all configured connectors (project + global)").action((options) => {
|
|
@@ -33989,15 +32767,13 @@ function registerCommands3(program2) {
|
|
|
33989
32767
|
const allStatuses = [];
|
|
33990
32768
|
function buildStatusEntry(name, source) {
|
|
33991
32769
|
const auth = getAuthStatus(name);
|
|
32770
|
+
const connectorName = name.startsWith("connect-") ? name : `connect-${name}`;
|
|
32771
|
+
const currentProfileFile = join19(configDir, connectorName, "current_profile");
|
|
33992
32772
|
let profile = "default";
|
|
33993
|
-
|
|
33994
|
-
|
|
33995
|
-
|
|
33996
|
-
|
|
33997
|
-
profile = readFileSync10(currentProfileFile, "utf-8").trim() || "default";
|
|
33998
|
-
} catch {}
|
|
33999
|
-
break;
|
|
34000
|
-
}
|
|
32773
|
+
if (existsSync18(currentProfileFile)) {
|
|
32774
|
+
try {
|
|
32775
|
+
profile = readFileSync10(currentProfileFile, "utf-8").trim() || "default";
|
|
32776
|
+
} catch {}
|
|
34001
32777
|
}
|
|
34002
32778
|
let expiryLabel = null;
|
|
34003
32779
|
let expired = false;
|
|
@@ -34032,11 +32808,21 @@ function registerCommands3(program2) {
|
|
|
34032
32808
|
seen.add(name);
|
|
34033
32809
|
allStatuses.push(buildStatusEntry(name, "project"));
|
|
34034
32810
|
}
|
|
34035
|
-
if (
|
|
32811
|
+
if (existsSync18(configDir)) {
|
|
34036
32812
|
try {
|
|
34037
|
-
|
|
34038
|
-
if (
|
|
34039
|
-
|
|
32813
|
+
const globalDirs = readdirSync12(configDir).filter((f) => {
|
|
32814
|
+
if (!f.startsWith("connect-"))
|
|
32815
|
+
return false;
|
|
32816
|
+
if (f.startsWith("connect-zzztest"))
|
|
32817
|
+
return false;
|
|
32818
|
+
try {
|
|
32819
|
+
return statSync7(join19(configDir, f)).isDirectory();
|
|
32820
|
+
} catch {
|
|
32821
|
+
return false;
|
|
32822
|
+
}
|
|
32823
|
+
});
|
|
32824
|
+
for (const dir of globalDirs) {
|
|
32825
|
+
const name = dir.replace("connect-", "");
|
|
34040
32826
|
if (seen.has(name))
|
|
34041
32827
|
continue;
|
|
34042
32828
|
seen.add(name);
|
|
@@ -34243,11 +33029,10 @@ init_registry2();
|
|
|
34243
33029
|
init_auth();
|
|
34244
33030
|
init_database();
|
|
34245
33031
|
import chalk5 from "chalk";
|
|
34246
|
-
import { existsSync as
|
|
33032
|
+
import { existsSync as existsSync19, readdirSync as readdirSync13, statSync as statSync8, readFileSync as readFileSync11, writeFileSync as writeFileSync9, mkdirSync as mkdirSync12 } from "fs";
|
|
34247
33033
|
import { join as join20 } from "path";
|
|
34248
33034
|
import { homedir as homedir8 } from "os";
|
|
34249
33035
|
import { createInterface as createInterface2 } from "readline";
|
|
34250
|
-
init_connector_resolver();
|
|
34251
33036
|
var SENSITIVE_FIELDS = new Set([
|
|
34252
33037
|
"clientsecret",
|
|
34253
33038
|
"client_secret",
|
|
@@ -34298,7 +33083,7 @@ function redactSecrets(obj) {
|
|
|
34298
33083
|
return obj;
|
|
34299
33084
|
}
|
|
34300
33085
|
function getOAuthTokenState(name) {
|
|
34301
|
-
const tokens =
|
|
33086
|
+
const tokens = loadTokens(name);
|
|
34302
33087
|
if (!tokens?.accessToken && !tokens?.refreshToken) {
|
|
34303
33088
|
return { hasTokens: false, expired: false };
|
|
34304
33089
|
}
|
|
@@ -34318,27 +33103,6 @@ function getOAuthTokenState(name) {
|
|
|
34318
33103
|
})();
|
|
34319
33104
|
return { hasTokens: true, expired: isExpired, expiresIn };
|
|
34320
33105
|
}
|
|
34321
|
-
function getCurrentOAuthProfile(name, connectorsHome = getConnectorsHome()) {
|
|
34322
|
-
for (const dir of getConnectorConfigReadDirs(name, connectorsHome)) {
|
|
34323
|
-
const currentProfilePath = join20(dir, "current_profile");
|
|
34324
|
-
if (!existsSync20(currentProfilePath))
|
|
34325
|
-
continue;
|
|
34326
|
-
const profile = readFileSync11(currentProfilePath, "utf8").trim();
|
|
34327
|
-
if (profile)
|
|
34328
|
-
return profile;
|
|
34329
|
-
}
|
|
34330
|
-
return "default";
|
|
34331
|
-
}
|
|
34332
|
-
function getOAuthTokenPathsForProfile(name, connectorsHome = getConnectorsHome(), profile = getCurrentOAuthProfile(name, connectorsHome)) {
|
|
34333
|
-
return getConnectorConfigReadDirs(name, connectorsHome).map((dir) => join20(dir, "profiles", profile, "tokens.json"));
|
|
34334
|
-
}
|
|
34335
|
-
function hasOAuthTokenFileUpdatedSince(tokenPaths, sinceMs) {
|
|
34336
|
-
return tokenPaths.some((tokensPath) => {
|
|
34337
|
-
if (!existsSync20(tokensPath))
|
|
34338
|
-
return false;
|
|
34339
|
-
return statSync8(tokensPath).mtimeMs >= sinceMs;
|
|
34340
|
-
});
|
|
34341
|
-
}
|
|
34342
33106
|
function registerCommands4(program2) {
|
|
34343
33107
|
program2.command("auth").argument("<connector>", "Connector name to configure auth for").option("-k, --key <value>", "API key or bearer token value (non-interactive)").option("-f, --field <field>", "Which field to set (for multi-field connectors)").option("--json", "Output as JSON", false).option("--no-browser", "Print OAuth URL without opening a browser (agent-friendly)", false).option("--refresh", "Refresh expired OAuth tokens", false).option("--port <port>", "OAuth server port (default: 9876)", "9876").description("Configure authentication for a connector").action(async (connector, options) => {
|
|
34344
33108
|
const meta = getConnector(connector);
|
|
@@ -34462,13 +33226,12 @@ ${meta.displayName} \u2014 Auth Configuration
|
|
|
34462
33226
|
try {
|
|
34463
33227
|
if (!options.browser) {
|
|
34464
33228
|
console.log(chalk5.dim(`Starting OAuth server on port ${port}...`));
|
|
34465
|
-
const { spawn:
|
|
33229
|
+
const { spawn: spawn4 } = await import("child_process");
|
|
34466
33230
|
const scriptPath = process.argv[1];
|
|
34467
|
-
const serverProc =
|
|
33231
|
+
const serverProc = spawn4("node", [scriptPath, "serve", "--port", String(port)], {
|
|
34468
33232
|
detached: true,
|
|
34469
33233
|
stdio: "ignore"
|
|
34470
33234
|
});
|
|
34471
|
-
const startedAt = Date.now();
|
|
34472
33235
|
serverProc.unref();
|
|
34473
33236
|
await new Promise((resolve) => setTimeout(resolve, 2000));
|
|
34474
33237
|
try {
|
|
@@ -34485,13 +33248,13 @@ ${meta.displayName} \u2014 Auth Configuration
|
|
|
34485
33248
|
`);
|
|
34486
33249
|
console.log(chalk5.dim("Waiting for authentication to complete..."));
|
|
34487
33250
|
const connectorsHome = getConnectorsHome();
|
|
34488
|
-
const
|
|
34489
|
-
const
|
|
33251
|
+
const connectorDirName = connector.startsWith("connect-") ? connector : `connect-${connector}`;
|
|
33252
|
+
const tokensPath = join20(connectorsHome, connectorDirName, "profiles", "default", "tokens.json");
|
|
34490
33253
|
let attempts = 0;
|
|
34491
33254
|
const maxAttempts = 360;
|
|
34492
33255
|
while (attempts < maxAttempts) {
|
|
34493
33256
|
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
34494
|
-
if (
|
|
33257
|
+
if (existsSync19(tokensPath)) {
|
|
34495
33258
|
break;
|
|
34496
33259
|
}
|
|
34497
33260
|
attempts++;
|
|
@@ -34505,7 +33268,7 @@ ${meta.displayName} \u2014 Auth Configuration
|
|
|
34505
33268
|
if (attempts >= maxAttempts) {
|
|
34506
33269
|
console.log();
|
|
34507
33270
|
console.log(chalk5.yellow("Timed out waiting for OAuth callback. The auth may still be in progress."));
|
|
34508
|
-
console.log(chalk5.dim(`Check ${
|
|
33271
|
+
console.log(chalk5.dim(`Check ${tokensPath} for tokens.`));
|
|
34509
33272
|
console.log(chalk5.dim("You can stop the server manually: lsof -ti :${port} | xargs kill"));
|
|
34510
33273
|
process.exit(1);
|
|
34511
33274
|
return;
|
|
@@ -34638,12 +33401,13 @@ Open this URL to authenticate:
|
|
|
34638
33401
|
let configuredCount = 0;
|
|
34639
33402
|
const configuredNames = [];
|
|
34640
33403
|
try {
|
|
34641
|
-
if (
|
|
34642
|
-
|
|
34643
|
-
|
|
34644
|
-
|
|
33404
|
+
if (existsSync19(connectorsHome)) {
|
|
33405
|
+
const entries = readdirSync13(connectorsHome).filter((e) => e.startsWith("connect-") && statSync8(join20(connectorsHome, e)).isDirectory());
|
|
33406
|
+
for (const entry of entries) {
|
|
33407
|
+
const profilesDir = join20(connectorsHome, entry, "profiles");
|
|
33408
|
+
if (existsSync19(profilesDir)) {
|
|
34645
33409
|
configuredCount++;
|
|
34646
|
-
configuredNames.push(
|
|
33410
|
+
configuredNames.push(entry.replace(/^connect-/, ""));
|
|
34647
33411
|
}
|
|
34648
33412
|
}
|
|
34649
33413
|
}
|
|
@@ -34692,45 +33456,46 @@ Open this URL to authenticate:
|
|
|
34692
33456
|
program2.command("export").option("-o, --output <file>", "Write to file instead of stdout").option("--include-secrets", "Include secrets in plaintext (dangerous \u2014 use only for backup/restore)").description("Export all connector credentials as JSON backup").action((options) => {
|
|
34693
33457
|
const connectDir = getConnectorsHome();
|
|
34694
33458
|
const result = {};
|
|
34695
|
-
if (
|
|
34696
|
-
for (const
|
|
34697
|
-
const
|
|
33459
|
+
if (existsSync19(connectDir)) {
|
|
33460
|
+
for (const entry of readdirSync13(connectDir)) {
|
|
33461
|
+
const entryPath = join20(connectDir, entry);
|
|
33462
|
+
if (!statSync8(entryPath).isDirectory() || !entry.startsWith("connect-"))
|
|
33463
|
+
continue;
|
|
33464
|
+
const connectorName = entry.replace(/^connect-/, "");
|
|
34698
33465
|
let credentials = undefined;
|
|
34699
|
-
|
|
34700
|
-
|
|
34701
|
-
|
|
34702
|
-
|
|
34703
|
-
|
|
34704
|
-
} catch {}
|
|
34705
|
-
}
|
|
33466
|
+
const credentialsPath = join20(entryPath, "credentials.json");
|
|
33467
|
+
if (existsSync19(credentialsPath)) {
|
|
33468
|
+
try {
|
|
33469
|
+
credentials = JSON.parse(readFileSync11(credentialsPath, "utf-8"));
|
|
33470
|
+
} catch {}
|
|
34706
33471
|
}
|
|
33472
|
+
const profilesDir = join20(entryPath, "profiles");
|
|
33473
|
+
if (!existsSync19(profilesDir) && !credentials)
|
|
33474
|
+
continue;
|
|
34707
33475
|
const profiles = {};
|
|
34708
|
-
|
|
34709
|
-
const
|
|
34710
|
-
|
|
34711
|
-
|
|
34712
|
-
|
|
34713
|
-
|
|
33476
|
+
if (existsSync19(profilesDir)) {
|
|
33477
|
+
for (const pEntry of readdirSync13(profilesDir)) {
|
|
33478
|
+
const pPath = join20(profilesDir, pEntry);
|
|
33479
|
+
if (statSync8(pPath).isFile() && pEntry.endsWith(".json")) {
|
|
33480
|
+
try {
|
|
33481
|
+
profiles[pEntry.replace(/\.json$/, "")] = JSON.parse(readFileSync11(pPath, "utf-8"));
|
|
33482
|
+
} catch {}
|
|
33483
|
+
} else if (statSync8(pPath).isDirectory()) {
|
|
33484
|
+
const configPath = join20(pPath, "config.json");
|
|
33485
|
+
const tokensPath = join20(pPath, "tokens.json");
|
|
33486
|
+
let merged = {};
|
|
33487
|
+
if (existsSync19(configPath)) {
|
|
34714
33488
|
try {
|
|
34715
|
-
|
|
33489
|
+
merged = { ...merged, ...JSON.parse(readFileSync11(configPath, "utf-8")) };
|
|
34716
33490
|
} catch {}
|
|
34717
|
-
} else if (statSync8(pPath).isDirectory()) {
|
|
34718
|
-
const configPath = join20(pPath, "config.json");
|
|
34719
|
-
const tokensPath = join20(pPath, "tokens.json");
|
|
34720
|
-
let merged = {};
|
|
34721
|
-
if (existsSync20(configPath)) {
|
|
34722
|
-
try {
|
|
34723
|
-
merged = { ...merged, ...JSON.parse(readFileSync11(configPath, "utf-8")) };
|
|
34724
|
-
} catch {}
|
|
34725
|
-
}
|
|
34726
|
-
if (existsSync20(tokensPath)) {
|
|
34727
|
-
try {
|
|
34728
|
-
merged = { ...merged, ...JSON.parse(readFileSync11(tokensPath, "utf-8")) };
|
|
34729
|
-
} catch {}
|
|
34730
|
-
}
|
|
34731
|
-
if (Object.keys(merged).length > 0)
|
|
34732
|
-
profiles[pEntry] = merged;
|
|
34733
33491
|
}
|
|
33492
|
+
if (existsSync19(tokensPath)) {
|
|
33493
|
+
try {
|
|
33494
|
+
merged = { ...merged, ...JSON.parse(readFileSync11(tokensPath, "utf-8")) };
|
|
33495
|
+
} catch {}
|
|
33496
|
+
}
|
|
33497
|
+
if (Object.keys(merged).length > 0)
|
|
33498
|
+
profiles[pEntry] = merged;
|
|
34734
33499
|
}
|
|
34735
33500
|
}
|
|
34736
33501
|
}
|
|
@@ -34761,7 +33526,7 @@ Open this URL to authenticate:
|
|
|
34761
33526
|
chunks.push(chunk.toString());
|
|
34762
33527
|
raw = chunks.join("");
|
|
34763
33528
|
} else {
|
|
34764
|
-
if (!
|
|
33529
|
+
if (!existsSync19(file)) {
|
|
34765
33530
|
if (options.json) {
|
|
34766
33531
|
console.log(JSON.stringify({ error: `File not found: ${file}` }));
|
|
34767
33532
|
} else {
|
|
@@ -34798,9 +33563,9 @@ Open this URL to authenticate:
|
|
|
34798
33563
|
for (const [connectorName, connData] of Object.entries(data.connectors)) {
|
|
34799
33564
|
if (!/^[a-z0-9-]+$/.test(connectorName))
|
|
34800
33565
|
continue;
|
|
34801
|
-
const connectorDir =
|
|
33566
|
+
const connectorDir = join20(connectDir, `connect-${connectorName}`);
|
|
34802
33567
|
if (connData.credentials && typeof connData.credentials === "object") {
|
|
34803
|
-
|
|
33568
|
+
mkdirSync12(connectorDir, { recursive: true });
|
|
34804
33569
|
writeFileSync9(join20(connectorDir, "credentials.json"), JSON.stringify(connData.credentials, null, 2));
|
|
34805
33570
|
imported++;
|
|
34806
33571
|
}
|
|
@@ -34810,7 +33575,7 @@ Open this URL to authenticate:
|
|
|
34810
33575
|
for (const [profileName, config] of Object.entries(connData.profiles)) {
|
|
34811
33576
|
if (!config || typeof config !== "object")
|
|
34812
33577
|
continue;
|
|
34813
|
-
|
|
33578
|
+
mkdirSync12(profilesDir, { recursive: true });
|
|
34814
33579
|
writeFileSync9(join20(profilesDir, `${profileName}.json`), JSON.stringify(config, null, 2));
|
|
34815
33580
|
imported++;
|
|
34816
33581
|
}
|
|
@@ -34824,7 +33589,7 @@ Open this URL to authenticate:
|
|
|
34824
33589
|
program2.command("auth-import").option("--json", "Output as JSON", false).option("-d, --dry-run", "Preview what would be imported without copying", false).option("--force", "Overwrite existing files in ~/.hasna/connectors/", false).description("Migrate auth tokens from ~/.connect/ to ~/.hasna/connectors/").action((options) => {
|
|
34825
33590
|
const oldBase = join20(homedir8(), ".connect");
|
|
34826
33591
|
const newBase = getConnectorsHome();
|
|
34827
|
-
if (!
|
|
33592
|
+
if (!existsSync19(oldBase)) {
|
|
34828
33593
|
if (options.json) {
|
|
34829
33594
|
console.log(JSON.stringify({ imported: [], skipped: [], error: null, message: "No ~/.connect/ directory found" }));
|
|
34830
33595
|
} else {
|
|
@@ -34832,7 +33597,7 @@ Open this URL to authenticate:
|
|
|
34832
33597
|
}
|
|
34833
33598
|
return;
|
|
34834
33599
|
}
|
|
34835
|
-
const entries =
|
|
33600
|
+
const entries = readdirSync13(oldBase).filter((name) => {
|
|
34836
33601
|
if (!name.startsWith("connect-"))
|
|
34837
33602
|
return false;
|
|
34838
33603
|
try {
|
|
@@ -34853,8 +33618,8 @@ Open this URL to authenticate:
|
|
|
34853
33618
|
const skipped = [];
|
|
34854
33619
|
for (const dirName of entries) {
|
|
34855
33620
|
const oldDir = join20(oldBase, dirName);
|
|
33621
|
+
const newDir = join20(newBase, dirName);
|
|
34856
33622
|
const connectorName = dirName.replace(/^connect-/, "");
|
|
34857
|
-
const newDir = getConnectorConfigDir(connectorName, newBase);
|
|
34858
33623
|
const allFiles = listFilesRecursive(oldDir);
|
|
34859
33624
|
const authFiles = allFiles.filter((f) => {
|
|
34860
33625
|
return f === "credentials.json" || f === "config.json" || f === "tokens.json" || f === "current_profile" || f.startsWith("profiles/") || f.startsWith("profiles\\");
|
|
@@ -34866,13 +33631,13 @@ Open this URL to authenticate:
|
|
|
34866
33631
|
for (const relFile of authFiles) {
|
|
34867
33632
|
const srcPath = join20(oldDir, relFile);
|
|
34868
33633
|
const destPath = join20(newDir, relFile);
|
|
34869
|
-
if (
|
|
33634
|
+
if (existsSync19(destPath) && !options.force) {
|
|
34870
33635
|
skippedFiles.push(relFile);
|
|
34871
33636
|
continue;
|
|
34872
33637
|
}
|
|
34873
33638
|
if (!options.dryRun) {
|
|
34874
33639
|
const parentDir = join20(destPath, "..");
|
|
34875
|
-
|
|
33640
|
+
mkdirSync12(parentDir, { recursive: true });
|
|
34876
33641
|
const content = readFileSync11(srcPath);
|
|
34877
33642
|
writeFileSync9(destPath, content);
|
|
34878
33643
|
}
|
|
@@ -34940,7 +33705,7 @@ init_installer();
|
|
|
34940
33705
|
init_auth();
|
|
34941
33706
|
init_database();
|
|
34942
33707
|
import chalk6 from "chalk";
|
|
34943
|
-
import { existsSync as
|
|
33708
|
+
import { existsSync as existsSync20, readdirSync as readdirSync14, statSync as statSync9, readFileSync as readFileSync12, writeFileSync as writeFileSync10 } from "fs";
|
|
34944
33709
|
import { join as join21 } from "path";
|
|
34945
33710
|
|
|
34946
33711
|
// src/lib/test-endpoints.ts
|
|
@@ -35140,7 +33905,6 @@ var TEST_ENDPOINTS = {
|
|
|
35140
33905
|
|
|
35141
33906
|
// src/cli/commands/misc.ts
|
|
35142
33907
|
init_auth();
|
|
35143
|
-
init_connector_resolver();
|
|
35144
33908
|
function registerCommands5(program2) {
|
|
35145
33909
|
program2.command("upgrade").alias("self-update").option("--check", "Only check for updates, don't install", false).option("--json", "Output as JSON", false).description("Check for updates and upgrade to the latest version").action(async (options) => {
|
|
35146
33910
|
const currentVersion = program2.version();
|
|
@@ -35371,21 +34135,29 @@ Available presets:
|
|
|
35371
34135
|
configured++;
|
|
35372
34136
|
else
|
|
35373
34137
|
unconfigured++;
|
|
34138
|
+
const connectorConfigDir = join21(configDir, name.startsWith("connect-") ? name : `connect-${name}`);
|
|
34139
|
+
const currentProfileFile = join21(connectorConfigDir, "current_profile");
|
|
35374
34140
|
let profile = "default";
|
|
35375
|
-
|
|
35376
|
-
|
|
35377
|
-
|
|
35378
|
-
|
|
35379
|
-
profile = readFileSync12(currentProfileFile, "utf-8").trim() || "default";
|
|
35380
|
-
} catch {}
|
|
35381
|
-
break;
|
|
35382
|
-
}
|
|
34141
|
+
if (existsSync20(currentProfileFile)) {
|
|
34142
|
+
try {
|
|
34143
|
+
profile = readFileSync12(currentProfileFile, "utf-8").trim() || "default";
|
|
34144
|
+
} catch {}
|
|
35383
34145
|
}
|
|
35384
34146
|
connectorDetails.push({ name, configured: auth.configured, authType: auth.type, profile, source: "project" });
|
|
35385
34147
|
}
|
|
35386
|
-
if (
|
|
34148
|
+
if (existsSync20(configDir)) {
|
|
35387
34149
|
try {
|
|
35388
|
-
|
|
34150
|
+
const globalDirs = readdirSync14(configDir).filter((f) => {
|
|
34151
|
+
if (!f.startsWith("connect-"))
|
|
34152
|
+
return false;
|
|
34153
|
+
try {
|
|
34154
|
+
return statSync9(join21(configDir, f)).isDirectory();
|
|
34155
|
+
} catch {
|
|
34156
|
+
return false;
|
|
34157
|
+
}
|
|
34158
|
+
});
|
|
34159
|
+
for (const dir of globalDirs) {
|
|
34160
|
+
const name = dir.replace("connect-", "");
|
|
35389
34161
|
if (seen.has(name))
|
|
35390
34162
|
continue;
|
|
35391
34163
|
const auth = getAuthStatus(name);
|
|
@@ -35393,15 +34165,12 @@ Available presets:
|
|
|
35393
34165
|
continue;
|
|
35394
34166
|
seen.add(name);
|
|
35395
34167
|
configured++;
|
|
34168
|
+
const currentProfileFile = join21(configDir, dir, "current_profile");
|
|
35396
34169
|
let profile = "default";
|
|
35397
|
-
|
|
35398
|
-
|
|
35399
|
-
|
|
35400
|
-
|
|
35401
|
-
profile = readFileSync12(currentProfileFile, "utf-8").trim() || "default";
|
|
35402
|
-
} catch {}
|
|
35403
|
-
break;
|
|
35404
|
-
}
|
|
34170
|
+
if (existsSync20(currentProfileFile)) {
|
|
34171
|
+
try {
|
|
34172
|
+
profile = readFileSync12(currentProfileFile, "utf-8").trim() || "default";
|
|
34173
|
+
} catch {}
|
|
35405
34174
|
}
|
|
35406
34175
|
connectorDetails.push({ name, configured: true, authType: auth.type, profile, source: "global" });
|
|
35407
34176
|
}
|
|
@@ -35411,7 +34180,7 @@ Available presets:
|
|
|
35411
34180
|
console.log(JSON.stringify({
|
|
35412
34181
|
version,
|
|
35413
34182
|
configDir,
|
|
35414
|
-
configDirExists:
|
|
34183
|
+
configDirExists: existsSync20(configDir),
|
|
35415
34184
|
installed: installed.length,
|
|
35416
34185
|
configured,
|
|
35417
34186
|
unconfigured,
|
|
@@ -35423,7 +34192,7 @@ Available presets:
|
|
|
35423
34192
|
Connectors Setup
|
|
35424
34193
|
`));
|
|
35425
34194
|
console.log(` Version: ${chalk6.cyan(version)}`);
|
|
35426
|
-
console.log(` Config: ${configDir}${
|
|
34195
|
+
console.log(` Config: ${configDir}${existsSync20(configDir) ? "" : chalk6.dim(" (not created yet)")}`);
|
|
35427
34196
|
console.log(` Installed: ${installed.length} connector${installed.length !== 1 ? "s" : ""}`);
|
|
35428
34197
|
console.log(` Configured: ${chalk6.green(String(configured))} ready, ${unconfigured > 0 ? chalk6.red(String(unconfigured)) : chalk6.dim("0")} need auth`);
|
|
35429
34198
|
const projectConnectors = connectorDetails.filter((c) => c.source === "project");
|
|
@@ -35514,19 +34283,16 @@ Testing connector credentials...
|
|
|
35514
34283
|
}
|
|
35515
34284
|
}
|
|
35516
34285
|
if (!apiKey) {
|
|
35517
|
-
const
|
|
34286
|
+
const connectorConfigDir = join21(getConnectorsHome(), name.startsWith("connect-") ? name : `connect-${name}`);
|
|
35518
34287
|
let currentProfile = "default";
|
|
35519
|
-
|
|
35520
|
-
|
|
35521
|
-
|
|
35522
|
-
|
|
35523
|
-
|
|
35524
|
-
} catch {}
|
|
35525
|
-
break;
|
|
35526
|
-
}
|
|
34288
|
+
const currentProfileFile = join21(connectorConfigDir, "current_profile");
|
|
34289
|
+
if (existsSync20(currentProfileFile)) {
|
|
34290
|
+
try {
|
|
34291
|
+
currentProfile = readFileSync12(currentProfileFile, "utf-8").trim() || "default";
|
|
34292
|
+
} catch {}
|
|
35527
34293
|
}
|
|
35528
|
-
const tokensFile =
|
|
35529
|
-
if (tokensFile) {
|
|
34294
|
+
const tokensFile = join21(connectorConfigDir, "profiles", currentProfile, "tokens.json");
|
|
34295
|
+
if (existsSync20(tokensFile)) {
|
|
35530
34296
|
try {
|
|
35531
34297
|
const tokens = JSON.parse(readFileSync12(tokensFile, "utf-8"));
|
|
35532
34298
|
const isExpired = tokens.expiresAt && Date.now() >= tokens.expiresAt - 60000;
|
|
@@ -35546,29 +34312,21 @@ Testing connector credentials...
|
|
|
35546
34312
|
} catch {}
|
|
35547
34313
|
}
|
|
35548
34314
|
if (!apiKey) {
|
|
35549
|
-
|
|
35550
|
-
|
|
35551
|
-
|
|
35552
|
-
|
|
35553
|
-
|
|
35554
|
-
|
|
35555
|
-
} catch {}
|
|
35556
|
-
if (apiKey)
|
|
35557
|
-
break;
|
|
35558
|
-
}
|
|
34315
|
+
const profileFile = join21(connectorConfigDir, "profiles", `${currentProfile}.json`);
|
|
34316
|
+
if (existsSync20(profileFile)) {
|
|
34317
|
+
try {
|
|
34318
|
+
const config = JSON.parse(readFileSync12(profileFile, "utf-8"));
|
|
34319
|
+
apiKey = Object.values(config).find((v) => typeof v === "string" && v.length > 0);
|
|
34320
|
+
} catch {}
|
|
35559
34321
|
}
|
|
35560
34322
|
}
|
|
35561
34323
|
if (!apiKey) {
|
|
35562
|
-
|
|
35563
|
-
|
|
35564
|
-
|
|
35565
|
-
|
|
35566
|
-
|
|
35567
|
-
|
|
35568
|
-
} catch {}
|
|
35569
|
-
if (apiKey)
|
|
35570
|
-
break;
|
|
35571
|
-
}
|
|
34324
|
+
const profileDirConfig = join21(connectorConfigDir, "profiles", currentProfile, "config.json");
|
|
34325
|
+
if (existsSync20(profileDirConfig)) {
|
|
34326
|
+
try {
|
|
34327
|
+
const config = JSON.parse(readFileSync12(profileDirConfig, "utf-8"));
|
|
34328
|
+
apiKey = Object.values(config).find((v) => typeof v === "string" && v.length > 0);
|
|
34329
|
+
} catch {}
|
|
35572
34330
|
}
|
|
35573
34331
|
}
|
|
35574
34332
|
}
|
|
@@ -35806,14 +34564,15 @@ Setting up ${meta.displayName}...
|
|
|
35806
34564
|
${chalk7.bold("Open this URL to authenticate:")}`);
|
|
35807
34565
|
console.log(` ${chalk7.cyan(oauthUrl)}
|
|
35808
34566
|
`);
|
|
35809
|
-
const { spawn:
|
|
34567
|
+
const { spawn: spawn4 } = await import("child_process");
|
|
35810
34568
|
const { getConnectorsHome: getConnectorsHome2 } = await Promise.resolve().then(() => (init_database(), exports_database));
|
|
34569
|
+
const { existsSync: existsSync8 } = await import("fs");
|
|
34570
|
+
const { join: join8 } = await import("path");
|
|
35811
34571
|
const scriptPath = process.argv[1];
|
|
35812
|
-
const serverProc =
|
|
34572
|
+
const serverProc = spawn4("node", [scriptPath, "serve", "--port", String(port)], {
|
|
35813
34573
|
detached: true,
|
|
35814
34574
|
stdio: "ignore"
|
|
35815
34575
|
});
|
|
35816
|
-
const startedAt = Date.now();
|
|
35817
34576
|
serverProc.unref();
|
|
35818
34577
|
await new Promise((resolve) => setTimeout(resolve, 2000));
|
|
35819
34578
|
try {
|
|
@@ -35825,13 +34584,13 @@ Setting up ${meta.displayName}...
|
|
|
35825
34584
|
}
|
|
35826
34585
|
console.log(chalk7.dim(" Waiting for authentication to complete..."));
|
|
35827
34586
|
const connectorsHome = getConnectorsHome2();
|
|
35828
|
-
const
|
|
35829
|
-
const
|
|
34587
|
+
const connectorDirName = name.startsWith("connect-") ? name : `connect-${name}`;
|
|
34588
|
+
const tokensPath = join8(connectorsHome, connectorDirName, "profiles", "default", "tokens.json");
|
|
35830
34589
|
let attempts = 0;
|
|
35831
34590
|
const maxAttempts = 360;
|
|
35832
34591
|
while (attempts < maxAttempts) {
|
|
35833
34592
|
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
35834
|
-
if (
|
|
34593
|
+
if (existsSync8(tokensPath))
|
|
35835
34594
|
break;
|
|
35836
34595
|
attempts++;
|
|
35837
34596
|
if (attempts % 6 === 0)
|