Published
Edited
Aug 2, 2021
Insert cell
md`# Exporting data state to a browser extension
_… a jsonion project, in an ObservableHQ playground._`
Insert cell
Insert cell
jsonion = new Object({
ref: () => {},
path: () => {},
stemIds: () => {},
"{collectionKey}": {
stemId: "{stemId}",
augmentations: ["{augmentationKey}"],

},
"{augmentationKey}": {
stemId: "{stemId}",
augments: ["{augmentationKey}"],

},
"{purposeKey}": {},

stemSchema: {},

typeWrap: () => {},
Type: {s: () => {}},
trieKeys: () => {},

__: [ /* {key: alias} */ ]
});
Insert cell
d_b = new Object({
i: {
"{chr.0}": {
"{keyPath}": {},
"{keyPath}__{sortedBy}": {},
}},
indexCfg: {},
toIndex: (indexingKey, dataset) => {
// charAt(0) // this.indexConfig //
},

_: { localStorage: { "jsonion.proxy": { "{tabIndex}": "{__diff}" }},
// … resolver functions
},
ctx: { // … methods of a simplistic adapter
localStorage: {},
"svg#snow-menu": {}
},
ctxProxy: { // … api: {}, cache: {}
components: {
}
},
parseSchemaObj: () => {},
hashIdQuake: () => {},
abbreviate: () => {},
abbr: () => { return this.abbreviate }
});
Insert cell
/* // // // // // // // // // //

rampage augmentation
priority collection
index coordinate purpose key
````` ``````````` ```````````````````
i { -0, 1, … n { {keyPath}__{sortedBy}


// // // // // // // // // // */

d_b.indexCfg = new Object({
sortedBy: {
'{timestamp.update}': 'DESC'
},
rangeParams: {
'{timestamp.update}': {
a_: 0, b_: (Date.now / 1000)
}
},
returnType: {
srcData: false,
partial: true,
caption: true,
pending: false,
cached: true,
ref: false
},
config: {
expire: {
temp: +37,
persistent: 7*24*3600*30,
},
priority: { highest: 1, lowest: 4,
deprioritizeUntil: 2, offloadAt: 3,
locked: 0
},
//
maxRangeLen: 5000,
minIndexLen: 100
}
});
Insert cell
/* // // // // // //

# Schema of a data node
… a uniform way of accessing a data node's context through time (plurality of database schemes is accounted for)

- Imports and exports JSON objects, specific for each data sources & store implementations (in-memory Key-Value stores & message queues, NoSQL databases)

- Compatibility with SQL is planned as an effort for efficiency: sliced views for serving a variety of aspects; relational data model is aligned with indexing; generating tables for augmented collections at peak demand

// // // // // // */


jsonion.stemSchema = {
__timestamps: {

__synonyms: {
"{origin}": {"{string}": "{string}"}
}},


__actions: {

__synonyms: {
"{origin}": {"{string}": "{string}"}
}},


__state: {

__synonyms: {
"{origin}": {"{string}": "{string}"}
}},


__chain: {

__synonyms: {
"{origin}": {"{string}": "{string}"}
}},

"__{tableKey}": {
"{relation.key}" : "{relation.value}",

__synonyms: {
"{origin}": {"{string}": "{string}"}
}}
},


jsonion.stemSchema.pointer = {
action: {},
valid: {},
time: {},
src: {}, rels: {},
augm: {}, embed: {},
stats: {}, chksum: {},
subset: {}, private: {},
},

jsonion.stemSchema.pointers = {
action: [
"actn", "action-s"
],
timestamps: [
["time-stamp-s", "t", "tn"], "#/action"
],
relations: [
"{related}", "{relation}",
"link-s",
["tag-s", "hashtag-s"]
],
src: [
"{sourceParams}", "mirror-s", "{sourceServiceParams}",
{
"blockchain": [
"{chain}*", [["tx*", "txId"]],
"blockchain*", "chain*",
"*Host", "*Service", "*Type", "*Name", "*Addr-ess", "*URL/i" ]
},
["dht", "distributedHashTable"]
],
augmentation: [
"augm-ent-ation-s", "ext-ension-s"
],
"validate-validation": [
[
"signatures", "cosigned", "cosigning", "undersigned", "undersigning"
],
["proof", "proofOf", "proofOfWork", "proofOfStake"],
"reactions"
],
stats: [
"stat-s", "statistic-s", "statistics", "aggregate-s", "aggregation-s"
],
chksum: [
"cksum-s", "chksum-s", "checksum-s", "digest", "hash-es", "hashchain-s", "merkle", "merkleTree-s"
],
subset: {
ref: [
["ref-s", "reference-s"],
"contains", "contained", "annotations", "includes", "included", "includesData"
],
view: [
"caption-s", "view-s", "partial-s", "partialView-s", "rootData", "rootDataNode-s", "rel-s", "related", "relatedData", "relatedDataNode-s"
]
}
};
Insert cell
jsonion.stemSchema.types = {
dataNodeStem: ["__optional", "__oneOf",
"TRANSLATION", "STEM", "MERGED", "ROOT", "MAIN", "MIRROR", "CAUSE", "EFFECT"
],
dataNodeTree: ["__optional", "__oneOf",
"SYNONYM", "SYNSET", "HYPERNYM", "HYPONYM"
]
};
Insert cell
/*

## Expression function wrapper, which validates "arguments" and resolves subtypes

*/

jsonion.typeWrap = function(
exprFn,
exprName,
invokingTrie = {},
config = null,
subtypeArgs = null,
runtimeArgs = null,

validation = null
){

var type = () => {
return exprFn( ...this.arguments )
};

type.name = exprName;
type.invokeWith =
( invokingTrie.length )
? invokingTrie : null;

type.config = (config)
? config : null;



//
// Wrap up in a validation function

if( validation ){
type.runValidated = () => {
var check = validation(...this.arguments)

if( check.valid ){
return
exprFn(subtypeArgs, runtimeArgs)
} else {
return [false, check]
}
}}


return type;

} // … consider storing within, the data states (eg. tokens and data references, checksum diff for comparison, ...)

//
// # Invoking a variety of types by arguments
// … storing and accessing subtypes of one expression
//
// ie. expressionType(), expressionType["subtype"]
//
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more