@cadenza.io/service 2.11.0 → 2.15.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 +19 -1
- package/dist/index.d.mts +54 -10
- package/dist/index.d.ts +54 -10
- package/dist/index.js +1761 -1353
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1762 -1354
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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
|
-
- **
|
|
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.
|
|
@@ -55,6 +56,23 @@ localTask.doOn('ContextService.process.failed');
|
|
|
55
56
|
|
|
56
57
|
For full examples, see this repository or the test suite.
|
|
57
58
|
|
|
59
|
+
## PostgresActor Documentation
|
|
60
|
+
|
|
61
|
+
Canonical PostgresActor docs:
|
|
62
|
+
|
|
63
|
+
- [PostgresActor Guide](./docs/postgres-actor-guide.md)
|
|
64
|
+
- [PostgresActor Reference](./docs/postgres-actor-reference.md)
|
|
65
|
+
|
|
66
|
+
High-level database service helper APIs:
|
|
67
|
+
|
|
68
|
+
- `Cadenza.createDatabaseService(...)`
|
|
69
|
+
- `Cadenza.createMetaDatabaseService(...)`
|
|
70
|
+
|
|
71
|
+
Workspace mirror (for cross-repo publication):
|
|
72
|
+
|
|
73
|
+
- [Workspace Guide Mirror](../docs/postgres-actor-guide.md)
|
|
74
|
+
- [Workspace Reference Mirror](../docs/postgres-actor-reference.md)
|
|
75
|
+
|
|
58
76
|
|
|
59
77
|
## Features
|
|
60
78
|
|
package/dist/index.d.mts
CHANGED
|
@@ -57,6 +57,14 @@ declare class DeputyTask extends Task {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
type DbOperationType$1 = "query" | "insert" | "update" | "delete";
|
|
60
|
+
type QueryMode = "rows" | "count" | "exists" | "one" | "aggregate";
|
|
61
|
+
type AggregateFunction = "count" | "sum" | "avg" | "min" | "max";
|
|
62
|
+
interface AggregateDefinition {
|
|
63
|
+
fn: AggregateFunction;
|
|
64
|
+
field?: string;
|
|
65
|
+
as?: string;
|
|
66
|
+
distinct?: boolean;
|
|
67
|
+
}
|
|
60
68
|
type SortDirection = "asc" | "desc";
|
|
61
69
|
interface JoinDefinition {
|
|
62
70
|
on: string;
|
|
@@ -88,6 +96,9 @@ interface DbOperationPayload {
|
|
|
88
96
|
filter?: Record<string, ValueOrList>;
|
|
89
97
|
fields?: string[];
|
|
90
98
|
joins?: Record<string, JoinDefinition>;
|
|
99
|
+
queryMode?: QueryMode;
|
|
100
|
+
aggregates?: AggregateDefinition[];
|
|
101
|
+
groupBy?: string[];
|
|
91
102
|
sort?: Record<string, SortDirection>;
|
|
92
103
|
limit?: number;
|
|
93
104
|
offset?: number;
|
|
@@ -434,6 +445,21 @@ interface TableDefinition {
|
|
|
434
445
|
description?: string;
|
|
435
446
|
input?: SchemaDefinition;
|
|
436
447
|
})[];
|
|
448
|
+
insert?: (string | {
|
|
449
|
+
intent: string;
|
|
450
|
+
description?: string;
|
|
451
|
+
input?: SchemaDefinition;
|
|
452
|
+
})[];
|
|
453
|
+
update?: (string | {
|
|
454
|
+
intent: string;
|
|
455
|
+
description?: string;
|
|
456
|
+
input?: SchemaDefinition;
|
|
457
|
+
})[];
|
|
458
|
+
delete?: (string | {
|
|
459
|
+
intent: string;
|
|
460
|
+
description?: string;
|
|
461
|
+
input?: SchemaDefinition;
|
|
462
|
+
})[];
|
|
437
463
|
};
|
|
438
464
|
initialData?: {
|
|
439
465
|
fields: string[];
|
|
@@ -481,6 +507,7 @@ interface DatabaseOptions {
|
|
|
481
507
|
databaseType?: "postgres";
|
|
482
508
|
databaseName?: string;
|
|
483
509
|
poolSize?: number;
|
|
510
|
+
ownerServiceName?: string | null;
|
|
484
511
|
}
|
|
485
512
|
/**
|
|
486
513
|
* The CadenzaService class serves as a central service layer providing various utility methods for managing tasks, signals, logging, and service interactions.
|
|
@@ -22404,14 +22431,28 @@ declare class CadenzaService {
|
|
|
22404
22431
|
*/
|
|
22405
22432
|
static createCadenzaMetaService(serviceName: string, description: string, options?: ServerOptions): void;
|
|
22406
22433
|
/**
|
|
22407
|
-
* Creates and initializes a
|
|
22408
|
-
* This
|
|
22434
|
+
* Creates and initializes a specialized PostgresActor.
|
|
22435
|
+
* This is actor-only and does not create or register a network service.
|
|
22409
22436
|
*
|
|
22410
|
-
* @param {string} name -
|
|
22411
|
-
* @param {DatabaseSchemaDefinition} schema -
|
|
22412
|
-
* @param {string} [description=""] -
|
|
22413
|
-
* @param {ServerOptions & DatabaseOptions} [options={}] -
|
|
22414
|
-
* @return {void}
|
|
22437
|
+
* @param {string} name - Logical PostgresActor name.
|
|
22438
|
+
* @param {DatabaseSchemaDefinition} schema - Database schema definition.
|
|
22439
|
+
* @param {string} [description=""] - Optional human-readable actor description.
|
|
22440
|
+
* @param {ServerOptions & DatabaseOptions} [options={}] - Actor/database runtime options.
|
|
22441
|
+
* @return {void}
|
|
22442
|
+
*/
|
|
22443
|
+
static createPostgresActor(name: string, schema: DatabaseSchemaDefinition, description?: string, options?: ServerOptions & DatabaseOptions): void;
|
|
22444
|
+
/**
|
|
22445
|
+
* Creates a meta PostgresActor.
|
|
22446
|
+
*
|
|
22447
|
+
* @param {string} name - Logical PostgresActor name.
|
|
22448
|
+
* @param {DatabaseSchemaDefinition} schema - Database schema definition.
|
|
22449
|
+
* @param {string} [description=""] - Optional description.
|
|
22450
|
+
* @param {ServerOptions & DatabaseOptions} [options={}] - Optional actor/database options.
|
|
22451
|
+
* @return {void}
|
|
22452
|
+
*/
|
|
22453
|
+
static createMetaPostgresActor(name: string, schema: DatabaseSchemaDefinition, description?: string, options?: ServerOptions & DatabaseOptions): void;
|
|
22454
|
+
/**
|
|
22455
|
+
* Creates a dedicated database service by composing a PostgresActor and a Cadenza service.
|
|
22415
22456
|
*/
|
|
22416
22457
|
static createDatabaseService(name: string, schema: DatabaseSchemaDefinition, description?: string, options?: ServerOptions & DatabaseOptions): void;
|
|
22417
22458
|
/**
|
|
@@ -22424,6 +22465,9 @@ declare class CadenzaService {
|
|
|
22424
22465
|
* @return {void} - This method does not return a value.
|
|
22425
22466
|
*/
|
|
22426
22467
|
static createMetaDatabaseService(name: string, schema: DatabaseSchemaDefinition, description?: string, options?: ServerOptions & DatabaseOptions): void;
|
|
22468
|
+
private static normalizePostgresActorOptions;
|
|
22469
|
+
private static normalizeDatabaseServiceOptions;
|
|
22470
|
+
private static registerDatabaseServiceBridgeTask;
|
|
22427
22471
|
static createActor<D extends Record<string, any> = AnyObject, R = AnyObject>(spec: ActorSpec<D, R>, options?: ActorFactoryOptions): Actor<D, R>;
|
|
22428
22472
|
static createActorFromDefinition<D extends Record<string, any> = AnyObject, R = AnyObject>(definition: ActorDefinition<D, R>, options?: ActorFactoryOptions<D, R>): Actor<D, R>;
|
|
22429
22473
|
/**
|
|
@@ -22718,14 +22762,14 @@ declare class CadenzaService {
|
|
|
22718
22762
|
*/
|
|
22719
22763
|
static createEphemeralTask(name: string, func: TaskFunction, description?: string, options?: TaskOptions & EphemeralTaskOptions): EphemeralTask;
|
|
22720
22764
|
/**
|
|
22721
|
-
* Creates an ephemeral meta
|
|
22765
|
+
* Creates an ephemeral meta-task with the specified name, function, description, and options.
|
|
22722
22766
|
* See {@link createEphemeralTask} and {@link createMetaTask} for more details.
|
|
22723
22767
|
*
|
|
22724
22768
|
* @param {string} name - The name of the task to be created.
|
|
22725
22769
|
* @param {TaskFunction} func - The function to be executed as part of the task.
|
|
22726
22770
|
* @param {string} [description] - An optional description of the task.
|
|
22727
22771
|
* @param {TaskOptions & EphemeralTaskOptions} [options={}] - Additional options for configuring the task.
|
|
22728
|
-
* @return {EphemeralTask} The created ephemeral meta
|
|
22772
|
+
* @return {EphemeralTask} The created ephemeral meta-task.
|
|
22729
22773
|
*/
|
|
22730
22774
|
static createEphemeralMetaTask(name: string, func: TaskFunction, description?: string, options?: TaskOptions & EphemeralTaskOptions): EphemeralTask;
|
|
22731
22775
|
/**
|
|
@@ -22921,4 +22965,4 @@ declare class SignalController {
|
|
|
22921
22965
|
constructor();
|
|
22922
22966
|
}
|
|
22923
22967
|
|
|
22924
|
-
export { DatabaseTask, type DbOperationPayload, type DbOperationType$1 as DbOperationType, type DeputyDescriptor, DeputyTask, type DistributedInquiryMeta, type DistributedInquiryOptions, GraphMetadataController, type InquiryResponderDescriptor, type InquiryResponderStatus, type JoinDefinition, type NetworkMode, type OpEffect, RestController, type SecurityProfile, type ServerOptions, type ServiceInstanceDescriptor, ServiceRegistry, SignalController, SignalTransmissionTask, SocketController, type SortDirection, type SubOperation, type SubOperationType, type ValueOrSubOp, CadenzaService as default };
|
|
22968
|
+
export { type AggregateDefinition, type AggregateFunction, DatabaseTask, type DbOperationPayload, type DbOperationType$1 as DbOperationType, type DeputyDescriptor, DeputyTask, type DistributedInquiryMeta, type DistributedInquiryOptions, GraphMetadataController, type InquiryResponderDescriptor, type InquiryResponderStatus, type JoinDefinition, type NetworkMode, type OpEffect, type QueryMode, RestController, type SecurityProfile, type ServerOptions, type ServiceInstanceDescriptor, ServiceRegistry, SignalController, SignalTransmissionTask, SocketController, type SortDirection, type SubOperation, type SubOperationType, type ValueOrSubOp, CadenzaService as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -57,6 +57,14 @@ declare class DeputyTask extends Task {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
type DbOperationType$1 = "query" | "insert" | "update" | "delete";
|
|
60
|
+
type QueryMode = "rows" | "count" | "exists" | "one" | "aggregate";
|
|
61
|
+
type AggregateFunction = "count" | "sum" | "avg" | "min" | "max";
|
|
62
|
+
interface AggregateDefinition {
|
|
63
|
+
fn: AggregateFunction;
|
|
64
|
+
field?: string;
|
|
65
|
+
as?: string;
|
|
66
|
+
distinct?: boolean;
|
|
67
|
+
}
|
|
60
68
|
type SortDirection = "asc" | "desc";
|
|
61
69
|
interface JoinDefinition {
|
|
62
70
|
on: string;
|
|
@@ -88,6 +96,9 @@ interface DbOperationPayload {
|
|
|
88
96
|
filter?: Record<string, ValueOrList>;
|
|
89
97
|
fields?: string[];
|
|
90
98
|
joins?: Record<string, JoinDefinition>;
|
|
99
|
+
queryMode?: QueryMode;
|
|
100
|
+
aggregates?: AggregateDefinition[];
|
|
101
|
+
groupBy?: string[];
|
|
91
102
|
sort?: Record<string, SortDirection>;
|
|
92
103
|
limit?: number;
|
|
93
104
|
offset?: number;
|
|
@@ -434,6 +445,21 @@ interface TableDefinition {
|
|
|
434
445
|
description?: string;
|
|
435
446
|
input?: SchemaDefinition;
|
|
436
447
|
})[];
|
|
448
|
+
insert?: (string | {
|
|
449
|
+
intent: string;
|
|
450
|
+
description?: string;
|
|
451
|
+
input?: SchemaDefinition;
|
|
452
|
+
})[];
|
|
453
|
+
update?: (string | {
|
|
454
|
+
intent: string;
|
|
455
|
+
description?: string;
|
|
456
|
+
input?: SchemaDefinition;
|
|
457
|
+
})[];
|
|
458
|
+
delete?: (string | {
|
|
459
|
+
intent: string;
|
|
460
|
+
description?: string;
|
|
461
|
+
input?: SchemaDefinition;
|
|
462
|
+
})[];
|
|
437
463
|
};
|
|
438
464
|
initialData?: {
|
|
439
465
|
fields: string[];
|
|
@@ -481,6 +507,7 @@ interface DatabaseOptions {
|
|
|
481
507
|
databaseType?: "postgres";
|
|
482
508
|
databaseName?: string;
|
|
483
509
|
poolSize?: number;
|
|
510
|
+
ownerServiceName?: string | null;
|
|
484
511
|
}
|
|
485
512
|
/**
|
|
486
513
|
* The CadenzaService class serves as a central service layer providing various utility methods for managing tasks, signals, logging, and service interactions.
|
|
@@ -22404,14 +22431,28 @@ declare class CadenzaService {
|
|
|
22404
22431
|
*/
|
|
22405
22432
|
static createCadenzaMetaService(serviceName: string, description: string, options?: ServerOptions): void;
|
|
22406
22433
|
/**
|
|
22407
|
-
* Creates and initializes a
|
|
22408
|
-
* This
|
|
22434
|
+
* Creates and initializes a specialized PostgresActor.
|
|
22435
|
+
* This is actor-only and does not create or register a network service.
|
|
22409
22436
|
*
|
|
22410
|
-
* @param {string} name -
|
|
22411
|
-
* @param {DatabaseSchemaDefinition} schema -
|
|
22412
|
-
* @param {string} [description=""] -
|
|
22413
|
-
* @param {ServerOptions & DatabaseOptions} [options={}] -
|
|
22414
|
-
* @return {void}
|
|
22437
|
+
* @param {string} name - Logical PostgresActor name.
|
|
22438
|
+
* @param {DatabaseSchemaDefinition} schema - Database schema definition.
|
|
22439
|
+
* @param {string} [description=""] - Optional human-readable actor description.
|
|
22440
|
+
* @param {ServerOptions & DatabaseOptions} [options={}] - Actor/database runtime options.
|
|
22441
|
+
* @return {void}
|
|
22442
|
+
*/
|
|
22443
|
+
static createPostgresActor(name: string, schema: DatabaseSchemaDefinition, description?: string, options?: ServerOptions & DatabaseOptions): void;
|
|
22444
|
+
/**
|
|
22445
|
+
* Creates a meta PostgresActor.
|
|
22446
|
+
*
|
|
22447
|
+
* @param {string} name - Logical PostgresActor name.
|
|
22448
|
+
* @param {DatabaseSchemaDefinition} schema - Database schema definition.
|
|
22449
|
+
* @param {string} [description=""] - Optional description.
|
|
22450
|
+
* @param {ServerOptions & DatabaseOptions} [options={}] - Optional actor/database options.
|
|
22451
|
+
* @return {void}
|
|
22452
|
+
*/
|
|
22453
|
+
static createMetaPostgresActor(name: string, schema: DatabaseSchemaDefinition, description?: string, options?: ServerOptions & DatabaseOptions): void;
|
|
22454
|
+
/**
|
|
22455
|
+
* Creates a dedicated database service by composing a PostgresActor and a Cadenza service.
|
|
22415
22456
|
*/
|
|
22416
22457
|
static createDatabaseService(name: string, schema: DatabaseSchemaDefinition, description?: string, options?: ServerOptions & DatabaseOptions): void;
|
|
22417
22458
|
/**
|
|
@@ -22424,6 +22465,9 @@ declare class CadenzaService {
|
|
|
22424
22465
|
* @return {void} - This method does not return a value.
|
|
22425
22466
|
*/
|
|
22426
22467
|
static createMetaDatabaseService(name: string, schema: DatabaseSchemaDefinition, description?: string, options?: ServerOptions & DatabaseOptions): void;
|
|
22468
|
+
private static normalizePostgresActorOptions;
|
|
22469
|
+
private static normalizeDatabaseServiceOptions;
|
|
22470
|
+
private static registerDatabaseServiceBridgeTask;
|
|
22427
22471
|
static createActor<D extends Record<string, any> = AnyObject, R = AnyObject>(spec: ActorSpec<D, R>, options?: ActorFactoryOptions): Actor<D, R>;
|
|
22428
22472
|
static createActorFromDefinition<D extends Record<string, any> = AnyObject, R = AnyObject>(definition: ActorDefinition<D, R>, options?: ActorFactoryOptions<D, R>): Actor<D, R>;
|
|
22429
22473
|
/**
|
|
@@ -22718,14 +22762,14 @@ declare class CadenzaService {
|
|
|
22718
22762
|
*/
|
|
22719
22763
|
static createEphemeralTask(name: string, func: TaskFunction, description?: string, options?: TaskOptions & EphemeralTaskOptions): EphemeralTask;
|
|
22720
22764
|
/**
|
|
22721
|
-
* Creates an ephemeral meta
|
|
22765
|
+
* Creates an ephemeral meta-task with the specified name, function, description, and options.
|
|
22722
22766
|
* See {@link createEphemeralTask} and {@link createMetaTask} for more details.
|
|
22723
22767
|
*
|
|
22724
22768
|
* @param {string} name - The name of the task to be created.
|
|
22725
22769
|
* @param {TaskFunction} func - The function to be executed as part of the task.
|
|
22726
22770
|
* @param {string} [description] - An optional description of the task.
|
|
22727
22771
|
* @param {TaskOptions & EphemeralTaskOptions} [options={}] - Additional options for configuring the task.
|
|
22728
|
-
* @return {EphemeralTask} The created ephemeral meta
|
|
22772
|
+
* @return {EphemeralTask} The created ephemeral meta-task.
|
|
22729
22773
|
*/
|
|
22730
22774
|
static createEphemeralMetaTask(name: string, func: TaskFunction, description?: string, options?: TaskOptions & EphemeralTaskOptions): EphemeralTask;
|
|
22731
22775
|
/**
|
|
@@ -22921,4 +22965,4 @@ declare class SignalController {
|
|
|
22921
22965
|
constructor();
|
|
22922
22966
|
}
|
|
22923
22967
|
|
|
22924
|
-
export { DatabaseTask, type DbOperationPayload, type DbOperationType$1 as DbOperationType, type DeputyDescriptor, DeputyTask, type DistributedInquiryMeta, type DistributedInquiryOptions, GraphMetadataController, type InquiryResponderDescriptor, type InquiryResponderStatus, type JoinDefinition, type NetworkMode, type OpEffect, RestController, type SecurityProfile, type ServerOptions, type ServiceInstanceDescriptor, ServiceRegistry, SignalController, SignalTransmissionTask, SocketController, type SortDirection, type SubOperation, type SubOperationType, type ValueOrSubOp, CadenzaService as default };
|
|
22968
|
+
export { type AggregateDefinition, type AggregateFunction, DatabaseTask, type DbOperationPayload, type DbOperationType$1 as DbOperationType, type DeputyDescriptor, DeputyTask, type DistributedInquiryMeta, type DistributedInquiryOptions, GraphMetadataController, type InquiryResponderDescriptor, type InquiryResponderStatus, type JoinDefinition, type NetworkMode, type OpEffect, type QueryMode, RestController, type SecurityProfile, type ServerOptions, type ServiceInstanceDescriptor, ServiceRegistry, SignalController, SignalTransmissionTask, SocketController, type SortDirection, type SubOperation, type SubOperationType, type ValueOrSubOp, CadenzaService as default };
|