@0xsequence/builder 2.2.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/LICENSE +219 -0
- package/README.md +4 -0
- package/dist/0xsequence-builder.cjs.d.ts +2 -0
- package/dist/0xsequence-builder.cjs.dev.js +487 -0
- package/dist/0xsequence-builder.cjs.js +7 -0
- package/dist/0xsequence-builder.cjs.prod.js +487 -0
- package/dist/0xsequence-builder.esm.js +449 -0
- package/dist/declarations/src/builder.gen.d.ts +222 -0
- package/dist/declarations/src/index.d.ts +7 -0
- package/package.json +22 -0
- package/src/builder.gen.ts +683 -0
- package/src/index.ts +30 -0
@@ -0,0 +1,449 @@
|
|
1
|
+
function _extends() {
|
2
|
+
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
3
|
+
for (var e = 1; e < arguments.length; e++) {
|
4
|
+
var t = arguments[e];
|
5
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
6
|
+
}
|
7
|
+
return n;
|
8
|
+
}, _extends.apply(null, arguments);
|
9
|
+
}
|
10
|
+
|
11
|
+
/* eslint-disable */
|
12
|
+
// NOTE: this is just a subset of the builder api to scope down the
|
13
|
+
// surface area of the client.
|
14
|
+
//
|
15
|
+
// In the future we can include additional interfaces as needed.
|
16
|
+
const WebrpcHeader = "Webrpc";
|
17
|
+
const WebrpcHeaderValue = "webrpc@v0.22.0;gen-typescript@v0.16.1;sequence-builder@v0.1.0";
|
18
|
+
|
19
|
+
// WebRPC description and code-gen version
|
20
|
+
const WebRPCVersion = "v1";
|
21
|
+
|
22
|
+
// Schema version of your RIDL schema
|
23
|
+
const WebRPCSchemaVersion = "v0.1.0";
|
24
|
+
|
25
|
+
// Schema hash generated from your RIDL schema
|
26
|
+
const WebRPCSchemaHash = "5b580e1afeb26e0b4a8ee026271e2466760da0aa";
|
27
|
+
function VersionFromHeader(headers) {
|
28
|
+
const headerValue = headers.get(WebrpcHeader);
|
29
|
+
if (!headerValue) {
|
30
|
+
return {
|
31
|
+
webrpcGenVersion: "",
|
32
|
+
codeGenName: "",
|
33
|
+
codeGenVersion: "",
|
34
|
+
schemaName: "",
|
35
|
+
schemaVersion: ""
|
36
|
+
};
|
37
|
+
}
|
38
|
+
return parseWebrpcGenVersions(headerValue);
|
39
|
+
}
|
40
|
+
function parseWebrpcGenVersions(header) {
|
41
|
+
const versions = header.split(";");
|
42
|
+
if (versions.length < 3) {
|
43
|
+
return {
|
44
|
+
webrpcGenVersion: "",
|
45
|
+
codeGenName: "",
|
46
|
+
codeGenVersion: "",
|
47
|
+
schemaName: "",
|
48
|
+
schemaVersion: ""
|
49
|
+
};
|
50
|
+
}
|
51
|
+
const [_, webrpcGenVersion] = versions[0].split("@");
|
52
|
+
const [codeGenName, codeGenVersion] = versions[1].split("@");
|
53
|
+
const [schemaName, schemaVersion] = versions[2].split("@");
|
54
|
+
return {
|
55
|
+
webrpcGenVersion,
|
56
|
+
codeGenName,
|
57
|
+
codeGenVersion,
|
58
|
+
schemaName,
|
59
|
+
schemaVersion
|
60
|
+
};
|
61
|
+
}
|
62
|
+
|
63
|
+
//
|
64
|
+
// Types
|
65
|
+
//
|
66
|
+
|
67
|
+
//
|
68
|
+
// Client
|
69
|
+
//
|
70
|
+
class Builder {
|
71
|
+
constructor(hostname, fetch) {
|
72
|
+
this.hostname = void 0;
|
73
|
+
this.fetch = void 0;
|
74
|
+
this.path = '/rpc/Builder/';
|
75
|
+
this.ping = (headers, signal) => {
|
76
|
+
return this.fetch(this.url('Ping'), createHTTPRequest({}, headers, signal)).then(res => {
|
77
|
+
return buildResponse(res).then(_data => {
|
78
|
+
return {
|
79
|
+
status: _data.status
|
80
|
+
};
|
81
|
+
});
|
82
|
+
}, error => {
|
83
|
+
throw WebrpcRequestFailedError.new({
|
84
|
+
cause: `fetch(): ${error.message || ''}`
|
85
|
+
});
|
86
|
+
});
|
87
|
+
};
|
88
|
+
this.registerAudienceContact = (args, headers, signal) => {
|
89
|
+
return this.fetch(this.url('RegisterAudienceContact'), createHTTPRequest(args, headers, signal)).then(res => {
|
90
|
+
return buildResponse(res).then(_data => {
|
91
|
+
return {
|
92
|
+
ok: _data.ok
|
93
|
+
};
|
94
|
+
});
|
95
|
+
}, error => {
|
96
|
+
throw WebrpcRequestFailedError.new({
|
97
|
+
cause: `fetch(): ${error.message || ''}`
|
98
|
+
});
|
99
|
+
});
|
100
|
+
};
|
101
|
+
this.getRegisteredAudienceContact = (args, headers, signal) => {
|
102
|
+
return this.fetch(this.url('GetRegisteredAudienceContact'), createHTTPRequest(args, headers, signal)).then(res => {
|
103
|
+
return buildResponse(res).then(_data => {
|
104
|
+
return {
|
105
|
+
contact: _data.contact
|
106
|
+
};
|
107
|
+
});
|
108
|
+
}, error => {
|
109
|
+
throw WebrpcRequestFailedError.new({
|
110
|
+
cause: `fetch(): ${error.message || ''}`
|
111
|
+
});
|
112
|
+
});
|
113
|
+
};
|
114
|
+
this.getAudienceRegistrationPublicStatus = (args, headers, signal) => {
|
115
|
+
return this.fetch(this.url('GetAudienceRegistrationPublicStatus'), createHTTPRequest(args, headers, signal)).then(res => {
|
116
|
+
return buildResponse(res).then(_data => {
|
117
|
+
return {
|
118
|
+
status: _data.status
|
119
|
+
};
|
120
|
+
});
|
121
|
+
}, error => {
|
122
|
+
throw WebrpcRequestFailedError.new({
|
123
|
+
cause: `fetch(): ${error.message || ''}`
|
124
|
+
});
|
125
|
+
});
|
126
|
+
};
|
127
|
+
this.isAudienceContactRegistered = (args, headers, signal) => {
|
128
|
+
return this.fetch(this.url('IsAudienceContactRegistered'), createHTTPRequest(args, headers, signal)).then(res => {
|
129
|
+
return buildResponse(res).then(_data => {
|
130
|
+
return {
|
131
|
+
registered: _data.registered
|
132
|
+
};
|
133
|
+
});
|
134
|
+
}, error => {
|
135
|
+
throw WebrpcRequestFailedError.new({
|
136
|
+
cause: `fetch(): ${error.message || ''}`
|
137
|
+
});
|
138
|
+
});
|
139
|
+
};
|
140
|
+
this.hostname = hostname.replace(/\/*$/, '');
|
141
|
+
this.fetch = (input, init) => fetch(input, init);
|
142
|
+
}
|
143
|
+
url(name) {
|
144
|
+
return this.hostname + this.path + name;
|
145
|
+
}
|
146
|
+
}
|
147
|
+
const createHTTPRequest = (body = {}, headers = {}, signal = null) => {
|
148
|
+
const reqHeaders = _extends({}, headers, {
|
149
|
+
'Content-Type': 'application/json'
|
150
|
+
});
|
151
|
+
reqHeaders[WebrpcHeader] = WebrpcHeaderValue;
|
152
|
+
return {
|
153
|
+
method: 'POST',
|
154
|
+
headers: reqHeaders,
|
155
|
+
body: JSON.stringify(body || {}),
|
156
|
+
signal
|
157
|
+
};
|
158
|
+
};
|
159
|
+
const buildResponse = res => {
|
160
|
+
return res.text().then(text => {
|
161
|
+
let data;
|
162
|
+
try {
|
163
|
+
data = JSON.parse(text);
|
164
|
+
} catch (error) {
|
165
|
+
let message = '';
|
166
|
+
if (error instanceof Error) {
|
167
|
+
message = error.message;
|
168
|
+
}
|
169
|
+
throw WebrpcBadResponseError.new({
|
170
|
+
status: res.status,
|
171
|
+
cause: `JSON.parse(): ${message}: response text: ${text}`
|
172
|
+
});
|
173
|
+
}
|
174
|
+
if (!res.ok) {
|
175
|
+
const code = typeof data.code === 'number' ? data.code : 0;
|
176
|
+
throw (webrpcErrorByCode[code] || WebrpcError).new(data);
|
177
|
+
}
|
178
|
+
return data;
|
179
|
+
});
|
180
|
+
};
|
181
|
+
|
182
|
+
//
|
183
|
+
// Errors
|
184
|
+
//
|
185
|
+
|
186
|
+
class WebrpcError extends Error {
|
187
|
+
constructor(name, code, message, status, cause) {
|
188
|
+
super(message);
|
189
|
+
this.name = void 0;
|
190
|
+
this.code = void 0;
|
191
|
+
this.message = void 0;
|
192
|
+
this.status = void 0;
|
193
|
+
this.cause = void 0;
|
194
|
+
/** @deprecated Use message instead of msg. Deprecated in webrpc v0.11.0. */
|
195
|
+
this.msg = void 0;
|
196
|
+
this.name = name || 'WebrpcError';
|
197
|
+
this.code = typeof code === 'number' ? code : 0;
|
198
|
+
this.message = message || `endpoint error ${this.code}`;
|
199
|
+
this.msg = this.message;
|
200
|
+
this.status = typeof status === 'number' ? status : 0;
|
201
|
+
this.cause = cause;
|
202
|
+
Object.setPrototypeOf(this, WebrpcError.prototype);
|
203
|
+
}
|
204
|
+
static new(payload) {
|
205
|
+
return new this(payload.error, payload.code, payload.message || payload.msg, payload.status, payload.cause);
|
206
|
+
}
|
207
|
+
}
|
208
|
+
|
209
|
+
// Webrpc errors
|
210
|
+
|
211
|
+
class WebrpcEndpointError extends WebrpcError {
|
212
|
+
constructor(name = 'WebrpcEndpoint', code = 0, message = 'endpoint error', status = 0, cause) {
|
213
|
+
super(name, code, message, status, cause);
|
214
|
+
Object.setPrototypeOf(this, WebrpcEndpointError.prototype);
|
215
|
+
}
|
216
|
+
}
|
217
|
+
class WebrpcRequestFailedError extends WebrpcError {
|
218
|
+
constructor(name = 'WebrpcRequestFailed', code = -1, message = 'request failed', status = 0, cause) {
|
219
|
+
super(name, code, message, status, cause);
|
220
|
+
Object.setPrototypeOf(this, WebrpcRequestFailedError.prototype);
|
221
|
+
}
|
222
|
+
}
|
223
|
+
class WebrpcBadRouteError extends WebrpcError {
|
224
|
+
constructor(name = 'WebrpcBadRoute', code = -2, message = 'bad route', status = 0, cause) {
|
225
|
+
super(name, code, message, status, cause);
|
226
|
+
Object.setPrototypeOf(this, WebrpcBadRouteError.prototype);
|
227
|
+
}
|
228
|
+
}
|
229
|
+
class WebrpcBadMethodError extends WebrpcError {
|
230
|
+
constructor(name = 'WebrpcBadMethod', code = -3, message = 'bad method', status = 0, cause) {
|
231
|
+
super(name, code, message, status, cause);
|
232
|
+
Object.setPrototypeOf(this, WebrpcBadMethodError.prototype);
|
233
|
+
}
|
234
|
+
}
|
235
|
+
class WebrpcBadRequestError extends WebrpcError {
|
236
|
+
constructor(name = 'WebrpcBadRequest', code = -4, message = 'bad request', status = 0, cause) {
|
237
|
+
super(name, code, message, status, cause);
|
238
|
+
Object.setPrototypeOf(this, WebrpcBadRequestError.prototype);
|
239
|
+
}
|
240
|
+
}
|
241
|
+
class WebrpcBadResponseError extends WebrpcError {
|
242
|
+
constructor(name = 'WebrpcBadResponse', code = -5, message = 'bad response', status = 0, cause) {
|
243
|
+
super(name, code, message, status, cause);
|
244
|
+
Object.setPrototypeOf(this, WebrpcBadResponseError.prototype);
|
245
|
+
}
|
246
|
+
}
|
247
|
+
class WebrpcServerPanicError extends WebrpcError {
|
248
|
+
constructor(name = 'WebrpcServerPanic', code = -6, message = 'server panic', status = 0, cause) {
|
249
|
+
super(name, code, message, status, cause);
|
250
|
+
Object.setPrototypeOf(this, WebrpcServerPanicError.prototype);
|
251
|
+
}
|
252
|
+
}
|
253
|
+
class WebrpcInternalErrorError extends WebrpcError {
|
254
|
+
constructor(name = 'WebrpcInternalError', code = -7, message = 'internal error', status = 0, cause) {
|
255
|
+
super(name, code, message, status, cause);
|
256
|
+
Object.setPrototypeOf(this, WebrpcInternalErrorError.prototype);
|
257
|
+
}
|
258
|
+
}
|
259
|
+
class WebrpcClientDisconnectedError extends WebrpcError {
|
260
|
+
constructor(name = 'WebrpcClientDisconnected', code = -8, message = 'client disconnected', status = 0, cause) {
|
261
|
+
super(name, code, message, status, cause);
|
262
|
+
Object.setPrototypeOf(this, WebrpcClientDisconnectedError.prototype);
|
263
|
+
}
|
264
|
+
}
|
265
|
+
class WebrpcStreamLostError extends WebrpcError {
|
266
|
+
constructor(name = 'WebrpcStreamLost', code = -9, message = 'stream lost', status = 0, cause) {
|
267
|
+
super(name, code, message, status, cause);
|
268
|
+
Object.setPrototypeOf(this, WebrpcStreamLostError.prototype);
|
269
|
+
}
|
270
|
+
}
|
271
|
+
class WebrpcStreamFinishedError extends WebrpcError {
|
272
|
+
constructor(name = 'WebrpcStreamFinished', code = -10, message = 'stream finished', status = 0, cause) {
|
273
|
+
super(name, code, message, status, cause);
|
274
|
+
Object.setPrototypeOf(this, WebrpcStreamFinishedError.prototype);
|
275
|
+
}
|
276
|
+
}
|
277
|
+
|
278
|
+
// Schema errors
|
279
|
+
|
280
|
+
class UnauthorizedError extends WebrpcError {
|
281
|
+
constructor(name = 'Unauthorized', code = 1000, message = 'Unauthorized access', status = 0, cause) {
|
282
|
+
super(name, code, message, status, cause);
|
283
|
+
Object.setPrototypeOf(this, UnauthorizedError.prototype);
|
284
|
+
}
|
285
|
+
}
|
286
|
+
class PermissionDeniedError extends WebrpcError {
|
287
|
+
constructor(name = 'PermissionDenied', code = 1001, message = 'Permission denied', status = 0, cause) {
|
288
|
+
super(name, code, message, status, cause);
|
289
|
+
Object.setPrototypeOf(this, PermissionDeniedError.prototype);
|
290
|
+
}
|
291
|
+
}
|
292
|
+
class SessionExpiredError extends WebrpcError {
|
293
|
+
constructor(name = 'SessionExpired', code = 1002, message = 'Session expired', status = 0, cause) {
|
294
|
+
super(name, code, message, status, cause);
|
295
|
+
Object.setPrototypeOf(this, SessionExpiredError.prototype);
|
296
|
+
}
|
297
|
+
}
|
298
|
+
class MethodNotFoundError extends WebrpcError {
|
299
|
+
constructor(name = 'MethodNotFound', code = 1003, message = 'Method not found', status = 0, cause) {
|
300
|
+
super(name, code, message, status, cause);
|
301
|
+
Object.setPrototypeOf(this, MethodNotFoundError.prototype);
|
302
|
+
}
|
303
|
+
}
|
304
|
+
class RequestConflictError extends WebrpcError {
|
305
|
+
constructor(name = 'RequestConflict', code = 1004, message = 'Conflict with target resource', status = 0, cause) {
|
306
|
+
super(name, code, message, status, cause);
|
307
|
+
Object.setPrototypeOf(this, RequestConflictError.prototype);
|
308
|
+
}
|
309
|
+
}
|
310
|
+
class ServiceDisabledError extends WebrpcError {
|
311
|
+
constructor(name = 'ServiceDisabled', code = 1005, message = 'Service disabled', status = 0, cause) {
|
312
|
+
super(name, code, message, status, cause);
|
313
|
+
Object.setPrototypeOf(this, ServiceDisabledError.prototype);
|
314
|
+
}
|
315
|
+
}
|
316
|
+
class TimeoutError extends WebrpcError {
|
317
|
+
constructor(name = 'Timeout', code = 2000, message = 'Request timed out', status = 0, cause) {
|
318
|
+
super(name, code, message, status, cause);
|
319
|
+
Object.setPrototypeOf(this, TimeoutError.prototype);
|
320
|
+
}
|
321
|
+
}
|
322
|
+
class InvalidArgumentError extends WebrpcError {
|
323
|
+
constructor(name = 'InvalidArgument', code = 2001, message = 'Invalid argument', status = 0, cause) {
|
324
|
+
super(name, code, message, status, cause);
|
325
|
+
Object.setPrototypeOf(this, InvalidArgumentError.prototype);
|
326
|
+
}
|
327
|
+
}
|
328
|
+
class NotFoundError extends WebrpcError {
|
329
|
+
constructor(name = 'NotFound', code = 3000, message = 'Resource not found', status = 0, cause) {
|
330
|
+
super(name, code, message, status, cause);
|
331
|
+
Object.setPrototypeOf(this, NotFoundError.prototype);
|
332
|
+
}
|
333
|
+
}
|
334
|
+
class UserNotFoundError extends WebrpcError {
|
335
|
+
constructor(name = 'UserNotFound', code = 3001, message = 'User not found', status = 0, cause) {
|
336
|
+
super(name, code, message, status, cause);
|
337
|
+
Object.setPrototypeOf(this, UserNotFoundError.prototype);
|
338
|
+
}
|
339
|
+
}
|
340
|
+
class ProjectNotFoundError extends WebrpcError {
|
341
|
+
constructor(name = 'ProjectNotFound', code = 3002, message = 'Project not found', status = 0, cause) {
|
342
|
+
super(name, code, message, status, cause);
|
343
|
+
Object.setPrototypeOf(this, ProjectNotFoundError.prototype);
|
344
|
+
}
|
345
|
+
}
|
346
|
+
class AlreadyCollaboratorError extends WebrpcError {
|
347
|
+
constructor(name = 'AlreadyCollaborator', code = 4001, message = 'Already a collaborator', status = 0, cause) {
|
348
|
+
super(name, code, message, status, cause);
|
349
|
+
Object.setPrototypeOf(this, AlreadyCollaboratorError.prototype);
|
350
|
+
}
|
351
|
+
}
|
352
|
+
let errors = /*#__PURE__*/function (errors) {
|
353
|
+
errors["WebrpcEndpoint"] = "WebrpcEndpoint";
|
354
|
+
errors["WebrpcRequestFailed"] = "WebrpcRequestFailed";
|
355
|
+
errors["WebrpcBadRoute"] = "WebrpcBadRoute";
|
356
|
+
errors["WebrpcBadMethod"] = "WebrpcBadMethod";
|
357
|
+
errors["WebrpcBadRequest"] = "WebrpcBadRequest";
|
358
|
+
errors["WebrpcBadResponse"] = "WebrpcBadResponse";
|
359
|
+
errors["WebrpcServerPanic"] = "WebrpcServerPanic";
|
360
|
+
errors["WebrpcInternalError"] = "WebrpcInternalError";
|
361
|
+
errors["WebrpcClientDisconnected"] = "WebrpcClientDisconnected";
|
362
|
+
errors["WebrpcStreamLost"] = "WebrpcStreamLost";
|
363
|
+
errors["WebrpcStreamFinished"] = "WebrpcStreamFinished";
|
364
|
+
errors["Unauthorized"] = "Unauthorized";
|
365
|
+
errors["PermissionDenied"] = "PermissionDenied";
|
366
|
+
errors["SessionExpired"] = "SessionExpired";
|
367
|
+
errors["MethodNotFound"] = "MethodNotFound";
|
368
|
+
errors["RequestConflict"] = "RequestConflict";
|
369
|
+
errors["ServiceDisabled"] = "ServiceDisabled";
|
370
|
+
errors["Timeout"] = "Timeout";
|
371
|
+
errors["InvalidArgument"] = "InvalidArgument";
|
372
|
+
errors["NotFound"] = "NotFound";
|
373
|
+
errors["UserNotFound"] = "UserNotFound";
|
374
|
+
errors["ProjectNotFound"] = "ProjectNotFound";
|
375
|
+
return errors;
|
376
|
+
}({});
|
377
|
+
let WebrpcErrorCodes = /*#__PURE__*/function (WebrpcErrorCodes) {
|
378
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcEndpoint"] = 0] = "WebrpcEndpoint";
|
379
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcRequestFailed"] = -1] = "WebrpcRequestFailed";
|
380
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcBadRoute"] = -2] = "WebrpcBadRoute";
|
381
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcBadMethod"] = -3] = "WebrpcBadMethod";
|
382
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcBadRequest"] = -4] = "WebrpcBadRequest";
|
383
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcBadResponse"] = -5] = "WebrpcBadResponse";
|
384
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcServerPanic"] = -6] = "WebrpcServerPanic";
|
385
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcInternalError"] = -7] = "WebrpcInternalError";
|
386
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcClientDisconnected"] = -8] = "WebrpcClientDisconnected";
|
387
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcStreamLost"] = -9] = "WebrpcStreamLost";
|
388
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcStreamFinished"] = -10] = "WebrpcStreamFinished";
|
389
|
+
WebrpcErrorCodes[WebrpcErrorCodes["Unauthorized"] = 1000] = "Unauthorized";
|
390
|
+
WebrpcErrorCodes[WebrpcErrorCodes["PermissionDenied"] = 1001] = "PermissionDenied";
|
391
|
+
WebrpcErrorCodes[WebrpcErrorCodes["SessionExpired"] = 1002] = "SessionExpired";
|
392
|
+
WebrpcErrorCodes[WebrpcErrorCodes["MethodNotFound"] = 1003] = "MethodNotFound";
|
393
|
+
WebrpcErrorCodes[WebrpcErrorCodes["RequestConflict"] = 1004] = "RequestConflict";
|
394
|
+
WebrpcErrorCodes[WebrpcErrorCodes["ServiceDisabled"] = 1005] = "ServiceDisabled";
|
395
|
+
WebrpcErrorCodes[WebrpcErrorCodes["Timeout"] = 2000] = "Timeout";
|
396
|
+
WebrpcErrorCodes[WebrpcErrorCodes["InvalidArgument"] = 2001] = "InvalidArgument";
|
397
|
+
WebrpcErrorCodes[WebrpcErrorCodes["NotFound"] = 3000] = "NotFound";
|
398
|
+
WebrpcErrorCodes[WebrpcErrorCodes["UserNotFound"] = 3001] = "UserNotFound";
|
399
|
+
WebrpcErrorCodes[WebrpcErrorCodes["ProjectNotFound"] = 3002] = "ProjectNotFound";
|
400
|
+
return WebrpcErrorCodes;
|
401
|
+
}({});
|
402
|
+
const webrpcErrorByCode = {
|
403
|
+
[0]: WebrpcEndpointError,
|
404
|
+
[-1]: WebrpcRequestFailedError,
|
405
|
+
[-2]: WebrpcBadRouteError,
|
406
|
+
[-3]: WebrpcBadMethodError,
|
407
|
+
[-4]: WebrpcBadRequestError,
|
408
|
+
[-5]: WebrpcBadResponseError,
|
409
|
+
[-6]: WebrpcServerPanicError,
|
410
|
+
[-7]: WebrpcInternalErrorError,
|
411
|
+
[-8]: WebrpcClientDisconnectedError,
|
412
|
+
[-9]: WebrpcStreamLostError,
|
413
|
+
[-10]: WebrpcStreamFinishedError,
|
414
|
+
[1000]: UnauthorizedError,
|
415
|
+
[1001]: PermissionDeniedError,
|
416
|
+
[1002]: SessionExpiredError,
|
417
|
+
[1003]: MethodNotFoundError,
|
418
|
+
[1004]: RequestConflictError,
|
419
|
+
[1005]: ServiceDisabledError,
|
420
|
+
[2000]: TimeoutError,
|
421
|
+
[2001]: InvalidArgumentError,
|
422
|
+
[3000]: NotFoundError,
|
423
|
+
[3001]: UserNotFoundError,
|
424
|
+
[3002]: ProjectNotFoundError
|
425
|
+
};
|
426
|
+
|
427
|
+
class SequenceBuilderClient extends Builder {
|
428
|
+
constructor(projectAccessKey, apiUrl) {
|
429
|
+
const hostname = apiUrl != null ? apiUrl : 'https://api.sequence.build';
|
430
|
+
super(hostname.endsWith('/') ? hostname.slice(0, -1) : hostname, fetch);
|
431
|
+
this.projectAccessKey = projectAccessKey;
|
432
|
+
this._fetch = (input, init) => {
|
433
|
+
// automatically include access key auth header to requests
|
434
|
+
// if its been set on the api client
|
435
|
+
const headers = {};
|
436
|
+
const projectAccessKey = this.projectAccessKey;
|
437
|
+
if (projectAccessKey && projectAccessKey.length > 0) {
|
438
|
+
headers['X-Access-Key'] = projectAccessKey;
|
439
|
+
}
|
440
|
+
|
441
|
+
// before the request is made
|
442
|
+
init.headers = _extends({}, init.headers, headers);
|
443
|
+
return fetch(input, init);
|
444
|
+
};
|
445
|
+
this.fetch = this._fetch;
|
446
|
+
}
|
447
|
+
}
|
448
|
+
|
449
|
+
export { AlreadyCollaboratorError, Builder, InvalidArgumentError, MethodNotFoundError, NotFoundError, PermissionDeniedError, ProjectNotFoundError, RequestConflictError, SequenceBuilderClient, ServiceDisabledError, SessionExpiredError, TimeoutError, UnauthorizedError, UserNotFoundError, VersionFromHeader, WebRPCSchemaHash, WebRPCSchemaVersion, WebRPCVersion, WebrpcBadMethodError, WebrpcBadRequestError, WebrpcBadResponseError, WebrpcBadRouteError, WebrpcClientDisconnectedError, WebrpcEndpointError, WebrpcError, WebrpcErrorCodes, WebrpcHeader, WebrpcHeaderValue, WebrpcInternalErrorError, WebrpcRequestFailedError, WebrpcServerPanicError, WebrpcStreamFinishedError, WebrpcStreamLostError, errors, webrpcErrorByCode };
|
@@ -0,0 +1,222 @@
|
|
1
|
+
export declare const WebrpcHeader = "Webrpc";
|
2
|
+
export declare const WebrpcHeaderValue = "webrpc@v0.22.0;gen-typescript@v0.16.1;sequence-builder@v0.1.0";
|
3
|
+
export declare const WebRPCVersion = "v1";
|
4
|
+
export declare const WebRPCSchemaVersion = "v0.1.0";
|
5
|
+
export declare const WebRPCSchemaHash = "5b580e1afeb26e0b4a8ee026271e2466760da0aa";
|
6
|
+
type WebrpcGenVersions = {
|
7
|
+
webrpcGenVersion: string;
|
8
|
+
codeGenName: string;
|
9
|
+
codeGenVersion: string;
|
10
|
+
schemaName: string;
|
11
|
+
schemaVersion: string;
|
12
|
+
};
|
13
|
+
export declare function VersionFromHeader(headers: Headers): WebrpcGenVersions;
|
14
|
+
export interface AudienceContact {
|
15
|
+
id?: number;
|
16
|
+
audienceId: number;
|
17
|
+
name?: string;
|
18
|
+
address: string;
|
19
|
+
email?: string;
|
20
|
+
userIp?: string;
|
21
|
+
stage?: number;
|
22
|
+
createdAt?: string;
|
23
|
+
updatedAt?: string;
|
24
|
+
}
|
25
|
+
export interface AudienceRegistrationStatus {
|
26
|
+
totalCount: number;
|
27
|
+
}
|
28
|
+
export interface WalletProof {
|
29
|
+
address: string;
|
30
|
+
message: string;
|
31
|
+
signature: string;
|
32
|
+
chainId: number;
|
33
|
+
}
|
34
|
+
export interface Builder {
|
35
|
+
ping(headers?: object, signal?: AbortSignal): Promise<PingReturn>;
|
36
|
+
registerAudienceContact(args: RegisterAudienceContactArgs, headers?: object, signal?: AbortSignal): Promise<RegisterAudienceContactReturn>;
|
37
|
+
getRegisteredAudienceContact(args: GetRegisteredAudienceContactArgs, headers?: object, signal?: AbortSignal): Promise<GetRegisteredAudienceContactReturn>;
|
38
|
+
getAudienceRegistrationPublicStatus(args: GetAudienceRegistrationPublicStatusArgs, headers?: object, signal?: AbortSignal): Promise<GetAudienceRegistrationPublicStatusReturn>;
|
39
|
+
isAudienceContactRegistered(args: IsAudienceContactRegisteredArgs, headers?: object, signal?: AbortSignal): Promise<IsAudienceContactRegisteredReturn>;
|
40
|
+
}
|
41
|
+
export interface PingArgs {
|
42
|
+
}
|
43
|
+
export interface PingReturn {
|
44
|
+
status: boolean;
|
45
|
+
}
|
46
|
+
export interface RegisterAudienceContactArgs {
|
47
|
+
projectId: number;
|
48
|
+
audienceId: number;
|
49
|
+
contact: AudienceContact;
|
50
|
+
walletProof: WalletProof;
|
51
|
+
}
|
52
|
+
export interface RegisterAudienceContactReturn {
|
53
|
+
ok: boolean;
|
54
|
+
}
|
55
|
+
export interface GetRegisteredAudienceContactArgs {
|
56
|
+
projectId: number;
|
57
|
+
audienceId: number;
|
58
|
+
walletProof: WalletProof;
|
59
|
+
}
|
60
|
+
export interface GetRegisteredAudienceContactReturn {
|
61
|
+
contact: AudienceContact;
|
62
|
+
}
|
63
|
+
export interface GetAudienceRegistrationPublicStatusArgs {
|
64
|
+
projectId: number;
|
65
|
+
audienceId: number;
|
66
|
+
}
|
67
|
+
export interface GetAudienceRegistrationPublicStatusReturn {
|
68
|
+
status: AudienceRegistrationStatus;
|
69
|
+
}
|
70
|
+
export interface IsAudienceContactRegisteredArgs {
|
71
|
+
projectId: number;
|
72
|
+
audienceId: number;
|
73
|
+
walletAddress: string;
|
74
|
+
}
|
75
|
+
export interface IsAudienceContactRegisteredReturn {
|
76
|
+
registered: boolean;
|
77
|
+
}
|
78
|
+
export declare class Builder implements Builder {
|
79
|
+
protected hostname: string;
|
80
|
+
protected fetch: Fetch;
|
81
|
+
protected path: string;
|
82
|
+
constructor(hostname: string, fetch: Fetch);
|
83
|
+
private url;
|
84
|
+
ping: (headers?: object, signal?: AbortSignal) => Promise<PingReturn>;
|
85
|
+
registerAudienceContact: (args: RegisterAudienceContactArgs, headers?: object, signal?: AbortSignal) => Promise<RegisterAudienceContactReturn>;
|
86
|
+
getRegisteredAudienceContact: (args: GetRegisteredAudienceContactArgs, headers?: object, signal?: AbortSignal) => Promise<GetRegisteredAudienceContactReturn>;
|
87
|
+
getAudienceRegistrationPublicStatus: (args: GetAudienceRegistrationPublicStatusArgs, headers?: object, signal?: AbortSignal) => Promise<GetAudienceRegistrationPublicStatusReturn>;
|
88
|
+
isAudienceContactRegistered: (args: IsAudienceContactRegisteredArgs, headers?: object, signal?: AbortSignal) => Promise<IsAudienceContactRegisteredReturn>;
|
89
|
+
}
|
90
|
+
export declare class WebrpcError extends Error {
|
91
|
+
name: string;
|
92
|
+
code: number;
|
93
|
+
message: string;
|
94
|
+
status: number;
|
95
|
+
cause?: string;
|
96
|
+
/** @deprecated Use message instead of msg. Deprecated in webrpc v0.11.0. */
|
97
|
+
msg: string;
|
98
|
+
constructor(name: string, code: number, message: string, status: number, cause?: string);
|
99
|
+
static new(payload: any): WebrpcError;
|
100
|
+
}
|
101
|
+
export declare class WebrpcEndpointError extends WebrpcError {
|
102
|
+
constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
|
103
|
+
}
|
104
|
+
export declare class WebrpcRequestFailedError extends WebrpcError {
|
105
|
+
constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
|
106
|
+
}
|
107
|
+
export declare class WebrpcBadRouteError extends WebrpcError {
|
108
|
+
constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
|
109
|
+
}
|
110
|
+
export declare class WebrpcBadMethodError extends WebrpcError {
|
111
|
+
constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
|
112
|
+
}
|
113
|
+
export declare class WebrpcBadRequestError extends WebrpcError {
|
114
|
+
constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
|
115
|
+
}
|
116
|
+
export declare class WebrpcBadResponseError extends WebrpcError {
|
117
|
+
constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
|
118
|
+
}
|
119
|
+
export declare class WebrpcServerPanicError extends WebrpcError {
|
120
|
+
constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
|
121
|
+
}
|
122
|
+
export declare class WebrpcInternalErrorError extends WebrpcError {
|
123
|
+
constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
|
124
|
+
}
|
125
|
+
export declare class WebrpcClientDisconnectedError extends WebrpcError {
|
126
|
+
constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
|
127
|
+
}
|
128
|
+
export declare class WebrpcStreamLostError extends WebrpcError {
|
129
|
+
constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
|
130
|
+
}
|
131
|
+
export declare class WebrpcStreamFinishedError extends WebrpcError {
|
132
|
+
constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
|
133
|
+
}
|
134
|
+
export declare class UnauthorizedError extends WebrpcError {
|
135
|
+
constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
|
136
|
+
}
|
137
|
+
export declare class PermissionDeniedError extends WebrpcError {
|
138
|
+
constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
|
139
|
+
}
|
140
|
+
export declare class SessionExpiredError extends WebrpcError {
|
141
|
+
constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
|
142
|
+
}
|
143
|
+
export declare class MethodNotFoundError extends WebrpcError {
|
144
|
+
constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
|
145
|
+
}
|
146
|
+
export declare class RequestConflictError extends WebrpcError {
|
147
|
+
constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
|
148
|
+
}
|
149
|
+
export declare class ServiceDisabledError extends WebrpcError {
|
150
|
+
constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
|
151
|
+
}
|
152
|
+
export declare class TimeoutError extends WebrpcError {
|
153
|
+
constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
|
154
|
+
}
|
155
|
+
export declare class InvalidArgumentError extends WebrpcError {
|
156
|
+
constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
|
157
|
+
}
|
158
|
+
export declare class NotFoundError extends WebrpcError {
|
159
|
+
constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
|
160
|
+
}
|
161
|
+
export declare class UserNotFoundError extends WebrpcError {
|
162
|
+
constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
|
163
|
+
}
|
164
|
+
export declare class ProjectNotFoundError extends WebrpcError {
|
165
|
+
constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
|
166
|
+
}
|
167
|
+
export declare class AlreadyCollaboratorError extends WebrpcError {
|
168
|
+
constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
|
169
|
+
}
|
170
|
+
export declare enum errors {
|
171
|
+
WebrpcEndpoint = "WebrpcEndpoint",
|
172
|
+
WebrpcRequestFailed = "WebrpcRequestFailed",
|
173
|
+
WebrpcBadRoute = "WebrpcBadRoute",
|
174
|
+
WebrpcBadMethod = "WebrpcBadMethod",
|
175
|
+
WebrpcBadRequest = "WebrpcBadRequest",
|
176
|
+
WebrpcBadResponse = "WebrpcBadResponse",
|
177
|
+
WebrpcServerPanic = "WebrpcServerPanic",
|
178
|
+
WebrpcInternalError = "WebrpcInternalError",
|
179
|
+
WebrpcClientDisconnected = "WebrpcClientDisconnected",
|
180
|
+
WebrpcStreamLost = "WebrpcStreamLost",
|
181
|
+
WebrpcStreamFinished = "WebrpcStreamFinished",
|
182
|
+
Unauthorized = "Unauthorized",
|
183
|
+
PermissionDenied = "PermissionDenied",
|
184
|
+
SessionExpired = "SessionExpired",
|
185
|
+
MethodNotFound = "MethodNotFound",
|
186
|
+
RequestConflict = "RequestConflict",
|
187
|
+
ServiceDisabled = "ServiceDisabled",
|
188
|
+
Timeout = "Timeout",
|
189
|
+
InvalidArgument = "InvalidArgument",
|
190
|
+
NotFound = "NotFound",
|
191
|
+
UserNotFound = "UserNotFound",
|
192
|
+
ProjectNotFound = "ProjectNotFound"
|
193
|
+
}
|
194
|
+
export declare enum WebrpcErrorCodes {
|
195
|
+
WebrpcEndpoint = 0,
|
196
|
+
WebrpcRequestFailed = -1,
|
197
|
+
WebrpcBadRoute = -2,
|
198
|
+
WebrpcBadMethod = -3,
|
199
|
+
WebrpcBadRequest = -4,
|
200
|
+
WebrpcBadResponse = -5,
|
201
|
+
WebrpcServerPanic = -6,
|
202
|
+
WebrpcInternalError = -7,
|
203
|
+
WebrpcClientDisconnected = -8,
|
204
|
+
WebrpcStreamLost = -9,
|
205
|
+
WebrpcStreamFinished = -10,
|
206
|
+
Unauthorized = 1000,
|
207
|
+
PermissionDenied = 1001,
|
208
|
+
SessionExpired = 1002,
|
209
|
+
MethodNotFound = 1003,
|
210
|
+
RequestConflict = 1004,
|
211
|
+
ServiceDisabled = 1005,
|
212
|
+
Timeout = 2000,
|
213
|
+
InvalidArgument = 2001,
|
214
|
+
NotFound = 3000,
|
215
|
+
UserNotFound = 3001,
|
216
|
+
ProjectNotFound = 3002
|
217
|
+
}
|
218
|
+
export declare const webrpcErrorByCode: {
|
219
|
+
[code: number]: any;
|
220
|
+
};
|
221
|
+
export type Fetch = (input: RequestInfo, init?: RequestInit) => Promise<Response>;
|
222
|
+
export {};
|
@@ -0,0 +1,7 @@
|
|
1
|
+
export * from "./builder.gen.js";
|
2
|
+
import { Builder as BuilderRpc } from "./builder.gen.js";
|
3
|
+
export declare class SequenceBuilderClient extends BuilderRpc {
|
4
|
+
projectAccessKey: string;
|
5
|
+
constructor(projectAccessKey: string, apiUrl?: string);
|
6
|
+
_fetch: (input: RequestInfo, init?: RequestInit) => Promise<Response>;
|
7
|
+
}
|