+52
-2
@@ -1,12 +1,12 @@
|
||||
// This file is autogenerated by the hyperschema compiler
|
||||
// Schema Version: 1
|
||||
// Schema Version: 2
|
||||
/* eslint-disable camelcase */
|
||||
/* eslint-disable quotes */
|
||||
/* eslint-disable space-before-function-paren */
|
||||
|
||||
const { c } = require('hyperschema/runtime')
|
||||
|
||||
const VERSION = 1
|
||||
const VERSION = 2
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
let version = VERSION
|
||||
@@ -236,6 +236,52 @@ const encoding8 = {
|
||||
}
|
||||
}
|
||||
|
||||
// @bridgeswarm/record
|
||||
const encoding9 = {
|
||||
preencode(state, m) {
|
||||
c.string.preencode(state, m.id)
|
||||
c.string.preencode(state, m.value)
|
||||
},
|
||||
encode(state, m) {
|
||||
c.string.encode(state, m.id)
|
||||
c.string.encode(state, m.value)
|
||||
},
|
||||
decode(state) {
|
||||
const r0 = c.string.decode(state)
|
||||
const r1 = c.string.decode(state)
|
||||
|
||||
return {
|
||||
id: r0,
|
||||
value: r1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// @bridgeswarm/note
|
||||
const encoding10 = {
|
||||
preencode(state, m) {
|
||||
c.string.preencode(state, m.id)
|
||||
c.string.preencode(state, m.title)
|
||||
c.string.preencode(state, m.body)
|
||||
},
|
||||
encode(state, m) {
|
||||
c.string.encode(state, m.id)
|
||||
c.string.encode(state, m.title)
|
||||
c.string.encode(state, m.body)
|
||||
},
|
||||
decode(state) {
|
||||
const r0 = c.string.decode(state)
|
||||
const r1 = c.string.decode(state)
|
||||
const r2 = c.string.decode(state)
|
||||
|
||||
return {
|
||||
id: r0,
|
||||
title: r1,
|
||||
body: r2
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function setVersion(v) {
|
||||
version = v
|
||||
}
|
||||
@@ -277,6 +323,10 @@ function getEncoding(name) {
|
||||
return encoding7
|
||||
case '@bridgeswarm/notify-request':
|
||||
return encoding8
|
||||
case '@bridgeswarm/record':
|
||||
return encoding9
|
||||
case '@bridgeswarm/note':
|
||||
return encoding10
|
||||
default:
|
||||
throw new Error('Encoder not found ' + name)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"version": 1,
|
||||
"offset": 0,
|
||||
"schema": [
|
||||
{
|
||||
"name": "records",
|
||||
"namespace": "bridgeswarm",
|
||||
"id": 0,
|
||||
"type": 1,
|
||||
"version": 1,
|
||||
"versionField": null,
|
||||
"indexes": [],
|
||||
"schema": "@bridgeswarm/record",
|
||||
"derived": false,
|
||||
"key": [
|
||||
"id"
|
||||
],
|
||||
"trigger": null
|
||||
},
|
||||
{
|
||||
"name": "notes",
|
||||
"namespace": "bridgeswarm",
|
||||
"id": 1,
|
||||
"type": 1,
|
||||
"version": 1,
|
||||
"versionField": null,
|
||||
"indexes": [],
|
||||
"schema": "@bridgeswarm/note",
|
||||
"derived": false,
|
||||
"key": [
|
||||
"id"
|
||||
],
|
||||
"trigger": null
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
// This file is autogenerated by the hyperdb compiler
|
||||
/* eslint-disable camelcase */
|
||||
|
||||
const { IndexEncoder, c, b4a } = require('hyperdb/runtime')
|
||||
const { version, getEncoding, setVersion } = require('./messages.js')
|
||||
|
||||
const versions = { schema: version, db: 1 }
|
||||
|
||||
// '@bridgeswarm/records' collection key
|
||||
const collection0_key = new IndexEncoder([
|
||||
IndexEncoder.STRING
|
||||
], { prefix: 0 })
|
||||
|
||||
function collection0_indexify (record) {
|
||||
const a = record.id
|
||||
return a === undefined ? [] : [a]
|
||||
}
|
||||
|
||||
// '@bridgeswarm/records' value encoding
|
||||
const collection0_enc = getEncoding('@bridgeswarm/record/hyperdb#0')
|
||||
|
||||
// '@bridgeswarm/records' reconstruction function
|
||||
function collection0_reconstruct (schemaVersion, keyBuf, valueBuf) {
|
||||
const key = collection0_key.decode(keyBuf)
|
||||
setVersion(schemaVersion)
|
||||
const state = { start: 0, end: valueBuf.byteLength, buffer: valueBuf }
|
||||
const type = c.uint.decode(state)
|
||||
if (type !== 0) throw new Error('Unknown collection type: ' + type)
|
||||
collection0.decodedVersion = c.uint.decode(state)
|
||||
const record = collection0_enc.decode(state)
|
||||
record.id = key[0]
|
||||
return record
|
||||
}
|
||||
// '@bridgeswarm/records' key reconstruction function
|
||||
function collection0_reconstruct_key (keyBuf) {
|
||||
const key = collection0_key.decode(keyBuf)
|
||||
return {
|
||||
id: key[0]
|
||||
}
|
||||
}
|
||||
|
||||
// '@bridgeswarm/records'
|
||||
const collection0 = {
|
||||
name: '@bridgeswarm/records',
|
||||
id: 0,
|
||||
version: 1,
|
||||
encodeKey (record) {
|
||||
const key = [record.id]
|
||||
return collection0_key.encode(key)
|
||||
},
|
||||
encodeKeyRange ({ gt, lt, gte, lte } = {}) {
|
||||
return collection0_key.encodeRange({
|
||||
gt: gt ? collection0_indexify(gt) : null,
|
||||
lt: lt ? collection0_indexify(lt) : null,
|
||||
gte: gte ? collection0_indexify(gte) : null,
|
||||
lte: lte ? collection0_indexify(lte) : null
|
||||
})
|
||||
},
|
||||
encodeValue (schemaVersion, collectionVersion, record) {
|
||||
setVersion(schemaVersion)
|
||||
const state = { start: 0, end: 2, buffer: null }
|
||||
collection0_enc.preencode(state, record)
|
||||
state.buffer = b4a.allocUnsafe(state.end)
|
||||
state.buffer[state.start++] = 0
|
||||
state.buffer[state.start++] = collectionVersion
|
||||
collection0_enc.encode(state, record)
|
||||
return state.buffer
|
||||
},
|
||||
trigger: null,
|
||||
reconstruct: collection0_reconstruct,
|
||||
reconstructKey: collection0_reconstruct_key,
|
||||
indexes: [],
|
||||
decodedVersion: 0
|
||||
}
|
||||
|
||||
// '@bridgeswarm/notes' collection key
|
||||
const collection1_key = new IndexEncoder([
|
||||
IndexEncoder.STRING
|
||||
], { prefix: 1 })
|
||||
|
||||
function collection1_indexify (record) {
|
||||
const a = record.id
|
||||
return a === undefined ? [] : [a]
|
||||
}
|
||||
|
||||
// '@bridgeswarm/notes' value encoding
|
||||
const collection1_enc = getEncoding('@bridgeswarm/note/hyperdb#1')
|
||||
|
||||
// '@bridgeswarm/notes' reconstruction function
|
||||
function collection1_reconstruct (schemaVersion, keyBuf, valueBuf) {
|
||||
const key = collection1_key.decode(keyBuf)
|
||||
setVersion(schemaVersion)
|
||||
const state = { start: 0, end: valueBuf.byteLength, buffer: valueBuf }
|
||||
const type = c.uint.decode(state)
|
||||
if (type !== 0) throw new Error('Unknown collection type: ' + type)
|
||||
collection1.decodedVersion = c.uint.decode(state)
|
||||
const record = collection1_enc.decode(state)
|
||||
record.id = key[0]
|
||||
return record
|
||||
}
|
||||
// '@bridgeswarm/notes' key reconstruction function
|
||||
function collection1_reconstruct_key (keyBuf) {
|
||||
const key = collection1_key.decode(keyBuf)
|
||||
return {
|
||||
id: key[0]
|
||||
}
|
||||
}
|
||||
|
||||
// '@bridgeswarm/notes'
|
||||
const collection1 = {
|
||||
name: '@bridgeswarm/notes',
|
||||
id: 1,
|
||||
version: 1,
|
||||
encodeKey (record) {
|
||||
const key = [record.id]
|
||||
return collection1_key.encode(key)
|
||||
},
|
||||
encodeKeyRange ({ gt, lt, gte, lte } = {}) {
|
||||
return collection1_key.encodeRange({
|
||||
gt: gt ? collection1_indexify(gt) : null,
|
||||
lt: lt ? collection1_indexify(lt) : null,
|
||||
gte: gte ? collection1_indexify(gte) : null,
|
||||
lte: lte ? collection1_indexify(lte) : null
|
||||
})
|
||||
},
|
||||
encodeValue (schemaVersion, collectionVersion, record) {
|
||||
setVersion(schemaVersion)
|
||||
const state = { start: 0, end: 2, buffer: null }
|
||||
collection1_enc.preencode(state, record)
|
||||
state.buffer = b4a.allocUnsafe(state.end)
|
||||
state.buffer[state.start++] = 0
|
||||
state.buffer[state.start++] = collectionVersion
|
||||
collection1_enc.encode(state, record)
|
||||
return state.buffer
|
||||
},
|
||||
trigger: null,
|
||||
reconstruct: collection1_reconstruct,
|
||||
reconstructKey: collection1_reconstruct_key,
|
||||
indexes: [],
|
||||
decodedVersion: 0
|
||||
}
|
||||
|
||||
const collections = [
|
||||
collection0,
|
||||
collection1
|
||||
]
|
||||
|
||||
const indexes = [
|
||||
]
|
||||
|
||||
module.exports = { versions, collections, indexes, resolveCollection, resolveIndex }
|
||||
|
||||
function resolveCollection (name) {
|
||||
switch (name) {
|
||||
case '@bridgeswarm/records': return collection0
|
||||
case '@bridgeswarm/notes': return collection1
|
||||
default: return null
|
||||
}
|
||||
}
|
||||
|
||||
function resolveIndex (name) {
|
||||
switch (name) {
|
||||
default: return null
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,408 @@
|
||||
// This file is autogenerated by the hyperschema compiler
|
||||
// Schema Version: 2
|
||||
/* eslint-disable camelcase */
|
||||
/* eslint-disable quotes */
|
||||
/* eslint-disable space-before-function-paren */
|
||||
|
||||
const { c } = require('hyperschema/runtime')
|
||||
|
||||
const VERSION = 2
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
let version = VERSION
|
||||
|
||||
// @bridgeswarm/ping-request
|
||||
const encoding0 = {
|
||||
preencode(state, m) {
|
||||
state.end++ // max flag is 1 so always one byte
|
||||
|
||||
if (m.value) c.string.preencode(state, m.value)
|
||||
},
|
||||
encode(state, m) {
|
||||
const flags = m.value ? 1 : 0
|
||||
|
||||
c.uint.encode(state, flags)
|
||||
|
||||
if (m.value) c.string.encode(state, m.value)
|
||||
},
|
||||
decode(state) {
|
||||
const flags = c.uint.decode(state)
|
||||
|
||||
return {
|
||||
value: (flags & 1) !== 0 ? c.string.decode(state) : null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// @bridgeswarm/ping-response
|
||||
const encoding1 = {
|
||||
preencode(state, m) {
|
||||
state.end++ // max flag is 1 so always one byte
|
||||
|
||||
if (m.pong) c.string.preencode(state, m.pong)
|
||||
},
|
||||
encode(state, m) {
|
||||
const flags = m.pong ? 1 : 0
|
||||
|
||||
c.uint.encode(state, flags)
|
||||
|
||||
if (m.pong) c.string.encode(state, m.pong)
|
||||
},
|
||||
decode(state) {
|
||||
const flags = c.uint.decode(state)
|
||||
|
||||
return {
|
||||
pong: (flags & 1) !== 0 ? c.string.decode(state) : null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// @bridgeswarm/stream-request-chunk
|
||||
const encoding2 = {
|
||||
preencode(state, m) {
|
||||
state.end++ // max flag is 2 so always one byte
|
||||
|
||||
if (m.n) c.uint.preencode(state, m.n)
|
||||
if (m.label) c.string.preencode(state, m.label)
|
||||
},
|
||||
encode(state, m) {
|
||||
const flags = (m.n ? 1 : 0) | (m.label ? 2 : 0)
|
||||
|
||||
c.uint.encode(state, flags)
|
||||
|
||||
if (m.n) c.uint.encode(state, m.n)
|
||||
if (m.label) c.string.encode(state, m.label)
|
||||
},
|
||||
decode(state) {
|
||||
const flags = c.uint.decode(state)
|
||||
|
||||
return {
|
||||
n: (flags & 1) !== 0 ? c.uint.decode(state) : 0,
|
||||
label: (flags & 2) !== 0 ? c.string.decode(state) : null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// @bridgeswarm/stream-sum-response
|
||||
const encoding3 = {
|
||||
preencode(state, m) {
|
||||
state.end++ // max flag is 2 so always one byte
|
||||
|
||||
if (m.sum) c.uint.preencode(state, m.sum)
|
||||
if (m.count) c.uint.preencode(state, m.count)
|
||||
},
|
||||
encode(state, m) {
|
||||
const flags = (m.sum ? 1 : 0) | (m.count ? 2 : 0)
|
||||
|
||||
c.uint.encode(state, flags)
|
||||
|
||||
if (m.sum) c.uint.encode(state, m.sum)
|
||||
if (m.count) c.uint.encode(state, m.count)
|
||||
},
|
||||
decode(state) {
|
||||
const flags = c.uint.decode(state)
|
||||
|
||||
return {
|
||||
sum: (flags & 1) !== 0 ? c.uint.decode(state) : 0,
|
||||
count: (flags & 2) !== 0 ? c.uint.decode(state) : 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// @bridgeswarm/fetch-request
|
||||
const encoding4 = {
|
||||
preencode(state, m) {
|
||||
state.end++ // max flag is 1 so always one byte
|
||||
|
||||
if (m.count) c.uint.preencode(state, m.count)
|
||||
},
|
||||
encode(state, m) {
|
||||
const flags = m.count ? 1 : 0
|
||||
|
||||
c.uint.encode(state, flags)
|
||||
|
||||
if (m.count) c.uint.encode(state, m.count)
|
||||
},
|
||||
decode(state) {
|
||||
const flags = c.uint.decode(state)
|
||||
|
||||
return {
|
||||
count: (flags & 1) !== 0 ? c.uint.decode(state) : 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// @bridgeswarm/fetch-chunk
|
||||
const encoding5 = {
|
||||
preencode(state, m) {
|
||||
state.end++ // max flag is 2 so always one byte
|
||||
|
||||
if (m.i) c.uint.preencode(state, m.i)
|
||||
if (m.data) c.string.preencode(state, m.data)
|
||||
},
|
||||
encode(state, m) {
|
||||
const flags = (m.i ? 1 : 0) | (m.data ? 2 : 0)
|
||||
|
||||
c.uint.encode(state, flags)
|
||||
|
||||
if (m.i) c.uint.encode(state, m.i)
|
||||
if (m.data) c.string.encode(state, m.data)
|
||||
},
|
||||
decode(state) {
|
||||
const flags = c.uint.decode(state)
|
||||
|
||||
return {
|
||||
i: (flags & 1) !== 0 ? c.uint.decode(state) : 0,
|
||||
data: (flags & 2) !== 0 ? c.string.decode(state) : null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// @bridgeswarm/duplex-in
|
||||
const encoding6 = {
|
||||
preencode(state, m) {
|
||||
state.end++ // max flag is 2 so always one byte
|
||||
|
||||
if (m.x) c.uint.preencode(state, m.x)
|
||||
if (m.y) c.string.preencode(state, m.y)
|
||||
},
|
||||
encode(state, m) {
|
||||
const flags = (m.x ? 1 : 0) | (m.y ? 2 : 0)
|
||||
|
||||
c.uint.encode(state, flags)
|
||||
|
||||
if (m.x) c.uint.encode(state, m.x)
|
||||
if (m.y) c.string.encode(state, m.y)
|
||||
},
|
||||
decode(state) {
|
||||
const flags = c.uint.decode(state)
|
||||
|
||||
return {
|
||||
x: (flags & 1) !== 0 ? c.uint.decode(state) : 0,
|
||||
y: (flags & 2) !== 0 ? c.string.decode(state) : null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// @bridgeswarm/duplex-out
|
||||
const encoding7 = {
|
||||
preencode(state, m) {
|
||||
state.end++ // max flag is 2 so always one byte
|
||||
|
||||
if (m.result) c.string.preencode(state, m.result)
|
||||
if (m.n) c.uint.preencode(state, m.n)
|
||||
},
|
||||
encode(state, m) {
|
||||
const flags = (m.result ? 1 : 0) | (m.n ? 2 : 0)
|
||||
|
||||
c.uint.encode(state, flags)
|
||||
|
||||
if (m.result) c.string.encode(state, m.result)
|
||||
if (m.n) c.uint.encode(state, m.n)
|
||||
},
|
||||
decode(state) {
|
||||
const flags = c.uint.decode(state)
|
||||
|
||||
return {
|
||||
result: (flags & 1) !== 0 ? c.string.decode(state) : null,
|
||||
n: (flags & 2) !== 0 ? c.uint.decode(state) : 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// @bridgeswarm/notify-request
|
||||
const encoding8 = {
|
||||
preencode(state, m) {
|
||||
state.end++ // max flag is 2 so always one byte
|
||||
|
||||
if (m.event) c.string.preencode(state, m.event)
|
||||
if (m.payload) c.uint.preencode(state, m.payload)
|
||||
},
|
||||
encode(state, m) {
|
||||
const flags = (m.event ? 1 : 0) | (m.payload ? 2 : 0)
|
||||
|
||||
c.uint.encode(state, flags)
|
||||
|
||||
if (m.event) c.string.encode(state, m.event)
|
||||
if (m.payload) c.uint.encode(state, m.payload)
|
||||
},
|
||||
decode(state) {
|
||||
const flags = c.uint.decode(state)
|
||||
|
||||
return {
|
||||
event: (flags & 1) !== 0 ? c.string.decode(state) : null,
|
||||
payload: (flags & 2) !== 0 ? c.uint.decode(state) : 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// @bridgeswarm/record
|
||||
const encoding9 = {
|
||||
preencode(state, m) {
|
||||
c.string.preencode(state, m.id)
|
||||
c.string.preencode(state, m.value)
|
||||
},
|
||||
encode(state, m) {
|
||||
c.string.encode(state, m.id)
|
||||
c.string.encode(state, m.value)
|
||||
},
|
||||
decode(state) {
|
||||
const r0 = c.string.decode(state)
|
||||
const r1 = c.string.decode(state)
|
||||
|
||||
return {
|
||||
id: r0,
|
||||
value: r1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// @bridgeswarm/note
|
||||
const encoding10 = {
|
||||
preencode(state, m) {
|
||||
c.string.preencode(state, m.id)
|
||||
c.string.preencode(state, m.title)
|
||||
c.string.preencode(state, m.body)
|
||||
},
|
||||
encode(state, m) {
|
||||
c.string.encode(state, m.id)
|
||||
c.string.encode(state, m.title)
|
||||
c.string.encode(state, m.body)
|
||||
},
|
||||
decode(state) {
|
||||
const r0 = c.string.decode(state)
|
||||
const r1 = c.string.decode(state)
|
||||
const r2 = c.string.decode(state)
|
||||
|
||||
return {
|
||||
id: r0,
|
||||
title: r1,
|
||||
body: r2
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// @bridgeswarm/record/hyperdb#0
|
||||
const encoding11 = {
|
||||
preencode(state, m) {
|
||||
c.string.preencode(state, m.value)
|
||||
},
|
||||
encode(state, m) {
|
||||
c.string.encode(state, m.value)
|
||||
},
|
||||
decode(state) {
|
||||
const r1 = c.string.decode(state)
|
||||
|
||||
return {
|
||||
id: null,
|
||||
value: r1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// @bridgeswarm/note/hyperdb#1
|
||||
const encoding12 = {
|
||||
preencode(state, m) {
|
||||
c.string.preencode(state, m.title)
|
||||
c.string.preencode(state, m.body)
|
||||
},
|
||||
encode(state, m) {
|
||||
c.string.encode(state, m.title)
|
||||
c.string.encode(state, m.body)
|
||||
},
|
||||
decode(state) {
|
||||
const r1 = c.string.decode(state)
|
||||
const r2 = c.string.decode(state)
|
||||
|
||||
return {
|
||||
id: null,
|
||||
title: r1,
|
||||
body: r2
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function setVersion(v) {
|
||||
version = v
|
||||
}
|
||||
|
||||
function encode(name, value, v = VERSION) {
|
||||
version = v
|
||||
return c.encode(getEncoding(name), value)
|
||||
}
|
||||
|
||||
function decode(name, buffer, v = VERSION) {
|
||||
version = v
|
||||
return c.decode(getEncoding(name), buffer)
|
||||
}
|
||||
|
||||
function getEnum(name) {
|
||||
switch (name) {
|
||||
default:
|
||||
throw new Error('Enum not found ' + name)
|
||||
}
|
||||
}
|
||||
|
||||
function getEncoding(name) {
|
||||
switch (name) {
|
||||
case '@bridgeswarm/ping-request':
|
||||
return encoding0
|
||||
case '@bridgeswarm/ping-response':
|
||||
return encoding1
|
||||
case '@bridgeswarm/stream-request-chunk':
|
||||
return encoding2
|
||||
case '@bridgeswarm/stream-sum-response':
|
||||
return encoding3
|
||||
case '@bridgeswarm/fetch-request':
|
||||
return encoding4
|
||||
case '@bridgeswarm/fetch-chunk':
|
||||
return encoding5
|
||||
case '@bridgeswarm/duplex-in':
|
||||
return encoding6
|
||||
case '@bridgeswarm/duplex-out':
|
||||
return encoding7
|
||||
case '@bridgeswarm/notify-request':
|
||||
return encoding8
|
||||
case '@bridgeswarm/record':
|
||||
return encoding9
|
||||
case '@bridgeswarm/note':
|
||||
return encoding10
|
||||
case '@bridgeswarm/record/hyperdb#0':
|
||||
return encoding11
|
||||
case '@bridgeswarm/note/hyperdb#1':
|
||||
return encoding12
|
||||
default:
|
||||
throw new Error('Encoder not found ' + name)
|
||||
}
|
||||
}
|
||||
|
||||
function getStruct(name, v = VERSION) {
|
||||
const enc = getEncoding(name)
|
||||
return {
|
||||
preencode(state, m) {
|
||||
version = v
|
||||
enc.preencode(state, m)
|
||||
},
|
||||
encode(state, m) {
|
||||
version = v
|
||||
enc.encode(state, m)
|
||||
},
|
||||
decode(state) {
|
||||
version = v
|
||||
return enc.decode(state)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const resolveStruct = getStruct // compat
|
||||
|
||||
module.exports = {
|
||||
resolveStruct,
|
||||
getStruct,
|
||||
getEnum,
|
||||
getEncoding,
|
||||
encode,
|
||||
decode,
|
||||
setVersion,
|
||||
version
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
// This file is autogenerated by the hyperschema compiler
|
||||
// Schema Version: 1
|
||||
// Schema Version: 2
|
||||
/* eslint-disable camelcase */
|
||||
/* eslint-disable quotes */
|
||||
/* eslint-disable space-before-function-paren */
|
||||
|
||||
const { c } = require('hyperschema/runtime')
|
||||
|
||||
const VERSION = 1
|
||||
const VERSION = 2
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
let version = VERSION
|
||||
@@ -236,6 +236,52 @@ const encoding8 = {
|
||||
}
|
||||
}
|
||||
|
||||
// @bridgeswarm/record
|
||||
const encoding9 = {
|
||||
preencode(state, m) {
|
||||
c.string.preencode(state, m.id)
|
||||
c.string.preencode(state, m.value)
|
||||
},
|
||||
encode(state, m) {
|
||||
c.string.encode(state, m.id)
|
||||
c.string.encode(state, m.value)
|
||||
},
|
||||
decode(state) {
|
||||
const r0 = c.string.decode(state)
|
||||
const r1 = c.string.decode(state)
|
||||
|
||||
return {
|
||||
id: r0,
|
||||
value: r1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// @bridgeswarm/note
|
||||
const encoding10 = {
|
||||
preencode(state, m) {
|
||||
c.string.preencode(state, m.id)
|
||||
c.string.preencode(state, m.title)
|
||||
c.string.preencode(state, m.body)
|
||||
},
|
||||
encode(state, m) {
|
||||
c.string.encode(state, m.id)
|
||||
c.string.encode(state, m.title)
|
||||
c.string.encode(state, m.body)
|
||||
},
|
||||
decode(state) {
|
||||
const r0 = c.string.decode(state)
|
||||
const r1 = c.string.decode(state)
|
||||
const r2 = c.string.decode(state)
|
||||
|
||||
return {
|
||||
id: r0,
|
||||
title: r1,
|
||||
body: r2
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function setVersion(v) {
|
||||
version = v
|
||||
}
|
||||
@@ -277,6 +323,10 @@ function getEncoding(name) {
|
||||
return encoding7
|
||||
case '@bridgeswarm/notify-request':
|
||||
return encoding8
|
||||
case '@bridgeswarm/record':
|
||||
return encoding9
|
||||
case '@bridgeswarm/note':
|
||||
return encoding10
|
||||
default:
|
||||
throw new Error('Encoder not found ' + name)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"version": 1,
|
||||
"version": 2,
|
||||
"schema": [
|
||||
{
|
||||
"name": "ping-request",
|
||||
@@ -147,6 +147,52 @@
|
||||
"version": 1
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "record",
|
||||
"namespace": "bridgeswarm",
|
||||
"compact": false,
|
||||
"flagsPosition": -1,
|
||||
"fields": [
|
||||
{
|
||||
"name": "id",
|
||||
"required": true,
|
||||
"type": "string",
|
||||
"version": 2
|
||||
},
|
||||
{
|
||||
"name": "value",
|
||||
"required": true,
|
||||
"type": "string",
|
||||
"version": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "note",
|
||||
"namespace": "bridgeswarm",
|
||||
"compact": false,
|
||||
"flagsPosition": -1,
|
||||
"fields": [
|
||||
{
|
||||
"name": "id",
|
||||
"required": true,
|
||||
"type": "string",
|
||||
"version": 2
|
||||
},
|
||||
{
|
||||
"name": "title",
|
||||
"required": true,
|
||||
"type": "string",
|
||||
"version": 2
|
||||
},
|
||||
{
|
||||
"name": "body",
|
||||
"required": true,
|
||||
"type": "string",
|
||||
"version": 2
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user