@band-ai/band-sdk-core 0.0.0-dev.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/bandcore.js +843 -0
- package/bandcore_bg.wasm +0 -0
- package/index.d.ts +147 -0
- package/package.json +23 -0
package/bandcore.js
ADDED
|
@@ -0,0 +1,843 @@
|
|
|
1
|
+
/* @ts-self-types="./index.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Ownership ledger for the inbound message-delivery lifecycle: in-flight,
|
|
5
|
+
* ack-pending, and completed states, each scoped by `(roomId,
|
|
6
|
+
* messageId)`.
|
|
7
|
+
*/
|
|
8
|
+
class ClaimRegistry {
|
|
9
|
+
__destroy_into_raw() {
|
|
10
|
+
const ptr = this.__wbg_ptr;
|
|
11
|
+
this.__wbg_ptr = 0;
|
|
12
|
+
ClaimRegistryFinalization.unregister(this);
|
|
13
|
+
return ptr;
|
|
14
|
+
}
|
|
15
|
+
free() {
|
|
16
|
+
const ptr = this.__destroy_into_raw();
|
|
17
|
+
wasm.__wbg_claimregistry_free(ptr, 0);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* @param {any} room_id
|
|
21
|
+
* @returns {string[]}
|
|
22
|
+
*/
|
|
23
|
+
completedIds(room_id) {
|
|
24
|
+
const ret = wasm.claimregistry_completedIds(this.__wbg_ptr, room_id);
|
|
25
|
+
if (ret[3]) {
|
|
26
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
27
|
+
}
|
|
28
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
|
|
29
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
30
|
+
return v1;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* @param {any} room_id
|
|
34
|
+
*/
|
|
35
|
+
discardCompleted(room_id) {
|
|
36
|
+
const ret = wasm.claimregistry_discardCompleted(this.__wbg_ptr, room_id);
|
|
37
|
+
if (ret[1]) {
|
|
38
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* @param {any} room_id
|
|
43
|
+
* @returns {string[]}
|
|
44
|
+
*/
|
|
45
|
+
inflightIds(room_id) {
|
|
46
|
+
const ret = wasm.claimregistry_inflightIds(this.__wbg_ptr, room_id);
|
|
47
|
+
if (ret[3]) {
|
|
48
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
49
|
+
}
|
|
50
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
|
|
51
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
52
|
+
return v1;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* @param {any} room_id
|
|
56
|
+
* @param {any} message_id
|
|
57
|
+
* @returns {boolean}
|
|
58
|
+
*/
|
|
59
|
+
isAckPending(room_id, message_id) {
|
|
60
|
+
const ret = wasm.claimregistry_isAckPending(this.__wbg_ptr, room_id, message_id);
|
|
61
|
+
if (ret[2]) {
|
|
62
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
63
|
+
}
|
|
64
|
+
return ret[0] !== 0;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* @param {any} room_id
|
|
68
|
+
* @param {any} message_id
|
|
69
|
+
* @returns {boolean}
|
|
70
|
+
*/
|
|
71
|
+
isCompleted(room_id, message_id) {
|
|
72
|
+
const ret = wasm.claimregistry_isCompleted(this.__wbg_ptr, room_id, message_id);
|
|
73
|
+
if (ret[2]) {
|
|
74
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
75
|
+
}
|
|
76
|
+
return ret[0] !== 0;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* @returns {number}
|
|
80
|
+
*/
|
|
81
|
+
get maxCompleted() {
|
|
82
|
+
const ret = wasm.claimregistry_maxCompleted(this.__wbg_ptr);
|
|
83
|
+
return ret >>> 0;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* @param {number | null} [maxCompleted]
|
|
87
|
+
*/
|
|
88
|
+
constructor(maxCompleted) {
|
|
89
|
+
const ret = wasm.claimregistry_new(!isLikeNone(maxCompleted), isLikeNone(maxCompleted) ? 0 : maxCompleted);
|
|
90
|
+
if (ret[2]) {
|
|
91
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
92
|
+
}
|
|
93
|
+
this.__wbg_ptr = ret[0];
|
|
94
|
+
ClaimRegistryFinalization.register(this, this.__wbg_ptr, this);
|
|
95
|
+
return this;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* @param {any} room_id
|
|
99
|
+
* @returns {string[]}
|
|
100
|
+
*/
|
|
101
|
+
pendingAckIds(room_id) {
|
|
102
|
+
const ret = wasm.claimregistry_pendingAckIds(this.__wbg_ptr, room_id);
|
|
103
|
+
if (ret[3]) {
|
|
104
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
105
|
+
}
|
|
106
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
|
|
107
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
108
|
+
return v1;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* @param {any} room_id
|
|
112
|
+
* @param {any} message_id
|
|
113
|
+
* @returns {number}
|
|
114
|
+
*/
|
|
115
|
+
recordAckRetry(room_id, message_id) {
|
|
116
|
+
const ret = wasm.claimregistry_recordAckRetry(this.__wbg_ptr, room_id, message_id);
|
|
117
|
+
if (ret[2]) {
|
|
118
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
119
|
+
}
|
|
120
|
+
return ret[0] >>> 0;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* @param {any} room_id
|
|
124
|
+
* @param {any} message_id
|
|
125
|
+
*/
|
|
126
|
+
release(room_id, message_id) {
|
|
127
|
+
const ret = wasm.claimregistry_release(this.__wbg_ptr, room_id, message_id);
|
|
128
|
+
if (ret[1]) {
|
|
129
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* @param {any} room_id
|
|
134
|
+
* @param {any} message_id
|
|
135
|
+
*/
|
|
136
|
+
rememberAckPending(room_id, message_id) {
|
|
137
|
+
const ret = wasm.claimregistry_rememberAckPending(this.__wbg_ptr, room_id, message_id);
|
|
138
|
+
if (ret[1]) {
|
|
139
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* @param {any} room_id
|
|
144
|
+
* @param {any} message_id
|
|
145
|
+
*/
|
|
146
|
+
rememberCompleted(room_id, message_id) {
|
|
147
|
+
const ret = wasm.claimregistry_rememberCompleted(this.__wbg_ptr, room_id, message_id);
|
|
148
|
+
if (ret[1]) {
|
|
149
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* @param {any} room_id
|
|
154
|
+
* @param {any} message_id
|
|
155
|
+
* @returns {boolean}
|
|
156
|
+
*/
|
|
157
|
+
tryClaim(room_id, message_id) {
|
|
158
|
+
const ret = wasm.claimregistry_tryClaim(this.__wbg_ptr, room_id, message_id);
|
|
159
|
+
if (ret[2]) {
|
|
160
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
161
|
+
}
|
|
162
|
+
return ret[0] !== 0;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
if (Symbol.dispose) ClaimRegistry.prototype[Symbol.dispose] = ClaimRegistry.prototype.free;
|
|
166
|
+
exports.ClaimRegistry = ClaimRegistry;
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* The always-injected passive participant roster. A participant is any
|
|
170
|
+
* plain object; `add`/`setAll` read `id`, `name`, `type`, `handle`,
|
|
171
|
+
* `description` from it and returned by [`list`](Self::list) -- every
|
|
172
|
+
* other key is dropped, matching the platform's own `participant_added`/
|
|
173
|
+
* `participant_removed` field set. `id` is required and must be a string;
|
|
174
|
+
* the other four are each a string or `null`/absent.
|
|
175
|
+
*/
|
|
176
|
+
class ParticipantRoster {
|
|
177
|
+
__destroy_into_raw() {
|
|
178
|
+
const ptr = this.__wbg_ptr;
|
|
179
|
+
this.__wbg_ptr = 0;
|
|
180
|
+
ParticipantRosterFinalization.unregister(this);
|
|
181
|
+
return ptr;
|
|
182
|
+
}
|
|
183
|
+
free() {
|
|
184
|
+
const ptr = this.__destroy_into_raw();
|
|
185
|
+
wasm.__wbg_participantroster_free(ptr, 0);
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Add a participant, or merge it into the existing entry with the
|
|
189
|
+
* same `id`. Returns `true` if newly added, `false` if an existing id
|
|
190
|
+
* was refreshed in place.
|
|
191
|
+
* @param {any} participant
|
|
192
|
+
* @returns {boolean}
|
|
193
|
+
*/
|
|
194
|
+
add(participant) {
|
|
195
|
+
const ret = wasm.participantroster_add(this.__wbg_ptr, participant);
|
|
196
|
+
if (ret[2]) {
|
|
197
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
198
|
+
}
|
|
199
|
+
return ret[0] !== 0;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Whether membership or any tracked field changed since the last
|
|
203
|
+
* `markSent()`.
|
|
204
|
+
* @returns {boolean}
|
|
205
|
+
*/
|
|
206
|
+
changed() {
|
|
207
|
+
const ret = wasm.participantroster_changed(this.__wbg_ptr);
|
|
208
|
+
return ret !== 0;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* The current roster, in add order, as an array of plain objects.
|
|
212
|
+
* @returns {Array<any>}
|
|
213
|
+
*/
|
|
214
|
+
list() {
|
|
215
|
+
const ret = wasm.participantroster_list(this.__wbg_ptr);
|
|
216
|
+
if (ret[2]) {
|
|
217
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
218
|
+
}
|
|
219
|
+
return takeFromExternrefTable0(ret[0]);
|
|
220
|
+
}
|
|
221
|
+
markSent() {
|
|
222
|
+
wasm.participantroster_markSent(this.__wbg_ptr);
|
|
223
|
+
}
|
|
224
|
+
constructor() {
|
|
225
|
+
const ret = wasm.participantroster_new();
|
|
226
|
+
this.__wbg_ptr = ret;
|
|
227
|
+
ParticipantRosterFinalization.register(this, this.__wbg_ptr, this);
|
|
228
|
+
return this;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Remove the participant with this id. Returns `true` if one was
|
|
232
|
+
* removed.
|
|
233
|
+
* @param {any} participantId
|
|
234
|
+
* @returns {boolean}
|
|
235
|
+
*/
|
|
236
|
+
remove(participantId) {
|
|
237
|
+
const ret = wasm.participantroster_remove(this.__wbg_ptr, participantId);
|
|
238
|
+
if (ret[2]) {
|
|
239
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
240
|
+
}
|
|
241
|
+
return ret[0] !== 0;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Replace the roster from an authoritative array of participants.
|
|
245
|
+
* Rejects the whole snapshot -- leaving the roster unchanged -- if any
|
|
246
|
+
* id appears in it more than once, throwing a native `Error` with
|
|
247
|
+
* `.issues` and `.traceContext`.
|
|
248
|
+
* @param {any} participants
|
|
249
|
+
* @param {any} traceContext
|
|
250
|
+
*/
|
|
251
|
+
setAll(participants, traceContext) {
|
|
252
|
+
const ret = wasm.participantroster_setAll(this.__wbg_ptr, participants, traceContext);
|
|
253
|
+
if (ret[1]) {
|
|
254
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
if (Symbol.dispose) ParticipantRoster.prototype[Symbol.dispose] = ParticipantRoster.prototype.free;
|
|
259
|
+
exports.ParticipantRoster = ParticipantRoster;
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Per-message retry budget: bounded attempt/failure tracking plus
|
|
263
|
+
* `discardAttempt` for a cycle the caller's own control signal aborted
|
|
264
|
+
* before it ran the handler.
|
|
265
|
+
*/
|
|
266
|
+
class RetryTracker {
|
|
267
|
+
__destroy_into_raw() {
|
|
268
|
+
const ptr = this.__wbg_ptr;
|
|
269
|
+
this.__wbg_ptr = 0;
|
|
270
|
+
RetryTrackerFinalization.unregister(this);
|
|
271
|
+
return ptr;
|
|
272
|
+
}
|
|
273
|
+
free() {
|
|
274
|
+
const ptr = this.__destroy_into_raw();
|
|
275
|
+
wasm.__wbg_retrytracker_free(ptr, 0);
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* @param {any} message_id
|
|
279
|
+
*/
|
|
280
|
+
discardAttempt(message_id) {
|
|
281
|
+
const ret = wasm.retrytracker_discardAttempt(this.__wbg_ptr, message_id);
|
|
282
|
+
if (ret[1]) {
|
|
283
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* @param {any} message_id
|
|
288
|
+
* @returns {boolean}
|
|
289
|
+
*/
|
|
290
|
+
isPermanentlyFailed(message_id) {
|
|
291
|
+
const ret = wasm.retrytracker_isPermanentlyFailed(this.__wbg_ptr, message_id);
|
|
292
|
+
if (ret[2]) {
|
|
293
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
294
|
+
}
|
|
295
|
+
return ret[0] !== 0;
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* @param {any} message_id
|
|
299
|
+
*/
|
|
300
|
+
markPermanentlyFailed(message_id) {
|
|
301
|
+
const ret = wasm.retrytracker_markPermanentlyFailed(this.__wbg_ptr, message_id);
|
|
302
|
+
if (ret[1]) {
|
|
303
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* @param {any} message_id
|
|
308
|
+
*/
|
|
309
|
+
markSuccess(message_id) {
|
|
310
|
+
const ret = wasm.retrytracker_markSuccess(this.__wbg_ptr, message_id);
|
|
311
|
+
if (ret[1]) {
|
|
312
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* @returns {number}
|
|
317
|
+
*/
|
|
318
|
+
get maxRetries() {
|
|
319
|
+
const ret = wasm.retrytracker_maxRetries(this.__wbg_ptr);
|
|
320
|
+
return ret >>> 0;
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* @param {number | null} [maxRetries]
|
|
324
|
+
* @param {number | null} [maxTracked]
|
|
325
|
+
*/
|
|
326
|
+
constructor(maxRetries, maxTracked) {
|
|
327
|
+
const ret = wasm.retrytracker_new(!isLikeNone(maxRetries), isLikeNone(maxRetries) ? 0 : maxRetries, !isLikeNone(maxTracked), isLikeNone(maxTracked) ? 0 : maxTracked);
|
|
328
|
+
if (ret[2]) {
|
|
329
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
330
|
+
}
|
|
331
|
+
this.__wbg_ptr = ret[0];
|
|
332
|
+
RetryTrackerFinalization.register(this, this.__wbg_ptr, this);
|
|
333
|
+
return this;
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Returns `[attemptCount, exceeded]`.
|
|
337
|
+
* @param {any} message_id
|
|
338
|
+
* @returns {Array<any>}
|
|
339
|
+
*/
|
|
340
|
+
recordAttempt(message_id) {
|
|
341
|
+
const ret = wasm.retrytracker_recordAttempt(this.__wbg_ptr, message_id);
|
|
342
|
+
if (ret[2]) {
|
|
343
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
344
|
+
}
|
|
345
|
+
return takeFromExternrefTable0(ret[0]);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
if (Symbol.dispose) RetryTracker.prototype[Symbol.dispose] = RetryTracker.prototype.free;
|
|
349
|
+
exports.RetryTracker = RetryTracker;
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* Validate and normalize an inbound platform event payload.
|
|
353
|
+
*
|
|
354
|
+
* On failure throws a native `Error` with `.issues` (an array of
|
|
355
|
+
* `{path, code, message}` objects) and `.traceContext`. A non-string
|
|
356
|
+
* `eventType` or `traceContext` throws a plain `Error` without `.issues`.
|
|
357
|
+
* @param {any} event_type
|
|
358
|
+
* @param {any} raw
|
|
359
|
+
* @param {any} traceContext
|
|
360
|
+
* @returns {any}
|
|
361
|
+
*/
|
|
362
|
+
function validateEventPayload(event_type, raw, traceContext) {
|
|
363
|
+
const ret = wasm.validateEventPayload(event_type, raw, traceContext);
|
|
364
|
+
if (ret[2]) {
|
|
365
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
366
|
+
}
|
|
367
|
+
return takeFromExternrefTable0(ret[0]);
|
|
368
|
+
}
|
|
369
|
+
exports.validateEventPayload = validateEventPayload;
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Validate that `type` belongs to `system`'s allowed type set.
|
|
373
|
+
*
|
|
374
|
+
* On failure throws a native `Error` with `.issues` (an array of
|
|
375
|
+
* `{path, code, message}` objects) and `.traceContext`. An unrecognized
|
|
376
|
+
* `system` and an unrecognized `type` are independent issues and both are
|
|
377
|
+
* reported when both strings are invalid. A non-string `system`, `type`,
|
|
378
|
+
* or `traceContext` throws a plain `Error` without `.issues`, matching
|
|
379
|
+
* this crate's contract for a value that cannot be converted.
|
|
380
|
+
* @param {any} system
|
|
381
|
+
* @param {any} memoryType
|
|
382
|
+
* @param {any} traceContext
|
|
383
|
+
*/
|
|
384
|
+
function validateMemoryTypeForSystem(system, memoryType, traceContext) {
|
|
385
|
+
const ret = wasm.validateMemoryTypeForSystem(system, memoryType, traceContext);
|
|
386
|
+
if (ret[1]) {
|
|
387
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
exports.validateMemoryTypeForSystem = validateMemoryTypeForSystem;
|
|
391
|
+
function __wbg_get_imports() {
|
|
392
|
+
const import0 = {
|
|
393
|
+
__proto__: null,
|
|
394
|
+
__wbg_Error_408e67f47ca7b58b: function(arg0, arg1) {
|
|
395
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
396
|
+
return ret;
|
|
397
|
+
},
|
|
398
|
+
__wbg_String_8564e559799eccda: function(arg0, arg1) {
|
|
399
|
+
const ret = String(arg1);
|
|
400
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
401
|
+
const len1 = WASM_VECTOR_LEN;
|
|
402
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
403
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
404
|
+
},
|
|
405
|
+
__wbg___wbindgen_bigint_get_as_i64_c4ecf48528083721: function(arg0, arg1) {
|
|
406
|
+
const v = arg1;
|
|
407
|
+
const ret = typeof(v) === 'bigint' ? v : undefined;
|
|
408
|
+
getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
|
|
409
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
410
|
+
},
|
|
411
|
+
__wbg___wbindgen_boolean_get_c9c83ebd41b34df3: function(arg0) {
|
|
412
|
+
const v = arg0;
|
|
413
|
+
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
414
|
+
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
415
|
+
},
|
|
416
|
+
__wbg___wbindgen_debug_string_a57024b9c6e4a48b: function(arg0, arg1) {
|
|
417
|
+
const ret = debugString(arg1);
|
|
418
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
419
|
+
const len1 = WASM_VECTOR_LEN;
|
|
420
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
421
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
422
|
+
},
|
|
423
|
+
__wbg___wbindgen_in_ac983077f137f2e6: function(arg0, arg1) {
|
|
424
|
+
const ret = arg0 in arg1;
|
|
425
|
+
return ret;
|
|
426
|
+
},
|
|
427
|
+
__wbg___wbindgen_is_bigint_8ffbbef442139384: function(arg0) {
|
|
428
|
+
const ret = typeof(arg0) === 'bigint';
|
|
429
|
+
return ret;
|
|
430
|
+
},
|
|
431
|
+
__wbg___wbindgen_is_function_5e4570eb24ffa122: function(arg0) {
|
|
432
|
+
const ret = typeof(arg0) === 'function';
|
|
433
|
+
return ret;
|
|
434
|
+
},
|
|
435
|
+
__wbg___wbindgen_is_null_7d13f41e1a2d5140: function(arg0) {
|
|
436
|
+
const ret = arg0 === null;
|
|
437
|
+
return ret;
|
|
438
|
+
},
|
|
439
|
+
__wbg___wbindgen_is_object_a2790eb24c211ea0: function(arg0) {
|
|
440
|
+
const val = arg0;
|
|
441
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
442
|
+
return ret;
|
|
443
|
+
},
|
|
444
|
+
__wbg___wbindgen_is_string_e6f02f0ea5f20a32: function(arg0) {
|
|
445
|
+
const ret = typeof(arg0) === 'string';
|
|
446
|
+
return ret;
|
|
447
|
+
},
|
|
448
|
+
__wbg___wbindgen_is_undefined_6cff064c44e0d823: function(arg0) {
|
|
449
|
+
const ret = arg0 === undefined;
|
|
450
|
+
return ret;
|
|
451
|
+
},
|
|
452
|
+
__wbg___wbindgen_jsval_eq_0a18949a61670320: function(arg0, arg1) {
|
|
453
|
+
const ret = arg0 === arg1;
|
|
454
|
+
return ret;
|
|
455
|
+
},
|
|
456
|
+
__wbg___wbindgen_jsval_loose_eq_acf2776254a8d832: function(arg0, arg1) {
|
|
457
|
+
const ret = arg0 == arg1;
|
|
458
|
+
return ret;
|
|
459
|
+
},
|
|
460
|
+
__wbg___wbindgen_number_get_136b9679cab35cfb: function(arg0, arg1) {
|
|
461
|
+
const obj = arg1;
|
|
462
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
463
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
464
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
465
|
+
},
|
|
466
|
+
__wbg___wbindgen_string_get_d154f1e671052120: function(arg0, arg1) {
|
|
467
|
+
const obj = arg1;
|
|
468
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
469
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
470
|
+
var len1 = WASM_VECTOR_LEN;
|
|
471
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
472
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
473
|
+
},
|
|
474
|
+
__wbg___wbindgen_throw_bb96b2010945f0bc: function(arg0, arg1) {
|
|
475
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
476
|
+
},
|
|
477
|
+
__wbg_call_1c5886ab9c57d1c7: function() { return handleError(function (arg0, arg1) {
|
|
478
|
+
const ret = arg0.call(arg1);
|
|
479
|
+
return ret;
|
|
480
|
+
}, arguments); },
|
|
481
|
+
__wbg_done_669171204c3dcae2: function(arg0) {
|
|
482
|
+
const ret = arg0.done;
|
|
483
|
+
return ret;
|
|
484
|
+
},
|
|
485
|
+
__wbg_entries_7774d489e1da5f4f: function(arg0) {
|
|
486
|
+
const ret = Object.entries(arg0);
|
|
487
|
+
return ret;
|
|
488
|
+
},
|
|
489
|
+
__wbg_get_c0c8f8d7da0c03dd: function(arg0, arg1) {
|
|
490
|
+
const ret = arg0[arg1 >>> 0];
|
|
491
|
+
return ret;
|
|
492
|
+
},
|
|
493
|
+
__wbg_get_d173c0308df22d37: function() { return handleError(function (arg0, arg1) {
|
|
494
|
+
const ret = Reflect.get(arg0, arg1);
|
|
495
|
+
return ret;
|
|
496
|
+
}, arguments); },
|
|
497
|
+
__wbg_get_unchecked_e20b893aeafc3fca: function(arg0, arg1) {
|
|
498
|
+
const ret = arg0[arg1 >>> 0];
|
|
499
|
+
return ret;
|
|
500
|
+
},
|
|
501
|
+
__wbg_instanceof_ArrayBuffer_993d02d2d254cad1: function(arg0) {
|
|
502
|
+
let result;
|
|
503
|
+
try {
|
|
504
|
+
result = arg0 instanceof ArrayBuffer;
|
|
505
|
+
} catch (_) {
|
|
506
|
+
result = false;
|
|
507
|
+
}
|
|
508
|
+
const ret = result;
|
|
509
|
+
return ret;
|
|
510
|
+
},
|
|
511
|
+
__wbg_instanceof_Map_9a4d6ead180ae3a9: function(arg0) {
|
|
512
|
+
let result;
|
|
513
|
+
try {
|
|
514
|
+
result = arg0 instanceof Map;
|
|
515
|
+
} catch (_) {
|
|
516
|
+
result = false;
|
|
517
|
+
}
|
|
518
|
+
const ret = result;
|
|
519
|
+
return ret;
|
|
520
|
+
},
|
|
521
|
+
__wbg_instanceof_Uint8Array_f935dbb0aa7cdeed: function(arg0) {
|
|
522
|
+
let result;
|
|
523
|
+
try {
|
|
524
|
+
result = arg0 instanceof Uint8Array;
|
|
525
|
+
} catch (_) {
|
|
526
|
+
result = false;
|
|
527
|
+
}
|
|
528
|
+
const ret = result;
|
|
529
|
+
return ret;
|
|
530
|
+
},
|
|
531
|
+
__wbg_isArray_6339f732981044bf: function(arg0) {
|
|
532
|
+
const ret = Array.isArray(arg0);
|
|
533
|
+
return ret;
|
|
534
|
+
},
|
|
535
|
+
__wbg_isSafeInteger_f3d6cd19ccfe4512: function(arg0) {
|
|
536
|
+
const ret = Number.isSafeInteger(arg0);
|
|
537
|
+
return ret;
|
|
538
|
+
},
|
|
539
|
+
__wbg_iterator_5cebbb86e33c6dd6: function() {
|
|
540
|
+
const ret = Symbol.iterator;
|
|
541
|
+
return ret;
|
|
542
|
+
},
|
|
543
|
+
__wbg_length_36bd29c6848c2144: function(arg0) {
|
|
544
|
+
const ret = arg0.length;
|
|
545
|
+
return ret;
|
|
546
|
+
},
|
|
547
|
+
__wbg_length_ecfa2c63d3d0d82c: function(arg0) {
|
|
548
|
+
const ret = arg0.length;
|
|
549
|
+
return ret;
|
|
550
|
+
},
|
|
551
|
+
__wbg_new_116be93542d39019: function() {
|
|
552
|
+
const ret = new Array();
|
|
553
|
+
return ret;
|
|
554
|
+
},
|
|
555
|
+
__wbg_new_358857d90afd5a2d: function(arg0, arg1) {
|
|
556
|
+
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
557
|
+
return ret;
|
|
558
|
+
},
|
|
559
|
+
__wbg_new_77cc4f4f472aeb81: function(arg0) {
|
|
560
|
+
const ret = new Uint8Array(arg0);
|
|
561
|
+
return ret;
|
|
562
|
+
},
|
|
563
|
+
__wbg_new_cdf041679ded4c5f: function() {
|
|
564
|
+
const ret = new Map();
|
|
565
|
+
return ret;
|
|
566
|
+
},
|
|
567
|
+
__wbg_new_ebe3e0f6837f0879: function() {
|
|
568
|
+
const ret = new Object();
|
|
569
|
+
return ret;
|
|
570
|
+
},
|
|
571
|
+
__wbg_next_42cf16ee0dafc9e2: function() { return handleError(function (arg0) {
|
|
572
|
+
const ret = arg0.next();
|
|
573
|
+
return ret;
|
|
574
|
+
}, arguments); },
|
|
575
|
+
__wbg_next_8f26b64fa5e9f64b: function(arg0) {
|
|
576
|
+
const ret = arg0.next;
|
|
577
|
+
return ret;
|
|
578
|
+
},
|
|
579
|
+
__wbg_of_598c0ff0cd48a890: function(arg0, arg1) {
|
|
580
|
+
const ret = Array.of(arg0, arg1);
|
|
581
|
+
return ret;
|
|
582
|
+
},
|
|
583
|
+
__wbg_prototypesetcall_de8e0d9553586985: function(arg0, arg1, arg2) {
|
|
584
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
585
|
+
},
|
|
586
|
+
__wbg_push_adb0107829f02d75: function(arg0, arg1) {
|
|
587
|
+
const ret = arg0.push(arg1);
|
|
588
|
+
return ret;
|
|
589
|
+
},
|
|
590
|
+
__wbg_set_014226dfeca53178: function(arg0, arg1, arg2) {
|
|
591
|
+
const ret = arg0.set(arg1, arg2);
|
|
592
|
+
return ret;
|
|
593
|
+
},
|
|
594
|
+
__wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
|
|
595
|
+
arg0[arg1] = arg2;
|
|
596
|
+
},
|
|
597
|
+
__wbg_set_8155bb79a948541b: function() { return handleError(function (arg0, arg1, arg2) {
|
|
598
|
+
const ret = Reflect.set(arg0, arg1, arg2);
|
|
599
|
+
return ret;
|
|
600
|
+
}, arguments); },
|
|
601
|
+
__wbg_set_a80955eb93b145c6: function(arg0, arg1, arg2) {
|
|
602
|
+
arg0[arg1 >>> 0] = arg2;
|
|
603
|
+
},
|
|
604
|
+
__wbg_value_1e2369fab29b420e: function(arg0) {
|
|
605
|
+
const ret = arg0.value;
|
|
606
|
+
return ret;
|
|
607
|
+
},
|
|
608
|
+
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
609
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
610
|
+
const ret = arg0;
|
|
611
|
+
return ret;
|
|
612
|
+
},
|
|
613
|
+
__wbindgen_cast_0000000000000002: function(arg0) {
|
|
614
|
+
// Cast intrinsic for `I64 -> Externref`.
|
|
615
|
+
const ret = arg0;
|
|
616
|
+
return ret;
|
|
617
|
+
},
|
|
618
|
+
__wbindgen_cast_0000000000000003: function(arg0, arg1) {
|
|
619
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
620
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
621
|
+
return ret;
|
|
622
|
+
},
|
|
623
|
+
__wbindgen_cast_0000000000000004: function(arg0) {
|
|
624
|
+
// Cast intrinsic for `U64 -> Externref`.
|
|
625
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
626
|
+
return ret;
|
|
627
|
+
},
|
|
628
|
+
__wbindgen_init_externref_table: function() {
|
|
629
|
+
const table = wasm.__wbindgen_externrefs;
|
|
630
|
+
const offset = table.grow(4);
|
|
631
|
+
table.set(0, undefined);
|
|
632
|
+
table.set(offset + 0, undefined);
|
|
633
|
+
table.set(offset + 1, null);
|
|
634
|
+
table.set(offset + 2, true);
|
|
635
|
+
table.set(offset + 3, false);
|
|
636
|
+
},
|
|
637
|
+
};
|
|
638
|
+
return {
|
|
639
|
+
__proto__: null,
|
|
640
|
+
"./bandcore_bg.js": import0,
|
|
641
|
+
};
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
const ClaimRegistryFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
645
|
+
? { register: () => {}, unregister: () => {} }
|
|
646
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_claimregistry_free(ptr, 1));
|
|
647
|
+
const ParticipantRosterFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
648
|
+
? { register: () => {}, unregister: () => {} }
|
|
649
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_participantroster_free(ptr, 1));
|
|
650
|
+
const RetryTrackerFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
651
|
+
? { register: () => {}, unregister: () => {} }
|
|
652
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_retrytracker_free(ptr, 1));
|
|
653
|
+
|
|
654
|
+
function addToExternrefTable0(obj) {
|
|
655
|
+
const idx = wasm.__externref_table_alloc();
|
|
656
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
657
|
+
return idx;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
function debugString(val) {
|
|
661
|
+
// primitive types
|
|
662
|
+
const type = typeof val;
|
|
663
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
664
|
+
return `${val}`;
|
|
665
|
+
}
|
|
666
|
+
if (type == 'string') {
|
|
667
|
+
return `"${val}"`;
|
|
668
|
+
}
|
|
669
|
+
if (type == 'symbol') {
|
|
670
|
+
const description = val.description;
|
|
671
|
+
if (description == null) {
|
|
672
|
+
return 'Symbol';
|
|
673
|
+
} else {
|
|
674
|
+
return `Symbol(${description})`;
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
if (type == 'function') {
|
|
678
|
+
const name = val.name;
|
|
679
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
680
|
+
return `Function(${name})`;
|
|
681
|
+
} else {
|
|
682
|
+
return 'Function';
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
// objects
|
|
686
|
+
if (Array.isArray(val)) {
|
|
687
|
+
const length = val.length;
|
|
688
|
+
let debug = '[';
|
|
689
|
+
if (length > 0) {
|
|
690
|
+
debug += debugString(val[0]);
|
|
691
|
+
}
|
|
692
|
+
for(let i = 1; i < length; i++) {
|
|
693
|
+
debug += ', ' + debugString(val[i]);
|
|
694
|
+
}
|
|
695
|
+
debug += ']';
|
|
696
|
+
return debug;
|
|
697
|
+
}
|
|
698
|
+
// Test for built-in
|
|
699
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
700
|
+
let className;
|
|
701
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
702
|
+
className = builtInMatches[1];
|
|
703
|
+
} else {
|
|
704
|
+
// Failed to match the standard '[object ClassName]'
|
|
705
|
+
return toString.call(val);
|
|
706
|
+
}
|
|
707
|
+
if (className == 'Object') {
|
|
708
|
+
// we're a user defined class or Object
|
|
709
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
710
|
+
// easier than looping through ownProperties of `val`.
|
|
711
|
+
try {
|
|
712
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
713
|
+
} catch (_) {
|
|
714
|
+
return 'Object';
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
// errors
|
|
718
|
+
if (val instanceof Error) {
|
|
719
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
720
|
+
}
|
|
721
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
722
|
+
return className;
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
function getArrayJsValueFromWasm0(ptr, len) {
|
|
726
|
+
ptr = ptr >>> 0;
|
|
727
|
+
const mem = getDataViewMemory0();
|
|
728
|
+
const result = [];
|
|
729
|
+
for (let i = ptr; i < ptr + 4 * len; i += 4) {
|
|
730
|
+
result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
|
|
731
|
+
}
|
|
732
|
+
wasm.__externref_drop_slice(ptr, len);
|
|
733
|
+
return result;
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
737
|
+
ptr = ptr >>> 0;
|
|
738
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
let cachedDataViewMemory0 = null;
|
|
742
|
+
function getDataViewMemory0() {
|
|
743
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
744
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
745
|
+
}
|
|
746
|
+
return cachedDataViewMemory0;
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
function getStringFromWasm0(ptr, len) {
|
|
750
|
+
return decodeText(ptr >>> 0, len);
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
let cachedUint8ArrayMemory0 = null;
|
|
754
|
+
function getUint8ArrayMemory0() {
|
|
755
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
756
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
757
|
+
}
|
|
758
|
+
return cachedUint8ArrayMemory0;
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
function handleError(f, args) {
|
|
762
|
+
try {
|
|
763
|
+
return f.apply(this, args);
|
|
764
|
+
} catch (e) {
|
|
765
|
+
const idx = addToExternrefTable0(e);
|
|
766
|
+
wasm.__wbindgen_exn_store(idx);
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
function isLikeNone(x) {
|
|
771
|
+
return x === undefined || x === null;
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
775
|
+
if (realloc === undefined) {
|
|
776
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
777
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
778
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
779
|
+
WASM_VECTOR_LEN = buf.length;
|
|
780
|
+
return ptr;
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
let len = arg.length;
|
|
784
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
785
|
+
|
|
786
|
+
const mem = getUint8ArrayMemory0();
|
|
787
|
+
|
|
788
|
+
let offset = 0;
|
|
789
|
+
|
|
790
|
+
for (; offset < len; offset++) {
|
|
791
|
+
const code = arg.charCodeAt(offset);
|
|
792
|
+
if (code > 0x7F) break;
|
|
793
|
+
mem[ptr + offset] = code;
|
|
794
|
+
}
|
|
795
|
+
if (offset !== len) {
|
|
796
|
+
if (offset !== 0) {
|
|
797
|
+
arg = arg.slice(offset);
|
|
798
|
+
}
|
|
799
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
800
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
801
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
802
|
+
|
|
803
|
+
offset += ret.written;
|
|
804
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
WASM_VECTOR_LEN = offset;
|
|
808
|
+
return ptr;
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
function takeFromExternrefTable0(idx) {
|
|
812
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
813
|
+
wasm.__externref_table_dealloc(idx);
|
|
814
|
+
return value;
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
818
|
+
cachedTextDecoder.decode();
|
|
819
|
+
function decodeText(ptr, len) {
|
|
820
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
const cachedTextEncoder = new TextEncoder();
|
|
824
|
+
|
|
825
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
826
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
827
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
828
|
+
view.set(buf);
|
|
829
|
+
return {
|
|
830
|
+
read: arg.length,
|
|
831
|
+
written: buf.length
|
|
832
|
+
};
|
|
833
|
+
};
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
let WASM_VECTOR_LEN = 0;
|
|
837
|
+
|
|
838
|
+
const wasmPath = `${__dirname}/bandcore_bg.wasm`;
|
|
839
|
+
const wasmBytes = require('fs').readFileSync(wasmPath);
|
|
840
|
+
const wasmModule = new WebAssembly.Module(wasmBytes);
|
|
841
|
+
let wasmInstance = new WebAssembly.Instance(wasmModule, __wbg_get_imports());
|
|
842
|
+
let wasm = wasmInstance.exports;
|
|
843
|
+
wasm.__wbindgen_start();
|
package/bandcore_bg.wasm
ADDED
|
Binary file
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/** Canonical inbound wire-event names `validateEventPayload` accepts. */
|
|
2
|
+
export type EventType =
|
|
3
|
+
| "message_created"
|
|
4
|
+
| "message_updated"
|
|
5
|
+
| "room_added"
|
|
6
|
+
| "room_removed"
|
|
7
|
+
| "room_deleted"
|
|
8
|
+
| "participant_added"
|
|
9
|
+
| "participant_removed"
|
|
10
|
+
| "contact_request_received"
|
|
11
|
+
| "contact_request_updated"
|
|
12
|
+
| "contact_added"
|
|
13
|
+
| "contact_removed"
|
|
14
|
+
| "supersede"
|
|
15
|
+
| "agent.control"
|
|
16
|
+
| "event_created";
|
|
17
|
+
|
|
18
|
+
export interface ValidationIssue {
|
|
19
|
+
path: string;
|
|
20
|
+
code: "missing" | "wrong_type" | "invalid_value";
|
|
21
|
+
message: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Validates and normalizes an inbound platform event payload.
|
|
26
|
+
*
|
|
27
|
+
* On failure throws a native `Error` with `.issues` (an array of
|
|
28
|
+
* `{path, code, message}` objects) and `.traceContext`. A non-string
|
|
29
|
+
* `eventType` or `traceContext` throws a plain `Error` without `.issues`.
|
|
30
|
+
*/
|
|
31
|
+
export function validateEventPayload(
|
|
32
|
+
eventType: string,
|
|
33
|
+
raw: unknown,
|
|
34
|
+
traceContext?: string | null,
|
|
35
|
+
): unknown;
|
|
36
|
+
|
|
37
|
+
/** Memory tier; constrains which `type` values are valid for it. */
|
|
38
|
+
export type MemorySystem = "sensory" | "working" | "long_term";
|
|
39
|
+
|
|
40
|
+
/** Content kind; must match the chosen {@link MemorySystem} tier. */
|
|
41
|
+
export type MemoryType =
|
|
42
|
+
| "iconic"
|
|
43
|
+
| "echoic"
|
|
44
|
+
| "haptic"
|
|
45
|
+
| "episodic"
|
|
46
|
+
| "semantic"
|
|
47
|
+
| "procedural";
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Validates that `type` belongs to `system`'s allowed type set.
|
|
51
|
+
*
|
|
52
|
+
* On failure throws a native `Error` with `.issues` (an array of
|
|
53
|
+
* `{path, code, message}` objects) and `.traceContext`. An unrecognized
|
|
54
|
+
* `system` and an unrecognized `type` are independent issues and both are
|
|
55
|
+
* reported when both strings are invalid. A non-string `system`, `type`,
|
|
56
|
+
* or `traceContext` throws a plain `Error` without `.issues`.
|
|
57
|
+
*/
|
|
58
|
+
export function validateMemoryTypeForSystem(
|
|
59
|
+
system: string,
|
|
60
|
+
type: string,
|
|
61
|
+
traceContext?: string | null,
|
|
62
|
+
): void;
|
|
63
|
+
|
|
64
|
+
/** A roster entry read by `ParticipantRoster`; every other key is ignored. */
|
|
65
|
+
export interface ParticipantFields {
|
|
66
|
+
id: string;
|
|
67
|
+
name?: string | null;
|
|
68
|
+
type?: string | null;
|
|
69
|
+
handle?: string | null;
|
|
70
|
+
description?: string | null;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Ownership ledger for the inbound message-delivery lifecycle: in-flight,
|
|
75
|
+
* ack-pending, and completed states, each scoped by `(roomId, messageId)`.
|
|
76
|
+
*
|
|
77
|
+
* Throws if `maxCompleted` is not a non-negative integer in range, or is
|
|
78
|
+
* `0` -- a zero capacity would evict every completed entry the instant it
|
|
79
|
+
* is recorded. Every `roomId`/`messageId` argument below throws a plain
|
|
80
|
+
* `Error` if it is not a string.
|
|
81
|
+
*/
|
|
82
|
+
export class ClaimRegistry {
|
|
83
|
+
constructor(maxCompleted?: number);
|
|
84
|
+
readonly maxCompleted: number;
|
|
85
|
+
tryClaim(roomId: string, messageId: string): boolean;
|
|
86
|
+
release(roomId: string, messageId: string): void;
|
|
87
|
+
inflightIds(roomId: string): string[];
|
|
88
|
+
isCompleted(roomId: string, messageId: string): boolean;
|
|
89
|
+
completedIds(roomId: string): string[];
|
|
90
|
+
discardCompleted(roomId: string): void;
|
|
91
|
+
rememberCompleted(roomId: string, messageId: string): void;
|
|
92
|
+
isAckPending(roomId: string, messageId: string): boolean;
|
|
93
|
+
rememberAckPending(roomId: string, messageId: string): void;
|
|
94
|
+
pendingAckIds(roomId: string): string[];
|
|
95
|
+
recordAckRetry(roomId: string, messageId: string): number;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Per-message retry budget: bounded attempt/failure tracking plus
|
|
100
|
+
* `discardAttempt` for a cycle the caller's own control signal aborted
|
|
101
|
+
* before it ran the handler.
|
|
102
|
+
*
|
|
103
|
+
* Throws if `maxRetries` or `maxTracked` is not a non-negative integer in
|
|
104
|
+
* range, or if `maxTracked` is `0` -- a zero capacity would evict every
|
|
105
|
+
* attempt the instant it is recorded. Every `messageId` argument below
|
|
106
|
+
* throws a plain `Error` if it is not a string.
|
|
107
|
+
*/
|
|
108
|
+
export class RetryTracker {
|
|
109
|
+
constructor(maxRetries?: number, maxTracked?: number);
|
|
110
|
+
readonly maxRetries: number;
|
|
111
|
+
/**
|
|
112
|
+
* Bounded at maxTracked distinct IDs, oldest-first -- a message can stop
|
|
113
|
+
* reporting permanently failed once enough newer IDs have failed too.
|
|
114
|
+
*/
|
|
115
|
+
isPermanentlyFailed(messageId: string): boolean;
|
|
116
|
+
/** Returns `[attemptCount, exceeded]`. */
|
|
117
|
+
recordAttempt(messageId: string): [number, boolean];
|
|
118
|
+
markSuccess(messageId: string): void;
|
|
119
|
+
discardAttempt(messageId: string): void;
|
|
120
|
+
markPermanentlyFailed(messageId: string): void;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* The always-injected passive participant roster. `add`/`setAll` read only
|
|
125
|
+
* `id`, `name`, `type`, `handle`, `description` from each participant --
|
|
126
|
+
* every other key is dropped.
|
|
127
|
+
*/
|
|
128
|
+
export class ParticipantRoster {
|
|
129
|
+
constructor();
|
|
130
|
+
/**
|
|
131
|
+
* Throws a native `Error` if `participant` is not a plain object, its
|
|
132
|
+
* `id` is missing/not a string, or another tracked field is not a
|
|
133
|
+
* string or `null`.
|
|
134
|
+
*/
|
|
135
|
+
add(participant: ParticipantFields): boolean;
|
|
136
|
+
/** Throws a plain `Error` if `participantId` is not a string. */
|
|
137
|
+
remove(participantId: string): boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Throws a native `Error` with `.issues` and `.traceContext`, leaving the
|
|
140
|
+
* roster unchanged, if `participants` names an id twice. Throws a plain
|
|
141
|
+
* `Error` without `.issues` if `traceContext` is not a string or `null`.
|
|
142
|
+
*/
|
|
143
|
+
setAll(participants: ParticipantFields[], traceContext?: string | null): void;
|
|
144
|
+
list(): ParticipantFields[];
|
|
145
|
+
changed(): boolean;
|
|
146
|
+
markSent(): void;
|
|
147
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@band-ai/band-sdk-core",
|
|
3
|
+
"version": "0.0.0-dev.0",
|
|
4
|
+
"description": "Shared Band event-payload validation",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/band-ai/band-sdk-core"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"bandcore.js",
|
|
12
|
+
"bandcore_bg.wasm",
|
|
13
|
+
"index.d.ts"
|
|
14
|
+
],
|
|
15
|
+
"main": "./bandcore.js",
|
|
16
|
+
"types": "./index.d.ts",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./index.d.ts",
|
|
20
|
+
"default": "./bandcore.js"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|