@spine-event-engine/client-node 2.0.0-snapshot.2 → 2.0.0-snapshot.20
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 +52 -56
- package/REFERENCE.md +13 -3
- package/dist/client/node-client.d.ts.map +1 -1
- package/dist/client/node-client.js +2 -5
- package/dist/client/node-client.js.map +1 -1
- package/dist/codegen/index.d.ts +2 -1
- package/dist/codegen/index.d.ts.map +1 -1
- package/dist/codegen/index.js +2 -1
- package/dist/codegen/index.js.map +1 -1
- package/dist/entity/entity-column.d.ts +34 -125
- package/dist/entity/entity-column.d.ts.map +1 -1
- package/dist/entity/entity-column.js +5 -287
- package/dist/entity/entity-column.js.map +1 -1
- package/dist/query/entity-query.d.ts +22 -164
- package/dist/query/entity-query.d.ts.map +1 -1
- package/dist/query/entity-query.js +5 -417
- package/dist/query/entity-query.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -7
package/README.md
CHANGED
|
@@ -1,29 +1,49 @@
|
|
|
1
1
|
# Spine client for Node.js
|
|
2
2
|
|
|
3
|
-
Use this package from a Node.js application to post commands, send queries,
|
|
4
|
-
create subscriptions for query-side views. It
|
|
5
|
-
the
|
|
3
|
+
Use this package from a Node.js ESM application to post commands, send queries,
|
|
4
|
+
or create subscriptions for query-side views. It owns the Node HTTP/2 transport;
|
|
5
|
+
the request and subscription API is shared with the browser client.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
This is an experimental snapshot. Install the snapshot explicitly while its API
|
|
8
|
+
and packaging continue to evolve:
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
```sh
|
|
11
|
+
pnpm add @spine-event-engine/client-node@snapshot
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
For detailed public contracts, lifecycle rules, and limits, read the
|
|
15
|
+
[reference](REFERENCE.md).
|
|
16
|
+
|
|
17
|
+
## 💡 Who should use it?
|
|
18
|
+
|
|
19
|
+
- ✅ Node.js services, workers, and command-line applications that call a Spine
|
|
20
|
+
application gateway.
|
|
21
|
+
- ✅ Applications that already own a generated Spine model package and a
|
|
22
|
+
reachable local or deployed Spine service.
|
|
23
|
+
- ❌ Browser applications; use `@spine-event-engine/client-web` instead.
|
|
11
24
|
|
|
12
|
-
##
|
|
25
|
+
## 🚀 Post a command to a local application
|
|
13
26
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
27
|
+
Before running this example, use Node.js with ESM support, generate and build
|
|
28
|
+
your application's Proto model, and start that application's local Spine
|
|
29
|
+
service. For the concrete Message Board workspace walkthrough, clone this
|
|
30
|
+
repository, run `pnpm install --frozen-lockfile && pnpm typecheck:build`, then
|
|
31
|
+
start `pnpm --dir examples/message-board/app start`. That command starts the
|
|
32
|
+
single-tenant local service at `http://127.0.0.1:8090`.
|
|
18
33
|
|
|
19
|
-
|
|
34
|
+
The imports below are the Message Board workspace model contract: its
|
|
35
|
+
`package.json` exports compiled `generated/*.js` modules after the setup above.
|
|
36
|
+
They are not an installable dependency for an external application. In your
|
|
37
|
+
application, depend on your own generated model package and replace this model
|
|
38
|
+
package name and generated export paths with the ones declared by its
|
|
39
|
+
`package.json` and `spine-proto.json`.
|
|
20
40
|
|
|
21
|
-
Create one client for the
|
|
22
|
-
|
|
23
|
-
|
|
41
|
+
Create one client for the component that manages the connection. A client from
|
|
42
|
+
`connectTo()` owns its HTTP/2 session, so always close it.
|
|
43
|
+
|
|
44
|
+
<!-- docs-snippet-path: examples/message-board/app/src/index.ts -->
|
|
24
45
|
|
|
25
46
|
```ts
|
|
26
|
-
// docs-snippet-path: examples/message-board/app/src/index.ts
|
|
27
47
|
import { create } from "@bufbuild/protobuf";
|
|
28
48
|
import { timestampFromDate } from "@bufbuild/protobuf/wkt";
|
|
29
49
|
import { Client } from "@spine-event-engine/client-node";
|
|
@@ -34,7 +54,7 @@ import {
|
|
|
34
54
|
} from "@spine-event-engine/example-message-board-model/generated/spine/examples/messageboard/message_board_pb.js";
|
|
35
55
|
import { UserIdSchema } from "@spine-event-engine/example-message-board-model/generated/spine/examples/messageboard/user_pb.js";
|
|
36
56
|
|
|
37
|
-
const client = Client.connectTo("http://127.0.0.1:
|
|
57
|
+
const client = Client.connectTo("http://127.0.0.1:8090");
|
|
38
58
|
const request = client.onBehalfOf("alice");
|
|
39
59
|
const result = await request.post(
|
|
40
60
|
PostMessageSchema,
|
|
@@ -47,18 +67,16 @@ const result = await request.post(
|
|
|
47
67
|
postedAt: timestampFromDate(new Date()),
|
|
48
68
|
}),
|
|
49
69
|
);
|
|
50
|
-
if (result.kind
|
|
70
|
+
if (result.kind !== "ok") throw new Error(`Message was not accepted: ${result.kind}`);
|
|
51
71
|
await client.close();
|
|
52
72
|
```
|
|
53
73
|
|
|
54
74
|
The URL is an application gateway URL. It is not an instruction to expose a
|
|
55
|
-
Spine server directly to the internet.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
API as the browser client; see the [client-web reference](../client-web/REFERENCE.md)
|
|
59
|
-
for its lifecycle and recovery limits.
|
|
75
|
+
Spine server directly to the internet. A successful call is an observation that
|
|
76
|
+
the local service accepted the command; handle rejection and error outcomes in
|
|
77
|
+
your application instead of assuming every command succeeds.
|
|
60
78
|
|
|
61
|
-
## 🔎 Query entities
|
|
79
|
+
## 🔎 Query generated entities
|
|
62
80
|
|
|
63
81
|
Generate entity columns from the model package, register them once, and build
|
|
64
82
|
queries with those declared columns. The `./codegen` entry point is for model
|
|
@@ -66,45 +84,23 @@ generation; applications use the generated definition and `EntityQuery`.
|
|
|
66
84
|
`limit()` requires an ordering. Only generated columns for the selected Entity
|
|
67
85
|
may be used in its predicates.
|
|
68
86
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
```sh
|
|
73
|
-
protoc --spine-entity-columns_out=generated proto/spine/examples/messageboard/message_board.proto
|
|
74
|
-
```
|
|
87
|
+
The [reference](REFERENCE.md) documents the query builder and its column-safety
|
|
88
|
+
rules.
|
|
75
89
|
|
|
76
|
-
|
|
77
|
-
// docs-snippet-path: examples/todo/src/index.ts
|
|
78
|
-
import { Client, EntityColumn, EntityQuery } from "@spine-event-engine/client-node";
|
|
79
|
-
import { create } from "@bufbuild/protobuf";
|
|
80
|
-
import { ActorContextSchema } from "@spine-event-engine/proto";
|
|
81
|
-
import { TaskListColumnDefinition } from "@spine-event-engine/example-todo/generated/spine/examples/todo/task_list_columns.js";
|
|
82
|
-
import { TaskListSchema } from "@spine-event-engine/example-todo/generated/spine/examples/todo/task_list_pb.js";
|
|
83
|
-
|
|
84
|
-
const columns = EntityColumn.register(TaskListSchema, TaskListColumnDefinition);
|
|
85
|
-
const query = EntityQuery.select({
|
|
86
|
-
schema: TaskListSchema,
|
|
87
|
-
columns,
|
|
88
|
-
context: create(ActorContextSchema, { actor: { value: "alice" } }),
|
|
89
|
-
})
|
|
90
|
-
.orderBy(columns.openTaskCount, "desc")
|
|
91
|
-
.limit(20)
|
|
92
|
-
.build();
|
|
93
|
-
const client = Client.connectTo("http://127.0.0.1:8080");
|
|
94
|
-
const response = await client.asGuest().send(query);
|
|
95
|
-
console.log(response.message.length);
|
|
96
|
-
await client.close();
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
## ⚠️ Connection behavior
|
|
90
|
+
## ⚠️ Cleanup and limits
|
|
100
91
|
|
|
101
92
|
The client does not make a server safe for public access. Put the authenticated
|
|
102
93
|
application gateway at the network boundary. Commands are not retried
|
|
103
94
|
automatically, and an interrupted subscription must be recreated before the
|
|
104
95
|
application re-reads current entity state.
|
|
105
96
|
|
|
97
|
+
Node subscriptions use the same `createSubscription`, `activate`, and `cancel`
|
|
98
|
+
API as the browser client; see the [client-web reference](https://github.com/SpineEventEngine/spine-ts/blob/master/packages/client-web/REFERENCE.md)
|
|
99
|
+
for lifecycle and recovery limits. Close the client during process shutdown so
|
|
100
|
+
its owned HTTP/2 session and subscriptions can finish cleanup.
|
|
101
|
+
|
|
106
102
|
## 🔗 Learn more
|
|
107
103
|
|
|
108
|
-
- [Browser client](
|
|
109
|
-
- [Server](
|
|
104
|
+
- [Browser client](https://github.com/SpineEventEngine/spine-ts/blob/master/packages/client-web/README.md)
|
|
105
|
+
- [Server](https://github.com/SpineEventEngine/spine-ts/blob/master/packages/server/README.md)
|
|
110
106
|
- [Detailed coding-agent reference](REFERENCE.md)
|
package/REFERENCE.md
CHANGED
|
@@ -5,18 +5,28 @@ Start with the [Node client overview](README.md) for the shortest connection pat
|
|
|
5
5
|
|
|
6
6
|
## Client construction
|
|
7
7
|
|
|
8
|
-
`Client.connectTo(baseUrl, options)` creates a shared `client-web` `Client` with a Node Connect HTTP/2 session. `client.close()` closes subscriptions and then aborts that session. `Client.usingTransport(transport, options)` uses a Connect transport supplied by the caller; closing the returned client does not close the supplied transport.
|
|
8
|
+
`Client.connectTo(baseUrl, options)` creates a shared `client-web` `Client` with a Node Connect HTTP/2 session. `client.close()` closes subscriptions and then aborts that session. `Client.usingTransport(transport, options)` uses a Connect transport supplied by the caller; closing the returned client does not close the supplied transport. Each `post()` creates its Command through the shared core signal-envelope helper, which assigns a fresh secure UUID-based Command ID.
|
|
9
9
|
|
|
10
10
|
The returned kernel supports `asGuest()` and `onBehalfOf(user)` request scopes. A scope has `post(schema, value, options)`, `send(query, options)`, and `createSubscription(topic, options)`. See the [client-web reference](../client-web/REFERENCE.md) for command outcomes, cancellation, subscription lifecycle, recovery, and terminal behavior shared by both clients.
|
|
11
11
|
|
|
12
12
|
## Entity query API
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
Normal model generation emits a `_query.ts` companion for each eligible Entity
|
|
15
|
+
state. Import its named query, for example `TaskListQuery`, then call
|
|
16
|
+
`TaskListQuery.create().openTaskCount().isAtLeast(1).build()`. The import
|
|
17
|
+
registers its declared columns automatically. The built query contains no actor
|
|
18
|
+
or tenant; `request.send(query)` binds both at execution.
|
|
19
|
+
|
|
20
|
+
`EntityColumn.register(schema, definition)` and `EntityQuery.select(...)` remain
|
|
21
|
+
available for existing low-level callers. Their schema-and-columns setup is not
|
|
22
|
+
required when using a generated query.
|
|
15
23
|
|
|
16
24
|
Predicates accept only columns registered for the selected Entity. `limit()` requires at least one order clause. The compiler packs declared values and the `version`, `archived`, and `deleted` system columns into the wire query. Builders and columns are immutable, so a predicate cannot be reused for a different Entity target.
|
|
17
25
|
|
|
18
26
|
## Code generation
|
|
19
27
|
|
|
20
|
-
|
|
28
|
+
Run the model package's normal `spine-proto generate` command. It emits the
|
|
29
|
+
query companion and column registration together; application code imports the
|
|
30
|
+
named query without a second generation command or manual registration.
|
|
21
31
|
|
|
22
32
|
This package is Node-only because it imports Node HTTP/2 and code-generation dependencies. Browser applications use `@spine-event-engine/client-web`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-client.d.ts","sourceRoot":"","sources":["../../src/client/node-client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"node-client.d.ts","sourceRoot":"","sources":["../../src/client/node-client.ts"],"names":[],"mappings":"AAeA,OAAO,EACL,MAAM,IAAI,SAAS,EACnB,KAAK,aAAa,EAEnB,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD;;GAEG;AACH,eAAO,MAAM,MAAM,EAAE,QAAQ,CAAC;IAG5B;;;;;;OAMG;IACH,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;IAE/D;;;;;;OAMG;IACH,cAAc,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;CAC1E,CAsBC,CAAC"}
|
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
* the License.
|
|
13
13
|
*/
|
|
14
14
|
import { Http2SessionManager, createGrpcTransport } from "@connectrpc/connect-node";
|
|
15
|
-
import { randomUUID } from "node:crypto";
|
|
16
15
|
import { Client as WebClient, } from "@spine-event-engine/client-web";
|
|
17
16
|
/**
|
|
18
17
|
* Creates Node transport-backed instances of the shared browser-safe client kernel.
|
|
@@ -45,12 +44,10 @@ const NodeClientTransport = Object.freeze({
|
|
|
45
44
|
*
|
|
46
45
|
* @param transport Connect transport used for client operations.
|
|
47
46
|
* @param onClose Optional cleanup for a transport owned by this package.
|
|
48
|
-
* @returns Shared transport contract
|
|
47
|
+
* @returns Shared transport contract.
|
|
49
48
|
*/
|
|
50
49
|
create(transport, onClose) {
|
|
51
|
-
return onClose === undefined
|
|
52
|
-
? { transport, createRequestId: randomUUID }
|
|
53
|
-
: { transport, createRequestId: randomUUID, close: onClose };
|
|
50
|
+
return onClose === undefined ? { transport } : { transport, close: onClose };
|
|
54
51
|
},
|
|
55
52
|
});
|
|
56
53
|
//# sourceMappingURL=node-client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-client.js","sourceRoot":"","sources":["../../src/client/node-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACpF,OAAO,
|
|
1
|
+
{"version":3,"file":"node-client.js","sourceRoot":"","sources":["../../src/client/node-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACpF,OAAO,EACL,MAAM,IAAI,SAAS,GAGpB,MAAM,gCAAgC,CAAC;AAGxC;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAoBd,MAAM,CAAC,MAAM,CAAC;IACjB,kBAAkB;IAElB;;OAEG;IACH,SAAS,CAAC,OAAe,EAAE,UAAyB,EAAE;QACpD,MAAM,QAAQ,GAAG,IAAI,mBAAmB,CAAC,OAAO,CAAC,CAAC;QAClD,OAAO,SAAS,CAAC,cAAc,CAC7B,mBAAmB,CAAC,MAAM,CAAC,mBAAmB,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,CAAC,EAAE,GAAG,EAAE;YAC1F,QAAQ,CAAC,KAAK,EAAE,CAAC;QACnB,CAAC,CAAC,EACF,OAAO,CACR,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,cAAc,CAAC,SAAoB,EAAE,UAAyB,EAAE;QAC9D,OAAO,SAAS,CAAC,cAAc,CAAC,mBAAmB,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,CAAC;IAClF,CAAC;CACF,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,CAAC;IACxC,kBAAkB;IAElB;;;;;;OAMG;IACH,MAAM,CAAC,SAAoB,EAAE,OAAoB;QAC/C,OAAO,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;IAC/E,CAAC;CACF,CAAC,CAAC"}
|
package/dist/codegen/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { GeneratedEntityColumns as CoreGeneratedEntityColumns } from "@spine-event-engine/core/codegen";
|
|
1
2
|
/**
|
|
2
3
|
* Generated-code-only helpers for descriptor-backed Entity metadata.
|
|
3
4
|
*/
|
|
4
|
-
export
|
|
5
|
+
export declare const GeneratedEntityColumns: typeof CoreGeneratedEntityColumns;
|
|
5
6
|
export type { EntityColumnDefinition, EntityColumnDefinitionEntry, } from "../entity/entity-column.js";
|
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/codegen/index.ts"],"names":[],"mappings":"AAcA;;GAEG;AACH,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/codegen/index.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,sBAAsB,IAAI,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AAExG;;GAEG;AACH,eAAO,MAAM,sBAAsB,EAAE,OAAO,0BAAuD,CAAC;AACpG,YAAY,EACV,sBAAsB,EACtB,2BAA2B,GAC5B,MAAM,4BAA4B,CAAC"}
|
package/dist/codegen/index.js
CHANGED
|
@@ -11,8 +11,9 @@
|
|
|
11
11
|
* or implied. See the License for the specific language governing permissions and limitations under
|
|
12
12
|
* the License.
|
|
13
13
|
*/
|
|
14
|
+
import { GeneratedEntityColumns as CoreGeneratedEntityColumns } from "@spine-event-engine/core/codegen";
|
|
14
15
|
/**
|
|
15
16
|
* Generated-code-only helpers for descriptor-backed Entity metadata.
|
|
16
17
|
*/
|
|
17
|
-
export
|
|
18
|
+
export const GeneratedEntityColumns = CoreGeneratedEntityColumns;
|
|
18
19
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/codegen/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/codegen/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,sBAAsB,IAAI,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AAExG;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAsC,0BAA0B,CAAC"}
|
|
@@ -1,158 +1,67 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { Message } from "@bufbuild/protobuf";
|
|
2
2
|
import type { GenMessage } from "@bufbuild/protobuf/codegenv2";
|
|
3
|
-
import { type
|
|
3
|
+
import { EntityColumn as CoreEntityColumn, type EntityColumn as CoreEntityColumnType, type EntityColumnDefinition as CoreEntityColumnDefinition, type EntityColumnDefinitionEntry as CoreColumnDefinitionEntry, type EntityColumnOperator as CoreEntityColumnOperator, type EntityColumnValue as CoreEntityColumnValue, type EntityColumnValueKind as CoreColumnValueKind, type EntityColumns as CoreEntityColumns, type EntityComparison as CoreEntityComparison, type EntityEqualityOperator as CoreEntityEqualityOperator, type EntityOrderingOperator as CoreEntityOrderingOperator } from "@spine-event-engine/core";
|
|
4
|
+
import { GeneratedEntityColumns } from "@spine-event-engine/core/codegen";
|
|
4
5
|
/**
|
|
5
6
|
* Operators available for every Entity column.
|
|
6
7
|
*/
|
|
7
|
-
export type EntityEqualityOperator =
|
|
8
|
+
export type EntityEqualityOperator = CoreEntityEqualityOperator;
|
|
8
9
|
/**
|
|
9
10
|
* Operators available for naturally ordered Entity column values.
|
|
10
11
|
*/
|
|
11
|
-
export type EntityOrderingOperator =
|
|
12
|
+
export type EntityOrderingOperator = CoreEntityOrderingOperator;
|
|
12
13
|
/**
|
|
13
14
|
* Comparison family derived from a column's Protobuf field descriptor.
|
|
14
15
|
*/
|
|
15
|
-
export type EntityComparison =
|
|
16
|
+
export type EntityComparison = CoreEntityComparison;
|
|
16
17
|
/**
|
|
17
18
|
* Runtime value category derived from a column's Protobuf field descriptor.
|
|
18
19
|
*/
|
|
19
|
-
export type EntityColumnValueKind =
|
|
20
|
+
export type EntityColumnValueKind = CoreColumnValueKind;
|
|
20
21
|
/**
|
|
21
22
|
* Represents one generated column declaration paired with its descriptor.
|
|
23
|
+
*
|
|
24
|
+
* @typeParam Comparison Comparison family supported by the column.
|
|
22
25
|
*/
|
|
23
|
-
export
|
|
24
|
-
/**
|
|
25
|
-
* Identifies the generated Protobuf field declared as a column.
|
|
26
|
-
*/
|
|
27
|
-
readonly field: DescField;
|
|
28
|
-
/**
|
|
29
|
-
* Identifies the comparison family supported by the field.
|
|
30
|
-
*/
|
|
31
|
-
readonly comparison: Comparison;
|
|
32
|
-
}
|
|
33
|
-
type StateFieldName<Schema extends GenMessage<Message>> = Exclude<keyof MessageShape<Schema>, "$typeName" | "$unknown"> & string;
|
|
34
|
-
type CollectionFieldName<Schema extends GenMessage<Message>> = {
|
|
35
|
-
[Name in StateFieldName<Schema>]: NonNullable<MessageShape<Schema>[Name]> extends readonly unknown[] ? Name : NonNullable<MessageShape<Schema>[Name]> extends object ? string extends keyof NonNullable<MessageShape<Schema>[Name]> ? Name : never : never;
|
|
36
|
-
}[StateFieldName<Schema>];
|
|
37
|
-
type SupportedStateFieldName<Schema extends GenMessage<Message>> = Exclude<StateFieldName<Schema> & keyof Schema["field"], CollectionFieldName<Schema>>;
|
|
38
|
-
type EntityColumnEntries = Readonly<Record<string, EntityColumnDefinitionEntry>>;
|
|
39
|
-
type SupportedEntryConstraint<Schema extends GenMessage<Message>, Entries extends EntityColumnEntries> = Exclude<keyof Entries, SupportedStateFieldName<Schema>> extends never ? unknown : never;
|
|
40
|
-
/**
|
|
41
|
-
* Brands generated column definitions for nominal type safety.
|
|
42
|
-
*/
|
|
43
|
-
declare const generatedDefinitionBrand: unique symbol;
|
|
26
|
+
export type EntityColumnDefinitionEntry<Comparison extends EntityComparison = EntityComparison> = CoreColumnDefinitionEntry<Comparison>;
|
|
44
27
|
/**
|
|
45
28
|
* Describes descriptor-backed column metadata emitted next to an Entity schema.
|
|
46
29
|
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*/
|
|
50
|
-
export interface EntityColumnDefinition<Schema extends GenMessage<Message>, Entries extends EntityColumnEntries> {
|
|
51
|
-
/**
|
|
52
|
-
* Brands metadata with its owning schema and generated entries.
|
|
53
|
-
*/
|
|
54
|
-
readonly [generatedDefinitionBrand]: readonly [Schema, Entries];
|
|
55
|
-
/**
|
|
56
|
-
* Stores exact generated entries, validated again during registration.
|
|
57
|
-
* @internal
|
|
58
|
-
*/
|
|
59
|
-
readonly entries: Entries;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Creates immutable Entity-column metadata emitted by the companion generator.
|
|
30
|
+
* @typeParam Schema Generated Protobuf schema that owns the columns.
|
|
31
|
+
* @typeParam Entries Generated column entries for the schema.
|
|
63
32
|
*/
|
|
64
|
-
export
|
|
65
|
-
/**
|
|
66
|
-
* Creates immutable metadata for one generated Entity schema.
|
|
67
|
-
*
|
|
68
|
-
* @param schema Generated Protobuf schema that owns the declared fields.
|
|
69
|
-
* @param entries Generated field descriptors and their comparison families.
|
|
70
|
-
* @returns Metadata accepted by {@link EntityColumn.register}.
|
|
71
|
-
*/
|
|
72
|
-
define<Schema extends GenMessage<Message>, const Entries extends EntityColumnEntries>(schema: Schema, entries: Entries & SupportedEntryConstraint<NoInfer<Schema>, Entries>): EntityColumnDefinition<Schema, Entries>;
|
|
73
|
-
}>;
|
|
74
|
-
type OperatorsFor<Entry> = Entry extends EntityColumnDefinitionEntry<"ordering"> ? EntityOrderingOperator : EntityEqualityOperator;
|
|
33
|
+
export type EntityColumnDefinition<Schema extends GenMessage<Message>, Entries extends Readonly<Record<string, EntityColumnDefinitionEntry>>> = CoreEntityColumnDefinition<Schema, Entries>;
|
|
75
34
|
/**
|
|
76
35
|
* Represents the typed column collection returned for one generated Entity definition.
|
|
36
|
+
*
|
|
37
|
+
* @typeParam Schema Generated Protobuf schema that owns the columns.
|
|
38
|
+
* @typeParam Entries Generated column entries for the schema.
|
|
77
39
|
*/
|
|
78
|
-
export type EntityColumns<Schema extends GenMessage<Message>, Entries extends
|
|
79
|
-
[Name in keyof Entries & StateFieldName<Schema>]: EntityColumn<Schema, Name, MessageShape<Schema>[Name], OperatorsFor<Entries[Name]>>;
|
|
80
|
-
} & {
|
|
81
|
-
/**
|
|
82
|
-
* Identifies the Entity version system column.
|
|
83
|
-
*/
|
|
84
|
-
readonly version: EntityColumn<Schema, "version", Version>;
|
|
85
|
-
/**
|
|
86
|
-
* Identifies the Entity archived system column.
|
|
87
|
-
*/
|
|
88
|
-
readonly archived: EntityColumn<Schema, "archived", boolean, EntityEqualityOperator>;
|
|
89
|
-
/**
|
|
90
|
-
* Identifies the Entity deleted system column.
|
|
91
|
-
*/
|
|
92
|
-
readonly deleted: EntityColumn<Schema, "deleted", boolean, EntityEqualityOperator>;
|
|
93
|
-
}>;
|
|
40
|
+
export type EntityColumns<Schema extends GenMessage<Message>, Entries extends Readonly<Record<string, EntityColumnDefinitionEntry>>> = CoreEntityColumns<Schema, Entries>;
|
|
94
41
|
/**
|
|
95
42
|
* Extracts the value type carried by an Entity column.
|
|
43
|
+
*
|
|
44
|
+
* @typeParam Column Entity column whose value type is extracted.
|
|
96
45
|
*/
|
|
97
|
-
export type EntityColumnValue<Column extends EntityColumn> = Column
|
|
46
|
+
export type EntityColumnValue<Column extends EntityColumn> = CoreEntityColumnValue<Column>;
|
|
98
47
|
/**
|
|
99
48
|
* Extracts the legal operator union carried by an Entity column.
|
|
49
|
+
*
|
|
50
|
+
* @typeParam Column Entity column whose operator type is extracted.
|
|
100
51
|
*/
|
|
101
|
-
export type EntityColumnOperator<Column extends EntityColumn> = Column
|
|
52
|
+
export type EntityColumnOperator<Column extends EntityColumn> = CoreEntityColumnOperator<Column>;
|
|
102
53
|
/**
|
|
103
|
-
*
|
|
54
|
+
* Represents an immutable, nominal, descriptor-backed Entity column.
|
|
104
55
|
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
56
|
+
* @typeParam Schema Generated Protobuf schema that owns the column.
|
|
57
|
+
* @typeParam Name Protobuf-ES property name for the column.
|
|
58
|
+
* @typeParam Value Value stored in the column.
|
|
59
|
+
* @typeParam Operator Operators accepted by the column.
|
|
60
|
+
*/
|
|
61
|
+
export type EntityColumn<Schema extends GenMessage<Message> = GenMessage<Message>, Name extends string = string, Value = unknown, Operator extends EntityOrderingOperator = EntityOrderingOperator> = CoreEntityColumnType<Schema, Name, Value, Operator>;
|
|
62
|
+
/**
|
|
63
|
+
* Exposes the canonical Entity-column constructor through this compatibility package.
|
|
108
64
|
*/
|
|
109
|
-
export declare
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Generated Protobuf schema that owns this column.
|
|
113
|
-
*/
|
|
114
|
-
readonly schema: Schema;
|
|
115
|
-
/**
|
|
116
|
-
* Protobuf field name, or the canonical system-column name.
|
|
117
|
-
*/
|
|
118
|
-
readonly name: string;
|
|
119
|
-
/**
|
|
120
|
-
* Protobuf-ES property name, or the canonical system-column name.
|
|
121
|
-
*/
|
|
122
|
-
readonly localName: Name;
|
|
123
|
-
/**
|
|
124
|
-
* Whether the column came from the state descriptor or Entity storage metadata.
|
|
125
|
-
*/
|
|
126
|
-
readonly source: "declared" | "system";
|
|
127
|
-
/**
|
|
128
|
-
* Exact declared field descriptor; system columns have no state field.
|
|
129
|
-
*/
|
|
130
|
-
readonly descriptor: DescField | undefined;
|
|
131
|
-
/**
|
|
132
|
-
* Runtime value category derived from the descriptor.
|
|
133
|
-
*/
|
|
134
|
-
readonly valueKind: EntityColumnValueKind;
|
|
135
|
-
/**
|
|
136
|
-
* Fully qualified message type for message-valued columns.
|
|
137
|
-
*/
|
|
138
|
-
readonly messageType: string | undefined;
|
|
139
|
-
/**
|
|
140
|
-
* Supported comparison family.
|
|
141
|
-
*/
|
|
142
|
-
readonly comparison: EntityComparison;
|
|
143
|
-
/**
|
|
144
|
-
* Exact operator set accepted for this column.
|
|
145
|
-
*/
|
|
146
|
-
readonly operators: readonly Operator[];
|
|
147
|
-
private constructor();
|
|
148
|
-
/**
|
|
149
|
-
* Registers generated Entity-column metadata for a schema.
|
|
150
|
-
*
|
|
151
|
-
* @param schema Generated Entity schema that owns the metadata.
|
|
152
|
-
* @param definition Immutable generated field metadata.
|
|
153
|
-
* @returns Stable immutable columns for the Entity schema.
|
|
154
|
-
*/
|
|
155
|
-
static register<Schema extends GenMessage<Message>, const Entries extends EntityColumnEntries>(schema: Schema, definition: EntityColumnDefinition<Schema, Entries>): EntityColumns<Schema, Entries>;
|
|
156
|
-
}
|
|
157
|
-
export {};
|
|
65
|
+
export declare const EntityColumn: typeof CoreEntityColumn;
|
|
66
|
+
export { GeneratedEntityColumns };
|
|
158
67
|
//# sourceMappingURL=entity-column.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity-column.d.ts","sourceRoot":"","sources":["../../src/entity/entity-column.ts"],"names":[],"mappings":"AAcA,OAAO,
|
|
1
|
+
{"version":3,"file":"entity-column.d.ts","sourceRoot":"","sources":["../../src/entity/entity-column.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EACL,YAAY,IAAI,gBAAgB,EAChC,KAAK,YAAY,IAAI,oBAAoB,EACzC,KAAK,sBAAsB,IAAI,0BAA0B,EACzD,KAAK,2BAA2B,IAAI,yBAAyB,EAC7D,KAAK,oBAAoB,IAAI,wBAAwB,EACrD,KAAK,iBAAiB,IAAI,qBAAqB,EAC/C,KAAK,qBAAqB,IAAI,mBAAmB,EACjD,KAAK,aAAa,IAAI,iBAAiB,EACvC,KAAK,gBAAgB,IAAI,oBAAoB,EAC7C,KAAK,sBAAsB,IAAI,0BAA0B,EACzD,KAAK,sBAAsB,IAAI,0BAA0B,EAC1D,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAE1E;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG,0BAA0B,CAAC;AAEhE;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG,0BAA0B,CAAC;AAEhE;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,oBAAoB,CAAC;AAEpD;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,mBAAmB,CAAC;AAExD;;;;GAIG;AACH,MAAM,MAAM,2BAA2B,CAAC,UAAU,SAAS,gBAAgB,GAAG,gBAAgB,IAC5F,yBAAyB,CAAC,UAAU,CAAC,CAAC;AAExC;;;;;GAKG;AACH,MAAM,MAAM,sBAAsB,CAChC,MAAM,SAAS,UAAU,CAAC,OAAO,CAAC,EAClC,OAAO,SAAS,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,2BAA2B,CAAC,CAAC,IACnE,0BAA0B,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,MAAM,aAAa,CACvB,MAAM,SAAS,UAAU,CAAC,OAAO,CAAC,EAClC,OAAO,SAAS,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,2BAA2B,CAAC,CAAC,IACnE,iBAAiB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEvC;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,CAAC,MAAM,SAAS,YAAY,IAAI,qBAAqB,CAAC,MAAM,CAAC,CAAC;AAE3F;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,CAAC,MAAM,SAAS,YAAY,IAAI,wBAAwB,CAAC,MAAM,CAAC,CAAC;AAEjG;;;;;;;GAOG;AACH,MAAM,MAAM,YAAY,CACtB,MAAM,SAAS,UAAU,CAAC,OAAO,CAAC,GAAG,UAAU,CAAC,OAAO,CAAC,EACxD,IAAI,SAAS,MAAM,GAAG,MAAM,EAC5B,KAAK,GAAG,OAAO,EACf,QAAQ,SAAS,sBAAsB,GAAG,sBAAsB,IAC9D,oBAAoB,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;AAExD;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,OAAO,gBAAmC,CAAC;AAEtE,OAAO,EAAE,sBAAsB,EAAE,CAAC"}
|