@cadenza.io/service 2.12.0 → 2.16.0

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/README.md CHANGED
@@ -16,7 +16,8 @@ This repository (@Cadenza.io/service) is an extension of the core package, provi
16
16
 
17
17
  The service package provides everything in the core package plus the following:
18
18
  - **Service Extension**: A Service exposes the local graphs and signals to other Services in the system and enables them to interact with tasks and signals across other Services in the system via socket and/or REST.
19
- - **Database Service Extension**: A Database Service takes a schema and auto generates the necessary tasks and signals to interact with that database using the cadenza model. It exposes those tasks using by creating a Service.
19
+ - **PostgresActor Extension**: A PostgresActor is a specialized actor that owns a Postgres pool, applies schema setup, and auto generates database tasks and intents without creating a network service.
20
+ - **Database Service Extension**: A Database Service is the higher-level helper that first creates a PostgresActor and then creates a Service that exposes those generated database tasks.
20
21
  - **CadenzaDB compatibility**: A service can connect to the official CadenzaDB service and will automatically sync realtime data for introspection and visualization.
21
22
 
22
23
  There is no need to install the core package separately. Instead, install the service package, which includes everything in the core package plus the distributed extensions.
@@ -40,6 +41,52 @@ import Cadenza from '@cadenza.io/service';
40
41
  Cadenza.createCadenzaService('MyService'); // Name should start with an uppercase letter and contain no spaces.
41
42
  ```
42
43
 
44
+ ### Creating a frontend runtime
45
+ Frontend mode keeps the same package and distributed primitives, but disables Node-only features such as REST/socket server creation, PostgresActors, and database-service bootstrapping.
46
+
47
+ ```typescript
48
+ import Cadenza from '@cadenza.io/service';
49
+
50
+ Cadenza.createCadenzaService('BrowserApp', 'Frontend app', {
51
+ isFrontend: true,
52
+ bootstrap: {
53
+ url: 'https://cadenza-db.example.com:5000',
54
+ },
55
+ });
56
+ ```
57
+
58
+ Frontend bootstrap resolution order is:
59
+
60
+ 1. `options.bootstrap.url`
61
+ 2. `globalThis.__CADENZA_RUNTIME__.bootstrapUrl`
62
+ 3. `CADENZA_DB_ADDRESS` plus optional `CADENZA_DB_PORT` on the server side
63
+
64
+ `CADENZA_DB_ADDRESS` now accepts either a full address with port, or a bare host/address when `CADENZA_DB_PORT` is also set.
65
+
66
+ ### SSR inquiries
67
+ For SSR use cases, use the request-scoped bridge for one-off distributed inquiries and pass dehydrated results to the browser runtime.
68
+
69
+ ```typescript
70
+ import {
71
+ createSSRInquiryBridge,
72
+ type HydrationOptions,
73
+ } from '@cadenza.io/service';
74
+
75
+ const bridge = createSSRInquiryBridge({
76
+ bootstrap: {
77
+ url: process.env.CADENZA_DB_ADDRESS,
78
+ },
79
+ });
80
+
81
+ const users = await bridge.inquire(
82
+ 'users-list',
83
+ {},
84
+ { hydrationKey: 'users-list.initial' },
85
+ );
86
+
87
+ const hydration: HydrationOptions = bridge.dehydrate();
88
+ ```
89
+
43
90
  ### Working with distribution
44
91
  Distribution is easy with Cadenza. You can delegate the flow by using a DeputyTask, or subscribe to foreign signals by prefixing them with the service name.
45
92
 
@@ -62,6 +109,11 @@ Canonical PostgresActor docs:
62
109
  - [PostgresActor Guide](./docs/postgres-actor-guide.md)
63
110
  - [PostgresActor Reference](./docs/postgres-actor-reference.md)
64
111
 
112
+ High-level database service helper APIs:
113
+
114
+ - `Cadenza.createDatabaseService(...)`
115
+ - `Cadenza.createMetaDatabaseService(...)`
116
+
65
117
  Workspace mirror (for cross-repo publication):
66
118
 
67
119
  - [Workspace Guide Mirror](../docs/postgres-actor-guide.md)