const e = require("path"),
r = require("@holepunchto/hyperschema-regen"),
c = require("hyperdispatch"),
o = require("hyperschema"),
h = require("hyperdb/builder"),
n = require("hyperconf/builder"),
t = require("hrpc"),
{
generateContractSchema: i,
generateConfigSchema: a,
generateLocalSchema: p,
generateAPISchema: s,
} = require("../index.js")
function y(r) {
const c = e.join(r, "contract"),
o = e.join(r, "local"),
h = e.join(r, "config"),
n = e.join(r, "api")
return {
contract: {
hyperschema: e.join(c, "hyperschema"),
hyperdb: e.join(c, "hyperdb"),
hyperdispatch: e.join(c, "hyperdispatch"),
},
local: { hyperschema: e.join(o, "hyperschema"), hyperdb: e.join(o, "hyperdb") },
config: { hyperschema: e.join(h, "hyperschema"), hyperconf: e.join(h, "hyperconf") },
api: { hyperschema: e.join(n, "hyperschema"), hrpc: e.join(n, "hrpc") },
}
}
function m(e) {
const r = require("./contract/hyperdispatch"),
n = require("./contract/hyperdb"),
t = o.from(e.contract.hyperschema)
;(i(t), o.toDisk(t))
const a = h.from(e.contract.hyperschema, e.contract.hyperdb)
;(n(a), h.toDisk(a))
const p = c.from(e.contract.hyperschema, e.contract.hyperdispatch, { offset: 2 })
;(r(p), c.toDisk(p))
}
function f(e) {
const r = require("./local/hyperdb"),
c = o.from(e.local.hyperschema)
;(p(c), o.toDisk(c))
const n = h.from(e.local.hyperschema, e.local.hyperdb)
;(r(n), h.toDisk(n))
}
function u(e, r) {
const c = require("../config/generate"),
h = o.from(e.config.hyperschema)
;(a(h), o.toDisk(h))
const t = n.from(e.config.hyperschema, e.config.hyperconf)
;(c(t, r), n.toDisk(t))
}
function d(e) {
const r = require("./api/hrpc"),
c = o.from(e.api.hyperschema)
;(s(c), o.toDisk(c))
const h = t.from(e.api.hyperschema, e.api.hrpc)
;(r(h), t.toDisk(h))
}
module.exports = function (e, { testing: c = !1 } = {}) {
c || r.checkout("schema/spec")
const o = y(e)
;(m(o),
f(o),
u(o, { testing: c }),
d(o),
c || r.validate("schema/spec/contract/hyperdb/db.json", "schema/spec/local/hyperdb/db.json"))
}