@0xsequence/builder 0.0.0-20241216114019

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,713 @@
1
+ /* eslint-disable */
2
+ // NOTE: this is just a subset of the builder api to scope down the
3
+ // surface area of the client.
4
+ //
5
+ // In the future we can include additional interfaces as needed.
6
+ export const WebrpcHeader = 'Webrpc'
7
+
8
+ export const WebrpcHeaderValue = 'webrpc@v0.22.0;gen-typescript@v0.16.1;sequence-builder@v0.1.0'
9
+
10
+ // WebRPC description and code-gen version
11
+ export const WebRPCVersion = 'v1'
12
+
13
+ // Schema version of your RIDL schema
14
+ export const WebRPCSchemaVersion = 'v0.1.0'
15
+
16
+ // Schema hash generated from your RIDL schema
17
+ export const WebRPCSchemaHash = '5b580e1afeb26e0b4a8ee026271e2466760da0aa'
18
+
19
+ type WebrpcGenVersions = {
20
+ webrpcGenVersion: string
21
+ codeGenName: string
22
+ codeGenVersion: string
23
+ schemaName: string
24
+ schemaVersion: string
25
+ }
26
+
27
+ export function VersionFromHeader(headers: Headers): WebrpcGenVersions {
28
+ const headerValue = headers.get(WebrpcHeader)
29
+ if (!headerValue) {
30
+ return {
31
+ webrpcGenVersion: '',
32
+ codeGenName: '',
33
+ codeGenVersion: '',
34
+ schemaName: '',
35
+ schemaVersion: ''
36
+ }
37
+ }
38
+
39
+ return parseWebrpcGenVersions(headerValue)
40
+ }
41
+
42
+ function parseWebrpcGenVersions(header: string): WebrpcGenVersions {
43
+ const versions = header.split(';')
44
+ if (versions.length < 3) {
45
+ return {
46
+ webrpcGenVersion: '',
47
+ codeGenName: '',
48
+ codeGenVersion: '',
49
+ schemaName: '',
50
+ schemaVersion: ''
51
+ }
52
+ }
53
+
54
+ const [_, webrpcGenVersion] = versions[0].split('@')
55
+ const [codeGenName, codeGenVersion] = versions[1].split('@')
56
+ const [schemaName, schemaVersion] = versions[2].split('@')
57
+
58
+ return {
59
+ webrpcGenVersion,
60
+ codeGenName,
61
+ codeGenVersion,
62
+ schemaName,
63
+ schemaVersion
64
+ }
65
+ }
66
+
67
+ //
68
+ // Types
69
+ //
70
+
71
+ export interface AudienceContact {
72
+ id?: number
73
+ audienceId: number
74
+ name?: string
75
+ address: string
76
+ email?: string
77
+ userIp?: string
78
+ stage?: number
79
+ createdAt?: string
80
+ updatedAt?: string
81
+ }
82
+
83
+ export interface AudienceRegistrationStatus {
84
+ totalCount: number
85
+ }
86
+
87
+ export interface WalletProof {
88
+ address: string
89
+ message: string
90
+ signature: string
91
+ chainId: number
92
+ }
93
+
94
+ export interface Builder {
95
+ ping(headers?: object, signal?: AbortSignal): Promise<PingReturn>
96
+ registerAudienceContact(
97
+ args: RegisterAudienceContactArgs,
98
+ headers?: object,
99
+ signal?: AbortSignal
100
+ ): Promise<RegisterAudienceContactReturn>
101
+ getRegisteredAudienceContact(
102
+ args: GetRegisteredAudienceContactArgs,
103
+ headers?: object,
104
+ signal?: AbortSignal
105
+ ): Promise<GetRegisteredAudienceContactReturn>
106
+ getAudienceRegistrationPublicStatus(
107
+ args: GetAudienceRegistrationPublicStatusArgs,
108
+ headers?: object,
109
+ signal?: AbortSignal
110
+ ): Promise<GetAudienceRegistrationPublicStatusReturn>
111
+ isAudienceContactRegistered(
112
+ args: IsAudienceContactRegisteredArgs,
113
+ headers?: object,
114
+ signal?: AbortSignal
115
+ ): Promise<IsAudienceContactRegisteredReturn>
116
+ }
117
+
118
+ export interface PingArgs {}
119
+
120
+ export interface PingReturn {
121
+ status: boolean
122
+ }
123
+
124
+ export interface RegisterAudienceContactArgs {
125
+ projectId: number
126
+ audienceId: number
127
+ contact: AudienceContact
128
+ walletProof: WalletProof
129
+ }
130
+
131
+ export interface RegisterAudienceContactReturn {
132
+ ok: boolean
133
+ }
134
+ export interface GetRegisteredAudienceContactArgs {
135
+ projectId: number
136
+ audienceId: number
137
+ walletProof: WalletProof
138
+ }
139
+
140
+ export interface GetRegisteredAudienceContactReturn {
141
+ contact: AudienceContact
142
+ }
143
+ export interface GetAudienceRegistrationPublicStatusArgs {
144
+ projectId: number
145
+ audienceId: number
146
+ }
147
+
148
+ export interface GetAudienceRegistrationPublicStatusReturn {
149
+ status: AudienceRegistrationStatus
150
+ }
151
+ export interface IsAudienceContactRegisteredArgs {
152
+ projectId: number
153
+ audienceId: number
154
+ walletAddress: string
155
+ }
156
+
157
+ export interface IsAudienceContactRegisteredReturn {
158
+ registered: boolean
159
+ }
160
+
161
+ //
162
+ // Client
163
+ //
164
+ export class Builder implements Builder {
165
+ protected hostname: string
166
+ protected fetch: Fetch
167
+ protected path = '/rpc/Builder/'
168
+
169
+ constructor(hostname: string, fetch: Fetch) {
170
+ this.hostname = hostname.replace(/\/*$/, '')
171
+ this.fetch = (input: RequestInfo, init?: RequestInit) => fetch(input, init)
172
+ }
173
+
174
+ private url(name: string): string {
175
+ return this.hostname + this.path + name
176
+ }
177
+
178
+ ping = (headers?: object, signal?: AbortSignal): Promise<PingReturn> => {
179
+ return this.fetch(this.url('Ping'), createHTTPRequest({}, headers, signal)).then(
180
+ res => {
181
+ return buildResponse(res).then(_data => {
182
+ return {
183
+ status: <boolean>_data.status
184
+ }
185
+ })
186
+ },
187
+ error => {
188
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
189
+ }
190
+ )
191
+ }
192
+
193
+ registerAudienceContact = (
194
+ args: RegisterAudienceContactArgs,
195
+ headers?: object,
196
+ signal?: AbortSignal
197
+ ): Promise<RegisterAudienceContactReturn> => {
198
+ return this.fetch(this.url('RegisterAudienceContact'), createHTTPRequest(args, headers, signal)).then(
199
+ res => {
200
+ return buildResponse(res).then(_data => {
201
+ return {
202
+ ok: <boolean>_data.ok
203
+ }
204
+ })
205
+ },
206
+ error => {
207
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
208
+ }
209
+ )
210
+ }
211
+
212
+ getRegisteredAudienceContact = (
213
+ args: GetRegisteredAudienceContactArgs,
214
+ headers?: object,
215
+ signal?: AbortSignal
216
+ ): Promise<GetRegisteredAudienceContactReturn> => {
217
+ return this.fetch(this.url('GetRegisteredAudienceContact'), createHTTPRequest(args, headers, signal)).then(
218
+ res => {
219
+ return buildResponse(res).then(_data => {
220
+ return {
221
+ contact: <AudienceContact>_data.contact
222
+ }
223
+ })
224
+ },
225
+ error => {
226
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
227
+ }
228
+ )
229
+ }
230
+
231
+ getAudienceRegistrationPublicStatus = (
232
+ args: GetAudienceRegistrationPublicStatusArgs,
233
+ headers?: object,
234
+ signal?: AbortSignal
235
+ ): Promise<GetAudienceRegistrationPublicStatusReturn> => {
236
+ return this.fetch(this.url('GetAudienceRegistrationPublicStatus'), createHTTPRequest(args, headers, signal)).then(
237
+ res => {
238
+ return buildResponse(res).then(_data => {
239
+ return {
240
+ status: <AudienceRegistrationStatus>_data.status
241
+ }
242
+ })
243
+ },
244
+ error => {
245
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
246
+ }
247
+ )
248
+ }
249
+
250
+ isAudienceContactRegistered = (
251
+ args: IsAudienceContactRegisteredArgs,
252
+ headers?: object,
253
+ signal?: AbortSignal
254
+ ): Promise<IsAudienceContactRegisteredReturn> => {
255
+ return this.fetch(this.url('IsAudienceContactRegistered'), createHTTPRequest(args, headers, signal)).then(
256
+ res => {
257
+ return buildResponse(res).then(_data => {
258
+ return {
259
+ registered: <boolean>_data.registered
260
+ }
261
+ })
262
+ },
263
+ error => {
264
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
265
+ }
266
+ )
267
+ }
268
+ }
269
+
270
+ const createHTTPRequest = (body: object = {}, headers: object = {}, signal: AbortSignal | null = null): object => {
271
+ const reqHeaders: { [key: string]: string } = { ...headers, 'Content-Type': 'application/json' }
272
+ reqHeaders[WebrpcHeader] = WebrpcHeaderValue
273
+
274
+ return {
275
+ method: 'POST',
276
+ headers: reqHeaders,
277
+ body: JSON.stringify(body || {}),
278
+ signal
279
+ }
280
+ }
281
+
282
+ const buildResponse = (res: Response): Promise<any> => {
283
+ return res.text().then(text => {
284
+ let data
285
+ try {
286
+ data = JSON.parse(text)
287
+ } catch (error) {
288
+ let message = ''
289
+ if (error instanceof Error) {
290
+ message = error.message
291
+ }
292
+ throw WebrpcBadResponseError.new({
293
+ status: res.status,
294
+ cause: `JSON.parse(): ${message}: response text: ${text}`
295
+ })
296
+ }
297
+ if (!res.ok) {
298
+ const code: number = typeof data.code === 'number' ? data.code : 0
299
+ throw (webrpcErrorByCode[code] || WebrpcError).new(data)
300
+ }
301
+ return data
302
+ })
303
+ }
304
+
305
+ //
306
+ // Errors
307
+ //
308
+
309
+ export class WebrpcError extends Error {
310
+ name: string
311
+ code: number
312
+ message: string
313
+ status: number
314
+ cause?: string
315
+
316
+ /** @deprecated Use message instead of msg. Deprecated in webrpc v0.11.0. */
317
+ msg: string
318
+
319
+ constructor(name: string, code: number, message: string, status: number, cause?: string) {
320
+ super(message)
321
+ this.name = name || 'WebrpcError'
322
+ this.code = typeof code === 'number' ? code : 0
323
+ this.message = message || `endpoint error ${this.code}`
324
+ this.msg = this.message
325
+ this.status = typeof status === 'number' ? status : 0
326
+ this.cause = cause
327
+ Object.setPrototypeOf(this, WebrpcError.prototype)
328
+ }
329
+
330
+ static new(payload: any): WebrpcError {
331
+ return new this(payload.error, payload.code, payload.message || payload.msg, payload.status, payload.cause)
332
+ }
333
+ }
334
+
335
+ // Webrpc errors
336
+
337
+ export class WebrpcEndpointError extends WebrpcError {
338
+ constructor(
339
+ name: string = 'WebrpcEndpoint',
340
+ code: number = 0,
341
+ message: string = 'endpoint error',
342
+ status: number = 0,
343
+ cause?: string
344
+ ) {
345
+ super(name, code, message, status, cause)
346
+ Object.setPrototypeOf(this, WebrpcEndpointError.prototype)
347
+ }
348
+ }
349
+
350
+ export class WebrpcRequestFailedError extends WebrpcError {
351
+ constructor(
352
+ name: string = 'WebrpcRequestFailed',
353
+ code: number = -1,
354
+ message: string = 'request failed',
355
+ status: number = 0,
356
+ cause?: string
357
+ ) {
358
+ super(name, code, message, status, cause)
359
+ Object.setPrototypeOf(this, WebrpcRequestFailedError.prototype)
360
+ }
361
+ }
362
+
363
+ export class WebrpcBadRouteError extends WebrpcError {
364
+ constructor(
365
+ name: string = 'WebrpcBadRoute',
366
+ code: number = -2,
367
+ message: string = 'bad route',
368
+ status: number = 0,
369
+ cause?: string
370
+ ) {
371
+ super(name, code, message, status, cause)
372
+ Object.setPrototypeOf(this, WebrpcBadRouteError.prototype)
373
+ }
374
+ }
375
+
376
+ export class WebrpcBadMethodError extends WebrpcError {
377
+ constructor(
378
+ name: string = 'WebrpcBadMethod',
379
+ code: number = -3,
380
+ message: string = 'bad method',
381
+ status: number = 0,
382
+ cause?: string
383
+ ) {
384
+ super(name, code, message, status, cause)
385
+ Object.setPrototypeOf(this, WebrpcBadMethodError.prototype)
386
+ }
387
+ }
388
+
389
+ export class WebrpcBadRequestError extends WebrpcError {
390
+ constructor(
391
+ name: string = 'WebrpcBadRequest',
392
+ code: number = -4,
393
+ message: string = 'bad request',
394
+ status: number = 0,
395
+ cause?: string
396
+ ) {
397
+ super(name, code, message, status, cause)
398
+ Object.setPrototypeOf(this, WebrpcBadRequestError.prototype)
399
+ }
400
+ }
401
+
402
+ export class WebrpcBadResponseError extends WebrpcError {
403
+ constructor(
404
+ name: string = 'WebrpcBadResponse',
405
+ code: number = -5,
406
+ message: string = 'bad response',
407
+ status: number = 0,
408
+ cause?: string
409
+ ) {
410
+ super(name, code, message, status, cause)
411
+ Object.setPrototypeOf(this, WebrpcBadResponseError.prototype)
412
+ }
413
+ }
414
+
415
+ export class WebrpcServerPanicError extends WebrpcError {
416
+ constructor(
417
+ name: string = 'WebrpcServerPanic',
418
+ code: number = -6,
419
+ message: string = 'server panic',
420
+ status: number = 0,
421
+ cause?: string
422
+ ) {
423
+ super(name, code, message, status, cause)
424
+ Object.setPrototypeOf(this, WebrpcServerPanicError.prototype)
425
+ }
426
+ }
427
+
428
+ export class WebrpcInternalErrorError extends WebrpcError {
429
+ constructor(
430
+ name: string = 'WebrpcInternalError',
431
+ code: number = -7,
432
+ message: string = 'internal error',
433
+ status: number = 0,
434
+ cause?: string
435
+ ) {
436
+ super(name, code, message, status, cause)
437
+ Object.setPrototypeOf(this, WebrpcInternalErrorError.prototype)
438
+ }
439
+ }
440
+
441
+ export class WebrpcClientDisconnectedError extends WebrpcError {
442
+ constructor(
443
+ name: string = 'WebrpcClientDisconnected',
444
+ code: number = -8,
445
+ message: string = 'client disconnected',
446
+ status: number = 0,
447
+ cause?: string
448
+ ) {
449
+ super(name, code, message, status, cause)
450
+ Object.setPrototypeOf(this, WebrpcClientDisconnectedError.prototype)
451
+ }
452
+ }
453
+
454
+ export class WebrpcStreamLostError extends WebrpcError {
455
+ constructor(
456
+ name: string = 'WebrpcStreamLost',
457
+ code: number = -9,
458
+ message: string = 'stream lost',
459
+ status: number = 0,
460
+ cause?: string
461
+ ) {
462
+ super(name, code, message, status, cause)
463
+ Object.setPrototypeOf(this, WebrpcStreamLostError.prototype)
464
+ }
465
+ }
466
+
467
+ export class WebrpcStreamFinishedError extends WebrpcError {
468
+ constructor(
469
+ name: string = 'WebrpcStreamFinished',
470
+ code: number = -10,
471
+ message: string = 'stream finished',
472
+ status: number = 0,
473
+ cause?: string
474
+ ) {
475
+ super(name, code, message, status, cause)
476
+ Object.setPrototypeOf(this, WebrpcStreamFinishedError.prototype)
477
+ }
478
+ }
479
+
480
+ // Schema errors
481
+
482
+ export class UnauthorizedError extends WebrpcError {
483
+ constructor(
484
+ name: string = 'Unauthorized',
485
+ code: number = 1000,
486
+ message: string = 'Unauthorized access',
487
+ status: number = 0,
488
+ cause?: string
489
+ ) {
490
+ super(name, code, message, status, cause)
491
+ Object.setPrototypeOf(this, UnauthorizedError.prototype)
492
+ }
493
+ }
494
+
495
+ export class PermissionDeniedError extends WebrpcError {
496
+ constructor(
497
+ name: string = 'PermissionDenied',
498
+ code: number = 1001,
499
+ message: string = 'Permission denied',
500
+ status: number = 0,
501
+ cause?: string
502
+ ) {
503
+ super(name, code, message, status, cause)
504
+ Object.setPrototypeOf(this, PermissionDeniedError.prototype)
505
+ }
506
+ }
507
+
508
+ export class SessionExpiredError extends WebrpcError {
509
+ constructor(
510
+ name: string = 'SessionExpired',
511
+ code: number = 1002,
512
+ message: string = 'Session expired',
513
+ status: number = 0,
514
+ cause?: string
515
+ ) {
516
+ super(name, code, message, status, cause)
517
+ Object.setPrototypeOf(this, SessionExpiredError.prototype)
518
+ }
519
+ }
520
+
521
+ export class MethodNotFoundError extends WebrpcError {
522
+ constructor(
523
+ name: string = 'MethodNotFound',
524
+ code: number = 1003,
525
+ message: string = 'Method not found',
526
+ status: number = 0,
527
+ cause?: string
528
+ ) {
529
+ super(name, code, message, status, cause)
530
+ Object.setPrototypeOf(this, MethodNotFoundError.prototype)
531
+ }
532
+ }
533
+
534
+ export class RequestConflictError extends WebrpcError {
535
+ constructor(
536
+ name: string = 'RequestConflict',
537
+ code: number = 1004,
538
+ message: string = 'Conflict with target resource',
539
+ status: number = 0,
540
+ cause?: string
541
+ ) {
542
+ super(name, code, message, status, cause)
543
+ Object.setPrototypeOf(this, RequestConflictError.prototype)
544
+ }
545
+ }
546
+
547
+ export class ServiceDisabledError extends WebrpcError {
548
+ constructor(
549
+ name: string = 'ServiceDisabled',
550
+ code: number = 1005,
551
+ message: string = 'Service disabled',
552
+ status: number = 0,
553
+ cause?: string
554
+ ) {
555
+ super(name, code, message, status, cause)
556
+ Object.setPrototypeOf(this, ServiceDisabledError.prototype)
557
+ }
558
+ }
559
+
560
+ export class TimeoutError extends WebrpcError {
561
+ constructor(
562
+ name: string = 'Timeout',
563
+ code: number = 2000,
564
+ message: string = 'Request timed out',
565
+ status: number = 0,
566
+ cause?: string
567
+ ) {
568
+ super(name, code, message, status, cause)
569
+ Object.setPrototypeOf(this, TimeoutError.prototype)
570
+ }
571
+ }
572
+
573
+ export class InvalidArgumentError extends WebrpcError {
574
+ constructor(
575
+ name: string = 'InvalidArgument',
576
+ code: number = 2001,
577
+ message: string = 'Invalid argument',
578
+ status: number = 0,
579
+ cause?: string
580
+ ) {
581
+ super(name, code, message, status, cause)
582
+ Object.setPrototypeOf(this, InvalidArgumentError.prototype)
583
+ }
584
+ }
585
+
586
+ export class NotFoundError extends WebrpcError {
587
+ constructor(
588
+ name: string = 'NotFound',
589
+ code: number = 3000,
590
+ message: string = 'Resource not found',
591
+ status: number = 0,
592
+ cause?: string
593
+ ) {
594
+ super(name, code, message, status, cause)
595
+ Object.setPrototypeOf(this, NotFoundError.prototype)
596
+ }
597
+ }
598
+
599
+ export class UserNotFoundError extends WebrpcError {
600
+ constructor(
601
+ name: string = 'UserNotFound',
602
+ code: number = 3001,
603
+ message: string = 'User not found',
604
+ status: number = 0,
605
+ cause?: string
606
+ ) {
607
+ super(name, code, message, status, cause)
608
+ Object.setPrototypeOf(this, UserNotFoundError.prototype)
609
+ }
610
+ }
611
+
612
+ export class ProjectNotFoundError extends WebrpcError {
613
+ constructor(
614
+ name: string = 'ProjectNotFound',
615
+ code: number = 3002,
616
+ message: string = 'Project not found',
617
+ status: number = 0,
618
+ cause?: string
619
+ ) {
620
+ super(name, code, message, status, cause)
621
+ Object.setPrototypeOf(this, ProjectNotFoundError.prototype)
622
+ }
623
+ }
624
+
625
+ export class AlreadyCollaboratorError extends WebrpcError {
626
+ constructor(
627
+ name: string = 'AlreadyCollaborator',
628
+ code: number = 4001,
629
+ message: string = 'Already a collaborator',
630
+ status: number = 0,
631
+ cause?: string
632
+ ) {
633
+ super(name, code, message, status, cause)
634
+ Object.setPrototypeOf(this, AlreadyCollaboratorError.prototype)
635
+ }
636
+ }
637
+
638
+ export enum errors {
639
+ WebrpcEndpoint = 'WebrpcEndpoint',
640
+ WebrpcRequestFailed = 'WebrpcRequestFailed',
641
+ WebrpcBadRoute = 'WebrpcBadRoute',
642
+ WebrpcBadMethod = 'WebrpcBadMethod',
643
+ WebrpcBadRequest = 'WebrpcBadRequest',
644
+ WebrpcBadResponse = 'WebrpcBadResponse',
645
+ WebrpcServerPanic = 'WebrpcServerPanic',
646
+ WebrpcInternalError = 'WebrpcInternalError',
647
+ WebrpcClientDisconnected = 'WebrpcClientDisconnected',
648
+ WebrpcStreamLost = 'WebrpcStreamLost',
649
+ WebrpcStreamFinished = 'WebrpcStreamFinished',
650
+ Unauthorized = 'Unauthorized',
651
+ PermissionDenied = 'PermissionDenied',
652
+ SessionExpired = 'SessionExpired',
653
+ MethodNotFound = 'MethodNotFound',
654
+ RequestConflict = 'RequestConflict',
655
+ ServiceDisabled = 'ServiceDisabled',
656
+ Timeout = 'Timeout',
657
+ InvalidArgument = 'InvalidArgument',
658
+ NotFound = 'NotFound',
659
+ UserNotFound = 'UserNotFound',
660
+ ProjectNotFound = 'ProjectNotFound'
661
+ }
662
+
663
+ export enum WebrpcErrorCodes {
664
+ WebrpcEndpoint = 0,
665
+ WebrpcRequestFailed = -1,
666
+ WebrpcBadRoute = -2,
667
+ WebrpcBadMethod = -3,
668
+ WebrpcBadRequest = -4,
669
+ WebrpcBadResponse = -5,
670
+ WebrpcServerPanic = -6,
671
+ WebrpcInternalError = -7,
672
+ WebrpcClientDisconnected = -8,
673
+ WebrpcStreamLost = -9,
674
+ WebrpcStreamFinished = -10,
675
+ Unauthorized = 1000,
676
+ PermissionDenied = 1001,
677
+ SessionExpired = 1002,
678
+ MethodNotFound = 1003,
679
+ RequestConflict = 1004,
680
+ ServiceDisabled = 1005,
681
+ Timeout = 2000,
682
+ InvalidArgument = 2001,
683
+ NotFound = 3000,
684
+ UserNotFound = 3001,
685
+ ProjectNotFound = 3002
686
+ }
687
+
688
+ export const webrpcErrorByCode: { [code: number]: any } = {
689
+ [0]: WebrpcEndpointError,
690
+ [-1]: WebrpcRequestFailedError,
691
+ [-2]: WebrpcBadRouteError,
692
+ [-3]: WebrpcBadMethodError,
693
+ [-4]: WebrpcBadRequestError,
694
+ [-5]: WebrpcBadResponseError,
695
+ [-6]: WebrpcServerPanicError,
696
+ [-7]: WebrpcInternalErrorError,
697
+ [-8]: WebrpcClientDisconnectedError,
698
+ [-9]: WebrpcStreamLostError,
699
+ [-10]: WebrpcStreamFinishedError,
700
+ [1000]: UnauthorizedError,
701
+ [1001]: PermissionDeniedError,
702
+ [1002]: SessionExpiredError,
703
+ [1003]: MethodNotFoundError,
704
+ [1004]: RequestConflictError,
705
+ [1005]: ServiceDisabledError,
706
+ [2000]: TimeoutError,
707
+ [2001]: InvalidArgumentError,
708
+ [3000]: NotFoundError,
709
+ [3001]: UserNotFoundError,
710
+ [3002]: ProjectNotFoundError
711
+ }
712
+
713
+ export type Fetch = (input: RequestInfo, init?: RequestInit) => Promise<Response>