@cero-base/cero 2.11.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +6 -5
- package/src/build/index.js +296 -57
- package/src/build/internal.js +80 -5
- package/src/build/schemas.js +118 -25
- package/src/extensions/mirror.js +2 -1
- package/src/extensions/profile-sync.js +17 -1
- package/src/handle/index.js +1222 -189
- package/src/index.js +68 -35
- package/src/lib/constants.js +4 -4
- package/src/lib/operators.js +66 -14
- package/src/lib/peek.js +14 -8
- package/src/lib/reserved.js +61 -0
- package/src/lib/spec.js +7 -1
- package/src/lib/swap.js +59 -6
- package/src/local/index.js +6 -2
- package/src/push/index.js +26 -13
- package/src/rpc/client.js +30 -10
- package/src/rpc/push.js +9 -3
- package/src/rpc/server.js +134 -51
- package/types/build/internal.d.ts +57 -0
- package/types/build/schemas.d.ts +58 -5
- package/types/extensions/index.d.ts +3 -0
- package/types/extensions/profile-sync.d.ts +1 -1
- package/types/handle/index.d.ts +123 -15
- package/types/index.d.ts +9 -6
- package/types/lib/constants.d.ts +2 -2
- package/types/lib/operators.d.ts +26 -6
- package/types/lib/peek.d.ts +7 -4
- package/types/lib/reserved.d.ts +1 -0
- package/types/lib/spec.d.ts +35 -2
- package/types/lib/swap.d.ts +28 -3
- package/types/push/index.d.ts +4 -12
- package/types/rpc/client.d.ts +35 -18
- package/types/rpc/server.d.ts +24 -3
- package/src/handle/join.js +0 -139
- package/types/handle/join.d.ts +0 -63
package/src/rpc/server.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import c from 'compact-encoding'
|
|
2
2
|
import safetyCatch from 'safety-catch'
|
|
3
|
+
import AbortController from 'bare-abort-controller'
|
|
3
4
|
|
|
4
5
|
import { RPCServer, bindCodec } from '@cero-base/core/rpc'
|
|
5
6
|
import { CeroError } from '@cero-base/core/errors'
|
|
6
7
|
|
|
7
8
|
import { cero, restore, link } from '../index.js'
|
|
9
|
+
import { peek } from '../lib/peek.js'
|
|
8
10
|
import {
|
|
9
11
|
put,
|
|
10
12
|
set,
|
|
@@ -15,6 +17,7 @@ import {
|
|
|
15
17
|
invite,
|
|
16
18
|
revoke,
|
|
17
19
|
rotate,
|
|
20
|
+
removed,
|
|
18
21
|
accept,
|
|
19
22
|
deny,
|
|
20
23
|
cancel,
|
|
@@ -35,6 +38,7 @@ const VERBS = new Map(
|
|
|
35
38
|
invite,
|
|
36
39
|
revoke,
|
|
37
40
|
rotate,
|
|
41
|
+
removed,
|
|
38
42
|
accept,
|
|
39
43
|
deny,
|
|
40
44
|
cancel,
|
|
@@ -73,9 +77,9 @@ const VERBS = new Map(
|
|
|
73
77
|
*/
|
|
74
78
|
|
|
75
79
|
/**
|
|
76
|
-
* IPC-side RPC server for cero. Bridges an `hrpc` channel to a live `Handle` tree:
|
|
77
|
-
* root via `cero()` as soon as it opens, so the network is up while the UI still loads
|
|
78
|
-
* exposes data ops, pairing, and handle lifecycle.
|
|
80
|
+
* IPC-side RPC server for cero. Bridges an `hrpc` channel to a live `Handle` tree: a store that holds an identity
|
|
81
|
+
* boots its root via `cero()` as soon as it opens, so the network is up while the UI still loads; a new one waits
|
|
82
|
+
* for the client to say how, by init, restore or link. Then it exposes data ops, pairing, and handle lifecycle.
|
|
79
83
|
*/
|
|
80
84
|
export class Server extends RPCServer {
|
|
81
85
|
/**
|
|
@@ -95,6 +99,8 @@ export class Server extends RPCServer {
|
|
|
95
99
|
this.opts = { ...opts, onerror: (err) => this._onerror(err) }
|
|
96
100
|
/** @type {Set<object>} open error streams, one per connected client */
|
|
97
101
|
this._errors = new Set()
|
|
102
|
+
/** @private */
|
|
103
|
+
this._reported = new WeakSet()
|
|
98
104
|
/** @type {Context | null} */
|
|
99
105
|
this.me = null
|
|
100
106
|
/** @type {Map<string, Context>} */
|
|
@@ -105,7 +111,13 @@ export class Server extends RPCServer {
|
|
|
105
111
|
this._held = new Map()
|
|
106
112
|
/** @private */
|
|
107
113
|
this._booting = null
|
|
114
|
+
/** @private */
|
|
115
|
+
this._adopting = null
|
|
116
|
+
/** @private */
|
|
117
|
+
this._stop = new AbortController()
|
|
108
118
|
this._wireInit()
|
|
119
|
+
this._wireRestore()
|
|
120
|
+
this._wireLink()
|
|
109
121
|
}
|
|
110
122
|
|
|
111
123
|
/**
|
|
@@ -129,34 +141,78 @@ export class Server extends RPCServer {
|
|
|
129
141
|
/** @private */
|
|
130
142
|
async _open() {
|
|
131
143
|
await super._open()
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
144
|
+
// its error is the app's even with no request waiting on it, unless the close stopped it
|
|
145
|
+
if (await peek(this.storage, this.spec, this.opts)) {
|
|
146
|
+
this._start().catch((err) => this.closing || this._onerror(err))
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Open the root, as `how` says on a new store: a phrase recovers, an invite links, neither creates.
|
|
152
|
+
* @private
|
|
153
|
+
*/
|
|
154
|
+
_start(how = {}) {
|
|
155
|
+
const booting = this._boot(how)
|
|
156
|
+
this._booting = booting
|
|
157
|
+
// it surfaces on the request that waits for it; the next one starts over
|
|
158
|
+
booting.catch(() => {
|
|
159
|
+
if (this._booting === booting) this._booting = null
|
|
160
|
+
})
|
|
161
|
+
return booting
|
|
135
162
|
}
|
|
136
163
|
|
|
137
164
|
/** @private */
|
|
138
|
-
async _boot() {
|
|
139
|
-
|
|
165
|
+
async _boot(how) {
|
|
166
|
+
// a close stops a recovery or a link still waiting for a device: the next open goes on with it
|
|
167
|
+
const opts = { ...this.opts, ...how, signal: this._stop.signal }
|
|
168
|
+
this.me = await cero(this.storage, this.spec, opts)
|
|
169
|
+
try {
|
|
170
|
+
await this.me.fileServer.listen()
|
|
171
|
+
this._wireData()
|
|
172
|
+
this._wireHandles()
|
|
173
|
+
this._wireVerbs()
|
|
174
|
+
} catch (err) {
|
|
175
|
+
// the next start opens the same store, whose lock a root left open here still holds
|
|
176
|
+
const me = this.me
|
|
177
|
+
this.me = null
|
|
178
|
+
await me.close().catch(this.opts.onerror)
|
|
179
|
+
throw err
|
|
180
|
+
}
|
|
140
181
|
this.handles.set(this.me.id, this.me)
|
|
141
|
-
await this.me.fileServer.listen()
|
|
142
|
-
this._wireData()
|
|
143
|
-
this._wireHandles()
|
|
144
|
-
this._wireVerbs()
|
|
145
|
-
this._wireRestore()
|
|
146
|
-
this._wireLink()
|
|
147
182
|
}
|
|
148
183
|
|
|
149
184
|
/** @private */
|
|
150
185
|
async _close() {
|
|
186
|
+
this._stop.abort()
|
|
151
187
|
await this._booting?.catch(() => {})
|
|
152
188
|
if (this.me) {
|
|
153
189
|
try {
|
|
154
190
|
await this.me.close()
|
|
155
191
|
} catch {}
|
|
156
192
|
}
|
|
193
|
+
// a link or a restore past its commit resolves with an open root, closed before this ends
|
|
194
|
+
await this._adopting
|
|
157
195
|
await super._close()
|
|
158
196
|
}
|
|
159
197
|
|
|
198
|
+
/**
|
|
199
|
+
* The root a restore or a link resolves with is the one served from here on; with the server closing it closes.
|
|
200
|
+
* @private
|
|
201
|
+
*/
|
|
202
|
+
_adopt(swapping) {
|
|
203
|
+
const adopted = swapping.then(async (me) => {
|
|
204
|
+
if (this.closing) {
|
|
205
|
+
await me.close()
|
|
206
|
+
throw CeroError.CLOSED('Server')
|
|
207
|
+
}
|
|
208
|
+
this.me = me
|
|
209
|
+
this.handles = new Map([[me.id, me]])
|
|
210
|
+
this._held.clear()
|
|
211
|
+
})
|
|
212
|
+
this._adopting = adopted.catch(() => {})
|
|
213
|
+
return adopted
|
|
214
|
+
}
|
|
215
|
+
|
|
160
216
|
/**
|
|
161
217
|
* End every watch stream bound to a handle (e.g. when it closes or leaves).
|
|
162
218
|
* @private
|
|
@@ -170,6 +226,9 @@ export class Server extends RPCServer {
|
|
|
170
226
|
|
|
171
227
|
/** @private */
|
|
172
228
|
_onerror(err) {
|
|
229
|
+
// a failed start rejects every request that waits on it, and reaches onerror once
|
|
230
|
+
if (this._reported.has(err)) return
|
|
231
|
+
if (err instanceof Error) this._reported.add(err)
|
|
173
232
|
if (!this._errors.size) return this._report(err)
|
|
174
233
|
const frame = {
|
|
175
234
|
message: err?.message || String(err),
|
|
@@ -186,12 +245,14 @@ export class Server extends RPCServer {
|
|
|
186
245
|
*/
|
|
187
246
|
_wireInit() {
|
|
188
247
|
this.rpc.onErrors((stream) => {
|
|
248
|
+
closeWithWire(stream)
|
|
189
249
|
this._errors.add(stream)
|
|
190
250
|
stream.on('error', safetyCatch)
|
|
191
251
|
stream.on('close', () => this._errors.delete(stream))
|
|
192
252
|
})
|
|
193
|
-
this.
|
|
194
|
-
await this.
|
|
253
|
+
this._on('onInit', async () => {
|
|
254
|
+
await this.ready()
|
|
255
|
+
await (this._booting ?? this._start())
|
|
195
256
|
// a reloaded UI is a new client on the same worker: it re-attaches, its old streams end, and every open the old
|
|
196
257
|
// page held is let go for it, as it never closes them
|
|
197
258
|
for (const handle of this._watchStreams.keys()) this._endWatches(handle)
|
|
@@ -205,11 +266,13 @@ export class Server extends RPCServer {
|
|
|
205
266
|
* @private
|
|
206
267
|
*/
|
|
207
268
|
_wireRestore() {
|
|
208
|
-
this.
|
|
209
|
-
|
|
210
|
-
this.
|
|
211
|
-
|
|
212
|
-
|
|
269
|
+
this._on('onRestore', async ({ phrase }) => {
|
|
270
|
+
await this.ready()
|
|
271
|
+
if (!this._booting) await this._start({ phrase })
|
|
272
|
+
else {
|
|
273
|
+
await this._booting
|
|
274
|
+
await this._adopt(restore(this.me, phrase))
|
|
275
|
+
}
|
|
213
276
|
return this._identity()
|
|
214
277
|
})
|
|
215
278
|
}
|
|
@@ -220,14 +283,18 @@ export class Server extends RPCServer {
|
|
|
220
283
|
*/
|
|
221
284
|
_wireLink() {
|
|
222
285
|
this.rpc.onLink((stream) => {
|
|
286
|
+
closeWithWire(stream)
|
|
223
287
|
stream.on('error', safetyCatch)
|
|
224
288
|
const run = async () => {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
this.
|
|
230
|
-
|
|
289
|
+
await this.ready()
|
|
290
|
+
const { invite } = stream.data
|
|
291
|
+
const onrequest = (id) => stream.write({ request: id })
|
|
292
|
+
// as link() waits: the invite's lifetime, a denial ends it
|
|
293
|
+
if (!this._booting) await this._start({ invite, onrequest, recoveryTimeout: 0 })
|
|
294
|
+
else {
|
|
295
|
+
await this._booting
|
|
296
|
+
await this._adopt(link(this.me, invite, { onrequest }))
|
|
297
|
+
}
|
|
231
298
|
stream.write({ request: '', ...this._identity() })
|
|
232
299
|
stream.end()
|
|
233
300
|
}
|
|
@@ -244,42 +311,42 @@ export class Server extends RPCServer {
|
|
|
244
311
|
* @private
|
|
245
312
|
*/
|
|
246
313
|
_wireData() {
|
|
247
|
-
this.
|
|
314
|
+
this._on('onAddFile', async ({ handle, data, name, type }) => {
|
|
248
315
|
const h = this._resolve(handle)
|
|
249
316
|
const { data: file } = await put(h.files, { data, type: type || '', name: name || null })
|
|
250
317
|
const { data: row } = await get(h.files, file.id)
|
|
251
318
|
return { data: h.spec.codec.encodeRow(h.files.schema, row) }
|
|
252
319
|
})
|
|
253
320
|
|
|
254
|
-
this.
|
|
321
|
+
this._on('onAddRow', async ({ handle, ref, data, local }) => {
|
|
255
322
|
const { ref: r, codec, info } = this._refOf(handle, ref, local)
|
|
256
323
|
const { data: row } = await put(r, received(codec.decodeRow(r.schema, data), info))
|
|
257
324
|
return { data: codec.encodeRow(r.schema, row) }
|
|
258
325
|
})
|
|
259
326
|
|
|
260
|
-
this.
|
|
327
|
+
this._on('onSet', async ({ handle, ref, data, fields, local, noUpsert }) => {
|
|
261
328
|
const { ref: r, codec, info } = this._refOf(handle, ref, local)
|
|
262
329
|
const row = received(codec.decodeRow(r.schema, data), info, fields)
|
|
263
330
|
const result = await set(r, row, { upsert: !noUpsert })
|
|
264
331
|
return { data: result ? codec.encodeRow(r.schema, result.data) : null }
|
|
265
332
|
})
|
|
266
333
|
|
|
267
|
-
this.
|
|
334
|
+
this._on('onGet', async ({ handle, ref, query, local }) => {
|
|
268
335
|
const { ref: r, codec } = this._refOf(handle, ref, local)
|
|
269
336
|
const q = fromWire(query)
|
|
270
337
|
return encodeGet(r, codec, q, await get(r, q))
|
|
271
338
|
})
|
|
272
339
|
|
|
273
|
-
this.
|
|
340
|
+
this._on('onDel', async ({ handle, ref, id, local }) => {
|
|
274
341
|
await del(this._refOf(handle, ref, local).ref, id)
|
|
275
342
|
return {}
|
|
276
343
|
})
|
|
277
344
|
|
|
278
345
|
this.rpc.onWatch((stream) => {
|
|
279
346
|
const { handle, ref, local } = stream.data
|
|
280
|
-
|
|
281
|
-
let r, codec, live
|
|
347
|
+
let query, r, codec, live
|
|
282
348
|
try {
|
|
349
|
+
query = fromWire(stream.data.query)
|
|
283
350
|
;({ ref: r, codec } = this._refOf(handle, ref, local))
|
|
284
351
|
live = watch(r, query)
|
|
285
352
|
} catch (err) {
|
|
@@ -315,6 +382,7 @@ export class Server extends RPCServer {
|
|
|
315
382
|
// a watch ending with its handle ends the client's
|
|
316
383
|
live.once('close', () => stream.destroy())
|
|
317
384
|
// channel teardown destroys the stream with CHANNEL_CLOSED; 'close' cleans up
|
|
385
|
+
closeWithWire(stream)
|
|
318
386
|
stream.on('error', safetyCatch)
|
|
319
387
|
stream.on('close', () => {
|
|
320
388
|
live.off('data', onData)
|
|
@@ -323,7 +391,7 @@ export class Server extends RPCServer {
|
|
|
323
391
|
})
|
|
324
392
|
})
|
|
325
393
|
|
|
326
|
-
this.
|
|
394
|
+
this._on('onCall', async ({ handle, op, data }) => {
|
|
327
395
|
const h = this._resolve(handle)
|
|
328
396
|
const r = h[op]
|
|
329
397
|
if (!r) throw CeroError.UNKNOWN('ref', op)
|
|
@@ -337,7 +405,7 @@ export class Server extends RPCServer {
|
|
|
337
405
|
* @private
|
|
338
406
|
*/
|
|
339
407
|
_wireHandles() {
|
|
340
|
-
this.
|
|
408
|
+
this._on('onAddHandle', async ({ handle, ref, data }) => {
|
|
341
409
|
const parent = this._resolve(handle)
|
|
342
410
|
const info = parent.spec.meta.refs?.[ref] || parent.spec.handles?.[ref]
|
|
343
411
|
if (!info) throw CeroError.UNKNOWN('handle type', ref)
|
|
@@ -349,16 +417,16 @@ export class Server extends RPCServer {
|
|
|
349
417
|
return { id, type: ref, name: opts.name || '' }
|
|
350
418
|
})
|
|
351
419
|
|
|
352
|
-
this.
|
|
420
|
+
this._on('onOpenHandle', async ({ parent, row, type }) => {
|
|
353
421
|
if (this._resolve(parent) !== this.me) throw CeroError.UNSUPPORTED('nested handles')
|
|
354
422
|
const { data } = await this.me.store.get('handles', row)
|
|
355
|
-
if (!data) throw CeroError.UNKNOWN('handle', row)
|
|
423
|
+
if (!data?.encryptionKey) throw CeroError.UNKNOWN('handle', row)
|
|
356
424
|
const child = await this.me._load(type, row)
|
|
357
425
|
this._hold(row, child)
|
|
358
426
|
return { id: row, type: data.type, name: data.name || '' }
|
|
359
427
|
})
|
|
360
428
|
|
|
361
|
-
this.
|
|
429
|
+
this._on('onJoin', async ({ parent, ref, invite }) => {
|
|
362
430
|
if (this._resolve(parent) !== this.me) throw CeroError.UNSUPPORTED('nested handles')
|
|
363
431
|
let child
|
|
364
432
|
try {
|
|
@@ -372,14 +440,14 @@ export class Server extends RPCServer {
|
|
|
372
440
|
return { id, type: ref, name: '' }
|
|
373
441
|
})
|
|
374
442
|
|
|
375
|
-
this.
|
|
443
|
+
this._on('onCloseHandle', async ({ handle }) => {
|
|
376
444
|
const h = this.handles.get(handle)
|
|
377
445
|
if (!h || h === this.me) return {}
|
|
378
446
|
await this._release(handle, h)
|
|
379
447
|
return {}
|
|
380
448
|
})
|
|
381
449
|
|
|
382
|
-
this.
|
|
450
|
+
this._on('onLeave', async ({ handle }) => {
|
|
383
451
|
await leave(this._resolve(handle))
|
|
384
452
|
this._held.delete(handle)
|
|
385
453
|
this._endWatches(handle)
|
|
@@ -400,7 +468,7 @@ export class Server extends RPCServer {
|
|
|
400
468
|
if (n > 0) this._held.set(id, n)
|
|
401
469
|
else this._held.delete(id)
|
|
402
470
|
await h.close()
|
|
403
|
-
// another holder on this device keeps it, with its watches; a reopen while it
|
|
471
|
+
// another holder on this device keeps it, with its watches; a reopen while it is idle registers it again
|
|
404
472
|
if (h._refs > 0) return
|
|
405
473
|
this._endWatches(id)
|
|
406
474
|
this.handles.delete(id)
|
|
@@ -420,17 +488,27 @@ export class Server extends RPCServer {
|
|
|
420
488
|
* @private
|
|
421
489
|
*/
|
|
422
490
|
_wireVerbs() {
|
|
423
|
-
this.
|
|
491
|
+
this._on('onVerb', async ({ handle, verb, args }) => {
|
|
424
492
|
const run = VERBS.get(verb)
|
|
425
493
|
if (!run) throw CeroError.UNKNOWN('verb', verb)
|
|
426
|
-
|
|
494
|
+
const data = await run(this._resolve(handle), ...c.decode(c.any, args))
|
|
495
|
+
return { data: data === undefined ? null : c.encode(c.any, data) }
|
|
496
|
+
})
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* Register a request handler whose error fails only its call.
|
|
501
|
+
* @private
|
|
502
|
+
*/
|
|
503
|
+
_on(name, fn) {
|
|
504
|
+
this.rpc[name](async (req) => {
|
|
427
505
|
try {
|
|
428
|
-
|
|
506
|
+
return await fn(req)
|
|
429
507
|
} catch (err) {
|
|
430
|
-
|
|
431
|
-
|
|
508
|
+
if (!CeroError.isCeroError(err)) this._onerror(err)
|
|
509
|
+
// bare-rpc rethrows a TypeError or a RangeError and ends the worker
|
|
510
|
+
throw Object.assign(new Error(err.message), { code: err.code, reason: err.reason })
|
|
432
511
|
}
|
|
433
|
-
return { data: data === undefined ? null : c.encode(c.any, data) }
|
|
434
512
|
})
|
|
435
513
|
}
|
|
436
514
|
|
|
@@ -465,9 +543,9 @@ export class Server extends RPCServer {
|
|
|
465
543
|
return { ref: this.me.local[name], codec: this.spec.local.codec, info }
|
|
466
544
|
}
|
|
467
545
|
const h = this._resolve(id)
|
|
468
|
-
const
|
|
469
|
-
if (!
|
|
470
|
-
return { ref:
|
|
546
|
+
const info = h.spec.meta.refs?.[name]
|
|
547
|
+
if (!info) throw CeroError.UNKNOWN('ref', name)
|
|
548
|
+
return { ref: h[name], codec: h.spec.codec, info }
|
|
471
549
|
}
|
|
472
550
|
|
|
473
551
|
/**
|
|
@@ -502,6 +580,11 @@ export async function serve(ipc, spec, opts) {
|
|
|
502
580
|
return server
|
|
503
581
|
}
|
|
504
582
|
|
|
583
|
+
// hrpc destroys only the wire's stream when the client drops it, never the one a handler holds
|
|
584
|
+
function closeWithWire(stream) {
|
|
585
|
+
stream.writeStream.once('close', () => stream.destroy())
|
|
586
|
+
}
|
|
587
|
+
|
|
505
588
|
// a query crosses as the client wrote it; no bytes is no query
|
|
506
589
|
function fromWire(buf) {
|
|
507
590
|
return buf ? c.decode(c.any, buf) : undefined
|
|
@@ -14,6 +14,10 @@ export declare const defs: {
|
|
|
14
14
|
};
|
|
15
15
|
handles: {
|
|
16
16
|
type: string;
|
|
17
|
+
indexes: {
|
|
18
|
+
state: string[];
|
|
19
|
+
type: string[];
|
|
20
|
+
};
|
|
17
21
|
};
|
|
18
22
|
files: {
|
|
19
23
|
type: string;
|
|
@@ -57,8 +61,20 @@ export declare const defs: {
|
|
|
57
61
|
topics: {
|
|
58
62
|
type: string;
|
|
59
63
|
};
|
|
64
|
+
told: {
|
|
65
|
+
type: string;
|
|
66
|
+
kind: string;
|
|
67
|
+
};
|
|
68
|
+
asks: {
|
|
69
|
+
type: string;
|
|
70
|
+
};
|
|
60
71
|
};
|
|
61
72
|
};
|
|
73
|
+
export declare const base: {
|
|
74
|
+
name: string;
|
|
75
|
+
type: string;
|
|
76
|
+
required: boolean;
|
|
77
|
+
}[];
|
|
62
78
|
export type RefInfo = import('../lib/spec.js').RefInfo;
|
|
63
79
|
export type FieldType = {
|
|
64
80
|
prim: string;
|
|
@@ -123,6 +139,25 @@ export declare function collections(ns: string, scope: 'main' | 'local'): Array<
|
|
|
123
139
|
schema: string;
|
|
124
140
|
key: string[];
|
|
125
141
|
}>;
|
|
142
|
+
/**
|
|
143
|
+
* @param {string} ns
|
|
144
|
+
* @returns {Array<{ name: string, schema: string, key: string[] }>}
|
|
145
|
+
*/
|
|
146
|
+
export declare function added(ns: string): Array<{
|
|
147
|
+
name: string;
|
|
148
|
+
schema: string;
|
|
149
|
+
key: string[];
|
|
150
|
+
}>;
|
|
151
|
+
/**
|
|
152
|
+
* @param {string} ns
|
|
153
|
+
* @param {'main' | 'local'} scope
|
|
154
|
+
* @returns {Array<{ name: string, collection: string, key: string[] }>}
|
|
155
|
+
*/
|
|
156
|
+
export declare function indexes(ns: string, scope: 'main' | 'local'): Array<{
|
|
157
|
+
name: string;
|
|
158
|
+
collection: string;
|
|
159
|
+
key: string[];
|
|
160
|
+
}>;
|
|
126
161
|
/**
|
|
127
162
|
* @param {string} ns
|
|
128
163
|
* @returns {Array<{ name: string, requestType: string }>}
|
|
@@ -131,6 +166,28 @@ export declare function dispatches(ns: string): Array<{
|
|
|
131
166
|
name: string;
|
|
132
167
|
requestType: string;
|
|
133
168
|
}>;
|
|
169
|
+
/**
|
|
170
|
+
* @param {string} ns
|
|
171
|
+
* @returns {Array<{ name: string, requestType: string }>}
|
|
172
|
+
*/
|
|
173
|
+
export declare function appended(ns: string): Array<{
|
|
174
|
+
name: string;
|
|
175
|
+
requestType: string;
|
|
176
|
+
}>;
|
|
177
|
+
/**
|
|
178
|
+
* The names Cero takes in a scope, which an app ref would shadow: its refs and collections, its
|
|
179
|
+
* types and its routes.
|
|
180
|
+
*
|
|
181
|
+
* @param {string} ns
|
|
182
|
+
* @param {'main' | 'local'} scope
|
|
183
|
+
* @param {boolean} root
|
|
184
|
+
* @returns {{ refs: Set<string>, types: Set<string>, routes: Set<string> }}
|
|
185
|
+
*/
|
|
186
|
+
export declare function reserved(ns: string, scope: 'main' | 'local', root: boolean): {
|
|
187
|
+
refs: Set<string>;
|
|
188
|
+
types: Set<string>;
|
|
189
|
+
routes: Set<string>;
|
|
190
|
+
};
|
|
134
191
|
/**
|
|
135
192
|
* @param {string} ns
|
|
136
193
|
* @returns {Array<{ name: string, request: { name: string }, response: { name: string, stream?: boolean } }>}
|
package/types/build/schemas.d.ts
CHANGED
|
@@ -34,6 +34,7 @@ export declare const main: {
|
|
|
34
34
|
index: import("@cero-base/core").Prim;
|
|
35
35
|
key: import("@cero-base/core").Prim;
|
|
36
36
|
proof: import("@cero-base/core").Prim;
|
|
37
|
+
chain: import("@cero-base/core").Prim;
|
|
37
38
|
};
|
|
38
39
|
invite: {
|
|
39
40
|
id: import("@cero-base/core").Prim;
|
|
@@ -43,6 +44,7 @@ export declare const main: {
|
|
|
43
44
|
createdAt: import("@cero-base/core").Prim;
|
|
44
45
|
index: import("@cero-base/core").Prim;
|
|
45
46
|
confirm: import("@cero-base/core").Prim;
|
|
47
|
+
secret: import("@cero-base/core").Prim;
|
|
46
48
|
};
|
|
47
49
|
handle: {
|
|
48
50
|
id: import("@cero-base/core").Prim;
|
|
@@ -54,6 +56,11 @@ export declare const main: {
|
|
|
54
56
|
updatedAt: import("@cero-base/core").Prim;
|
|
55
57
|
index: import("@cero-base/core").Prim;
|
|
56
58
|
epochs: import("@cero-base/core").Prim;
|
|
59
|
+
state: import("@cero-base/core").Prim;
|
|
60
|
+
reason: import("@cero-base/core").Prim;
|
|
61
|
+
by: import("@cero-base/core").Prim;
|
|
62
|
+
invite: import("@cero-base/core").Prim;
|
|
63
|
+
writer: import("@cero-base/core").Prim;
|
|
57
64
|
};
|
|
58
65
|
file: {
|
|
59
66
|
id: import("@cero-base/core").Prim;
|
|
@@ -71,9 +78,11 @@ export declare const main: {
|
|
|
71
78
|
createdAt: import("@cero-base/core").Prim;
|
|
72
79
|
commit: import("@cero-base/core").Prim;
|
|
73
80
|
stamp: import("@cero-base/core").Prim;
|
|
81
|
+
aside: import("@cero-base/core").Prim;
|
|
74
82
|
};
|
|
75
83
|
join: {
|
|
76
84
|
box: import("@cero-base/core").Prim;
|
|
85
|
+
invite: import("@cero-base/core").Prim;
|
|
77
86
|
};
|
|
78
87
|
accept: {
|
|
79
88
|
id: import("@cero-base/core").Prim;
|
|
@@ -91,10 +100,17 @@ export declare const main: {
|
|
|
91
100
|
expires: import("@cero-base/core").Prim;
|
|
92
101
|
role: import("@cero-base/core").Prim;
|
|
93
102
|
key: import("@cero-base/core").Prim;
|
|
103
|
+
promised: import("@cero-base/core").Prim;
|
|
104
|
+
proof: import("@cero-base/core").Prim;
|
|
105
|
+
accepted: import("@cero-base/core").Prim;
|
|
94
106
|
};
|
|
95
107
|
removal: {
|
|
96
108
|
id: import("@cero-base/core").Prim;
|
|
97
109
|
index: import("@cero-base/core").Prim;
|
|
110
|
+
by: import("@cero-base/core").Prim;
|
|
111
|
+
removed: import("@cero-base/core").Prim;
|
|
112
|
+
standing: import("@cero-base/core").Prim;
|
|
113
|
+
spent: import("@cero-base/core").Prim;
|
|
98
114
|
};
|
|
99
115
|
status: {
|
|
100
116
|
role: import("@cero-base/core").Prim;
|
|
@@ -102,12 +118,9 @@ export declare const main: {
|
|
|
102
118
|
epoch: import("@cero-base/core").Prim;
|
|
103
119
|
suspended: import("@cero-base/core").Prim;
|
|
104
120
|
behind: import("@cero-base/core").Prim;
|
|
121
|
+
version: import("@cero-base/core").Prim;
|
|
105
122
|
nearby: import("@cero-base/core").Prim;
|
|
106
|
-
|
|
107
|
-
joining: {
|
|
108
|
-
id: import("@cero-base/core").Prim;
|
|
109
|
-
type: import("@cero-base/core").Prim;
|
|
110
|
-
invite: import("@cero-base/core").Prim;
|
|
123
|
+
owed: import("@cero-base/core").Prim;
|
|
111
124
|
};
|
|
112
125
|
peer: {
|
|
113
126
|
id: import("@cero-base/core").Prim;
|
|
@@ -120,11 +133,20 @@ export declare const main: {
|
|
|
120
133
|
reply: import("@cero-base/core").Prim;
|
|
121
134
|
reason: import("@cero-base/core").Prim;
|
|
122
135
|
expires: import("@cero-base/core").Prim;
|
|
136
|
+
invite: import("@cero-base/core").Prim;
|
|
137
|
+
spent: import("@cero-base/core").Prim;
|
|
138
|
+
identity: import("@cero-base/core").Prim;
|
|
123
139
|
};
|
|
124
140
|
spent: {
|
|
125
141
|
id: import("@cero-base/core").Prim;
|
|
126
142
|
reason: import("@cero-base/core").Prim;
|
|
127
143
|
expires: import("@cero-base/core").Prim;
|
|
144
|
+
secret: import("@cero-base/core").Prim;
|
|
145
|
+
confirm: import("@cero-base/core").Prim;
|
|
146
|
+
};
|
|
147
|
+
owed: {
|
|
148
|
+
id: import("@cero-base/core").Prim;
|
|
149
|
+
reply: import("@cero-base/core").Prim;
|
|
128
150
|
};
|
|
129
151
|
deny: {
|
|
130
152
|
id: import("@cero-base/core").Prim;
|
|
@@ -136,6 +158,14 @@ export declare const main: {
|
|
|
136
158
|
type: import("@cero-base/core").Prim;
|
|
137
159
|
name: import("@cero-base/core").Prim;
|
|
138
160
|
};
|
|
161
|
+
upgrade: {
|
|
162
|
+
version: import("@cero-base/core").Prim;
|
|
163
|
+
};
|
|
164
|
+
revoke: {
|
|
165
|
+
removed: import("@cero-base/core").Prim;
|
|
166
|
+
standing: import("@cero-base/core").Prim;
|
|
167
|
+
proof: import("@cero-base/core").Prim;
|
|
168
|
+
};
|
|
139
169
|
};
|
|
140
170
|
export declare const local: {
|
|
141
171
|
master: {
|
|
@@ -158,6 +188,11 @@ export declare const local: {
|
|
|
158
188
|
publicKey: import("@cero-base/core").Prim;
|
|
159
189
|
secretKey: import("@cero-base/core").Prim;
|
|
160
190
|
encryptionKey: import("@cero-base/core").Prim;
|
|
191
|
+
invite: import("@cero-base/core").Prim;
|
|
192
|
+
used: import("@cero-base/core").Prim;
|
|
193
|
+
told: import("@cero-base/core").Prim;
|
|
194
|
+
stamp: import("@cero-base/core").Prim;
|
|
195
|
+
waited: import("@cero-base/core").Prim;
|
|
161
196
|
};
|
|
162
197
|
serving: {
|
|
163
198
|
id: import("@cero-base/core").Prim;
|
|
@@ -183,6 +218,8 @@ export declare const local: {
|
|
|
183
218
|
name: import("@cero-base/core").Prim;
|
|
184
219
|
erase: import("@cero-base/core").Prim;
|
|
185
220
|
fetched: import("@cero-base/core").Prim;
|
|
221
|
+
handled: import("@cero-base/core").Prim;
|
|
222
|
+
sealed: import("@cero-base/core").Prim;
|
|
186
223
|
};
|
|
187
224
|
environment: {
|
|
188
225
|
channel: import("@cero-base/core").Prim;
|
|
@@ -195,6 +232,21 @@ export declare const local: {
|
|
|
195
232
|
name: import("@cero-base/core").Prim;
|
|
196
233
|
encryptionKey: import("@cero-base/core").Prim;
|
|
197
234
|
epochs: import("@cero-base/core").Prim;
|
|
235
|
+
writers: import("@cero-base/core").Prim;
|
|
236
|
+
};
|
|
237
|
+
told: {
|
|
238
|
+
removed: import("@cero-base/core").Prim;
|
|
239
|
+
standing: import("@cero-base/core").Prim;
|
|
240
|
+
stamp: import("@cero-base/core").Prim;
|
|
241
|
+
};
|
|
242
|
+
ask: {
|
|
243
|
+
id: import("@cero-base/core").Prim;
|
|
244
|
+
handle: import("@cero-base/core").Prim;
|
|
245
|
+
type: import("@cero-base/core").Prim;
|
|
246
|
+
invite: import("@cero-base/core").Prim;
|
|
247
|
+
publicKey: import("@cero-base/core").Prim;
|
|
248
|
+
secretKey: import("@cero-base/core").Prim;
|
|
249
|
+
createdAt: import("@cero-base/core").Prim;
|
|
198
250
|
};
|
|
199
251
|
};
|
|
200
252
|
export declare const contract: {
|
|
@@ -219,6 +271,7 @@ export declare const rpc: {
|
|
|
219
271
|
fields: {
|
|
220
272
|
prim: string;
|
|
221
273
|
required?: boolean;
|
|
274
|
+
later?: boolean;
|
|
222
275
|
array: boolean;
|
|
223
276
|
};
|
|
224
277
|
};
|
|
@@ -18,6 +18,7 @@ export declare const cero: {
|
|
|
18
18
|
signal?: AbortSignal;
|
|
19
19
|
}): () => void;
|
|
20
20
|
get(ref: operators.Ref, q?: string | Record<string, unknown>): Promise<operators.SingleResult | operators.ListResult>;
|
|
21
|
+
supports(ref: operators.Ref, field?: string): Promise<boolean>;
|
|
21
22
|
watch(ref: operators.Ref, query?: string | (Record<string, unknown> & {
|
|
22
23
|
changes?: boolean;
|
|
23
24
|
}), opts?: {
|
|
@@ -42,6 +43,7 @@ export declare const cero: {
|
|
|
42
43
|
deny(ctx: operators.Context, request: {
|
|
43
44
|
id: string;
|
|
44
45
|
}, reason?: string): Promise<void>;
|
|
46
|
+
removed(ctx: operators.Context, id: string): Promise<'removed' | 'left' | null>;
|
|
45
47
|
leave(ctx: operators.Context): Promise<void>;
|
|
46
48
|
close(ctx: operators.Context): Promise<void>;
|
|
47
49
|
cancel(me: operators.Context, code: string): Promise<boolean>;
|
|
@@ -82,6 +84,7 @@ export declare const cero: {
|
|
|
82
84
|
fixed64: import("@cero-base/core").Prim;
|
|
83
85
|
file: import("@cero-base/core").Prim;
|
|
84
86
|
required: (marker: import("@cero-base/core").Prim) => import("@cero-base/core").Prim;
|
|
87
|
+
later: <T extends import("@cero-base/core").Prim | import("@cero-base/core").TypeDef>(def: T) => T;
|
|
85
88
|
single(fields: Record<string, import("@cero-base/core").Prim>, opts?: {
|
|
86
89
|
push?: boolean;
|
|
87
90
|
}): import("@cero-base/core").TypeDef;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Mirror your `profile` onto your `member` row in every handle you're in.
|
|
2
|
+
* Mirror your `profile` onto your `member` row in every handle you're in, open or closed here.
|
|
3
3
|
*
|
|
4
4
|
* @param {{ fields?: Record<string, object> }} [opts] Extra fields, as `t` types.
|
|
5
5
|
* @returns {import('./index.js').Extension}
|