@hatchet-dev/typescript-sdk 1.34.0-alpha.1 → 1.34.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 +1 -0
- package/clients/admin/rpc.d.ts +1 -1
- package/clients/admin/rpc.js +3 -3
- package/clients/admin/trigger-request.d.ts +18 -0
- package/clients/admin/trigger-request.js +66 -0
- package/clients/event/event-client.d.ts +4 -17
- package/clients/event/event-client.js +5 -43
- package/clients/event/rpc.d.ts +22 -3
- package/clients/event/rpc.js +66 -3
- package/clients/transport/fetch-transport.d.ts +73 -0
- package/clients/transport/fetch-transport.js +152 -0
- package/clients/transport/grpc-target.js +48 -3
- package/clients/transport/index.d.ts +2 -1
- package/clients/transport/index.js +6 -1
- package/clients/transport/node-transport.js +1 -2
- package/clients/transport/transport.d.ts +6 -0
- package/clients/transport/transport.js +7 -0
- package/clients/transport/ts-proto-client.js +16 -2
- package/core/client.d.ts +102 -0
- package/core/client.js +250 -0
- package/core/features/events.d.ts +25 -0
- package/core/features/events.js +57 -0
- package/core/features/logs.d.ts +26 -0
- package/core/features/logs.js +51 -0
- package/core/features/rate-limits.d.ts +19 -0
- package/core/features/rate-limits.js +30 -0
- package/core/features/runs.d.ts +33 -0
- package/core/features/runs.js +84 -0
- package/core/features/streams.d.ts +11 -0
- package/core/features/streams.js +23 -0
- package/core/features/workflows.d.ts +22 -0
- package/core/features/workflows.js +46 -0
- package/core/index.d.ts +42 -4
- package/core/index.js +79 -5
- package/core/logger.d.ts +19 -0
- package/core/logger.js +45 -0
- package/core/run-detail.d.ts +14 -0
- package/core/run-detail.js +79 -0
- package/core/run-ref.d.ts +63 -0
- package/core/run-ref.js +217 -0
- package/core/types.d.ts +182 -0
- package/core/types.js +2 -0
- package/dist/check-edge-entry.mjs +72 -14
- package/dist/check-edge-entry.test.ts +57 -0
- package/package.json +5 -2
- package/protoc/v1/streams.d.ts +79 -0
- package/protoc/v1/streams.js +511 -0
- package/protoc-es/v1/streams_pb.d.ts +133 -0
- package/protoc-es/v1/streams_pb.js +41 -0
- package/scripts/check-edge-entry.mjs +72 -14
- package/scripts/check-edge-entry.test.ts +57 -0
- package/util/batch.js +2 -1
- package/util/config-loader/token.d.ts +5 -0
- package/util/config-loader/token.js +8 -0
- package/util/errors/bulk-trigger-partial-error.d.ts +17 -0
- package/util/errors/bulk-trigger-partial-error.js +55 -0
- package/v1/client/admin.d.ts +4 -54
- package/v1/client/admin.js +9 -72
- package/v1/client/client.d.ts +14 -1
- package/v1/client/client.js +18 -0
- package/v1/client/features/index.d.ts +1 -0
- package/v1/client/features/index.js +1 -0
- package/v1/client/features/runs.d.ts +9 -27
- package/v1/client/features/runs.js +10 -55
- package/v1/client/features/streams.d.ts +47 -0
- package/v1/client/features/streams.js +210 -0
- package/v1/examples/durable-streams/publish-latency.d.ts +15 -0
- package/v1/examples/durable-streams/publish-latency.js +50 -0
- package/v1/examples/durable_callback_ordering/workflow.js +5 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { BinaryReader, BinaryWriter } from '@bufbuild/protobuf/wire';
|
|
2
|
+
import type { CallContext, CallOptions } from 'nice-grpc-common';
|
|
3
|
+
export declare const protobufPackage = "v1";
|
|
4
|
+
export interface PublishStreamMessageRequest {
|
|
5
|
+
namespace: string;
|
|
6
|
+
topic: string;
|
|
7
|
+
payload: Uint8Array;
|
|
8
|
+
producerId: string;
|
|
9
|
+
producerSeq: number;
|
|
10
|
+
}
|
|
11
|
+
export interface PublishStreamMessageResponse {
|
|
12
|
+
}
|
|
13
|
+
export interface SubscribeStreamRequest {
|
|
14
|
+
namespace: string;
|
|
15
|
+
topic: string;
|
|
16
|
+
cursor?: string | undefined;
|
|
17
|
+
}
|
|
18
|
+
export interface StreamMessage {
|
|
19
|
+
entries: StreamEntry[];
|
|
20
|
+
hangup: boolean;
|
|
21
|
+
cursor: string;
|
|
22
|
+
}
|
|
23
|
+
export interface StreamEntry {
|
|
24
|
+
payload: Uint8Array;
|
|
25
|
+
cursor: string;
|
|
26
|
+
createdAt: Date | undefined;
|
|
27
|
+
}
|
|
28
|
+
export declare const PublishStreamMessageRequest: MessageFns<PublishStreamMessageRequest>;
|
|
29
|
+
export declare const PublishStreamMessageResponse: MessageFns<PublishStreamMessageResponse>;
|
|
30
|
+
export declare const SubscribeStreamRequest: MessageFns<SubscribeStreamRequest>;
|
|
31
|
+
export declare const StreamMessage: MessageFns<StreamMessage>;
|
|
32
|
+
export declare const StreamEntry: MessageFns<StreamEntry>;
|
|
33
|
+
export type V1StreamsDefinition = typeof V1StreamsDefinition;
|
|
34
|
+
export declare const V1StreamsDefinition: {
|
|
35
|
+
readonly name: "V1Streams";
|
|
36
|
+
readonly fullName: "v1.V1Streams";
|
|
37
|
+
readonly methods: {
|
|
38
|
+
readonly publish: {
|
|
39
|
+
readonly name: "Publish";
|
|
40
|
+
readonly requestType: typeof PublishStreamMessageRequest;
|
|
41
|
+
readonly requestStream: false;
|
|
42
|
+
readonly responseType: typeof PublishStreamMessageResponse;
|
|
43
|
+
readonly responseStream: false;
|
|
44
|
+
readonly options: {};
|
|
45
|
+
};
|
|
46
|
+
readonly subscribe: {
|
|
47
|
+
readonly name: "Subscribe";
|
|
48
|
+
readonly requestType: typeof SubscribeStreamRequest;
|
|
49
|
+
readonly requestStream: false;
|
|
50
|
+
readonly responseType: typeof StreamMessage;
|
|
51
|
+
readonly responseStream: true;
|
|
52
|
+
readonly options: {};
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
export interface V1StreamsServiceImplementation<CallContextExt = {}> {
|
|
57
|
+
publish(request: PublishStreamMessageRequest, context: CallContext & CallContextExt): Promise<DeepPartial<PublishStreamMessageResponse>>;
|
|
58
|
+
subscribe(request: SubscribeStreamRequest, context: CallContext & CallContextExt): ServerStreamingMethodResult<DeepPartial<StreamMessage>>;
|
|
59
|
+
}
|
|
60
|
+
export interface V1StreamsClient<CallOptionsExt = {}> {
|
|
61
|
+
publish(request: DeepPartial<PublishStreamMessageRequest>, options?: CallOptions & CallOptionsExt): Promise<PublishStreamMessageResponse>;
|
|
62
|
+
subscribe(request: DeepPartial<SubscribeStreamRequest>, options?: CallOptions & CallOptionsExt): AsyncIterable<StreamMessage>;
|
|
63
|
+
}
|
|
64
|
+
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
|
65
|
+
export type DeepPartial<T> = T extends Builtin ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
|
|
66
|
+
[K in keyof T]?: DeepPartial<T[K]>;
|
|
67
|
+
} : Partial<T>;
|
|
68
|
+
export type ServerStreamingMethodResult<Response> = {
|
|
69
|
+
[Symbol.asyncIterator](): AsyncIterator<Response, void>;
|
|
70
|
+
};
|
|
71
|
+
export interface MessageFns<T> {
|
|
72
|
+
encode(message: T, writer?: BinaryWriter): BinaryWriter;
|
|
73
|
+
decode(input: BinaryReader | Uint8Array, length?: number): T;
|
|
74
|
+
fromJSON(object: any): T;
|
|
75
|
+
toJSON(message: T): unknown;
|
|
76
|
+
create(base?: DeepPartial<T>): T;
|
|
77
|
+
fromPartial(object: DeepPartial<T>): T;
|
|
78
|
+
}
|
|
79
|
+
export {};
|
|
@@ -0,0 +1,511 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
|
+
// versions:
|
|
4
|
+
// protoc-gen-ts_proto v2.12.0
|
|
5
|
+
// protoc v3.19.1
|
|
6
|
+
// source: v1/streams.proto
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.V1StreamsDefinition = exports.StreamEntry = exports.StreamMessage = exports.SubscribeStreamRequest = exports.PublishStreamMessageResponse = exports.PublishStreamMessageRequest = exports.protobufPackage = void 0;
|
|
9
|
+
/* eslint-disable */
|
|
10
|
+
const wire_1 = require("@bufbuild/protobuf/wire");
|
|
11
|
+
const timestamp_1 = require("../google/protobuf/timestamp");
|
|
12
|
+
exports.protobufPackage = 'v1';
|
|
13
|
+
function createBasePublishStreamMessageRequest() {
|
|
14
|
+
return { namespace: '', topic: '', payload: new Uint8Array(0), producerId: '', producerSeq: 0 };
|
|
15
|
+
}
|
|
16
|
+
exports.PublishStreamMessageRequest = {
|
|
17
|
+
encode(message, writer = new wire_1.BinaryWriter()) {
|
|
18
|
+
if (message.namespace !== '') {
|
|
19
|
+
writer.uint32(10).string(message.namespace);
|
|
20
|
+
}
|
|
21
|
+
if (message.topic !== '') {
|
|
22
|
+
writer.uint32(18).string(message.topic);
|
|
23
|
+
}
|
|
24
|
+
if (message.payload.length !== 0) {
|
|
25
|
+
writer.uint32(26).bytes(message.payload);
|
|
26
|
+
}
|
|
27
|
+
if (message.producerId !== '') {
|
|
28
|
+
writer.uint32(34).string(message.producerId);
|
|
29
|
+
}
|
|
30
|
+
if (message.producerSeq !== 0) {
|
|
31
|
+
writer.uint32(40).int64(message.producerSeq);
|
|
32
|
+
}
|
|
33
|
+
return writer;
|
|
34
|
+
},
|
|
35
|
+
decode(input, length) {
|
|
36
|
+
const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
|
|
37
|
+
const end = length === undefined ? reader.len : reader.pos + length;
|
|
38
|
+
const message = createBasePublishStreamMessageRequest();
|
|
39
|
+
while (reader.pos < end) {
|
|
40
|
+
const tag = reader.uint32();
|
|
41
|
+
switch (tag >>> 3) {
|
|
42
|
+
case 1: {
|
|
43
|
+
if (tag !== 10) {
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
message.namespace = reader.string();
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
case 2: {
|
|
50
|
+
if (tag !== 18) {
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
message.topic = reader.string();
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
case 3: {
|
|
57
|
+
if (tag !== 26) {
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
message.payload = reader.bytes();
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
case 4: {
|
|
64
|
+
if (tag !== 34) {
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
message.producerId = reader.string();
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
case 5: {
|
|
71
|
+
if (tag !== 40) {
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
message.producerSeq = longToNumber(reader.int64());
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
reader.skip(tag & 7);
|
|
82
|
+
}
|
|
83
|
+
return message;
|
|
84
|
+
},
|
|
85
|
+
fromJSON(object) {
|
|
86
|
+
return {
|
|
87
|
+
namespace: isSet(object.namespace) ? globalThis.String(object.namespace) : '',
|
|
88
|
+
topic: isSet(object.topic) ? globalThis.String(object.topic) : '',
|
|
89
|
+
payload: isSet(object.payload) ? bytesFromBase64(object.payload) : new Uint8Array(0),
|
|
90
|
+
producerId: isSet(object.producerId)
|
|
91
|
+
? globalThis.String(object.producerId)
|
|
92
|
+
: isSet(object.producer_id)
|
|
93
|
+
? globalThis.String(object.producer_id)
|
|
94
|
+
: '',
|
|
95
|
+
producerSeq: isSet(object.producerSeq)
|
|
96
|
+
? globalThis.Number(object.producerSeq)
|
|
97
|
+
: isSet(object.producer_seq)
|
|
98
|
+
? globalThis.Number(object.producer_seq)
|
|
99
|
+
: 0,
|
|
100
|
+
};
|
|
101
|
+
},
|
|
102
|
+
toJSON(message) {
|
|
103
|
+
const obj = {};
|
|
104
|
+
if (message.namespace !== '') {
|
|
105
|
+
obj.namespace = message.namespace;
|
|
106
|
+
}
|
|
107
|
+
if (message.topic !== '') {
|
|
108
|
+
obj.topic = message.topic;
|
|
109
|
+
}
|
|
110
|
+
if (message.payload.length !== 0) {
|
|
111
|
+
obj.payload = base64FromBytes(message.payload);
|
|
112
|
+
}
|
|
113
|
+
if (message.producerId !== '') {
|
|
114
|
+
obj.producerId = message.producerId;
|
|
115
|
+
}
|
|
116
|
+
if (message.producerSeq !== 0) {
|
|
117
|
+
obj.producerSeq = Math.round(message.producerSeq);
|
|
118
|
+
}
|
|
119
|
+
return obj;
|
|
120
|
+
},
|
|
121
|
+
create(base) {
|
|
122
|
+
return exports.PublishStreamMessageRequest.fromPartial(base !== null && base !== void 0 ? base : {});
|
|
123
|
+
},
|
|
124
|
+
fromPartial(object) {
|
|
125
|
+
var _a, _b, _c, _d, _e;
|
|
126
|
+
const message = createBasePublishStreamMessageRequest();
|
|
127
|
+
message.namespace = (_a = object.namespace) !== null && _a !== void 0 ? _a : '';
|
|
128
|
+
message.topic = (_b = object.topic) !== null && _b !== void 0 ? _b : '';
|
|
129
|
+
message.payload = (_c = object.payload) !== null && _c !== void 0 ? _c : new Uint8Array(0);
|
|
130
|
+
message.producerId = (_d = object.producerId) !== null && _d !== void 0 ? _d : '';
|
|
131
|
+
message.producerSeq = (_e = object.producerSeq) !== null && _e !== void 0 ? _e : 0;
|
|
132
|
+
return message;
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
function createBasePublishStreamMessageResponse() {
|
|
136
|
+
return {};
|
|
137
|
+
}
|
|
138
|
+
exports.PublishStreamMessageResponse = {
|
|
139
|
+
encode(_, writer = new wire_1.BinaryWriter()) {
|
|
140
|
+
return writer;
|
|
141
|
+
},
|
|
142
|
+
decode(input, length) {
|
|
143
|
+
const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
|
|
144
|
+
const end = length === undefined ? reader.len : reader.pos + length;
|
|
145
|
+
const message = createBasePublishStreamMessageResponse();
|
|
146
|
+
while (reader.pos < end) {
|
|
147
|
+
const tag = reader.uint32();
|
|
148
|
+
switch (tag >>> 3) {
|
|
149
|
+
}
|
|
150
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
reader.skip(tag & 7);
|
|
154
|
+
}
|
|
155
|
+
return message;
|
|
156
|
+
},
|
|
157
|
+
fromJSON(_) {
|
|
158
|
+
return {};
|
|
159
|
+
},
|
|
160
|
+
toJSON(_) {
|
|
161
|
+
const obj = {};
|
|
162
|
+
return obj;
|
|
163
|
+
},
|
|
164
|
+
create(base) {
|
|
165
|
+
return exports.PublishStreamMessageResponse.fromPartial(base !== null && base !== void 0 ? base : {});
|
|
166
|
+
},
|
|
167
|
+
fromPartial(_) {
|
|
168
|
+
const message = createBasePublishStreamMessageResponse();
|
|
169
|
+
return message;
|
|
170
|
+
},
|
|
171
|
+
};
|
|
172
|
+
function createBaseSubscribeStreamRequest() {
|
|
173
|
+
return { namespace: '', topic: '', cursor: undefined };
|
|
174
|
+
}
|
|
175
|
+
exports.SubscribeStreamRequest = {
|
|
176
|
+
encode(message, writer = new wire_1.BinaryWriter()) {
|
|
177
|
+
if (message.namespace !== '') {
|
|
178
|
+
writer.uint32(10).string(message.namespace);
|
|
179
|
+
}
|
|
180
|
+
if (message.topic !== '') {
|
|
181
|
+
writer.uint32(18).string(message.topic);
|
|
182
|
+
}
|
|
183
|
+
if (message.cursor !== undefined) {
|
|
184
|
+
writer.uint32(26).string(message.cursor);
|
|
185
|
+
}
|
|
186
|
+
return writer;
|
|
187
|
+
},
|
|
188
|
+
decode(input, length) {
|
|
189
|
+
const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
|
|
190
|
+
const end = length === undefined ? reader.len : reader.pos + length;
|
|
191
|
+
const message = createBaseSubscribeStreamRequest();
|
|
192
|
+
while (reader.pos < end) {
|
|
193
|
+
const tag = reader.uint32();
|
|
194
|
+
switch (tag >>> 3) {
|
|
195
|
+
case 1: {
|
|
196
|
+
if (tag !== 10) {
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
message.namespace = reader.string();
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
case 2: {
|
|
203
|
+
if (tag !== 18) {
|
|
204
|
+
break;
|
|
205
|
+
}
|
|
206
|
+
message.topic = reader.string();
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
209
|
+
case 3: {
|
|
210
|
+
if (tag !== 26) {
|
|
211
|
+
break;
|
|
212
|
+
}
|
|
213
|
+
message.cursor = reader.string();
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
218
|
+
break;
|
|
219
|
+
}
|
|
220
|
+
reader.skip(tag & 7);
|
|
221
|
+
}
|
|
222
|
+
return message;
|
|
223
|
+
},
|
|
224
|
+
fromJSON(object) {
|
|
225
|
+
return {
|
|
226
|
+
namespace: isSet(object.namespace) ? globalThis.String(object.namespace) : '',
|
|
227
|
+
topic: isSet(object.topic) ? globalThis.String(object.topic) : '',
|
|
228
|
+
cursor: isSet(object.cursor) ? globalThis.String(object.cursor) : undefined,
|
|
229
|
+
};
|
|
230
|
+
},
|
|
231
|
+
toJSON(message) {
|
|
232
|
+
const obj = {};
|
|
233
|
+
if (message.namespace !== '') {
|
|
234
|
+
obj.namespace = message.namespace;
|
|
235
|
+
}
|
|
236
|
+
if (message.topic !== '') {
|
|
237
|
+
obj.topic = message.topic;
|
|
238
|
+
}
|
|
239
|
+
if (message.cursor !== undefined) {
|
|
240
|
+
obj.cursor = message.cursor;
|
|
241
|
+
}
|
|
242
|
+
return obj;
|
|
243
|
+
},
|
|
244
|
+
create(base) {
|
|
245
|
+
return exports.SubscribeStreamRequest.fromPartial(base !== null && base !== void 0 ? base : {});
|
|
246
|
+
},
|
|
247
|
+
fromPartial(object) {
|
|
248
|
+
var _a, _b, _c;
|
|
249
|
+
const message = createBaseSubscribeStreamRequest();
|
|
250
|
+
message.namespace = (_a = object.namespace) !== null && _a !== void 0 ? _a : '';
|
|
251
|
+
message.topic = (_b = object.topic) !== null && _b !== void 0 ? _b : '';
|
|
252
|
+
message.cursor = (_c = object.cursor) !== null && _c !== void 0 ? _c : undefined;
|
|
253
|
+
return message;
|
|
254
|
+
},
|
|
255
|
+
};
|
|
256
|
+
function createBaseStreamMessage() {
|
|
257
|
+
return { entries: [], hangup: false, cursor: '' };
|
|
258
|
+
}
|
|
259
|
+
exports.StreamMessage = {
|
|
260
|
+
encode(message, writer = new wire_1.BinaryWriter()) {
|
|
261
|
+
for (const v of message.entries) {
|
|
262
|
+
exports.StreamEntry.encode(v, writer.uint32(10).fork()).join();
|
|
263
|
+
}
|
|
264
|
+
if (message.hangup !== false) {
|
|
265
|
+
writer.uint32(16).bool(message.hangup);
|
|
266
|
+
}
|
|
267
|
+
if (message.cursor !== '') {
|
|
268
|
+
writer.uint32(26).string(message.cursor);
|
|
269
|
+
}
|
|
270
|
+
return writer;
|
|
271
|
+
},
|
|
272
|
+
decode(input, length) {
|
|
273
|
+
const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
|
|
274
|
+
const end = length === undefined ? reader.len : reader.pos + length;
|
|
275
|
+
const message = createBaseStreamMessage();
|
|
276
|
+
while (reader.pos < end) {
|
|
277
|
+
const tag = reader.uint32();
|
|
278
|
+
switch (tag >>> 3) {
|
|
279
|
+
case 1: {
|
|
280
|
+
if (tag !== 10) {
|
|
281
|
+
break;
|
|
282
|
+
}
|
|
283
|
+
message.entries.push(exports.StreamEntry.decode(reader, reader.uint32()));
|
|
284
|
+
continue;
|
|
285
|
+
}
|
|
286
|
+
case 2: {
|
|
287
|
+
if (tag !== 16) {
|
|
288
|
+
break;
|
|
289
|
+
}
|
|
290
|
+
message.hangup = reader.bool();
|
|
291
|
+
continue;
|
|
292
|
+
}
|
|
293
|
+
case 3: {
|
|
294
|
+
if (tag !== 26) {
|
|
295
|
+
break;
|
|
296
|
+
}
|
|
297
|
+
message.cursor = reader.string();
|
|
298
|
+
continue;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
302
|
+
break;
|
|
303
|
+
}
|
|
304
|
+
reader.skip(tag & 7);
|
|
305
|
+
}
|
|
306
|
+
return message;
|
|
307
|
+
},
|
|
308
|
+
fromJSON(object) {
|
|
309
|
+
return {
|
|
310
|
+
entries: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.entries)
|
|
311
|
+
? object.entries.map((e) => exports.StreamEntry.fromJSON(e))
|
|
312
|
+
: [],
|
|
313
|
+
hangup: isSet(object.hangup) ? globalThis.Boolean(object.hangup) : false,
|
|
314
|
+
cursor: isSet(object.cursor) ? globalThis.String(object.cursor) : '',
|
|
315
|
+
};
|
|
316
|
+
},
|
|
317
|
+
toJSON(message) {
|
|
318
|
+
var _a;
|
|
319
|
+
const obj = {};
|
|
320
|
+
if ((_a = message.entries) === null || _a === void 0 ? void 0 : _a.length) {
|
|
321
|
+
obj.entries = message.entries.map((e) => exports.StreamEntry.toJSON(e));
|
|
322
|
+
}
|
|
323
|
+
if (message.hangup !== false) {
|
|
324
|
+
obj.hangup = message.hangup;
|
|
325
|
+
}
|
|
326
|
+
if (message.cursor !== '') {
|
|
327
|
+
obj.cursor = message.cursor;
|
|
328
|
+
}
|
|
329
|
+
return obj;
|
|
330
|
+
},
|
|
331
|
+
create(base) {
|
|
332
|
+
return exports.StreamMessage.fromPartial(base !== null && base !== void 0 ? base : {});
|
|
333
|
+
},
|
|
334
|
+
fromPartial(object) {
|
|
335
|
+
var _a, _b, _c;
|
|
336
|
+
const message = createBaseStreamMessage();
|
|
337
|
+
message.entries = ((_a = object.entries) === null || _a === void 0 ? void 0 : _a.map((e) => exports.StreamEntry.fromPartial(e))) || [];
|
|
338
|
+
message.hangup = (_b = object.hangup) !== null && _b !== void 0 ? _b : false;
|
|
339
|
+
message.cursor = (_c = object.cursor) !== null && _c !== void 0 ? _c : '';
|
|
340
|
+
return message;
|
|
341
|
+
},
|
|
342
|
+
};
|
|
343
|
+
function createBaseStreamEntry() {
|
|
344
|
+
return { payload: new Uint8Array(0), cursor: '', createdAt: undefined };
|
|
345
|
+
}
|
|
346
|
+
exports.StreamEntry = {
|
|
347
|
+
encode(message, writer = new wire_1.BinaryWriter()) {
|
|
348
|
+
if (message.payload.length !== 0) {
|
|
349
|
+
writer.uint32(10).bytes(message.payload);
|
|
350
|
+
}
|
|
351
|
+
if (message.cursor !== '') {
|
|
352
|
+
writer.uint32(18).string(message.cursor);
|
|
353
|
+
}
|
|
354
|
+
if (message.createdAt !== undefined) {
|
|
355
|
+
timestamp_1.Timestamp.encode(toTimestamp(message.createdAt), writer.uint32(26).fork()).join();
|
|
356
|
+
}
|
|
357
|
+
return writer;
|
|
358
|
+
},
|
|
359
|
+
decode(input, length) {
|
|
360
|
+
const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
|
|
361
|
+
const end = length === undefined ? reader.len : reader.pos + length;
|
|
362
|
+
const message = createBaseStreamEntry();
|
|
363
|
+
while (reader.pos < end) {
|
|
364
|
+
const tag = reader.uint32();
|
|
365
|
+
switch (tag >>> 3) {
|
|
366
|
+
case 1: {
|
|
367
|
+
if (tag !== 10) {
|
|
368
|
+
break;
|
|
369
|
+
}
|
|
370
|
+
message.payload = reader.bytes();
|
|
371
|
+
continue;
|
|
372
|
+
}
|
|
373
|
+
case 2: {
|
|
374
|
+
if (tag !== 18) {
|
|
375
|
+
break;
|
|
376
|
+
}
|
|
377
|
+
message.cursor = reader.string();
|
|
378
|
+
continue;
|
|
379
|
+
}
|
|
380
|
+
case 3: {
|
|
381
|
+
if (tag !== 26) {
|
|
382
|
+
break;
|
|
383
|
+
}
|
|
384
|
+
message.createdAt = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
|
|
385
|
+
continue;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
389
|
+
break;
|
|
390
|
+
}
|
|
391
|
+
reader.skip(tag & 7);
|
|
392
|
+
}
|
|
393
|
+
return message;
|
|
394
|
+
},
|
|
395
|
+
fromJSON(object) {
|
|
396
|
+
return {
|
|
397
|
+
payload: isSet(object.payload) ? bytesFromBase64(object.payload) : new Uint8Array(0),
|
|
398
|
+
cursor: isSet(object.cursor) ? globalThis.String(object.cursor) : '',
|
|
399
|
+
createdAt: isSet(object.createdAt)
|
|
400
|
+
? fromJsonTimestamp(object.createdAt)
|
|
401
|
+
: isSet(object.created_at)
|
|
402
|
+
? fromJsonTimestamp(object.created_at)
|
|
403
|
+
: undefined,
|
|
404
|
+
};
|
|
405
|
+
},
|
|
406
|
+
toJSON(message) {
|
|
407
|
+
const obj = {};
|
|
408
|
+
if (message.payload.length !== 0) {
|
|
409
|
+
obj.payload = base64FromBytes(message.payload);
|
|
410
|
+
}
|
|
411
|
+
if (message.cursor !== '') {
|
|
412
|
+
obj.cursor = message.cursor;
|
|
413
|
+
}
|
|
414
|
+
if (message.createdAt !== undefined) {
|
|
415
|
+
obj.createdAt = message.createdAt.toISOString();
|
|
416
|
+
}
|
|
417
|
+
return obj;
|
|
418
|
+
},
|
|
419
|
+
create(base) {
|
|
420
|
+
return exports.StreamEntry.fromPartial(base !== null && base !== void 0 ? base : {});
|
|
421
|
+
},
|
|
422
|
+
fromPartial(object) {
|
|
423
|
+
var _a, _b, _c;
|
|
424
|
+
const message = createBaseStreamEntry();
|
|
425
|
+
message.payload = (_a = object.payload) !== null && _a !== void 0 ? _a : new Uint8Array(0);
|
|
426
|
+
message.cursor = (_b = object.cursor) !== null && _b !== void 0 ? _b : '';
|
|
427
|
+
message.createdAt = (_c = object.createdAt) !== null && _c !== void 0 ? _c : undefined;
|
|
428
|
+
return message;
|
|
429
|
+
},
|
|
430
|
+
};
|
|
431
|
+
exports.V1StreamsDefinition = {
|
|
432
|
+
name: 'V1Streams',
|
|
433
|
+
fullName: 'v1.V1Streams',
|
|
434
|
+
methods: {
|
|
435
|
+
publish: {
|
|
436
|
+
name: 'Publish',
|
|
437
|
+
requestType: exports.PublishStreamMessageRequest,
|
|
438
|
+
requestStream: false,
|
|
439
|
+
responseType: exports.PublishStreamMessageResponse,
|
|
440
|
+
responseStream: false,
|
|
441
|
+
options: {},
|
|
442
|
+
},
|
|
443
|
+
subscribe: {
|
|
444
|
+
name: 'Subscribe',
|
|
445
|
+
requestType: exports.SubscribeStreamRequest,
|
|
446
|
+
requestStream: false,
|
|
447
|
+
responseType: exports.StreamMessage,
|
|
448
|
+
responseStream: true,
|
|
449
|
+
options: {},
|
|
450
|
+
},
|
|
451
|
+
},
|
|
452
|
+
};
|
|
453
|
+
function bytesFromBase64(b64) {
|
|
454
|
+
if (globalThis.Buffer) {
|
|
455
|
+
return Uint8Array.from(globalThis.Buffer.from(b64, 'base64'));
|
|
456
|
+
}
|
|
457
|
+
else {
|
|
458
|
+
const bin = globalThis.atob(b64);
|
|
459
|
+
const arr = new Uint8Array(bin.length);
|
|
460
|
+
for (let i = 0; i < bin.length; ++i) {
|
|
461
|
+
arr[i] = bin.charCodeAt(i);
|
|
462
|
+
}
|
|
463
|
+
return arr;
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
function base64FromBytes(arr) {
|
|
467
|
+
if (globalThis.Buffer) {
|
|
468
|
+
return globalThis.Buffer.from(arr).toString('base64');
|
|
469
|
+
}
|
|
470
|
+
else {
|
|
471
|
+
const bin = [];
|
|
472
|
+
arr.forEach((byte) => {
|
|
473
|
+
bin.push(globalThis.String.fromCharCode(byte));
|
|
474
|
+
});
|
|
475
|
+
return globalThis.btoa(bin.join(''));
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
function toTimestamp(date) {
|
|
479
|
+
const seconds = Math.trunc(date.getTime() / 1000);
|
|
480
|
+
const nanos = (date.getTime() % 1000) * 1000000;
|
|
481
|
+
return { seconds, nanos };
|
|
482
|
+
}
|
|
483
|
+
function fromTimestamp(t) {
|
|
484
|
+
let millis = (t.seconds || 0) * 1000;
|
|
485
|
+
millis += (t.nanos || 0) / 1000000;
|
|
486
|
+
return new globalThis.Date(millis);
|
|
487
|
+
}
|
|
488
|
+
function fromJsonTimestamp(o) {
|
|
489
|
+
if (o instanceof globalThis.Date) {
|
|
490
|
+
return o;
|
|
491
|
+
}
|
|
492
|
+
else if (typeof o === 'string') {
|
|
493
|
+
return new globalThis.Date(o);
|
|
494
|
+
}
|
|
495
|
+
else {
|
|
496
|
+
return fromTimestamp(timestamp_1.Timestamp.fromJSON(o));
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
function longToNumber(int64) {
|
|
500
|
+
const num = globalThis.Number(int64.toString());
|
|
501
|
+
if (num > globalThis.Number.MAX_SAFE_INTEGER) {
|
|
502
|
+
throw new globalThis.Error('Value is larger than Number.MAX_SAFE_INTEGER');
|
|
503
|
+
}
|
|
504
|
+
if (num < globalThis.Number.MIN_SAFE_INTEGER) {
|
|
505
|
+
throw new globalThis.Error('Value is smaller than Number.MIN_SAFE_INTEGER');
|
|
506
|
+
}
|
|
507
|
+
return num;
|
|
508
|
+
}
|
|
509
|
+
function isSet(value) {
|
|
510
|
+
return value !== null && value !== undefined;
|
|
511
|
+
}
|