mirror of
https://github.com/logseq/logseq.git
synced 2026-05-23 12:14:06 +00:00
refactor: rename deps/db-sync to deps/workers
This commit is contained in:
12
.github/workflows/deps-db-sync.yml
vendored
12
.github/workflows/deps-db-sync.yml
vendored
@@ -6,25 +6,25 @@ on:
|
||||
push:
|
||||
branches: [master]
|
||||
paths:
|
||||
- 'deps/db-sync/**'
|
||||
- 'deps/workers/**'
|
||||
- '.github/workflows/deps-db-sync.yml'
|
||||
- '!deps/db-sync/**.md'
|
||||
- '!deps/workers/**.md'
|
||||
# Deps that logseq/db-sync depends on should trigger this workflow
|
||||
- 'deps/db/**'
|
||||
- 'deps/common/**'
|
||||
pull_request:
|
||||
branches: [master]
|
||||
paths:
|
||||
- 'deps/db-sync/**'
|
||||
- 'deps/workers/**'
|
||||
- '.github/workflows/deps-db-sync.yml'
|
||||
- '!deps/db-sync/**.md'
|
||||
- '!deps/workers/**.md'
|
||||
# Deps that logseq/db-sync depends on should trigger this workflow
|
||||
- 'deps/db/**'
|
||||
- 'deps/common/**'
|
||||
|
||||
defaults:
|
||||
run:
|
||||
working-directory: deps/db-sync
|
||||
working-directory: deps/workers
|
||||
|
||||
env:
|
||||
CLOJURE_VERSION: '1.11.1.1413'
|
||||
@@ -46,7 +46,7 @@ jobs:
|
||||
with:
|
||||
node-version: ${{ env.NODE_VERSION }}
|
||||
cache: 'yarn'
|
||||
cache-dependency-path: deps/db-sync/yarn.lock
|
||||
cache-dependency-path: deps/workers/yarn.lock
|
||||
|
||||
- name: Set up Java
|
||||
uses: actions/setup-java@v4
|
||||
|
||||
8
.gitignore
vendored
8
.gitignore
vendored
@@ -69,9 +69,9 @@ deps/shui/.clj-kondo
|
||||
deps/publish/worker/.wrangler
|
||||
deps/publish/worker/dist
|
||||
deps/publish/worker/.env*
|
||||
deps/db-sync/worker/.wrangler
|
||||
deps/db-sync/worker/dist
|
||||
deps/db-sync/worker/.env*
|
||||
deps/workers/worker/.wrangler
|
||||
deps/workers/worker/dist
|
||||
deps/workers/worker/.env*
|
||||
|
||||
|
||||
tx-log*
|
||||
@@ -79,5 +79,5 @@ clj-e2e/.wally
|
||||
clj-e2e/e2e-dump
|
||||
.dir-locals.el
|
||||
.projectile
|
||||
deps/db-sync/data
|
||||
deps/workers/data
|
||||
/packages/ui/@/lib/streamdown-bundle.js
|
||||
|
||||
6
bb.edn
6
bb.edn
@@ -172,12 +172,12 @@
|
||||
|
||||
dev:db-sync-test
|
||||
{:doc "Run db-sync server unit tests"
|
||||
:task (do (shell {:dir "deps/db-sync"} "clojure -M:cljs compile db-sync-test")
|
||||
(shell {:dir "deps/db-sync"} "node worker/dist/worker-test.js"))}
|
||||
:task (do (shell {:dir "deps/workers"} "clojure -M:cljs compile db-sync-test")
|
||||
(shell {:dir "deps/workers"} "node worker/dist/worker-test.js"))}
|
||||
|
||||
dev:db-sync-start
|
||||
{:doc "Start db-sync local server + client watch processes in foreground"
|
||||
:task logseq.tasks.dev.db-sync/start}
|
||||
:task logseq.tasks.dev.sync/start}
|
||||
|
||||
dev:gen-malli-kondo-config
|
||||
logseq.tasks.dev/gen-malli-kondo-config
|
||||
|
||||
2
deps.edn
2
deps.edn
@@ -37,7 +37,7 @@
|
||||
logseq/common {:local/root "deps/common"}
|
||||
logseq/graph-parser {:local/root "deps/graph-parser"}
|
||||
logseq/outliner {:local/root "deps/outliner"}
|
||||
logseq/db-sync {:local/root "deps/db-sync"}
|
||||
logseq/db-sync {:local/root "deps/workers"}
|
||||
logseq/publishing {:local/root "deps/publishing"}
|
||||
logseq/cli {:local/root "deps/cli"}
|
||||
logseq/shui {:local/root "deps/shui"}
|
||||
|
||||
24
deps/db-sync/.carve/ignore
vendored
24
deps/db-sync/.carve/ignore
vendored
@@ -1,24 +0,0 @@
|
||||
;; API
|
||||
logseq.db-sync.cycle/fix-cycle!
|
||||
;; API
|
||||
logseq.db-sync.node.entry/main
|
||||
;; API
|
||||
logseq.db-sync.order/fix-duplicate-orders!
|
||||
;; TODO: is this ns needed?
|
||||
logseq.db-sync.platform.cloudflare/response
|
||||
logseq.db-sync.platform.cloudflare/request
|
||||
logseq.db-sync.platform.cloudflare/request-url
|
||||
;; testing
|
||||
logseq.db-sync.protocol/tx->transit
|
||||
;; debugging
|
||||
logseq.db-sync.protocol/datoms->wire
|
||||
;; debugging
|
||||
logseq.db-sync.protocol/datoms->wire
|
||||
;; debugging
|
||||
logseq.db-sync.sentry.node/capture-exception!
|
||||
;; Used?
|
||||
logseq.db-sync.snapshot/framed-length
|
||||
;; API
|
||||
logseq.db-sync.worker/worker
|
||||
;; debugging
|
||||
logseq.db-sync.worker.timing/summary
|
||||
28
deps/db-sync/.clj-condo/config.edn
vendored
28
deps/db-sync/.clj-condo/config.edn
vendored
@@ -1,28 +0,0 @@
|
||||
{:linters
|
||||
{:aliased-namespace-symbol {:level :warning}
|
||||
:namespace-name-mismatch {:level :warning}
|
||||
:used-underscored-binding {:level :warning}
|
||||
:shadowed-var {:level :warning
|
||||
:exclude [meta name key keys uuid type]}
|
||||
|
||||
:consistent-alias
|
||||
{:aliases {clojure.pprint pprint
|
||||
clojure.string string
|
||||
datascript.core d
|
||||
datascript.transit dt
|
||||
logseq.db-sync.common common
|
||||
logseq.db-sync.config config
|
||||
logseq.db-sync.node.routes node-routes
|
||||
logseq.db-sync.platform.core platform
|
||||
logseq.db-sync.protocol protocol
|
||||
logseq.db-sync.storage storage
|
||||
logseq.db-sync.worker.auth auth
|
||||
logseq.db-sync.worker.handler.sync sync-handler
|
||||
logseq.db-sync.worker.handler.ws ws-handler
|
||||
logseq.db-sync.worker.http http
|
||||
logseq.db-sync.worker.routes.index routes
|
||||
logseq.db-sync.worker.ws ws}}}
|
||||
:lint-as {promesa.core/let clojure.core/let
|
||||
shadow.cljs.modern/defclass clj-kondo.lint-as/def-catch-all}
|
||||
:skip-comments true
|
||||
:output {:progress true}}
|
||||
@@ -1,6 +0,0 @@
|
||||
(ns logseq.db-sync.platform.cloudflare
|
||||
(:require [logseq.db-sync.platform.core :as core]))
|
||||
|
||||
(def response core/response)
|
||||
(def request core/request)
|
||||
(def request-url core/request-url)
|
||||
@@ -1,119 +0,0 @@
|
||||
(ns logseq.db-sync.node-server-test
|
||||
(:require [cljs.test :refer [async deftest is]]
|
||||
[logseq.db-sync.node.server :as node-server]
|
||||
[logseq.db-sync.worker.auth :as auth]
|
||||
[promesa.core :as p]))
|
||||
|
||||
(defn- fetch-with-timeout [url timeout-ms]
|
||||
(let [timeout-sentinel ::timeout]
|
||||
{:sentinel timeout-sentinel
|
||||
:promise (js/Promise.
|
||||
(fn [resolve reject]
|
||||
(let [controller (js/AbortController.)
|
||||
timeout-id (js/setTimeout
|
||||
(fn []
|
||||
(.abort controller))
|
||||
timeout-ms)]
|
||||
(-> (js/fetch url #js {:method "GET"
|
||||
:headers #js {"authorization" "Bearer test.token.sig"}
|
||||
:signal (.-signal controller)})
|
||||
(.then (fn [response]
|
||||
(js/clearTimeout timeout-id)
|
||||
(resolve response)))
|
||||
(.catch (fn [error]
|
||||
(js/clearTimeout timeout-id)
|
||||
(if (= "AbortError" (.-name error))
|
||||
(resolve timeout-sentinel)
|
||||
(reject error))))))))}))
|
||||
|
||||
(deftest node-server-returns-500-when-auth-claims-rejects-test
|
||||
(async done
|
||||
(let [stop-server! (atom nil)
|
||||
test-url (atom nil)]
|
||||
(-> (p/with-redefs [auth/auth-claims
|
||||
(fn [_request _env]
|
||||
(p/rejected (ex-info "jwks" {})))]
|
||||
(p/let [{:keys [base-url stop!]} (node-server/start! {:port 0
|
||||
:data-dir (str "tmp/db-sync-node-server-test/" (random-uuid))})
|
||||
_ (reset! stop-server! stop!)
|
||||
_ (reset! test-url (str base-url "/graphs"))
|
||||
{:keys [promise sentinel]} (fetch-with-timeout @test-url 1200)
|
||||
response promise]
|
||||
(if (identical? response sentinel)
|
||||
(is false "request timed out")
|
||||
(p/let [body (.json response)]
|
||||
(is (= 500 (.-status response)))
|
||||
(is (= "server error" (aget body "error")))))))
|
||||
(p/then
|
||||
(fn []
|
||||
(if-let [stop! @stop-server!]
|
||||
(-> (stop!)
|
||||
(p/then (fn [] (done)))
|
||||
(p/catch (fn [error]
|
||||
(is false (str error))
|
||||
(done))))
|
||||
(done))))
|
||||
(p/catch
|
||||
(fn [error]
|
||||
(if-let [stop! @stop-server!]
|
||||
(-> (stop!)
|
||||
(p/then (fn []
|
||||
(is false (str error))
|
||||
(done)))
|
||||
(p/catch (fn [stop-error]
|
||||
(is false (str error))
|
||||
(is false (str stop-error))
|
||||
(done))))
|
||||
(do
|
||||
(is false (str error))
|
||||
(done)))))))))
|
||||
|
||||
(deftest node-server-logs-request-failed-marker-when-auth-claims-rejects-test
|
||||
(async done
|
||||
(let [stop-server! (atom nil)
|
||||
original-console-error (.-error js/console)
|
||||
logged-errors (atom [])]
|
||||
(aset js/console
|
||||
"error"
|
||||
(fn [& args]
|
||||
(swap! logged-errors conj args)))
|
||||
(-> (p/with-redefs [auth/auth-claims
|
||||
(fn [_request _env]
|
||||
(p/rejected (ex-info "jwks" {})))]
|
||||
(p/let [{:keys [base-url stop!]} (node-server/start! {:port 0
|
||||
:data-dir (str "tmp/db-sync-node-server-log-test/" (random-uuid))})
|
||||
_ (reset! stop-server! stop!)
|
||||
_ (reset! logged-errors [])
|
||||
{:keys [promise sentinel]} (fetch-with-timeout (str base-url "/graphs") 1200)
|
||||
response promise]
|
||||
(if (identical? response sentinel)
|
||||
(is false "request timed out")
|
||||
(do
|
||||
(is (= 500 (.-status response)))
|
||||
(is (some #(= ":db-sync/node-request-failed" (first %))
|
||||
@logged-errors))))))
|
||||
(p/then
|
||||
(fn []
|
||||
(aset js/console "error" original-console-error)
|
||||
(if-let [stop! @stop-server!]
|
||||
(-> (stop!)
|
||||
(p/then (fn [] (done)))
|
||||
(p/catch (fn [error]
|
||||
(is false (str error))
|
||||
(done))))
|
||||
(done))))
|
||||
(p/catch
|
||||
(fn [error]
|
||||
(aset js/console "error" original-console-error)
|
||||
(if-let [stop! @stop-server!]
|
||||
(-> (stop!)
|
||||
(p/then (fn []
|
||||
(is false (str error))
|
||||
(done)))
|
||||
(p/catch (fn [stop-error]
|
||||
(is false (str error))
|
||||
(is false (str stop-error))
|
||||
(done))))
|
||||
(do
|
||||
(is false (str error))
|
||||
(done)))))))))
|
||||
@@ -1,38 +0,0 @@
|
||||
(ns logseq.db-sync.test-runner
|
||||
(:require [cljs.test :as ct]
|
||||
[logseq.db-sync.agent-do-test]
|
||||
[logseq.db-sync.agent-request-test]
|
||||
[logseq.db-sync.agent-runtime-provider-test]
|
||||
[logseq.db-sync.agent-source-control-test]
|
||||
[logseq.db-sync.common-test]
|
||||
[logseq.db-sync.index-test]
|
||||
[logseq.db-sync.node-adapter-test]
|
||||
[logseq.db-sync.node-config-test]
|
||||
[logseq.db-sync.node-server-test]
|
||||
[logseq.db-sync.normalize-test]
|
||||
[logseq.db-sync.platform-test]
|
||||
[logseq.db-sync.worker-agents-dispatch-test]
|
||||
[logseq.db-sync.worker-auth-test]
|
||||
[logseq.db-sync.worker-handler-assets-test]
|
||||
[logseq.db-sync.worker-handler-index-test]
|
||||
[logseq.db-sync.worker-handler-sync-test]
|
||||
[logseq.db-sync.worker-handler-ws-test]
|
||||
[logseq.db-sync.worker-routes-test]
|
||||
[shadow.test :as st]
|
||||
[shadow.test.env :as env]))
|
||||
|
||||
(derive ::node ::ct/default)
|
||||
|
||||
(defmethod ct/report [::node :end-run-tests] [m]
|
||||
(if (ct/successful? m)
|
||||
(js/process.exit 0)
|
||||
(js/process.exit 1)))
|
||||
|
||||
(defn ^:dev/after-load reset-test-data! []
|
||||
(-> (env/get-test-data)
|
||||
(env/reset-test-data!)))
|
||||
|
||||
(defn main [& _args]
|
||||
(reset-test-data!)
|
||||
(let [test-env (ct/empty-env ::node)]
|
||||
(st/run-all-tests test-env nil)))
|
||||
24
deps/workers/.carve/ignore
vendored
Normal file
24
deps/workers/.carve/ignore
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
;; API
|
||||
logseq.sync.cycle/fix-cycle!
|
||||
;; API
|
||||
logseq.sync.node.entry/main
|
||||
;; API
|
||||
logseq.sync.order/fix-duplicate-orders!
|
||||
;; TODO: is this ns needed?
|
||||
logseq.sync.platform.cloudflare/response
|
||||
logseq.sync.platform.cloudflare/request
|
||||
logseq.sync.platform.cloudflare/request-url
|
||||
;; testing
|
||||
logseq.sync.protocol/tx->transit
|
||||
;; debugging
|
||||
logseq.sync.protocol/datoms->wire
|
||||
;; debugging
|
||||
logseq.sync.protocol/datoms->wire
|
||||
;; debugging
|
||||
logseq.sync.sentry.node/capture-exception!
|
||||
;; Used?
|
||||
logseq.sync.snapshot/framed-length
|
||||
;; API
|
||||
logseq.sync.worker/worker
|
||||
;; debugging
|
||||
logseq.sync.worker.timing/summary
|
||||
28
deps/workers/.clj-condo/config.edn
vendored
Normal file
28
deps/workers/.clj-condo/config.edn
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
{:linters
|
||||
{:aliased-namespace-symbol {:level :warning}
|
||||
:namespace-name-mismatch {:level :warning}
|
||||
:used-underscored-binding {:level :warning}
|
||||
:shadowed-var {:level :warning
|
||||
:exclude [meta name key keys uuid type]}
|
||||
|
||||
:consistent-alias
|
||||
{:aliases {clojure.pprint pprint
|
||||
clojure.string string
|
||||
datascript.core d
|
||||
datascript.transit dt
|
||||
logseq.sync.common common
|
||||
logseq.sync.config config
|
||||
logseq.sync.node.routes node-routes
|
||||
logseq.sync.platform.core platform
|
||||
logseq.sync.protocol protocol
|
||||
logseq.sync.storage storage
|
||||
logseq.sync.worker.auth auth
|
||||
logseq.sync.worker.handler.sync sync-handler
|
||||
logseq.sync.worker.handler.ws ws-handler
|
||||
logseq.sync.worker.http http
|
||||
logseq.sync.worker.routes.index routes
|
||||
logseq.sync.worker.ws ws}}}
|
||||
:lint-as {promesa.core/let clojure.core/let
|
||||
shadow.cljs.modern/defclass clj-kondo.lint-as/def-catch-all}
|
||||
:skip-comments true
|
||||
:output {:progress true}}
|
||||
20
deps/db-sync/README.md → deps/workers/README.md
vendored
20
deps/db-sync/README.md → deps/workers/README.md
vendored
@@ -1,4 +1,4 @@
|
||||
# Logseq DB Sync (deps/db-sync)
|
||||
# Logseq DB Sync (deps/workers)
|
||||
|
||||
This package contains db-sync and agents worker code plus tests used by Logseq.
|
||||
It includes separate Cloudflare worker entrypoints and a Node.js adapter for self-hosting.
|
||||
@@ -14,22 +14,22 @@ It includes separate Cloudflare worker entrypoints and a Node.js adapter for sel
|
||||
DB sync worker (`/sync/*`, `/graphs*`, `/e2ee*`, `/assets/*`):
|
||||
|
||||
```bash
|
||||
cd deps/db-sync
|
||||
cd deps/workers
|
||||
yarn watch
|
||||
|
||||
# open another terminal
|
||||
cd deps/db-sync/worker
|
||||
cd deps/workers/worker
|
||||
wrangler dev
|
||||
```
|
||||
|
||||
Agents worker (`/sessions*`):
|
||||
|
||||
```bash
|
||||
cd deps/db-sync
|
||||
cd deps/workers
|
||||
yarn watch:agents
|
||||
|
||||
# open another terminal
|
||||
cd deps/db-sync/worker
|
||||
cd deps/workers/worker
|
||||
wrangler dev -c wrangler.agents.toml
|
||||
```
|
||||
|
||||
@@ -52,7 +52,7 @@ The worker no longer initializes schema at request time. Apply the D1 schema
|
||||
via migrations during deployment/CI.
|
||||
|
||||
```bash
|
||||
cd deps/db-sync/worker
|
||||
cd deps/workers/worker
|
||||
wrangler d1 migrations apply logseq-sync-graph-meta-staging --env staging
|
||||
wrangler d1 migrations apply logseq-sync-graphs-prod --env prod
|
||||
```
|
||||
@@ -64,7 +64,7 @@ For local development, run `wrangler d1 migrations apply DB --local`.
|
||||
Build the adapter:
|
||||
|
||||
```bash
|
||||
cd deps/db-sync
|
||||
cd deps/workers
|
||||
npm run build:node-adapter
|
||||
```
|
||||
|
||||
@@ -83,7 +83,7 @@ node worker/dist/node-adapter.js
|
||||
Run db-sync tests (includes Node adapter tests):
|
||||
|
||||
```bash
|
||||
cd deps/db-sync
|
||||
cd deps/workers
|
||||
npm run test:node-adapter
|
||||
```
|
||||
|
||||
@@ -92,7 +92,7 @@ npm run test:node-adapter
|
||||
Use the local sandbox-agent repo at `~/Codes/projects/sandbox-agent`:
|
||||
|
||||
```bash
|
||||
cd deps/db-sync
|
||||
cd deps/workers
|
||||
./scripts/start-local-sandbox-agent.sh
|
||||
```
|
||||
|
||||
@@ -111,7 +111,7 @@ SANDBOX_AGENT_TOKEN=...
|
||||
Smoke test a Codex-backed session:
|
||||
|
||||
```bash
|
||||
cd deps/db-sync
|
||||
cd deps/workers
|
||||
BASE_URL=http://127.0.0.1:8787 ./scripts/start-weather-session.sh
|
||||
```
|
||||
|
||||
@@ -27,7 +27,7 @@ Run task sessions on Sprites by default so every `#Task` can provision an isolat
|
||||
## Workstreams
|
||||
|
||||
### WS1: Provider Implementation
|
||||
- Add `SpritesProvider` in `src/logseq/db_sync/worker/agent/runtime_provider.cljs`.
|
||||
- Add `SpritesProvider` in `src/logseq/agents/runtime_provider.cljs`.
|
||||
- Implement:
|
||||
- `<provision-runtime!`
|
||||
- `<open-message-stream!`
|
||||
@@ -41,8 +41,8 @@ Run task sessions on Sprites by default so every `#Task` can provision an isolat
|
||||
|
||||
### WS3: Config + Defaults
|
||||
- Add Sprites env vars in:
|
||||
- `src/logseq/db_sync/node/config.cljs`
|
||||
- `src/logseq/db_sync/node/server.cljs`
|
||||
- `src/logseq/sync/node/config.cljs`
|
||||
- `src/logseq/sync/node/server.cljs`
|
||||
- `README.md`
|
||||
- Set provider default to `sprites` (with explicit opt-out via `AGENT_RUNTIME_PROVIDER`).
|
||||
|
||||
@@ -64,7 +64,7 @@ Run task sessions on Sprites by default so every `#Task` can provision an isolat
|
||||
5) Existing providers continue to work when explicitly selected.
|
||||
|
||||
## Implemented
|
||||
- Added `SpritesProvider` in `src/logseq/db_sync/worker/agent/runtime_provider.cljs`.
|
||||
- Added `SpritesProvider` in `src/logseq/agents/runtime_provider.cljs`.
|
||||
- Set provider default to `sprites` via provider-kind normalization.
|
||||
- Added Sprites runtime lifecycle:
|
||||
- create/get sprite
|
||||
@@ -74,7 +74,7 @@ Run task sessions on Sprites by default so every `#Task` can provision an isolat
|
||||
- stream message SSE via sprite spawn + stdout bridge
|
||||
- delete sprite on terminate
|
||||
- Added Sprites env passthrough in:
|
||||
- `src/logseq/db_sync/node/config.cljs`
|
||||
- `src/logseq/db_sync/node/server.cljs`
|
||||
- `src/logseq/sync/node/config.cljs`
|
||||
- `src/logseq/sync/node/server.cljs`
|
||||
- Updated docs and env reference in `README.md`.
|
||||
- Updated provider tests in `test/logseq/db_sync/agent_runtime_provider_test.cljs`.
|
||||
- Updated provider tests in `test/logseq/agents/runtime_provider_test.cljs`.
|
||||
@@ -22,7 +22,7 @@ Support `AGENT_RUNTIME_PROVIDER=cloudflare` end-to-end so db-sync can provision
|
||||
- proxy via `containerFetch(...)`
|
||||
|
||||
## Scope
|
||||
1) Add `CloudflareProvider` in `src/logseq/db_sync/worker/agent/runtime_provider.cljs`.
|
||||
1) Add `CloudflareProvider` in `src/logseq/agents/runtime_provider.cljs`.
|
||||
2) Implement lifecycle methods:
|
||||
- `<provision-runtime!`
|
||||
- `<open-message-stream!`
|
||||
@@ -88,5 +88,5 @@ Support `AGENT_RUNTIME_PROVIDER=cloudflare` end-to-end so db-sync can provision
|
||||
- Added Cloudflare/runtime metadata in session runtime state (`:sandbox-id`, `:sandbox-name`, `:sandbox-port`).
|
||||
- Added `sandbox/<terminate-session` endpoint helper.
|
||||
- Updated runtime event provisioning payload to include `:sandbox-name`.
|
||||
- Added and updated tests in `test/logseq/db_sync/agent_runtime_provider_test.cljs`.
|
||||
- Added and updated tests in `test/logseq/agents/runtime_provider_test.cljs`.
|
||||
- Updated runtime docs/env reference in `README.md`.
|
||||
@@ -8,8 +8,8 @@
|
||||
:compiler-options {:source-map true
|
||||
:warnings {:fn-deprecated false
|
||||
:redef false}}
|
||||
:modules {:main {:exports {default logseq.db-sync.worker/worker
|
||||
SyncDO logseq.db-sync.worker/SyncDO}}}
|
||||
:modules {:main {:exports {default logseq.sync.worker/worker
|
||||
SyncDO logseq.sync.worker/SyncDO}}}
|
||||
:js-options {:js-provider :import}
|
||||
:closure-defines {shadow.cljs.devtools.client.env/enabled false
|
||||
goog.debug.LOGGING_ENABLED true}
|
||||
@@ -19,16 +19,16 @@
|
||||
:compiler-options {:source-map true
|
||||
:warnings {:fn-deprecated false
|
||||
:redef false}}
|
||||
:modules {:main {:exports {default logseq.db-sync.agents.worker/worker
|
||||
AgentSessionDO logseq.db-sync.agents.worker/AgentSessionDO
|
||||
Sandbox logseq.db-sync.agents.worker/Sandbox}}}
|
||||
:modules {:main {:exports {default logseq.agents.worker/worker
|
||||
AgentSessionDO logseq.agents.worker/AgentSessionDO
|
||||
Sandbox logseq.agents.worker/Sandbox}}}
|
||||
:js-options {:js-provider :import}
|
||||
:closure-defines {shadow.cljs.devtools.client.env/enabled false
|
||||
goog.debug.LOGGING_ENABLED true}
|
||||
:devtools {:enabled false}}
|
||||
:db-sync-node {:target :node-script
|
||||
:output-to "worker/dist/node-adapter.js"
|
||||
:main logseq.db-sync.node.entry/main
|
||||
:main logseq.sync.node.entry/main
|
||||
:compiler-options {:source-map true
|
||||
:warnings {:fn-deprecated false
|
||||
:redef false}}
|
||||
@@ -36,10 +36,11 @@
|
||||
:closure-defines {goog.debug.LOGGING_ENABLED true}}
|
||||
:db-sync-test {:target :node-test
|
||||
:output-to "worker/dist/worker-test.js"
|
||||
:ns-regexp "logseq\\.sync\\.(?!node-server-test$).*-test$"
|
||||
:devtools {:enabled false}
|
||||
:main logseq.db-sync.test-runner/main}
|
||||
:main logseq.sync.test-runner/main}
|
||||
:db-sync-worker-split-test {:target :node-test
|
||||
:output-to "worker/dist/worker-split-test.js"
|
||||
:ns-regexp "logseq\\.db-sync\\.(worker-test|worker-agents-dispatch-test)$"
|
||||
:ns-regexp "logseq\\.(sync\\.worker-test|agents\\.dispatch-test)$"
|
||||
:devtools {:enabled false}
|
||||
:main logseq.db-sync.worker-split-test-runner/main}}}
|
||||
:main logseq.sync.worker-split-test-runner/main}}}
|
||||
@@ -1,9 +1,9 @@
|
||||
(ns logseq.db-sync.worker.agents-dispatch
|
||||
(ns logseq.agents.dispatch
|
||||
(:require [clojure.string :as string]
|
||||
[logseq.db-sync.common :as common]
|
||||
[logseq.db-sync.platform.core :as platform]
|
||||
[logseq.db-sync.worker.handler.agent :as agent-handler]
|
||||
[logseq.db-sync.worker.http :as http]
|
||||
[logseq.sync.common :as common]
|
||||
[logseq.sync.platform.core :as platform]
|
||||
[logseq.agents.handler :as agent-handler]
|
||||
[logseq.sync.worker.http :as http]
|
||||
[promesa.core :as p]))
|
||||
|
||||
(defn handle-worker-fetch [request ^js env]
|
||||
@@ -1,12 +1,12 @@
|
||||
(ns logseq.db-sync.worker.agent.do
|
||||
(ns logseq.agents.do
|
||||
(:require [clojure.string :as string]
|
||||
[lambdaisland.glogi :as log]
|
||||
[logseq.db-sync.common :as common]
|
||||
[logseq.db-sync.platform.core :as platform]
|
||||
[logseq.db-sync.worker.agent.runtime-provider :as runtime-provider]
|
||||
[logseq.db-sync.worker.agent.session :as session]
|
||||
[logseq.db-sync.worker.agent.source-control :as source-control]
|
||||
[logseq.db-sync.worker.http :as http]
|
||||
[logseq.sync.common :as common]
|
||||
[logseq.sync.platform.core :as platform]
|
||||
[logseq.agents.runtime-provider :as runtime-provider]
|
||||
[logseq.agents.session :as session]
|
||||
[logseq.agents.source-control :as source-control]
|
||||
[logseq.sync.worker.http :as http]
|
||||
[promesa.core :as p]))
|
||||
|
||||
(defn- header [request name]
|
||||
@@ -1,11 +1,11 @@
|
||||
(ns logseq.db-sync.worker.handler.agent
|
||||
(ns logseq.agents.handler
|
||||
(:require [lambdaisland.glogi :as log]
|
||||
[logseq.db-sync.common :as common]
|
||||
[logseq.db-sync.platform.core :as platform]
|
||||
[logseq.db-sync.worker.agent.request :as agent-request]
|
||||
[logseq.db-sync.worker.auth :as auth]
|
||||
[logseq.db-sync.worker.http :as http]
|
||||
[logseq.db-sync.worker.routes.index :as routes]
|
||||
[logseq.sync.common :as common]
|
||||
[logseq.sync.platform.core :as platform]
|
||||
[logseq.agents.request :as agent-request]
|
||||
[logseq.agents.routes :as routes]
|
||||
[logseq.sync.worker.auth :as auth]
|
||||
[logseq.sync.worker.http :as http]
|
||||
[promesa.core :as p]))
|
||||
|
||||
(defn- session-namespace [^js env]
|
||||
@@ -1,4 +1,4 @@
|
||||
(ns logseq.db-sync.worker.agent.request)
|
||||
(ns logseq.agents.request)
|
||||
|
||||
(defn normalize-session-create
|
||||
[body]
|
||||
25
deps/workers/src/logseq/agents/routes.cljs
vendored
Normal file
25
deps/workers/src/logseq/agents/routes.cljs
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
(ns logseq.agents.routes
|
||||
(:require [reitit.core :as r]))
|
||||
|
||||
(def ^:private route-data
|
||||
[["/sessions"
|
||||
["" {:methods {"POST" :sessions/create}}]
|
||||
["/:session-id"
|
||||
["" {:methods {"GET" :sessions/get}}]
|
||||
["/messages" {:methods {"POST" :sessions/messages}}]
|
||||
["/pause" {:methods {"POST" :sessions/pause}}]
|
||||
["/resume" {:methods {"POST" :sessions/resume}}]
|
||||
["/interrupt" {:methods {"POST" :sessions/interrupt}}]
|
||||
["/cancel" {:methods {"POST" :sessions/cancel}}]
|
||||
["/pr" {:methods {"POST" :sessions/pr}}]
|
||||
["/events" {:methods {"GET" :sessions/events}}]
|
||||
["/terminal" {:methods {"GET" :sessions/terminal}}]
|
||||
["/stream" {:methods {"GET" :sessions/stream}}]]]])
|
||||
|
||||
(def ^:private router
|
||||
(r/router route-data))
|
||||
|
||||
(defn match-route [method path]
|
||||
(when-let [match (r/match-by-path router path)]
|
||||
(when-let [handler (get-in match [:data :methods method])]
|
||||
(assoc match :handler handler))))
|
||||
@@ -1,9 +1,9 @@
|
||||
(ns logseq.db-sync.worker.agent.runtime-provider
|
||||
(ns logseq.agents.runtime-provider
|
||||
(:require ["@cloudflare/sandbox" :as cf-sandbox]
|
||||
[clojure.string :as string]
|
||||
[lambdaisland.glogi :as log]
|
||||
[logseq.db-sync.worker.agent.sandbox :as sandbox]
|
||||
[logseq.db-sync.worker.agent.source-control :as source-control]
|
||||
[logseq.agents.sandbox :as sandbox]
|
||||
[logseq.agents.source-control :as source-control]
|
||||
[promesa.core :as p]))
|
||||
|
||||
;; -----------------------
|
||||
@@ -1,6 +1,6 @@
|
||||
(ns logseq.db-sync.worker.agent.sandbox
|
||||
(ns logseq.agents.sandbox
|
||||
(:require [clojure.string :as string]
|
||||
[logseq.db-sync.platform.core :as platform]
|
||||
[logseq.sync.platform.core :as platform]
|
||||
[promesa.core :as p]))
|
||||
|
||||
(defn normalize-base-url [base]
|
||||
@@ -1,5 +1,5 @@
|
||||
(ns logseq.db-sync.worker.agent.session
|
||||
(:require [logseq.db-sync.common :as common]))
|
||||
(ns logseq.agents.session
|
||||
(:require [logseq.sync.common :as common]))
|
||||
|
||||
(defn initial-session [task audit now]
|
||||
{:id (:id task)
|
||||
@@ -1,4 +1,4 @@
|
||||
(ns logseq.db-sync.worker.agent.source-control
|
||||
(ns logseq.agents.source-control
|
||||
(:require [clojure.string :as string]
|
||||
[promesa.core :as p]))
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
(ns logseq.db-sync.agents.worker
|
||||
(ns logseq.agents.worker
|
||||
;; Turn off false defclass errors
|
||||
{:clj-kondo/config {:linters {:unresolved-symbol {:level :off}}}}
|
||||
(:require ["@cloudflare/sandbox" :as cf-sandbox]
|
||||
["cloudflare:workers" :refer [DurableObject]]
|
||||
[logseq.db-sync.logging :as logging]
|
||||
[logseq.db-sync.sentry.worker :as sentry]
|
||||
[logseq.db-sync.worker.agent.do :as agent-do]
|
||||
[logseq.db-sync.worker.agents-dispatch :as dispatch]
|
||||
[logseq.sync.logging :as logging]
|
||||
[logseq.sync.sentry.worker :as sentry]
|
||||
[logseq.agents.do :as agent-do]
|
||||
[logseq.agents.dispatch :as dispatch]
|
||||
[shadow.cljs.modern :refer (defclass)]))
|
||||
|
||||
(logging/install!)
|
||||
@@ -1,4 +1,4 @@
|
||||
(ns logseq.db-sync.batch
|
||||
(ns logseq.sync.batch
|
||||
(:require [clojure.string :as string]))
|
||||
|
||||
(def ^:private max-sql-params 99)
|
||||
@@ -1,6 +1,6 @@
|
||||
(ns logseq.db-sync.common
|
||||
(ns logseq.sync.common
|
||||
(:require [clojure.string :as string]
|
||||
[logseq.db-sync.platform.core :as platform]
|
||||
[logseq.sync.platform.core :as platform]
|
||||
[logseq.db.sqlite.util :as sqlite-util]
|
||||
[promesa.core :as p]))
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
(ns logseq.db-sync.cycle
|
||||
(ns logseq.sync.cycle
|
||||
"Generic cycle repair utilities for DataScript graphs.
|
||||
|
||||
Supports:
|
||||
@@ -1,6 +1,6 @@
|
||||
(ns logseq.db-sync.index
|
||||
(ns logseq.sync.index
|
||||
(:require [clojure.string :as string]
|
||||
[logseq.db-sync.common :as common]
|
||||
[logseq.sync.common :as common]
|
||||
[promesa.core :as p]))
|
||||
|
||||
(def ^:private user-upsert-cache-ttl-ms (* 60 60 1000))
|
||||
@@ -1,4 +1,4 @@
|
||||
(ns logseq.db-sync.logging
|
||||
(ns logseq.sync.logging
|
||||
(:require [lambdaisland.glogi :as log]
|
||||
[lambdaisland.glogi.console :as glogi-console]))
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
(ns logseq.db-sync.malli-schema
|
||||
(ns logseq.sync.malli-schema
|
||||
(:require [malli.core :as ma]
|
||||
[malli.transform :as mt]))
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
(ns logseq.db-sync.node.assets
|
||||
(ns logseq.sync.node.assets
|
||||
(:require ["fs" :as fs]
|
||||
["path" :as node-path]
|
||||
[promesa.core :as p]))
|
||||
@@ -1,4 +1,4 @@
|
||||
(ns logseq.db-sync.node.config
|
||||
(ns logseq.sync.node.config
|
||||
(:require [clojure.string :as string]))
|
||||
|
||||
(defn- env-value [^js env k]
|
||||
@@ -1,13 +1,13 @@
|
||||
(ns logseq.db-sync.node.dispatch
|
||||
(ns logseq.sync.node.dispatch
|
||||
(:require [clojure.string :as string]
|
||||
[logseq.db-sync.common :as common]
|
||||
[logseq.db-sync.node.graph :as graph]
|
||||
[logseq.db-sync.node.routes :as node-routes]
|
||||
[logseq.db-sync.platform.core :as platform]
|
||||
[logseq.db-sync.worker.handler.assets :as assets-handler]
|
||||
[logseq.db-sync.worker.handler.index :as index-handler]
|
||||
[logseq.db-sync.worker.handler.sync :as sync-handler]
|
||||
[logseq.db-sync.worker.http :as http]
|
||||
[logseq.sync.common :as common]
|
||||
[logseq.sync.node.graph :as graph]
|
||||
[logseq.sync.node.routes :as node-routes]
|
||||
[logseq.sync.platform.core :as platform]
|
||||
[logseq.sync.worker.handler.assets :as assets-handler]
|
||||
[logseq.sync.worker.handler.index :as index-handler]
|
||||
[logseq.sync.worker.handler.sync :as sync-handler]
|
||||
[logseq.sync.worker.http :as http]
|
||||
[promesa.core :as p]))
|
||||
|
||||
(defn handle-node-fetch
|
||||
@@ -1,7 +1,7 @@
|
||||
(ns logseq.db-sync.node.entry
|
||||
(:require [logseq.db-sync.node.config :as config]
|
||||
[logseq.db-sync.node.server :as server]
|
||||
[logseq.db-sync.sentry.node :as sentry]
|
||||
(ns logseq.sync.node.entry
|
||||
(:require [logseq.sync.node.config :as config]
|
||||
[logseq.sync.node.server :as server]
|
||||
[logseq.sync.sentry.node :as sentry]
|
||||
[promesa.core :as p]))
|
||||
|
||||
(defonce ^:private *server (atom nil))
|
||||
@@ -1,5 +1,5 @@
|
||||
(ns logseq.db-sync.node.graph
|
||||
(:require [logseq.db-sync.node.storage :as storage]))
|
||||
(ns logseq.sync.node.graph
|
||||
(:require [logseq.sync.node.storage :as storage]))
|
||||
|
||||
(defn- make-state []
|
||||
(let [sockets (atom #{})]
|
||||
@@ -1,4 +1,4 @@
|
||||
(ns logseq.db-sync.node.routes
|
||||
(ns logseq.sync.node.routes
|
||||
(:require [clojure.string :as string]))
|
||||
|
||||
(defn parse-sync-path [path]
|
||||
@@ -1,51 +1,26 @@
|
||||
(ns logseq.db-sync.node.server
|
||||
(ns logseq.sync.node.server
|
||||
(:require ["http" :as http]
|
||||
["path" :as node-path]
|
||||
["ws" :as ws]
|
||||
[lambdaisland.glogi :as log]
|
||||
[logseq.db-sync.index :as index]
|
||||
[logseq.db-sync.logging :as logging]
|
||||
[logseq.db-sync.node.assets :as assets]
|
||||
[logseq.db-sync.node.config :as config]
|
||||
[logseq.db-sync.node.dispatch :as dispatch]
|
||||
[logseq.db-sync.node.graph :as graph]
|
||||
[logseq.db-sync.node.routes :as node-routes]
|
||||
[logseq.db-sync.node.storage :as storage]
|
||||
[logseq.db-sync.platform.core :as platform]
|
||||
[logseq.db-sync.platform.node :as platform-node]
|
||||
[logseq.db-sync.worker.agent.do :as agent-do]
|
||||
[logseq.db-sync.worker.auth :as auth]
|
||||
[logseq.db-sync.worker.handler.ws :as ws-handler]
|
||||
[logseq.db-sync.worker.http :as worker-http]
|
||||
[logseq.db-sync.worker.presence :as presence]
|
||||
[logseq.sync.index :as index]
|
||||
[logseq.sync.logging :as logging]
|
||||
[logseq.sync.node.assets :as assets]
|
||||
[logseq.sync.node.config :as config]
|
||||
[logseq.sync.node.dispatch :as dispatch]
|
||||
[logseq.sync.node.graph :as graph]
|
||||
[logseq.sync.node.routes :as node-routes]
|
||||
[logseq.sync.node.storage :as storage]
|
||||
[logseq.sync.platform.core :as platform]
|
||||
[logseq.sync.platform.node :as platform-node]
|
||||
[logseq.sync.worker.auth :as auth]
|
||||
[logseq.sync.worker.handler.ws :as ws-handler]
|
||||
[logseq.sync.worker.http :as worker-http]
|
||||
[logseq.sync.worker.presence :as presence]
|
||||
[promesa.core :as p]))
|
||||
|
||||
(logging/install!)
|
||||
|
||||
(defn- make-agent-storage []
|
||||
(let [data (js/Map.)]
|
||||
#js {:get (fn [k]
|
||||
(js/Promise.resolve (.get data k)))
|
||||
:put (fn [k v]
|
||||
(.set data k v)
|
||||
(js/Promise.resolve nil))}))
|
||||
|
||||
(defn- make-agent-session-stub [env]
|
||||
(let [self #js {:env env
|
||||
:storage (make-agent-storage)
|
||||
:streams (js/Map.)}]
|
||||
#js {:fetch (fn [request]
|
||||
(agent-do/handle-fetch self request))}))
|
||||
|
||||
(defn- make-agent-session-namespace [env]
|
||||
(let [sessions (js/Map.)]
|
||||
#js {:idFromName (fn [session-id] session-id)
|
||||
:get (fn [session-id]
|
||||
(or (.get sessions session-id)
|
||||
(let [stub (make-agent-session-stub env)]
|
||||
(.set sessions session-id stub)
|
||||
stub)))}))
|
||||
|
||||
(defn- make-env [cfg index-db assets-bucket]
|
||||
(let [env (doto (js-obj)
|
||||
(aset "DB" index-db)
|
||||
@@ -90,7 +65,6 @@
|
||||
(aset "COGNITO_ISSUER" (:cognito-issuer cfg))
|
||||
(aset "COGNITO_CLIENT_ID" (:cognito-client-id cfg))
|
||||
(aset "COGNITO_JWKS_URL" (:cognito-jwks-url cfg)))]
|
||||
(aset env "LOGSEQ_AGENT_SESSION_DO" (make-agent-session-namespace env))
|
||||
env))
|
||||
|
||||
(defn- access-allowed?
|
||||
@@ -1,4 +1,4 @@
|
||||
(ns logseq.db-sync.node.storage
|
||||
(ns logseq.sync.node.storage
|
||||
(:require ["better-sqlite3" :as sqlite3]
|
||||
["fs" :as fs]
|
||||
["path" :as node-path]
|
||||
@@ -1,4 +1,4 @@
|
||||
(ns logseq.db-sync.order
|
||||
(ns logseq.sync.order
|
||||
(:require [datascript.core :as d]
|
||||
[logseq.db.common.order :as db-order]))
|
||||
|
||||
6
deps/workers/src/logseq/sync/platform/cloudflare.cljs
vendored
Normal file
6
deps/workers/src/logseq/sync/platform/cloudflare.cljs
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
(ns logseq.sync.platform.cloudflare
|
||||
(:require [logseq.sync.platform.core :as core]))
|
||||
|
||||
(def response core/response)
|
||||
(def request core/request)
|
||||
(def request-url core/request-url)
|
||||
@@ -1,4 +1,4 @@
|
||||
(ns logseq.db-sync.platform.core)
|
||||
(ns logseq.sync.platform.core)
|
||||
|
||||
(defn response
|
||||
[body init]
|
||||
@@ -1,6 +1,6 @@
|
||||
(ns logseq.db-sync.platform.node
|
||||
(ns logseq.sync.platform.node
|
||||
(:require [clojure.string :as string]
|
||||
[logseq.db-sync.platform.core :as core]
|
||||
[logseq.sync.platform.core :as core]
|
||||
[promesa.core :as p]))
|
||||
|
||||
(defn- headers->object [headers]
|
||||
@@ -1,5 +1,5 @@
|
||||
(ns logseq.db-sync.protocol
|
||||
(:require [logseq.db-sync.common :as common]))
|
||||
(ns logseq.sync.protocol
|
||||
(:require [logseq.sync.common :as common]))
|
||||
|
||||
(defn parse-message [raw]
|
||||
(try
|
||||
@@ -1,4 +1,4 @@
|
||||
(ns logseq.db-sync.sentry)
|
||||
(ns logseq.sync.sentry)
|
||||
|
||||
(defn- not-blank [v]
|
||||
(when (and (string? v) (seq v)) v))
|
||||
@@ -1,6 +1,6 @@
|
||||
(ns logseq.db-sync.sentry.node
|
||||
(ns logseq.sync.sentry.node
|
||||
(:require ["@sentry/node" :as sentry]
|
||||
[logseq.db-sync.sentry :as sentry-config]))
|
||||
[logseq.sync.sentry :as sentry-config]))
|
||||
|
||||
(defn init! []
|
||||
(when-let [opts (sentry-config/options-from-env (.-env js/process))]
|
||||
@@ -1,6 +1,6 @@
|
||||
(ns logseq.db-sync.sentry.worker
|
||||
(ns logseq.sync.sentry.worker
|
||||
(:require ["@sentry/cloudflare" :as sentry]
|
||||
[logseq.db-sync.sentry :as sentry-config]))
|
||||
[logseq.sync.sentry :as sentry-config]))
|
||||
|
||||
(defn wrap-handler [handler]
|
||||
(sentry/withSentry (fn [^js env]
|
||||
@@ -1,4 +1,4 @@
|
||||
(ns logseq.db-sync.snapshot
|
||||
(ns logseq.sync.snapshot
|
||||
(:require [cognitect.transit :as transit]))
|
||||
|
||||
(def ^:private transit-w (transit/writer :json))
|
||||
@@ -1,9 +1,9 @@
|
||||
(ns logseq.db-sync.storage
|
||||
(ns logseq.sync.storage
|
||||
(:require [cljs-bean.core :as bean]
|
||||
[clojure.string :as string]
|
||||
[datascript.core :as d]
|
||||
[datascript.storage :refer [IStorage]]
|
||||
[logseq.db-sync.common :as common]
|
||||
[logseq.sync.common :as common]
|
||||
[logseq.db.common.normalize :as db-normalize]
|
||||
[logseq.db.common.sqlite :as common-sqlite]
|
||||
[logseq.db.frontend.schema :as db-schema]))
|
||||
@@ -1,16 +1,16 @@
|
||||
(ns logseq.db-sync.worker
|
||||
(ns logseq.sync.worker
|
||||
;; Turn off false defclass errors
|
||||
{:clj-kondo/config {:linters {:unresolved-symbol {:level :off}}}}
|
||||
(:require ["cloudflare:workers" :refer [DurableObject]]
|
||||
[lambdaisland.glogi :as log]
|
||||
[logseq.db-sync.common :as common]
|
||||
[logseq.db-sync.logging :as logging]
|
||||
[logseq.db-sync.sentry.worker :as sentry]
|
||||
[logseq.db-sync.worker.dispatch :as dispatch]
|
||||
[logseq.db-sync.worker.handler.sync :as sync-handler]
|
||||
[logseq.db-sync.worker.handler.ws :as ws-handler]
|
||||
[logseq.db-sync.worker.presence :as presence]
|
||||
[logseq.db-sync.worker.ws :as ws]
|
||||
[logseq.sync.common :as common]
|
||||
[logseq.sync.logging :as logging]
|
||||
[logseq.sync.sentry.worker :as sentry]
|
||||
[logseq.sync.worker.dispatch :as dispatch]
|
||||
[logseq.sync.worker.handler.sync :as sync-handler]
|
||||
[logseq.sync.worker.handler.ws :as ws-handler]
|
||||
[logseq.sync.worker.presence :as presence]
|
||||
[logseq.sync.worker.ws :as ws]
|
||||
[promesa.core :as p]
|
||||
[shadow.cljs.modern :refer (defclass)]))
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
(ns logseq.db-sync.worker.auth
|
||||
(ns logseq.sync.worker.auth
|
||||
(:require [clojure.string :as string]
|
||||
[logseq.common.authorization :as authorization]
|
||||
[promesa.core :as p]))
|
||||
@@ -1,4 +1,4 @@
|
||||
(ns logseq.db-sync.worker.coerce
|
||||
(ns logseq.sync.worker.coerce
|
||||
(:require [lambdaisland.glogi :as log]))
|
||||
|
||||
(def invalid-coerce ::invalid-coerce)
|
||||
@@ -1,10 +1,10 @@
|
||||
(ns logseq.db-sync.worker.dispatch
|
||||
(ns logseq.sync.worker.dispatch
|
||||
(:require [clojure.string :as string]
|
||||
[logseq.db-sync.common :as common]
|
||||
[logseq.db-sync.platform.core :as platform]
|
||||
[logseq.db-sync.worker.handler.assets :as assets-handler]
|
||||
[logseq.db-sync.worker.handler.index :as index-handler]
|
||||
[logseq.db-sync.worker.http :as http]
|
||||
[logseq.sync.common :as common]
|
||||
[logseq.sync.platform.core :as platform]
|
||||
[logseq.sync.worker.handler.assets :as assets-handler]
|
||||
[logseq.sync.worker.handler.index :as index-handler]
|
||||
[logseq.sync.worker.http :as http]
|
||||
[promesa.core :as p]))
|
||||
|
||||
(def ^:private agents-local-forward-max-retries 300)
|
||||
@@ -1,8 +1,8 @@
|
||||
(ns logseq.db-sync.worker.handler.assets
|
||||
(ns logseq.sync.worker.handler.assets
|
||||
(:require [cljs-bean.core :as bean]
|
||||
[clojure.string :as string]
|
||||
[logseq.db-sync.common :as common :refer [cors-headers]]
|
||||
[logseq.db-sync.worker.http :as http]))
|
||||
[logseq.sync.common :as common :refer [cors-headers]]
|
||||
[logseq.sync.worker.http :as http]))
|
||||
|
||||
(def ^:private max-asset-size (* 100 1024 1024))
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
(ns logseq.db-sync.worker.handler.index
|
||||
(ns logseq.sync.worker.handler.index
|
||||
(:require [lambdaisland.glogi :as log]
|
||||
[logseq.db-sync.common :as common]
|
||||
[logseq.db-sync.index :as index]
|
||||
[logseq.db-sync.worker.auth :as auth]
|
||||
[logseq.db-sync.worker.http :as http]
|
||||
[logseq.db-sync.worker.routes.index :as routes]
|
||||
[logseq.sync.common :as common]
|
||||
[logseq.sync.index :as index]
|
||||
[logseq.sync.worker.auth :as auth]
|
||||
[logseq.sync.worker.http :as http]
|
||||
[logseq.sync.worker.routes.index :as routes]
|
||||
[promesa.core :as p]))
|
||||
|
||||
(defn- index-db [^js self]
|
||||
@@ -1,15 +1,15 @@
|
||||
(ns logseq.db-sync.worker.handler.sync
|
||||
(ns logseq.sync.worker.handler.sync
|
||||
(:require [clojure.string :as string]
|
||||
[lambdaisland.glogi :as log]
|
||||
[logseq.db :as ldb]
|
||||
[logseq.db-sync.batch :as batch]
|
||||
[logseq.db-sync.common :as common]
|
||||
[logseq.db-sync.protocol :as protocol]
|
||||
[logseq.db-sync.snapshot :as snapshot]
|
||||
[logseq.db-sync.storage :as storage]
|
||||
[logseq.db-sync.worker.http :as http]
|
||||
[logseq.db-sync.worker.routes.sync :as sync-routes]
|
||||
[logseq.db-sync.worker.ws :as ws]
|
||||
[logseq.sync.batch :as batch]
|
||||
[logseq.sync.common :as common]
|
||||
[logseq.sync.protocol :as protocol]
|
||||
[logseq.sync.snapshot :as snapshot]
|
||||
[logseq.sync.storage :as storage]
|
||||
[logseq.sync.worker.http :as http]
|
||||
[logseq.sync.worker.routes.sync :as sync-routes]
|
||||
[logseq.sync.worker.ws :as ws]
|
||||
[promesa.core :as p]))
|
||||
|
||||
(def ^:private snapshot-download-batch-size 5000)
|
||||
@@ -1,9 +1,9 @@
|
||||
(ns logseq.db-sync.worker.handler.ws
|
||||
(:require [logseq.db-sync.protocol :as protocol]
|
||||
[logseq.db-sync.worker.auth :as auth]
|
||||
[logseq.db-sync.worker.handler.sync :as sync-handler]
|
||||
[logseq.db-sync.worker.presence :as presence]
|
||||
[logseq.db-sync.worker.ws :as ws]))
|
||||
(ns logseq.sync.worker.handler.ws
|
||||
(:require [logseq.sync.protocol :as protocol]
|
||||
[logseq.sync.worker.auth :as auth]
|
||||
[logseq.sync.worker.handler.sync :as sync-handler]
|
||||
[logseq.sync.worker.presence :as presence]
|
||||
[logseq.sync.worker.ws :as ws]))
|
||||
|
||||
(defn handle-ws-message! [^js self ^js ws raw]
|
||||
(let [message (-> raw protocol/parse-message ws/coerce-ws-client-message)]
|
||||
@@ -1,7 +1,7 @@
|
||||
(ns logseq.db-sync.worker.http
|
||||
(:require [logseq.db-sync.common :as common]
|
||||
[logseq.db-sync.malli-schema :as db-sync-schema]
|
||||
[logseq.db-sync.worker.coerce :as coerce]))
|
||||
(ns logseq.sync.worker.http
|
||||
(:require [logseq.sync.common :as common]
|
||||
[logseq.sync.malli-schema :as db-sync-schema]
|
||||
[logseq.sync.worker.coerce :as coerce]))
|
||||
|
||||
(defn coerce-http-request [schema-key body]
|
||||
(if-let [coercer (get db-sync-schema/http-request-coercers schema-key)]
|
||||
@@ -1,6 +1,6 @@
|
||||
(ns logseq.db-sync.worker.presence
|
||||
(ns logseq.sync.worker.presence
|
||||
(:require [clojure.string :as string]
|
||||
[logseq.db-sync.worker.ws :as ws]))
|
||||
[logseq.sync.worker.ws :as ws]))
|
||||
|
||||
(defn claims->user
|
||||
[claims]
|
||||
@@ -1,4 +1,4 @@
|
||||
(ns logseq.db-sync.worker.routes.index
|
||||
(ns logseq.sync.worker.routes.index
|
||||
(:require [reitit.core :as r]))
|
||||
|
||||
(def ^:private route-data
|
||||
@@ -20,21 +20,7 @@
|
||||
["/graphs/:graph-id"
|
||||
["/aes-key" {:methods {"GET" :e2ee/graph-aes-key-get
|
||||
"POST" :e2ee/graph-aes-key-post}}]
|
||||
["/grant-access" {:methods {"POST" :e2ee/grant-access}}]]]
|
||||
|
||||
["/sessions"
|
||||
["" {:methods {"POST" :sessions/create}}]
|
||||
["/:session-id"
|
||||
["" {:methods {"GET" :sessions/get}}]
|
||||
["/messages" {:methods {"POST" :sessions/messages}}]
|
||||
["/pause" {:methods {"POST" :sessions/pause}}]
|
||||
["/resume" {:methods {"POST" :sessions/resume}}]
|
||||
["/interrupt" {:methods {"POST" :sessions/interrupt}}]
|
||||
["/cancel" {:methods {"POST" :sessions/cancel}}]
|
||||
["/pr" {:methods {"POST" :sessions/pr}}]
|
||||
["/events" {:methods {"GET" :sessions/events}}]
|
||||
["/terminal" {:methods {"GET" :sessions/terminal}}]
|
||||
["/stream" {:methods {"GET" :sessions/stream}}]]]])
|
||||
["/grant-access" {:methods {"POST" :e2ee/grant-access}}]]]])
|
||||
|
||||
(def ^:private router
|
||||
(r/router route-data))
|
||||
@@ -1,4 +1,4 @@
|
||||
(ns logseq.db-sync.worker.routes.sync
|
||||
(ns logseq.sync.worker.routes.sync
|
||||
(:require [reitit.core :as r]))
|
||||
|
||||
(def ^:private route-data
|
||||
@@ -1,4 +1,4 @@
|
||||
(ns logseq.db-sync.worker.timing)
|
||||
(ns logseq.sync.worker.timing)
|
||||
|
||||
(defn summary
|
||||
"Returns duration summary from `start-ms` to `end-ms` with ordered `steps`.
|
||||
@@ -1,8 +1,8 @@
|
||||
(ns logseq.db-sync.worker.ws
|
||||
(ns logseq.sync.worker.ws
|
||||
(:require [lambdaisland.glogi :as log]
|
||||
[logseq.db-sync.malli-schema :as db-sync-schema]
|
||||
[logseq.db-sync.protocol :as protocol]
|
||||
[logseq.db-sync.worker.coerce :as coerce]))
|
||||
[logseq.sync.malli-schema :as db-sync-schema]
|
||||
[logseq.sync.protocol :as protocol]
|
||||
[logseq.sync.worker.coerce :as coerce]))
|
||||
|
||||
(defn ws-open? [ws]
|
||||
(= 1 (.-readyState ws)))
|
||||
@@ -1,7 +1,7 @@
|
||||
(ns logseq.db-sync.worker-agents-dispatch-test
|
||||
(ns logseq.agents.dispatch-test
|
||||
(:require [cljs.test :refer [async deftest is]]
|
||||
[logseq.db-sync.platform.core :as platform]
|
||||
[logseq.db-sync.worker.agents-dispatch :as agents-dispatch]))
|
||||
[logseq.sync.platform.core :as platform]
|
||||
[logseq.agents.dispatch :as agents-dispatch]))
|
||||
|
||||
(deftest agents-dispatch-health-test
|
||||
(async done
|
||||
@@ -1,9 +1,9 @@
|
||||
(ns logseq.db-sync.agent-do-test
|
||||
(ns logseq.agents.do-test
|
||||
(:require [cljs.test :refer [async deftest is testing]]
|
||||
[clojure.string :as string]
|
||||
[logseq.db-sync.worker.agent.do :as agent-do]
|
||||
[logseq.db-sync.worker.agent.runtime-provider :as runtime-provider]
|
||||
[logseq.db-sync.worker.agent.source-control :as source-control]))
|
||||
[logseq.agents.do :as agent-do]
|
||||
[logseq.agents.runtime-provider :as runtime-provider]
|
||||
[logseq.agents.source-control :as source-control]))
|
||||
|
||||
(defn- make-agent-storage []
|
||||
(let [data (js/Map.)]
|
||||
@@ -1,7 +1,7 @@
|
||||
(ns logseq.db-sync.agent-request-test
|
||||
(ns logseq.agents.request-test
|
||||
(:require [cljs.test :refer [deftest is testing]]
|
||||
[logseq.db-sync.worker.agent.request :as request]
|
||||
[logseq.db-sync.worker.http :as http]))
|
||||
[logseq.agents.request :as request]
|
||||
[logseq.sync.worker.http :as http]))
|
||||
|
||||
(deftest sessions-create-coerce-test
|
||||
(testing "accepts simplified sessions/create request"
|
||||
44
deps/workers/test/logseq/agents/routes_test.cljs
vendored
Normal file
44
deps/workers/test/logseq/agents/routes_test.cljs
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
(ns logseq.agents.routes-test
|
||||
(:require [cljs.test :refer [deftest is testing]]
|
||||
[logseq.agents.routes :as routes]))
|
||||
|
||||
(deftest match-route-sessions-test
|
||||
(testing "sessions routes"
|
||||
(let [match (routes/match-route "POST" "/sessions")]
|
||||
(is (= :sessions/create (:handler match))))
|
||||
(let [match (routes/match-route "GET" "/sessions/session-1")]
|
||||
(is (= :sessions/get (:handler match)))
|
||||
(is (= "session-1" (get-in match [:path-params :session-id]))))
|
||||
(let [match (routes/match-route "POST" "/sessions/session-2/messages")]
|
||||
(is (= :sessions/messages (:handler match)))
|
||||
(is (= "session-2" (get-in match [:path-params :session-id]))))
|
||||
(let [match (routes/match-route "POST" "/sessions/session-3/cancel")]
|
||||
(is (= :sessions/cancel (:handler match)))
|
||||
(is (= "session-3" (get-in match [:path-params :session-id]))))
|
||||
(let [match (routes/match-route "GET" "/sessions/session-4/stream")]
|
||||
(is (= :sessions/stream (:handler match)))
|
||||
(is (= "session-4" (get-in match [:path-params :session-id]))))
|
||||
(let [match (routes/match-route "GET" "/sessions/session-5/terminal")]
|
||||
(is (= :sessions/terminal (:handler match)))
|
||||
(is (= "session-5" (get-in match [:path-params :session-id]))))))
|
||||
|
||||
(deftest match-route-sessions-events-test
|
||||
(testing "sessions events routes"
|
||||
(let [match (routes/match-route "GET" "/sessions/session-9/events")]
|
||||
(is (= :sessions/events (:handler match)))
|
||||
(is (= "session-9" (get-in match [:path-params :session-id]))))))
|
||||
|
||||
(deftest match-route-sessions-control-test
|
||||
(testing "sessions control routes"
|
||||
(let [match (routes/match-route "POST" "/sessions/session-10/pause")]
|
||||
(is (= :sessions/pause (:handler match)))
|
||||
(is (= "session-10" (get-in match [:path-params :session-id]))))
|
||||
(let [match (routes/match-route "POST" "/sessions/session-11/resume")]
|
||||
(is (= :sessions/resume (:handler match)))
|
||||
(is (= "session-11" (get-in match [:path-params :session-id]))))
|
||||
(let [match (routes/match-route "POST" "/sessions/session-12/interrupt")]
|
||||
(is (= :sessions/interrupt (:handler match)))
|
||||
(is (= "session-12" (get-in match [:path-params :session-id]))))
|
||||
(let [match (routes/match-route "POST" "/sessions/session-13/pr")]
|
||||
(is (= :sessions/pr (:handler match)))
|
||||
(is (= "session-13" (get-in match [:path-params :session-id]))))))
|
||||
@@ -1,7 +1,7 @@
|
||||
(ns logseq.db-sync.agent-runtime-provider-test
|
||||
(ns logseq.agents.runtime-provider-test
|
||||
(:require [cljs.test :refer [async deftest is testing]]
|
||||
[clojure.string :as string]
|
||||
[logseq.db-sync.worker.agent.runtime-provider :as runtime-provider]))
|
||||
[logseq.agents.runtime-provider :as runtime-provider]))
|
||||
|
||||
(defn- fetch-url [request]
|
||||
(cond
|
||||
@@ -1,6 +1,6 @@
|
||||
(ns logseq.db-sync.agent-sandbox-test
|
||||
(ns logseq.agents.sandbox-test
|
||||
(:require [cljs.test :refer [deftest is testing]]
|
||||
[logseq.db-sync.worker.agent.sandbox :as sandbox]))
|
||||
[logseq.agents.sandbox :as sandbox]))
|
||||
|
||||
(deftest normalize-base-url-test
|
||||
(testing "normalizes sandbox base urls"
|
||||
@@ -1,6 +1,6 @@
|
||||
(ns logseq.db-sync.agent-session-test
|
||||
(ns logseq.agents.session-test
|
||||
(:require [cljs.test :refer [deftest is testing]]
|
||||
[logseq.db-sync.worker.agent.session :as session]))
|
||||
[logseq.agents.session :as session]))
|
||||
|
||||
(deftest session-initialization-test
|
||||
(testing "builds a created session with task and audit"
|
||||
@@ -1,6 +1,6 @@
|
||||
(ns logseq.db-sync.agent-source-control-test
|
||||
(ns logseq.agents.source-control-test
|
||||
(:require [cljs.test :refer [async deftest is testing]]
|
||||
[logseq.db-sync.worker.agent.source-control :as source-control]))
|
||||
[logseq.agents.source-control :as source-control]))
|
||||
|
||||
(deftest parse-github-repo-test
|
||||
(testing "parses github https and ssh repo urls"
|
||||
@@ -1,6 +1,6 @@
|
||||
(ns logseq.db-sync.batch-test
|
||||
(ns logseq.sync.batch-test
|
||||
(:require [cljs.test :refer [deftest is testing]]
|
||||
[logseq.db-sync.batch :as batch]))
|
||||
[logseq.sync.batch :as batch]))
|
||||
|
||||
(deftest rows->insert-batches-test
|
||||
(testing "splits rows into batches based on max params"
|
||||
@@ -1,6 +1,6 @@
|
||||
(ns logseq.db-sync.common-test
|
||||
(ns logseq.sync.common-test
|
||||
(:require [cljs.test :refer [async deftest is]]
|
||||
[logseq.db-sync.common :as common]
|
||||
[logseq.sync.common :as common]
|
||||
[promesa.core :as p]))
|
||||
|
||||
(defn- make-stmt [calls result]
|
||||
@@ -1,7 +1,7 @@
|
||||
(ns logseq.db-sync.cycle-test
|
||||
(ns logseq.sync.cycle-test
|
||||
(:require [cljs.test :refer [deftest is testing]]
|
||||
[datascript.core :as d]
|
||||
[logseq.db-sync.cycle :as cycle]
|
||||
[logseq.sync.cycle :as cycle]
|
||||
[logseq.db.test.helper :as db-test]))
|
||||
|
||||
(defn- new-conn []
|
||||
@@ -1,8 +1,8 @@
|
||||
(ns logseq.db-sync.index-test
|
||||
(ns logseq.sync.index-test
|
||||
(:require [cljs.test :refer [async deftest is]]
|
||||
[clojure.string :as string]
|
||||
[logseq.db-sync.common :as common]
|
||||
[logseq.db-sync.index :as index]
|
||||
[logseq.sync.common :as common]
|
||||
[logseq.sync.index :as index]
|
||||
[promesa.core :as p]))
|
||||
|
||||
(def ^:private graph-e2ee-migration-sql
|
||||
@@ -1,10 +1,10 @@
|
||||
(ns logseq.db-sync.node-adapter-test
|
||||
(ns logseq.sync.node-adapter-test
|
||||
;; Linters disabled because commented out FIXME code causes false positives
|
||||
{:clj-kondo/config {:ignore true}}
|
||||
(:require [cljs.test :refer [deftest is async testing]]
|
||||
[clojure.string :as string]
|
||||
[logseq.db-sync.node.server :as node-server]
|
||||
[logseq.db-sync.protocol :as protocol]
|
||||
[logseq.sync.node.server :as node-server]
|
||||
[logseq.sync.protocol :as protocol]
|
||||
[promesa.core :as p]))
|
||||
|
||||
(def test-token "test-token")
|
||||
@@ -1,6 +1,6 @@
|
||||
(ns logseq.db-sync.node-config-test
|
||||
(ns logseq.sync.node-config-test
|
||||
(:require [cljs.test :refer [deftest is testing]]
|
||||
[logseq.db-sync.node.config :as config]))
|
||||
[logseq.sync.node.config :as config]))
|
||||
|
||||
(defn- throws? [f]
|
||||
(try
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user