feat(v1.1.2-docs): migrations + shared DocsService trait + TriggerEvent::Docs
Migrations 0013_docs.sql + 0014_docs_triggers.sql land the docs table (JSONB body + GIN-on-jsonb_path_ops index, PK keyed on (app_id, collection, id) for cross-app isolation) and widen the triggers.kind and outbox.source_kind CHECK constraints to include 'docs', plus the docs_trigger_details detail table mirroring kv_trigger_details. picloud-shared grows the DocsService trait + DocRow/DocsListPage/ DocsError + NoopDocsService, the TriggerEvent::Docs variant with the prev_data change-data-capture surface, the DocsEventOp enum, the docs field on the Services bundle, and the SDK_VERSION bump 1.2 -> 1.3. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -18,8 +18,8 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::{
|
||||
DeadLetterService, KvService, NoopDeadLetterService, NoopEventEmitter, NoopKvService,
|
||||
ServiceEventEmitter,
|
||||
DeadLetterService, DocsService, KvService, NoopDeadLetterService, NoopDocsService,
|
||||
NoopEventEmitter, NoopKvService, ServiceEventEmitter,
|
||||
};
|
||||
|
||||
/// SDK service bundle. See module docs for the lifecycle and the v1.1.x
|
||||
@@ -30,15 +30,20 @@ pub struct Services {
|
||||
/// in-memory in tests.
|
||||
pub kv: Arc<dyn KvService>,
|
||||
|
||||
/// Document store (v1.1.2). Backed by Postgres in the picloud
|
||||
/// binary; in-memory in tests.
|
||||
pub docs: Arc<dyn DocsService>,
|
||||
|
||||
/// Dead-letter management (v1.1.1). Scripts get
|
||||
/// `dead_letters::replay(id)` and `dead_letters::resolve(id, reason)`.
|
||||
pub dead_letters: Arc<dyn DeadLetterService>,
|
||||
|
||||
/// Event emitter for the triggers outbox. Mutating service methods
|
||||
/// (`KvService::set/delete`, future `docs::*`, `files::*`, etc.)
|
||||
/// call `events.emit(cx, event)` after the write succeeds. The
|
||||
/// outbox-backed impl in `manager-core::outbox_event_emitter`
|
||||
/// replaces v1.1.0's `NoopEventEmitter`.
|
||||
/// (`KvService::set/delete`, `DocsService::create/update/delete`,
|
||||
/// future `files::*`, etc.) call `events.emit(cx, event)` after
|
||||
/// the write succeeds. The outbox-backed impl in
|
||||
/// `manager-core::outbox_event_emitter` replaces v1.1.0's
|
||||
/// `NoopEventEmitter`.
|
||||
pub events: Arc<dyn ServiceEventEmitter>,
|
||||
}
|
||||
|
||||
@@ -49,11 +54,13 @@ impl Services {
|
||||
#[must_use]
|
||||
pub fn new(
|
||||
kv: Arc<dyn KvService>,
|
||||
docs: Arc<dyn DocsService>,
|
||||
dead_letters: Arc<dyn DeadLetterService>,
|
||||
events: Arc<dyn ServiceEventEmitter>,
|
||||
) -> Self {
|
||||
Self {
|
||||
kv,
|
||||
docs,
|
||||
dead_letters,
|
||||
events,
|
||||
}
|
||||
@@ -68,6 +75,7 @@ impl Services {
|
||||
pub fn with_noop_services() -> Self {
|
||||
Self::new(
|
||||
Arc::new(NoopKvService),
|
||||
Arc::new(NoopDocsService),
|
||||
Arc::new(NoopDeadLetterService),
|
||||
Arc::new(NoopEventEmitter),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user