docs(files): unified file client + backends после #58–#61 (#53)
Release Please / Release Please (push) Skipped
Release / GoReleaser (push) Skipped
Tests / Secret scan (gitleaks) (push) Skipped
Tests / Test (Go 1.25) (push) Skipped
Tests / Test (Go stable) (push) Skipped
Release Please / Release Please (push) Skipped
Release / GoReleaser (push) Skipped
Tests / Secret scan (gitleaks) (push) Skipped
Tests / Test (Go 1.25) (push) Skipped
Tests / Test (Go stable) (push) Skipped
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
---
|
||||
type: index
|
||||
status: current
|
||||
related:
|
||||
- README.md
|
||||
---
|
||||
|
||||
# docs — индекс
|
||||
|
||||
Документация `go-onlyoffice`. Код — источник истины, доки только описывают.
|
||||
|
||||
| файл | о чём |
|
||||
|------|-------|
|
||||
| [unified-file-client.md](unified-file-client.md) | Единый файловый клиент: `FileStore`/`Searcher`, `c.Files()`, фасад, порядок чтения/записи, SQL read-only, как добавить backend |
|
||||
| [community-server-db.md](community-server-db.md) | Прямой read-only SQL-доступ к БД Community Server (MySQL/Postgres), `ONLYOFFICE_DSN`, схема, MinIO-download |
|
||||
| [elasticsearch.md](elasticsearch.md) | Полнотекстовый поиск: индекс OnlyOffice `files_file` и свой `oo_docs_text` (PDF/сканы) |
|
||||
| [rclone-webdav.md](rclone-webdav.md) | Монтирование WebDAV-дерева Documents как ФС (docker compose + FUSE) |
|
||||
| [crm-associations.md](crm-associations.md) | Связи CRM: company ↔ person ↔ deal ↔ project ↔ invoice ↔ mail |
|
||||
|
||||
## См. также
|
||||
|
||||
- [`../README.md`](../README.md) — установка, CLI-команды, env.
|
||||
- [`../AGENTS.md`](../AGENTS.md) — топология репо и правила.
|
||||
@@ -25,8 +25,10 @@ REST, WebDAV, SQL (PostgreSQL/MySQL), Elasticsearch. Правило одно:
|
||||
`Size`, `MIME`, `Created`, `Modified`, `Updated` (сырая строка API),
|
||||
`Version`, `Provider`, `FilesCount`/`FoldersCount` (папки).
|
||||
Чего бэкенд не даёт — остаётся в нуле.
|
||||
- `SearchQuery` — `Text`, `InContent`, `FolderID`, `Extensions`, `Limit`.
|
||||
- `SearchHit` — `Entry` + `Score`, `Highlight`, `Path`.
|
||||
- `SearchQuery` — `Text`, `InContent`, `FolderID`, `Extensions`, `Limit`,
|
||||
`Substring` (регистронезависимое `*term*` по имени, несколько слов AND).
|
||||
- `SearchHit` — `Entry` + `Score`, `Highlight`, `Path []string` (предки
|
||||
root → leaf).
|
||||
|
||||
## Интерфейсы
|
||||
|
||||
@@ -113,11 +115,12 @@ e, _ := f.Stat(ctx, "19423") // e.Provider == "mysql"
|
||||
entries, _ := f.List(ctx, "676") // пойдёт в SQL
|
||||
```
|
||||
|
||||
`Client.FileStore("pg"|"sql"|"postgres"|"mysql")` — одноразовый доступ к
|
||||
SQL-стору без фасада: открывает из env; при ошибке возвращает заглушку,
|
||||
которая отдаёт ошибку открытия на каждом вызове (не `nil`). `SQLFileStore()`
|
||||
— тот же открыватель, но с ошибкой. Отвечавший бэкенд видно по
|
||||
`Entry.Provider` (`mysql` / `postgres` у SQL, `rest` у REST).
|
||||
`Client.FileStore("rest"|"dav"|"webdav"|"pg"|"sql"|"postgres"|"mysql")` —
|
||||
прямой доступ к одному бэкенду без фасада. SQL открывается из env; при ошибке
|
||||
возвращается заглушка, которая отдаёт ошибку открытия на каждом вызове (не
|
||||
`nil`). `SQLFileStore()` — тот же открыватель, но с ошибкой. Пустое/неизвестное
|
||||
имя — REST. Отвечавший бэкенд видно по `Entry.Provider` (`mysql`/`postgres` у
|
||||
SQL, `rest`/`dav` у HTTP).
|
||||
|
||||
## CLI
|
||||
|
||||
@@ -125,6 +128,7 @@ SQL-стору без фасада: открывает из env; при ошиб
|
||||
# поиск: --backend oo (индекс OnlyOffice) | own (свой oo_docs_text)
|
||||
oo search "Rechnung"
|
||||
oo search "Mahngebühr" --content
|
||||
oo search "Rechnung 2025" --substring # *term* по имени, слова AND
|
||||
oo search "S1021" --content --backend own --folder 634 --limit 50 --json
|
||||
|
||||
# наполнение своего индекса (PDF/сканы, idempotent upsert по file id)
|
||||
@@ -193,11 +197,27 @@ res, _ := ti.IndexFolder(ctx, "634", onlyoffice.IndexOptions{Recursive: true})
|
||||
|
||||
```bash
|
||||
go test ./... # unit, без сети
|
||||
go test -race ./...
|
||||
go test -tags=integration ./... # live (креды в .env)
|
||||
go test ./ -run 'FileStore|Facade|ESText|PG'
|
||||
```
|
||||
|
||||
- `file_store_integration_test.go` — `TestIntegrationFileStores`: полный набор
|
||||
read+write (create/upload/list/stat/download/move/copy/rename/delete) через
|
||||
REST и DAV. Нужен `ONLYOFFICE_URL/USER/PASS`.
|
||||
- `file_pg_integration_test.go` — `TestIntegrationPGStore`,
|
||||
`TestIntegrationSQLFacade`: SQL против REST, `ErrReadOnly`. Нужен
|
||||
`ONLYOFFICE_DSN` (+ `MINIO_*` для `Download`).
|
||||
- `file_es_integration_test.go` — `TestIntegrationESFacadeUsesES`: доказывает,
|
||||
что `c.Files().Search()` идёт в ES, а не в REST. Нужен `ONLYOFFICE_ES_URL`.
|
||||
- `file_es_text_integration_test.go` — свой индекс `oo_docs_text`.
|
||||
|
||||
Каждый тест делает чистый `skip` без своего env. HTTP-транспорт и auth ретраят
|
||||
transient-ответы (429/502/503/504) централизованно (`retryRaw`/`DoRetry`), см.
|
||||
[`retry.go`](../retry.go).
|
||||
|
||||
## См. также
|
||||
|
||||
- [elasticsearch.md](elasticsearch.md) — индекс OnlyOffice и свой `oo_docs_text`.
|
||||
- [community-server-db.md](community-server-db.md) — SQL-стор и схема БД.
|
||||
- [rclone-webdav.md](rclone-webdav.md) — монтирование Documents через FUSE.
|
||||
|
||||
Reference in New Issue
Block a user