@restatedev/restate-sdk 0.9.1 → 1.0.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 +10 -0
- package/dist/src/connection/buffered_connection.d.ts +1 -2
- package/dist/src/connection/buffered_connection.d.ts.map +1 -1
- package/dist/src/connection/buffered_connection.js.map +1 -1
- package/dist/src/connection/connection.d.ts +1 -0
- package/dist/src/connection/connection.d.ts.map +1 -1
- package/dist/src/connection/http_connection.d.ts +6 -2
- package/dist/src/connection/http_connection.d.ts.map +1 -1
- package/dist/src/connection/http_connection.js +8 -3
- package/dist/src/connection/http_connection.js.map +1 -1
- package/dist/src/connection/lambda_connection.d.ts +3 -1
- package/dist/src/connection/lambda_connection.d.ts.map +1 -1
- package/dist/src/connection/lambda_connection.js +6 -1
- package/dist/src/connection/lambda_connection.js.map +1 -1
- package/dist/src/context.d.ts +149 -44
- package/dist/src/context.d.ts.map +1 -1
- package/dist/src/context.js.map +1 -1
- package/dist/src/context_impl.d.ts +16 -13
- package/dist/src/context_impl.d.ts.map +1 -1
- package/dist/src/context_impl.js +123 -34
- package/dist/src/context_impl.js.map +1 -1
- package/dist/src/endpoint/endpoint_impl.d.ts +5 -6
- package/dist/src/endpoint/endpoint_impl.d.ts.map +1 -1
- package/dist/src/endpoint/endpoint_impl.js +44 -18
- package/dist/src/endpoint/endpoint_impl.js.map +1 -1
- package/dist/src/endpoint/http2_handler.d.ts.map +1 -1
- package/dist/src/endpoint/http2_handler.js +42 -9
- package/dist/src/endpoint/http2_handler.js.map +1 -1
- package/dist/src/endpoint/lambda_handler.d.ts.map +1 -1
- package/dist/src/endpoint/lambda_handler.js +36 -14
- package/dist/src/endpoint/lambda_handler.js.map +1 -1
- package/dist/src/endpoint.d.ts +5 -3
- package/dist/src/endpoint.d.ts.map +1 -1
- package/dist/src/endpoint.js.map +1 -1
- package/dist/src/generated/proto/discovery_pb.d.ts +18 -0
- package/dist/src/generated/proto/discovery_pb.d.ts.map +1 -0
- package/dist/src/generated/proto/discovery_pb.js +40 -0
- package/dist/src/generated/proto/discovery_pb.js.map +1 -0
- package/dist/src/generated/proto/protocol_pb.d.ts +186 -0
- package/dist/src/generated/proto/protocol_pb.d.ts.map +1 -1
- package/dist/src/generated/proto/protocol_pb.js +177 -1
- package/dist/src/generated/proto/protocol_pb.js.map +1 -1
- package/dist/src/generated/version.d.ts +1 -1
- package/dist/src/generated/version.js +1 -1
- package/dist/src/io/decoder.d.ts +0 -1
- package/dist/src/io/decoder.d.ts.map +1 -1
- package/dist/src/io/decoder.js +2 -8
- package/dist/src/io/decoder.js.map +1 -1
- package/dist/src/io/encoder.d.ts.map +1 -1
- package/dist/src/io/encoder.js +1 -2
- package/dist/src/io/encoder.js.map +1 -1
- package/dist/src/journal.d.ts.map +1 -1
- package/dist/src/journal.js +17 -0
- package/dist/src/journal.js.map +1 -1
- package/dist/src/logger.d.ts.map +1 -1
- package/dist/src/logger.js +0 -7
- package/dist/src/logger.js.map +1 -1
- package/dist/src/public_api.d.ts +4 -4
- package/dist/src/public_api.d.ts.map +1 -1
- package/dist/src/public_api.js +3 -26
- package/dist/src/public_api.js.map +1 -1
- package/dist/src/state_machine.d.ts +3 -2
- package/dist/src/state_machine.d.ts.map +1 -1
- package/dist/src/state_machine.js +9 -9
- package/dist/src/state_machine.js.map +1 -1
- package/dist/src/types/components.d.ts +31 -19
- package/dist/src/types/components.d.ts.map +1 -1
- package/dist/src/types/components.js +127 -30
- package/dist/src/types/components.js.map +1 -1
- package/dist/src/types/discovery.d.ts +6 -3
- package/dist/src/types/discovery.d.ts.map +1 -1
- package/dist/src/types/discovery.js +2 -0
- package/dist/src/types/discovery.js.map +1 -1
- package/dist/src/types/protocol.d.ts +13 -4
- package/dist/src/types/protocol.d.ts.map +1 -1
- package/dist/src/types/protocol.js +95 -5
- package/dist/src/types/protocol.js.map +1 -1
- package/dist/src/types/rpc.d.ts +276 -26
- package/dist/src/types/rpc.d.ts.map +1 -1
- package/dist/src/types/rpc.js +385 -5
- package/dist/src/types/rpc.js.map +1 -1
- package/dist/src/types/types.d.ts +2 -4
- package/dist/src/types/types.d.ts.map +1 -1
- package/dist/src/types/types.js +3 -14
- package/dist/src/types/types.js.map +1 -1
- package/dist/src/utils/serde.d.ts +2 -0
- package/dist/src/utils/serde.d.ts.map +1 -1
- package/dist/src/utils/serde.js +28 -4
- package/dist/src/utils/serde.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/dist/src/clients/workflow_client.d.ts +0 -77
- package/dist/src/clients/workflow_client.d.ts.map +0 -1
- package/dist/src/clients/workflow_client.js +0 -172
- package/dist/src/clients/workflow_client.js.map +0 -1
- package/dist/src/workflows/workflow.d.ts +0 -101
- package/dist/src/workflows/workflow.d.ts.map +0 -1
- package/dist/src/workflows/workflow.js +0 -84
- package/dist/src/workflows/workflow.js.map +0 -1
- package/dist/src/workflows/workflow_state_service.d.ts +0 -35
- package/dist/src/workflows/workflow_state_service.d.ts.map +0 -1
- package/dist/src/workflows/workflow_state_service.js +0 -201
- package/dist/src/workflows/workflow_state_service.js.map +0 -1
- package/dist/src/workflows/workflow_wrapper_service.d.ts +0 -10
- package/dist/src/workflows/workflow_wrapper_service.d.ts.map +0 -1
- package/dist/src/workflows/workflow_wrapper_service.js +0 -285
- package/dist/src/workflows/workflow_wrapper_service.js.map +0 -1
|
@@ -25,6 +25,8 @@ const components_1 = require("../types/components");
|
|
|
25
25
|
const discovery_1 = require("../types/discovery");
|
|
26
26
|
const validate_1 = require("./request_signing/validate");
|
|
27
27
|
const user_agent_1 = require("../user_agent");
|
|
28
|
+
const protocol_1 = require("../types/protocol");
|
|
29
|
+
const discovery_pb_1 = require("../generated/proto/discovery_pb");
|
|
28
30
|
class Http2Handler {
|
|
29
31
|
endpoint;
|
|
30
32
|
constructor(endpoint) {
|
|
@@ -41,7 +43,7 @@ class Http2Handler {
|
|
|
41
43
|
return;
|
|
42
44
|
}
|
|
43
45
|
else {
|
|
44
|
-
return this.handleConnection(url, stream);
|
|
46
|
+
return this.handleConnection(request, url, stream);
|
|
45
47
|
}
|
|
46
48
|
})
|
|
47
49
|
.catch((e) => {
|
|
@@ -73,14 +75,29 @@ class Http2Handler {
|
|
|
73
75
|
return true;
|
|
74
76
|
}
|
|
75
77
|
}
|
|
76
|
-
handleConnection(url, stream) {
|
|
78
|
+
handleConnection(request, url, stream) {
|
|
77
79
|
const route = (0, components_1.parseUrlComponents)(url.pathname ?? undefined);
|
|
78
80
|
if (!route) {
|
|
79
81
|
return respondNotFound(stream);
|
|
80
82
|
}
|
|
81
83
|
if (route === "discovery") {
|
|
84
|
+
const acceptVersionsString = request.headers["accept"];
|
|
85
|
+
const serviceDiscoveryProtocolVersion = (0, protocol_1.selectSupportedServiceDiscoveryProtocolVersion)(acceptVersionsString);
|
|
86
|
+
if (serviceDiscoveryProtocolVersion ==
|
|
87
|
+
discovery_pb_1.ServiceDiscoveryProtocolVersion.SERVICE_DISCOVERY_PROTOCOL_VERSION_UNSPECIFIED) {
|
|
88
|
+
const errorMessage = `Unsupported service discovery protocol version '${acceptVersionsString}'`;
|
|
89
|
+
logger_1.rlog.warn(errorMessage);
|
|
90
|
+
return respondUnsupportedProtocolVersion(stream, errorMessage);
|
|
91
|
+
}
|
|
82
92
|
const discovery = this.endpoint.computeDiscovery(discovery_1.ProtocolMode.BIDI_STREAM);
|
|
83
|
-
return respondDiscovery(discovery, stream);
|
|
93
|
+
return respondDiscovery(serviceDiscoveryProtocolVersion, discovery, stream);
|
|
94
|
+
}
|
|
95
|
+
const serviceProtocolVersionString = request.headers["content-type"];
|
|
96
|
+
const serviceProtocolVersion = (0, protocol_1.parseServiceProtocolVersion)(serviceProtocolVersionString);
|
|
97
|
+
if (!(0, protocol_1.isServiceProtocolVersionSupported)(serviceProtocolVersion)) {
|
|
98
|
+
const errorMessage = `Unsupported service protocol version '${serviceProtocolVersionString}'`;
|
|
99
|
+
logger_1.rlog.warn(errorMessage);
|
|
100
|
+
return respondUnsupportedProtocolVersion(stream, errorMessage);
|
|
84
101
|
}
|
|
85
102
|
const urlComponents = route;
|
|
86
103
|
const component = this.endpoint.componentByName(urlComponents.componentName);
|
|
@@ -93,20 +110,36 @@ class Http2Handler {
|
|
|
93
110
|
}
|
|
94
111
|
// valid connection, let's dispatch the invocation
|
|
95
112
|
stream.respond({
|
|
96
|
-
"content-type":
|
|
113
|
+
"content-type": (0, protocol_1.serviceProtocolVersionToHeaderValue)(serviceProtocolVersion),
|
|
97
114
|
"x-restate-server": user_agent_1.X_RESTATE_SERVER,
|
|
98
115
|
":status": 200,
|
|
99
116
|
});
|
|
100
|
-
const restateStream = http_connection_1.RestateHttp2Connection.from(stream);
|
|
117
|
+
const restateStream = http_connection_1.RestateHttp2Connection.from(request, stream);
|
|
101
118
|
return handleInvocation(handler, restateStream);
|
|
102
119
|
}
|
|
103
120
|
}
|
|
104
121
|
exports.Http2Handler = Http2Handler;
|
|
105
|
-
function
|
|
106
|
-
|
|
122
|
+
function respondUnsupportedProtocolVersion(stream, errorMessage) {
|
|
123
|
+
stream.respond({
|
|
124
|
+
":status": 415,
|
|
125
|
+
"content-type": "text/plain",
|
|
126
|
+
"x-restate-server": user_agent_1.X_RESTATE_SERVER,
|
|
127
|
+
});
|
|
128
|
+
stream.end(errorMessage);
|
|
129
|
+
return (0, promises_1.finished)(stream);
|
|
130
|
+
}
|
|
131
|
+
function respondDiscovery(serviceDiscoveryProtocolVersion, response, http2Stream) {
|
|
132
|
+
let responseData;
|
|
133
|
+
if (serviceDiscoveryProtocolVersion === discovery_pb_1.ServiceDiscoveryProtocolVersion.V1) {
|
|
134
|
+
responseData = JSON.stringify(response);
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
// should not be reached since we check for compatibility before
|
|
138
|
+
throw new Error(`Unsupported service discovery protocol version: ${serviceDiscoveryProtocolVersion}`);
|
|
139
|
+
}
|
|
107
140
|
http2Stream.respond({
|
|
108
141
|
":status": 200,
|
|
109
|
-
"content-type":
|
|
142
|
+
"content-type": (0, protocol_1.serviceDiscoveryProtocolVersionToHeaderValue)(serviceDiscoveryProtocolVersion),
|
|
110
143
|
"x-restate-server": user_agent_1.X_RESTATE_SERVER,
|
|
111
144
|
});
|
|
112
145
|
return (0, promises_1.pipeline)(node_stream_1.default.Readable.from(responseData), http2Stream, {
|
|
@@ -135,7 +168,7 @@ async function handleInvocation(handler, connection) {
|
|
|
135
168
|
}
|
|
136
169
|
// step 2: create the state machine
|
|
137
170
|
const invocation = journalBuilder.build();
|
|
138
|
-
const stateMachine = new state_machine_1.StateMachine(connection, invocation, discovery_1.ProtocolMode.BIDI_STREAM, handler
|
|
171
|
+
const stateMachine = new state_machine_1.StateMachine(connection, invocation, discovery_1.ProtocolMode.BIDI_STREAM, handler.kind(), invocation.inferLoggerContext());
|
|
139
172
|
connection.pipeToConsumer(stateMachine);
|
|
140
173
|
// step 3: invoke the function
|
|
141
174
|
// This call would propagate errors in the state machine logic, but not errors
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http2_handler.js","sourceRoot":"","sources":["../../../src/endpoint/http2_handler.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;;;;AAEH,8DAAiC;AACjC,mDAA0D;AAG1D,mEAAuE;AACvE,4CAA8C;AAC9C,8CAAkD;AAClD,oDAAgD;AAChD,sCAAiC;AACjC,
|
|
1
|
+
{"version":3,"file":"http2_handler.js","sourceRoot":"","sources":["../../../src/endpoint/http2_handler.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;;;;AAEH,8DAAiC;AACjC,mDAA0D;AAG1D,mEAAuE;AACvE,4CAA8C;AAC9C,8CAAkD;AAClD,oDAAgD;AAChD,sCAAiC;AACjC,oDAI6B;AAC7B,kDAA4D;AAC5D,yDAAsE;AAEtE,8CAAiD;AACjD,gDAM2B;AAC3B,kEAAkF;AAElF,MAAa,YAAY;IACM;IAA7B,YAA6B,QAAsB;QAAtB,aAAQ,GAAR,QAAQ,CA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AAG,IAAI,4BAAY,CACnC,UAAU,EACV,UAAU,EACV,wBAAY,CAAC,WAAW,EACxB,OAAO,CAAC,IAAI,EAAE,EACd,UAAU,CAAC,kBAAkB,EAAE,CAChC,CAAC;IACF,UAAU,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;IAExC,8BAA8B;IAE9B,8EAA8E;IAC9E,4EAA4E;IAC5E,kFAAkF;IAClF,qBAAqB;IACrB,IAAI;QACF,MAAM,YAAY,CAAC,MAAM,EAAE,CAAC;KAC7B;YAAS;QACR,iDAAiD;QACjD,UAAU,CAAC,qBAAqB,EAAE,CAAC;KACpC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lambda_handler.d.ts","sourceRoot":"","sources":["../../../src/endpoint/lambda_handler.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EACV,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EACrB,uBAAuB,EACvB,OAAO,EACR,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"lambda_handler.d.ts","sourceRoot":"","sources":["../../../src/endpoint/lambda_handler.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EACV,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EACrB,uBAAuB,EACvB,OAAO,EACR,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AA2B/C,qBAAa,aAAa;IACZ,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBAAR,QAAQ,EAAE,YAAY;IAInD;;OAEG;IACG,aAAa,CACjB,KAAK,EAAE,oBAAoB,GAAG,sBAAsB,EACpD,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,qBAAqB,GAAG,uBAAuB,CAAC;YAsD7C,2BAA2B;YAkC3B,YAAY;IAoD1B,OAAO,CAAC,eAAe;IA8CvB,OAAO,CAAC,eAAe;CAWxB"}
|
|
@@ -23,6 +23,7 @@ const components_1 = require("../types/components");
|
|
|
23
23
|
const validate_1 = require("./request_signing/validate");
|
|
24
24
|
const user_agent_1 = require("../user_agent");
|
|
25
25
|
const node_buffer_1 = require("node:buffer");
|
|
26
|
+
const discovery_pb_1 = require("../generated/proto/discovery_pb");
|
|
26
27
|
class LambdaHandler {
|
|
27
28
|
endpoint;
|
|
28
29
|
constructor(endpoint) {
|
|
@@ -45,7 +46,14 @@ class LambdaHandler {
|
|
|
45
46
|
return this.toErrorResponse(404, msg);
|
|
46
47
|
}
|
|
47
48
|
if (parsed === "discovery") {
|
|
48
|
-
return this.handleDiscovery();
|
|
49
|
+
return this.handleDiscovery(event.headers["accept"]);
|
|
50
|
+
}
|
|
51
|
+
const serviceProtocolVersionString = event.headers["content-type"];
|
|
52
|
+
const serviceProtocolVersion = (0, protocol_1.parseServiceProtocolVersion)(serviceProtocolVersionString);
|
|
53
|
+
if (!(0, protocol_1.isServiceProtocolVersionSupported)(serviceProtocolVersion)) {
|
|
54
|
+
const errorMessage = `Unsupported service protocol version '${serviceProtocolVersionString}'`;
|
|
55
|
+
logger_1.rlog.warn(errorMessage);
|
|
56
|
+
return this.toErrorResponse(415, errorMessage);
|
|
49
57
|
}
|
|
50
58
|
const parsedUrl = parsed;
|
|
51
59
|
const method = this.endpoint.componentByName(parsedUrl.componentName);
|
|
@@ -63,7 +71,7 @@ class LambdaHandler {
|
|
|
63
71
|
if (!event.body) {
|
|
64
72
|
throw new Error("The incoming message body was null");
|
|
65
73
|
}
|
|
66
|
-
return this.handleInvoke(handler, event.body, context);
|
|
74
|
+
return this.handleInvoke(handler, event.body, event.headers, context, serviceProtocolVersion);
|
|
67
75
|
}
|
|
68
76
|
async validateConnectionSignature(path, headers) {
|
|
69
77
|
if (!this.endpoint.keySet) {
|
|
@@ -82,12 +90,12 @@ class LambdaHandler {
|
|
|
82
90
|
}
|
|
83
91
|
catch (e) {
|
|
84
92
|
const error = (0, errors_1.ensureError)(e);
|
|
85
|
-
logger_1.rlog.error("Error while attempting to validate request signature:" +
|
|
86
|
-
error.message);
|
|
93
|
+
logger_1.rlog.error("Error while attempting to validate request signature: " +
|
|
94
|
+
(error.stack ?? error.message));
|
|
87
95
|
return this.toErrorResponse(401, "Unauthorized");
|
|
88
96
|
}
|
|
89
97
|
}
|
|
90
|
-
async handleInvoke(handler, body, context) {
|
|
98
|
+
async handleInvoke(handler, body, headers, context, serviceProtocolVersion) {
|
|
91
99
|
try {
|
|
92
100
|
// build the previous journal from the events
|
|
93
101
|
let decodedEntries = (0, decoder_1.decodeLambdaBody)(body);
|
|
@@ -96,16 +104,16 @@ class LambdaHandler {
|
|
|
96
104
|
const alreadyCompleted = decodedEntries.find((e) => e.messageType === protocol_1.OUTPUT_ENTRY_MESSAGE_TYPE) !== undefined;
|
|
97
105
|
decodedEntries = null;
|
|
98
106
|
// set up and invoke the state machine
|
|
99
|
-
const connection = new lambda_connection_1.LambdaConnection(alreadyCompleted);
|
|
107
|
+
const connection = new lambda_connection_1.LambdaConnection(headers, alreadyCompleted);
|
|
100
108
|
const invocation = journalBuilder.build();
|
|
101
|
-
const stateMachine = new state_machine_1.StateMachine(connection, invocation, discovery_1.ProtocolMode.REQUEST_RESPONSE, handler
|
|
109
|
+
const stateMachine = new state_machine_1.StateMachine(connection, invocation, discovery_1.ProtocolMode.REQUEST_RESPONSE, handler.kind(), invocation.inferLoggerContext({
|
|
102
110
|
AWSRequestId: context.awsRequestId,
|
|
103
111
|
}));
|
|
104
112
|
await stateMachine.invoke();
|
|
105
113
|
const result = await connection.getResult();
|
|
106
114
|
return {
|
|
107
115
|
headers: {
|
|
108
|
-
"content-type":
|
|
116
|
+
"content-type": (0, protocol_1.serviceProtocolVersionToHeaderValue)(serviceProtocolVersion),
|
|
109
117
|
"x-restate-server": user_agent_1.X_RESTATE_SERVER,
|
|
110
118
|
},
|
|
111
119
|
statusCode: 200,
|
|
@@ -120,13 +128,27 @@ class LambdaHandler {
|
|
|
120
128
|
return this.toErrorResponse(500, error.message);
|
|
121
129
|
}
|
|
122
130
|
}
|
|
123
|
-
handleDiscovery() {
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
|
|
131
|
+
handleDiscovery(acceptVersionsString) {
|
|
132
|
+
const serviceDiscoveryProtocolVersion = (0, protocol_1.selectSupportedServiceDiscoveryProtocolVersion)(acceptVersionsString);
|
|
133
|
+
if (serviceDiscoveryProtocolVersion ===
|
|
134
|
+
discovery_pb_1.ServiceDiscoveryProtocolVersion.SERVICE_DISCOVERY_PROTOCOL_VERSION_UNSPECIFIED) {
|
|
135
|
+
const errorMessage = `Unsupported service discovery protocol version '${acceptVersionsString}'`;
|
|
136
|
+
logger_1.rlog.warn(errorMessage);
|
|
137
|
+
return this.toErrorResponse(415, errorMessage);
|
|
138
|
+
}
|
|
139
|
+
const discovery = this.endpoint.computeDiscovery(discovery_1.ProtocolMode.REQUEST_RESPONSE);
|
|
140
|
+
let body;
|
|
141
|
+
if (serviceDiscoveryProtocolVersion === discovery_pb_1.ServiceDiscoveryProtocolVersion.V1) {
|
|
142
|
+
const discoveryJson = JSON.stringify(discovery);
|
|
143
|
+
body = node_buffer_1.Buffer.from(discoveryJson).toString("base64");
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
// should not be reached since we check for compatibility before
|
|
147
|
+
throw new Error(`Unsupported service discovery protocol version: ${serviceDiscoveryProtocolVersion}`);
|
|
148
|
+
}
|
|
127
149
|
return {
|
|
128
150
|
headers: {
|
|
129
|
-
"content-type":
|
|
151
|
+
"content-type": (0, protocol_1.serviceDiscoveryProtocolVersionToHeaderValue)(serviceDiscoveryProtocolVersion),
|
|
130
152
|
"x-restate-server": user_agent_1.X_RESTATE_SERVER,
|
|
131
153
|
},
|
|
132
154
|
statusCode: 200,
|
|
@@ -137,7 +159,7 @@ class LambdaHandler {
|
|
|
137
159
|
toErrorResponse(code, message) {
|
|
138
160
|
return {
|
|
139
161
|
headers: {
|
|
140
|
-
"content-type": "
|
|
162
|
+
"content-type": "text/plain",
|
|
141
163
|
"x-restate-server": user_agent_1.X_RESTATE_SERVER,
|
|
142
164
|
},
|
|
143
165
|
statusCode: code,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lambda_handler.js","sourceRoot":"","sources":["../../../src/endpoint/lambda_handler.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAEH,sCAAiC;AASjC,uEAAmE;AACnE,8CAAkD;AAClD,2CAAiD;AAEjD,oDAAgD;AAChD,4CAA8C;AAC9C,
|
|
1
|
+
{"version":3,"file":"lambda_handler.js","sourceRoot":"","sources":["../../../src/endpoint/lambda_handler.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAEH,sCAAiC;AASjC,uEAAmE;AACnE,8CAAkD;AAClD,2CAAiD;AAEjD,oDAAgD;AAChD,4CAA8C;AAC9C,gDAO2B;AAC3B,kDAAkD;AAClD,oDAI6B;AAC7B,yDAAsE;AACtE,8CAAiD;AACjD,6CAAqC;AACrC,kEAAkF;AAGlF,MAAa,aAAa;IACK;IAA7B,YAA6B,QAAsB;QAAtB,aAAQ,GAAR,QAAQ,CAAc;IAAG,CAAC;IAEvD,6EAA6E;IAE7E;;OAEG;IACH,KAAK,CAAC,aAAa,CACjB,KAAoD,EACpD,OAAgB;QAEhB,MAAM,IAAI,GAAG,MAAM,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC;QAE1D,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,2BAA2B,CAAC,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;QAC1E,IAAI,KAAK,KAAK,IAAI,EAAE;YAClB,OAAO,KAAK,CAAC;SACd;QAED,MAAM,MAAM,GAAG,IAAA,+BAAkB,EAAC,IAAI,CAAC,CAAC;QACxC,IAAI,CAAC,MAAM,EAAE;YACX,MAAM,GAAG,GAAG,4FAA4F,IAAI,E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,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;SAC/D,CAAC;IACJ,CAAC;CACF;AAhND,sCAgNC;AAED,SAAS,cAAc,CAAC,IAAgB;IACtC,MAAM,MAAM,GAAG,IAAI,YAAY,oBAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,oBAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjE,OAAO,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AACnC,CAAC"}
|
package/dist/src/endpoint.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { VirtualObjectDefinition, ServiceDefinition } from "./types/rpc";
|
|
3
2
|
import { Http2ServerRequest, Http2ServerResponse } from "http2";
|
|
3
|
+
import type { VirtualObjectDefinition, ServiceDefinition, WorkflowDefinition } from "@restatedev/restate-sdk-core";
|
|
4
4
|
/**
|
|
5
5
|
* Create a new {@link RestateEndpoint}.
|
|
6
6
|
*/
|
|
@@ -44,9 +44,11 @@ export interface ServiceBundle {
|
|
|
44
44
|
*/
|
|
45
45
|
export interface RestateEndpoint {
|
|
46
46
|
/**
|
|
47
|
-
* Binds a new durable
|
|
47
|
+
* Binds a new durable service / virtual object / workflow.
|
|
48
|
+
*
|
|
49
|
+
* see restate.service, restate.object, and restate.workflow for more details.
|
|
48
50
|
**/
|
|
49
|
-
bind<P extends string, M>(service: ServiceDefinition<P, M> | VirtualObjectDefinition<P, M>): RestateEndpoint;
|
|
51
|
+
bind<P extends string, M>(service: ServiceDefinition<P, M> | VirtualObjectDefinition<P, M> | WorkflowDefinition<P, M>): RestateEndpoint;
|
|
50
52
|
/**
|
|
51
53
|
* Adds one or more services to this endpoint. This will call the
|
|
52
54
|
* {@link ServiceBundle.registerServices} function to register all services at this endpoint.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"endpoint.d.ts","sourceRoot":"","sources":["../../src/endpoint.ts"],"names":[],"mappings":";AAWA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"endpoint.d.ts","sourceRoot":"","sources":["../../src/endpoint.ts"],"names":[],"mappings":";AAWA,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAEhE,OAAO,KAAK,EACV,uBAAuB,EACvB,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,8BAA8B,CAAC;AAEtC;;GAEG;AACH,wBAAgB,QAAQ,IAAI,eAAe,CAE1C;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,gBAAgB,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI,CAAC;CACnD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;QAII;IACJ,IAAI,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,EACtB,OAAO,EACH,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC,GACvB,uBAAuB,CAAC,CAAC,EAAE,CAAC,CAAC,GAC7B,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,GAC3B,eAAe,CAAC;IAEnB;;;OAGG;IACH,UAAU,CAAC,QAAQ,EAAE,aAAa,GAAG,eAAe,CAAC;IAErD;;;;;;;;OAQG;IACH,cAAc,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,eAAe,CAAC;IAEnD;;;;;;;OAOG;IAEH,aAAa,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IAExD;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEvC;;OAEG;IACH,YAAY,IAAI,CACd,OAAO,EAAE,kBAAkB,EAC3B,QAAQ,EAAE,mBAAmB,KAC1B,IAAI,CAAC;CACX"}
|
package/dist/src/endpoint.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"endpoint.js","sourceRoot":"","sources":["../../src/endpoint.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;
|
|
1
|
+
{"version":3,"file":"endpoint.js","sourceRoot":"","sources":["../../src/endpoint.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAGH,4DAAwD;AAOxD;;GAEG;AACH,SAAgB,QAAQ;IACtB,OAAO,IAAA,4BAAY,GAAE,CAAC;AACxB,CAAC;AAFD,4BAEC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Service discovery protocol version.
|
|
3
|
+
*
|
|
4
|
+
* @generated from enum dev.restate.service.discovery.ServiceDiscoveryProtocolVersion
|
|
5
|
+
*/
|
|
6
|
+
export declare enum ServiceDiscoveryProtocolVersion {
|
|
7
|
+
/**
|
|
8
|
+
* @generated from enum value: SERVICE_DISCOVERY_PROTOCOL_VERSION_UNSPECIFIED = 0;
|
|
9
|
+
*/
|
|
10
|
+
SERVICE_DISCOVERY_PROTOCOL_VERSION_UNSPECIFIED = 0,
|
|
11
|
+
/**
|
|
12
|
+
* initial service discovery protocol version using endpoint_manifest_schema.json
|
|
13
|
+
*
|
|
14
|
+
* @generated from enum value: V1 = 1;
|
|
15
|
+
*/
|
|
16
|
+
V1 = 1
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=discovery_pb.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery_pb.d.ts","sourceRoot":"","sources":["../../../../src/generated/proto/discovery_pb.ts"],"names":[],"mappings":"AAgBA;;;;GAIG;AACH,oBAAY,+BAA+B;IACzC;;OAEG;IACH,8CAA8C,IAAI;IAElD;;;;OAIG;IACH,EAAE,IAAI;CACP"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) 2024 - Restate Software, Inc., Restate GmbH
|
|
3
|
+
//
|
|
4
|
+
// This file is part of the Restate service protocol, which is
|
|
5
|
+
// released under the MIT license.
|
|
6
|
+
//
|
|
7
|
+
// You can find a copy of the license in file LICENSE in the root
|
|
8
|
+
// directory of this repository or package, or at
|
|
9
|
+
// https://github.com/restatedev/service-protocol/blob/main/LICENSE
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.ServiceDiscoveryProtocolVersion = void 0;
|
|
12
|
+
// @generated by protoc-gen-es v1.9.0 with parameter "target=ts,import_extension=none"
|
|
13
|
+
// @generated from file proto/discovery.proto (package dev.restate.service.discovery, syntax proto3)
|
|
14
|
+
/* eslint-disable */
|
|
15
|
+
// @ts-nocheck
|
|
16
|
+
const protobuf_1 = require("@bufbuild/protobuf");
|
|
17
|
+
/**
|
|
18
|
+
* Service discovery protocol version.
|
|
19
|
+
*
|
|
20
|
+
* @generated from enum dev.restate.service.discovery.ServiceDiscoveryProtocolVersion
|
|
21
|
+
*/
|
|
22
|
+
var ServiceDiscoveryProtocolVersion;
|
|
23
|
+
(function (ServiceDiscoveryProtocolVersion) {
|
|
24
|
+
/**
|
|
25
|
+
* @generated from enum value: SERVICE_DISCOVERY_PROTOCOL_VERSION_UNSPECIFIED = 0;
|
|
26
|
+
*/
|
|
27
|
+
ServiceDiscoveryProtocolVersion[ServiceDiscoveryProtocolVersion["SERVICE_DISCOVERY_PROTOCOL_VERSION_UNSPECIFIED"] = 0] = "SERVICE_DISCOVERY_PROTOCOL_VERSION_UNSPECIFIED";
|
|
28
|
+
/**
|
|
29
|
+
* initial service discovery protocol version using endpoint_manifest_schema.json
|
|
30
|
+
*
|
|
31
|
+
* @generated from enum value: V1 = 1;
|
|
32
|
+
*/
|
|
33
|
+
ServiceDiscoveryProtocolVersion[ServiceDiscoveryProtocolVersion["V1"] = 1] = "V1";
|
|
34
|
+
})(ServiceDiscoveryProtocolVersion = exports.ServiceDiscoveryProtocolVersion || (exports.ServiceDiscoveryProtocolVersion = {}));
|
|
35
|
+
// Retrieve enum metadata with: proto3.getEnumType(ServiceDiscoveryProtocolVersion)
|
|
36
|
+
protobuf_1.proto3.util.setEnumType(ServiceDiscoveryProtocolVersion, "dev.restate.service.discovery.ServiceDiscoveryProtocolVersion", [
|
|
37
|
+
{ no: 0, name: "SERVICE_DISCOVERY_PROTOCOL_VERSION_UNSPECIFIED" },
|
|
38
|
+
{ no: 1, name: "V1" },
|
|
39
|
+
]);
|
|
40
|
+
//# sourceMappingURL=discovery_pb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery_pb.js","sourceRoot":"","sources":["../../../../src/generated/proto/discovery_pb.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,EAAE;AACF,8DAA8D;AAC9D,kCAAkC;AAClC,EAAE;AACF,iEAAiE;AACjE,iDAAiD;AACjD,mEAAmE;;;AAEnE,sFAAsF;AACtF,oGAAoG;AACpG,oBAAoB;AACpB,cAAc;AAEd,iDAA4C;AAE5C;;;;GAIG;AACH,IAAY,+BAYX;AAZD,WAAY,+BAA+B;IACzC;;OAEG;IACH,yKAAkD,CAAA;IAElD;;;;OAIG;IACH,iFAAM,CAAA;AACR,CAAC,EAZW,+BAA+B,GAA/B,uCAA+B,KAA/B,uCAA+B,QAY1C;AACD,mFAAmF;AACnF,iBAAM,CAAC,IAAI,CAAC,WAAW,CAAC,+BAA+B,EAAE,+DAA+D,EAAE;IACxH,EAAE,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,gDAAgD,EAAE;IACjE,EAAE,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE;CACtB,CAAC,CAAC"}
|
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf";
|
|
2
2
|
import { Message, proto3 } from "@bufbuild/protobuf";
|
|
3
|
+
/**
|
|
4
|
+
* Service protocol version.
|
|
5
|
+
*
|
|
6
|
+
* @generated from enum dev.restate.service.protocol.ServiceProtocolVersion
|
|
7
|
+
*/
|
|
8
|
+
export declare enum ServiceProtocolVersion {
|
|
9
|
+
/**
|
|
10
|
+
* @generated from enum value: SERVICE_PROTOCOL_VERSION_UNSPECIFIED = 0;
|
|
11
|
+
*/
|
|
12
|
+
SERVICE_PROTOCOL_VERSION_UNSPECIFIED = 0,
|
|
13
|
+
/**
|
|
14
|
+
* initial service protocol version
|
|
15
|
+
*
|
|
16
|
+
* @generated from enum value: V1 = 1;
|
|
17
|
+
*/
|
|
18
|
+
V1 = 1
|
|
19
|
+
}
|
|
3
20
|
/**
|
|
4
21
|
* Type: 0x0000 + 0
|
|
5
22
|
*
|
|
@@ -499,6 +516,175 @@ export declare class GetStateKeysEntryMessage_StateKeys extends Message<GetState
|
|
|
499
516
|
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): GetStateKeysEntryMessage_StateKeys;
|
|
500
517
|
static equals(a: GetStateKeysEntryMessage_StateKeys | PlainMessage<GetStateKeysEntryMessage_StateKeys> | undefined, b: GetStateKeysEntryMessage_StateKeys | PlainMessage<GetStateKeysEntryMessage_StateKeys> | undefined): boolean;
|
|
501
518
|
}
|
|
519
|
+
/**
|
|
520
|
+
* Completable: Yes
|
|
521
|
+
* Fallible: No
|
|
522
|
+
* Type: 0x0800 + 8
|
|
523
|
+
*
|
|
524
|
+
* @generated from message dev.restate.service.protocol.GetPromiseEntryMessage
|
|
525
|
+
*/
|
|
526
|
+
export declare class GetPromiseEntryMessage extends Message<GetPromiseEntryMessage> {
|
|
527
|
+
/**
|
|
528
|
+
* @generated from field: string key = 1;
|
|
529
|
+
*/
|
|
530
|
+
key: string;
|
|
531
|
+
/**
|
|
532
|
+
* @generated from oneof dev.restate.service.protocol.GetPromiseEntryMessage.result
|
|
533
|
+
*/
|
|
534
|
+
result: {
|
|
535
|
+
/**
|
|
536
|
+
* @generated from field: bytes value = 14;
|
|
537
|
+
*/
|
|
538
|
+
value: Uint8Array;
|
|
539
|
+
case: "value";
|
|
540
|
+
} | {
|
|
541
|
+
/**
|
|
542
|
+
* @generated from field: dev.restate.service.protocol.Failure failure = 15;
|
|
543
|
+
*/
|
|
544
|
+
value: Failure;
|
|
545
|
+
case: "failure";
|
|
546
|
+
} | {
|
|
547
|
+
case: undefined;
|
|
548
|
+
value?: undefined;
|
|
549
|
+
};
|
|
550
|
+
/**
|
|
551
|
+
* Entry name
|
|
552
|
+
*
|
|
553
|
+
* @generated from field: string name = 12;
|
|
554
|
+
*/
|
|
555
|
+
name: string;
|
|
556
|
+
constructor(data?: PartialMessage<GetPromiseEntryMessage>);
|
|
557
|
+
static readonly runtime: typeof proto3;
|
|
558
|
+
static readonly typeName = "dev.restate.service.protocol.GetPromiseEntryMessage";
|
|
559
|
+
static readonly fields: FieldList;
|
|
560
|
+
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): GetPromiseEntryMessage;
|
|
561
|
+
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): GetPromiseEntryMessage;
|
|
562
|
+
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): GetPromiseEntryMessage;
|
|
563
|
+
static equals(a: GetPromiseEntryMessage | PlainMessage<GetPromiseEntryMessage> | undefined, b: GetPromiseEntryMessage | PlainMessage<GetPromiseEntryMessage> | undefined): boolean;
|
|
564
|
+
}
|
|
565
|
+
/**
|
|
566
|
+
* Completable: Yes
|
|
567
|
+
* Fallible: No
|
|
568
|
+
* Type: 0x0800 + 9
|
|
569
|
+
*
|
|
570
|
+
* @generated from message dev.restate.service.protocol.PeekPromiseEntryMessage
|
|
571
|
+
*/
|
|
572
|
+
export declare class PeekPromiseEntryMessage extends Message<PeekPromiseEntryMessage> {
|
|
573
|
+
/**
|
|
574
|
+
* @generated from field: string key = 1;
|
|
575
|
+
*/
|
|
576
|
+
key: string;
|
|
577
|
+
/**
|
|
578
|
+
* @generated from oneof dev.restate.service.protocol.PeekPromiseEntryMessage.result
|
|
579
|
+
*/
|
|
580
|
+
result: {
|
|
581
|
+
/**
|
|
582
|
+
* @generated from field: dev.restate.service.protocol.Empty empty = 13;
|
|
583
|
+
*/
|
|
584
|
+
value: Empty;
|
|
585
|
+
case: "empty";
|
|
586
|
+
} | {
|
|
587
|
+
/**
|
|
588
|
+
* @generated from field: bytes value = 14;
|
|
589
|
+
*/
|
|
590
|
+
value: Uint8Array;
|
|
591
|
+
case: "value";
|
|
592
|
+
} | {
|
|
593
|
+
/**
|
|
594
|
+
* @generated from field: dev.restate.service.protocol.Failure failure = 15;
|
|
595
|
+
*/
|
|
596
|
+
value: Failure;
|
|
597
|
+
case: "failure";
|
|
598
|
+
} | {
|
|
599
|
+
case: undefined;
|
|
600
|
+
value?: undefined;
|
|
601
|
+
};
|
|
602
|
+
/**
|
|
603
|
+
* Entry name
|
|
604
|
+
*
|
|
605
|
+
* @generated from field: string name = 12;
|
|
606
|
+
*/
|
|
607
|
+
name: string;
|
|
608
|
+
constructor(data?: PartialMessage<PeekPromiseEntryMessage>);
|
|
609
|
+
static readonly runtime: typeof proto3;
|
|
610
|
+
static readonly typeName = "dev.restate.service.protocol.PeekPromiseEntryMessage";
|
|
611
|
+
static readonly fields: FieldList;
|
|
612
|
+
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): PeekPromiseEntryMessage;
|
|
613
|
+
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): PeekPromiseEntryMessage;
|
|
614
|
+
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): PeekPromiseEntryMessage;
|
|
615
|
+
static equals(a: PeekPromiseEntryMessage | PlainMessage<PeekPromiseEntryMessage> | undefined, b: PeekPromiseEntryMessage | PlainMessage<PeekPromiseEntryMessage> | undefined): boolean;
|
|
616
|
+
}
|
|
617
|
+
/**
|
|
618
|
+
* Completable: Yes
|
|
619
|
+
* Fallible: No
|
|
620
|
+
* Type: 0x0800 + A
|
|
621
|
+
*
|
|
622
|
+
* @generated from message dev.restate.service.protocol.CompletePromiseEntryMessage
|
|
623
|
+
*/
|
|
624
|
+
export declare class CompletePromiseEntryMessage extends Message<CompletePromiseEntryMessage> {
|
|
625
|
+
/**
|
|
626
|
+
* @generated from field: string key = 1;
|
|
627
|
+
*/
|
|
628
|
+
key: string;
|
|
629
|
+
/**
|
|
630
|
+
* The value to use to complete the promise
|
|
631
|
+
*
|
|
632
|
+
* @generated from oneof dev.restate.service.protocol.CompletePromiseEntryMessage.completion
|
|
633
|
+
*/
|
|
634
|
+
completion: {
|
|
635
|
+
/**
|
|
636
|
+
* @generated from field: bytes completion_value = 2;
|
|
637
|
+
*/
|
|
638
|
+
value: Uint8Array;
|
|
639
|
+
case: "completionValue";
|
|
640
|
+
} | {
|
|
641
|
+
/**
|
|
642
|
+
* @generated from field: dev.restate.service.protocol.Failure completion_failure = 3;
|
|
643
|
+
*/
|
|
644
|
+
value: Failure;
|
|
645
|
+
case: "completionFailure";
|
|
646
|
+
} | {
|
|
647
|
+
case: undefined;
|
|
648
|
+
value?: undefined;
|
|
649
|
+
};
|
|
650
|
+
/**
|
|
651
|
+
* @generated from oneof dev.restate.service.protocol.CompletePromiseEntryMessage.result
|
|
652
|
+
*/
|
|
653
|
+
result: {
|
|
654
|
+
/**
|
|
655
|
+
* Returns empty if value was set successfully
|
|
656
|
+
*
|
|
657
|
+
* @generated from field: dev.restate.service.protocol.Empty empty = 13;
|
|
658
|
+
*/
|
|
659
|
+
value: Empty;
|
|
660
|
+
case: "empty";
|
|
661
|
+
} | {
|
|
662
|
+
/**
|
|
663
|
+
* Returns a failure if the promise was already completed
|
|
664
|
+
*
|
|
665
|
+
* @generated from field: dev.restate.service.protocol.Failure failure = 15;
|
|
666
|
+
*/
|
|
667
|
+
value: Failure;
|
|
668
|
+
case: "failure";
|
|
669
|
+
} | {
|
|
670
|
+
case: undefined;
|
|
671
|
+
value?: undefined;
|
|
672
|
+
};
|
|
673
|
+
/**
|
|
674
|
+
* Entry name
|
|
675
|
+
*
|
|
676
|
+
* @generated from field: string name = 12;
|
|
677
|
+
*/
|
|
678
|
+
name: string;
|
|
679
|
+
constructor(data?: PartialMessage<CompletePromiseEntryMessage>);
|
|
680
|
+
static readonly runtime: typeof proto3;
|
|
681
|
+
static readonly typeName = "dev.restate.service.protocol.CompletePromiseEntryMessage";
|
|
682
|
+
static readonly fields: FieldList;
|
|
683
|
+
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): CompletePromiseEntryMessage;
|
|
684
|
+
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): CompletePromiseEntryMessage;
|
|
685
|
+
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): CompletePromiseEntryMessage;
|
|
686
|
+
static equals(a: CompletePromiseEntryMessage | PlainMessage<CompletePromiseEntryMessage> | undefined, b: CompletePromiseEntryMessage | PlainMessage<CompletePromiseEntryMessage> | undefined): boolean;
|
|
687
|
+
}
|
|
502
688
|
/**
|
|
503
689
|
* Completable: Yes
|
|
504
690
|
* Fallible: No
|