@wovin/core 0.0.1-RC9 → 0.0.2
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/dist/applog/applog-helpers.d.ts +23 -0
- package/dist/applog/applog-helpers.d.ts.map +1 -0
- package/dist/applog/applog-utils.d.ts +41 -0
- package/dist/applog/applog-utils.d.ts.map +1 -0
- package/dist/applog/datom-types.d.ts +84 -0
- package/dist/applog/datom-types.d.ts.map +1 -0
- package/dist/applog.d.ts +4 -70
- package/dist/applog.d.ts.map +1 -0
- package/dist/applog.min.js +2 -0
- package/dist/chunk-5R2ELTEJ.min.js +40 -0
- package/dist/chunk-5R2ELTEJ.min.js.map +1 -0
- package/dist/chunk-7IDQIMQO.min.js +1 -0
- package/dist/chunk-F3MRAJXL.min.js +2 -0
- package/dist/{types.js.map → chunk-F3MRAJXL.min.js.map} +1 -1
- package/dist/chunk-HHXZXKNM.min.js +7 -0
- package/dist/chunk-HHXZXKNM.min.js.map +1 -0
- package/dist/chunk-KESATLM4.min.js +8 -0
- package/dist/chunk-KESATLM4.min.js.map +1 -0
- package/dist/chunk-LECZSORU.min.js +2 -0
- package/dist/chunk-LECZSORU.min.js.map +1 -0
- package/dist/chunk-NGPPHX5A.min.js +2 -0
- package/dist/chunk-NGPPHX5A.min.js.map +1 -0
- package/dist/chunk-PL6CNZTW.min.js +2 -0
- package/dist/chunk-PL6CNZTW.min.js.map +1 -0
- package/dist/chunk-RPPZKO5L.min.js +1 -0
- package/dist/index.d.ts +8 -12
- package/dist/index.d.ts.map +1 -0
- package/dist/index.min.js +2 -0
- package/dist/index.min.js.map +1 -0
- package/dist/ipfs/car.d.ts +15 -0
- package/dist/ipfs/car.d.ts.map +1 -0
- package/dist/ipfs/ipfs-utils.d.ts +17 -0
- package/dist/ipfs/ipfs-utils.d.ts.map +1 -0
- package/dist/ipfs.d.ts +3 -36
- package/dist/ipfs.d.ts.map +1 -0
- package/dist/ipfs.min.js +2 -0
- package/dist/mobx/mobx-utils.d.ts +67 -0
- package/dist/mobx/mobx-utils.d.ts.map +1 -0
- package/dist/pubsub/connector.d.ts +7 -0
- package/dist/pubsub/connector.d.ts.map +1 -0
- package/dist/pubsub/publication.d.ts +6 -0
- package/dist/pubsub/publication.d.ts.map +1 -0
- package/dist/{pubsub.d.cts → pubsub/pubsub-types.d.ts} +7 -12
- package/dist/pubsub/pubsub-types.d.ts.map +1 -0
- package/dist/pubsub.d.ts +4 -41
- package/dist/pubsub.d.ts.map +1 -0
- package/dist/pubsub.min.js +2 -0
- package/dist/query/basic.d.ts +65 -0
- package/dist/query/basic.d.ts.map +1 -0
- package/dist/query/divergences.d.ts +12 -0
- package/dist/query/divergences.d.ts.map +1 -0
- package/dist/query/matchers.d.ts +4 -0
- package/dist/query/matchers.d.ts.map +1 -0
- package/dist/query.d.ts +5 -0
- package/dist/query.d.ts.map +1 -0
- package/dist/query.min.js +2 -0
- package/dist/query.min.js.map +1 -0
- package/dist/stream/basic.d.ts +34 -0
- package/dist/stream/basic.d.ts.map +1 -0
- package/dist/stream/filters.d.ts +38 -0
- package/dist/stream/filters.d.ts.map +1 -0
- package/dist/{mapped-8h8bwRuM.d.ts → stream/mapped.d.ts} +5 -6
- package/dist/stream/mapped.d.ts.map +1 -0
- package/dist/{writeable-0WbsIiQn.d.cts → stream/writeable.d.ts} +7 -6
- package/dist/stream/writeable.d.ts.map +1 -0
- package/dist/stream.d.ts +5 -44
- package/dist/stream.d.ts.map +1 -0
- package/dist/stream.min.js +2 -0
- package/dist/stream.min.js.map +1 -0
- package/dist/types/typescript-utils.d.ts +33 -0
- package/dist/types/typescript-utils.d.ts.map +1 -0
- package/dist/types.d.ts +2 -4
- package/dist/types.d.ts.map +1 -0
- package/dist/types.min.js +2 -0
- package/dist/types.min.js.map +1 -0
- package/dist/utils.d.ts +1 -2
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.min.js +1 -0
- package/dist/utils.min.js.map +1 -0
- package/package.json +80 -46
- package/dist/applog.cjs +0 -85
- package/dist/applog.cjs.map +0 -1
- package/dist/applog.d.cts +0 -70
- package/dist/applog.js +0 -85
- package/dist/chunk-F3FYYIAV.js +0 -11
- package/dist/chunk-GT5X2WN4.cjs +0 -59
- package/dist/chunk-GT5X2WN4.cjs.map +0 -1
- package/dist/chunk-JSAJQXI2.cjs +0 -577
- package/dist/chunk-JSAJQXI2.cjs.map +0 -1
- package/dist/chunk-KDR7QXOQ.js +0 -56
- package/dist/chunk-KDR7QXOQ.js.map +0 -1
- package/dist/chunk-KGTU6PJ3.js +0 -577
- package/dist/chunk-KGTU6PJ3.js.map +0 -1
- package/dist/chunk-KHY3SRML.js +0 -768
- package/dist/chunk-KHY3SRML.js.map +0 -1
- package/dist/chunk-OOC3HK3E.cjs +0 -56
- package/dist/chunk-OOC3HK3E.cjs.map +0 -1
- package/dist/chunk-QXNFGJ5R.js +0 -59
- package/dist/chunk-QXNFGJ5R.js.map +0 -1
- package/dist/chunk-UOPZAYFM.cjs +0 -11
- package/dist/chunk-UOPZAYFM.cjs.map +0 -1
- package/dist/chunk-ZPOYKHY6.cjs +0 -768
- package/dist/chunk-ZPOYKHY6.cjs.map +0 -1
- package/dist/index.cjs +0 -87
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -12
- package/dist/index.js +0 -87
- package/dist/index.js.map +0 -1
- package/dist/ipfs.cjs +0 -28
- package/dist/ipfs.cjs.map +0 -1
- package/dist/ipfs.d.cts +0 -36
- package/dist/ipfs.js +0 -28
- package/dist/mapped-mkKwhQgZ.d.cts +0 -20
- package/dist/pubsub.cjs +0 -14
- package/dist/pubsub.cjs.map +0 -1
- package/dist/pubsub.js +0 -14
- package/dist/pubsub.js.map +0 -1
- package/dist/queries.cjs +0 -112
- package/dist/queries.cjs.map +0 -1
- package/dist/queries.d.cts +0 -141
- package/dist/queries.d.ts +0 -141
- package/dist/queries.js +0 -112
- package/dist/queries.js.map +0 -1
- package/dist/stream.cjs +0 -37
- package/dist/stream.cjs.map +0 -1
- package/dist/stream.d.cts +0 -44
- package/dist/stream.js +0 -37
- package/dist/types-A9kYLtyU.d.cts +0 -153
- package/dist/types-A9kYLtyU.d.ts +0 -153
- package/dist/types.cjs +0 -46
- package/dist/types.cjs.map +0 -1
- package/dist/types.d.cts +0 -4
- package/dist/types.js +0 -46
- package/dist/utils.cjs +0 -1
- package/dist/utils.cjs.map +0 -1
- package/dist/utils.d.cts +0 -2
- package/dist/utils.js +0 -1
- package/dist/writeable-r_920qCb.d.ts +0 -16
- /package/dist/{applog.js.map → applog.min.js.map} +0 -0
- /package/dist/{chunk-F3FYYIAV.js.map → chunk-7IDQIMQO.min.js.map} +0 -0
- /package/dist/{ipfs.js.map → chunk-RPPZKO5L.min.js.map} +0 -0
- /package/dist/{stream.js.map → ipfs.min.js.map} +0 -0
- /package/dist/{utils.js.map → pubsub.min.js.map} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/data/applog-utils.ts","../src/mobx/mobx-utils.ts","../src/stream/basic.ts","../src/stream/mapped.ts","../src/stream/filters.ts"],"names":["context","sum","mean","Logger","comparer","stringify","WARN","LOG","DEBUG","VERBOSE","ERROR","reaction","computation","computed","untracked","getDependencyTree","makeObservable","observable","action","onBecomeUnobserved","toJS","rollingFilter","rollingMapper","rollingAcc","getUntrackedPattern","getUntrackedFilterResults"],"mappings":";;;;;AAAA,SAAS,cAAc;AACvB,SAAS,gBAAgB;AACzB,SAAS,gBAAgB;AACzB,OAAO,eAAe;AAWtB,IAAM,EAAE,MAAM,KAAK,OAAO,SAAS,MAAM,IAAI,OAAO,MAAM,OAAO,KAAK;AAE/D,IAAM,oBAAoB,CAAC,MAAc,MAAc,MAAsB,UACnF,QAAQ,QACL,KAAK,cAAc,MAAM,OAAO,IAChC,KAAK,cAAc,MAAM,OAAO;AAE7B,SAAS,gBAAgB,aAAuB,MAAsB,OAAO;AACnF,SAAO,YAAY,KAAK,CAAC,GAAG,MAAM,kBAAkB,EAAE,IAAI,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AAC,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,CAACA,MAAK,CAAC,GAAGA,MAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9H,MAAI,CAAC,OAAO,QAAQ,gBAAgB,EAAE,QAAQ;AAC7C,UAAM,IAAI,MAAM,kBAAkB;AAAA,EACnC;AACA,SAAO;AACR;AACO,SAAS,WACf,SACC;AACD,SAAO,CAAC,SACP,KAAK,OAAO,YAAU;AACrB,eAAW,CAAC,OAAO,YAAY,KAAK,OAAO,QAAQ,OAAO,GAAG;AAC5D,YAAM,cAAc,OAAO,MAAM,WAAW,GAAG,IAAI,MAAM,MAAM,CAAC,IAAI,KAAK;AAEzE,YAAM,cAA2C;AACjD,UAAI,CAAC,gBAAgB,OAAuB,aAAa,WAAW,GAAG;AACtE,eAAO;AAAA,MACR;AAAA,IACD;AACA,WAAO;AAAA,EACR,CAAC;AACH;AAKO,IAAM,4BAA4B,SAASK,2BACjD,QACA,SACA,OAA0B,CAAC,GAC1B;AACD,QAAM,mBAAmB,oBAAoB,OAAO;AACpD,QAAM,SAAS,WAAW,gBAAgB;AAC1C,SAAOX,WAAU,MAAM,OAAO,OAAO,OAAO,CAAC;AAC9C;AAQO,SAAS,UAA4B,QAAsB,QAAgD;AACjH,SAAO,OAAO,QAAQ,SAAS,MAAM;AACtC;AACO,SAAS,UAAU,QAAmE;AAC5F,MAAI,OAAO,QAAQ,QAAQ;AAC1B,UAAMJ,OAAM,wCAAwC,OAAO,OAAO;AAAA,EACnE;AACA,SAAO;AACR;AACO,SAAS,kBAAkB,QAAgE;AACjG,MACC,CAAC,UAAU,QAAQ,gBAAgB,KACnC,CAAC,UAAU,QAAQ,gBAAgB;AAClC,UAAMA,OAAM,sCAAsC,OAAO,OAAO;AAClE,SAAO;AACR","sourcesContent":["import { Logger } from 'besonders-logger'\nimport { isBefore } from 'date-fns'\nimport { comparer } from 'mobx'\nimport stringify from 'safe-stable-stringify'\nimport type {\n\tApplog,\n\tApplogValue,\n\tDatalogQueryPattern,\n\tDatalogQueryResultEntry,\n\tResultContext,\n\tSearchContext,\n\tValueOrMatcher,\n} from './datom-types'\n\nconst { WARN, LOG, DEBUG, VERBOSE, ERROR } = Logger.setup(Logger.DEBUG) // eslint-disable-line no-unused-vars\n\nexport const isoDateStrCompare = (strA: string, strB: string, dir: 'asc' | 'desc' = 'asc') =>\n\tdir === 'asc'\n\t\t? strA.localeCompare(strB, 'en-US')\n\t\t: strB.localeCompare(strA, 'en-US')\n/** Sort by TS (modifies the array, but also returns for ease of use) */\nexport function sortApplogsByTs(appLogArray: Applog[], dir: 'asc' | 'desc' = 'asc') {\n\treturn appLogArray.sort((a, b) => isoDateStrCompare(a.ts, b.ts, dir))\n}\nexport const isTsBefore = (log: Applog, logToCompare: Applog) => isBefore(new Date(log.ts), new Date(logToCompare.ts))\nexport const uniqueEnFromAppLogs = (appLogArray: Applog[]) => [...new Set(appLogArray.map(eachLog => eachLog.en))]\nexport const areApplogsEqual = (logA: Applog, logB: Applog) => comparer.structural(logA, logB)\n\nexport const removeDuplicateAppLogs = (appLogArray: Applog[]) => {\n\tconst logMap = new Map()\n\tfor (const eachLog of appLogArray) {\n\t\tif (!eachLog) {\n\t\t\tERROR(`falsy entry in applogs`, appLogArray)\n\t\t\tthrow new Error(`falsy entry in applogs`)\n\t\t}\n\t\tlogMap.set(stringify(eachLog), eachLog)\n\t}\n\treturn Array.from(logMap.values())\n}\n\n// export const removeDuplicateAndMaybeDeletedAppLogs = (ds: ApplogStream, appLogArray: Applog[], removeDeletedEntities = true) => {\n// \tconst logMap = new Map()\n// \tfor (const eachLog of appLogArray) {\n// \t\tif (!removeDeletedEntities || ds.entityIsDeleted(eachLog.en))\n// \t\t\tlogMap.set(stringify(eachLog), eachLog)\n// \t}\n// \treturn Array.from(logMap.values())\n// }\n\nexport const getHashID = (stringifiable: any, lngth = 8) => cyrb53hash(stringify(stringifiable), 31, lngth) as string\n\nexport function isVariable(x: any): x is string {\n\treturn typeof x === 'string' && x.startsWith('?')\n}\nexport function variableNameWithoutQuestionmark(str: string) {\n\treturn str.slice(1)\n}\n// export function isMatcher(x: any): x is string {\n// \treturn\n// }\nexport function isStaticPattern(x: any): x is ApplogValue {\n\tif (!['string', 'boolean', 'number', 'function'].includes(typeof x)) WARN(`Unhandled pattern value type:`, typeof x, x)\n\treturn !isVariable(x) && ['string', 'boolean', 'number'].includes(typeof x)\n}\n// export function isIgnorePattern(x: any): boolean {\n// \treturn x === '_'\n// }\n\n/*\n * In a pattern from a Query:\n * - variables that don't have a value in the search context:\n * - remove from pattern\n * - add to variableToFill as: { en: 'movieID' } (useful for mapTo)\n * - variables that have a value set:\n * - replace placeholder with actual value\n */\nexport function resolveOrRemoveVariables(pattern: DatalogQueryPattern, candidate: SearchContext) {\n\tlet variablesToFill = {} as Partial<{ [key in keyof Applog]: string }>\n\tconst newPattern = Object.entries(pattern).reduce((acc, [patternKey, patternValue]) => {\n\t\tif (isVariable(patternValue)) {\n\t\t\tconst varName = variableNameWithoutQuestionmark(patternValue)\n\t\t\tconst candidateValue = candidate[varName]\n\t\t\tif (candidateValue) {\n\t\t\t\tacc[patternKey] = candidateValue\n\t\t\t} else {\n\t\t\t\tvariablesToFill[patternKey] = varName\n\t\t\t\t// do nothing to acc = remove field from pattern\n\t\t\t}\n\t\t} else {\n\t\t\tacc[patternKey] = patternValue // keep static value\n\t\t}\n\t\treturn acc\n\t}, {})\n\n\treturn [newPattern, variablesToFill]\n}\n\nfunction matchVariable(variable: string, triplePart: ApplogValue, context: SearchContext): SearchContext {\n\tif (context.hasOwnProperty(variable)) {\n\t\t// TODO: fix lint error with: if (Object.hasOwnProperty.call(context, variable)) {\n\t\tconst bound = context[variable]\n\t\tconst match = matchPart(bound, triplePart, context)\n\t\tVERBOSE('[matchVariable] match?', variable, bound, match)\n\t\treturn match\n\t}\n\tVERBOSE('[matchVariable] initializing variable', variable, 'to', triplePart)\n\treturn { ...context, [variable]: triplePart }\n}\n\nexport function matchPartStatic(field: keyof Applog, patternPart: ValueOrMatcher<ApplogValue>, atomPart: ApplogValue): boolean {\n\tVERBOSE('[matchPartStatic]', field, patternPart, patternPart === atomPart ? '===' : '!==', atomPart)\n\n\tconst result = (() => {\n\t\tif (typeof patternPart === 'function') {\n\t\t\treturn patternPart(atomPart)\n\t\t}\n\t\tif (Array.isArray(patternPart) && !Array.isArray(atomPart) /* ? how to handle array values */) {\n\t\t\treturn patternPart.includes(atomPart)\n\t\t}\n\t\t// if (field === 'at' && typeof patternPart === 'string' && patternPart.endsWith('*')) {\n\t\t// \treturn typeof atomPart === 'string' && atomPart.startsWith(patternPart.slice(0, -1))\n\t\t// }\n\t\treturn patternPart === atomPart\n\t})()\n\n\tVERBOSE('[matchPartStatic] =>', field.startsWith('!') ? '!' : '', result)\n\tif (field.startsWith('!')) {\n\t\treturn !result\n\t} else {\n\t\treturn result\n\t}\n}\nexport function matchPart(patternPart: ValueOrMatcher<ApplogValue>, atomPart: ApplogValue, context: SearchContext): ResultContext {\n\tif (!context) {\n\t\tVERBOSE('[matchPart] no context')\n\t\treturn null\n\t}\n\tif (typeof patternPart === 'string') {\n\t\tif (isVariable(patternPart)) {\n\t\t\treturn matchVariable(patternPart, atomPart, context)\n\t\t} /* TODO: else if (isIgnorePattern(patternPart)) {\n\t\t\treturn matchVariable(patternPart, atomPart, context)\n\t\t} */\n\t}\n\tVERBOSE('[matchPart]', patternPart, patternPart === atomPart ? '===' : '!==', atomPart)\n\tif (typeof patternPart === 'function') {\n\t\treturn patternPart(atomPart) ? context : null\n\t}\n\treturn patternPart === atomPart ? context : null\n}\n\n/**\n * Check if pattern matches triple with context substitutions\n */\nexport function matchPattern(pattern: DatalogQueryPattern, applog: Applog, context: SearchContext): ResultContext {\n\treturn Object.entries(pattern).reduce((context, [field, patternValue]) => {\n\t\tconst applogValue = applog[field]\n\t\t// @ts-expect-error wtf no idea //HACK: ts weird\n\t\tconst patternValT: ValueOrMatcher<ApplogValue> = patternValue\n\t\treturn matchPart(patternValT, applogValue, context)\n\t}, context)\n}\n\nexport function actualize<SELECT extends string>(context: ResultContext, find: readonly SELECT[]): DatalogQueryResultEntry<SELECT> {\n\treturn Object.fromEntries(find.map((findField) => {\n\t\tif (context === null) {\n\t\t\tthrow new Error(`actualize context is null ${find}`)\n\t\t}\n\t\treturn [\n\t\t\tisVariable(findField) ? findField.replace(/^\\?/, '') : findField,\n\t\t\tisVariable(findField) ? context[findField] : findField,\n\t\t]\n\t})) as DatalogQueryResultEntry<SELECT>\n}\nconst sum = function sum(array: number[]) {\n\tvar num = 0\n\tfor (var i = 0, l = array.length; i < l; i++) num += array[i]\n\treturn num\n}\nconst mean = function mean(array: number[]) {\n\treturn sum(array) / array.length\n}\nexport const arrStats = {\n\tmax: function(array: number[]) {\n\t\treturn Math.max.apply(null, array)\n\t},\n\n\tmin: function(array: number[]) {\n\t\treturn Math.min.apply(null, array)\n\t},\n\n\trange: function(array: number[]) {\n\t\treturn arrStats.max(array) - arrStats.min(array)\n\t},\n\n\tmidrange: function(array: number[]) {\n\t\treturn arrStats.range(array) / 2\n\t},\n\n\tsum,\n\n\tmean,\n\n\taverage: mean,\n\n\tmedian: function(array: number[]) {\n\t\tarray.sort(function(a, b) {\n\t\t\treturn a - b\n\t\t})\n\t\tvar mid = array.length / 2\n\t\treturn mid % 1 ? array[mid - 0.5] : (array[mid - 1] + array[mid]) / 2\n\t},\n\n\tmodes: function(array: number[]) {\n\t\tif (!array.length) return []\n\t\tvar modeMap = {},\n\t\t\tmaxCount = 0,\n\t\t\tmodes = []\n\n\t\tarray.forEach(function(val) {\n\t\t\tif (!modeMap[val]) modeMap[val] = 1\n\t\t\telse modeMap[val]++\n\n\t\t\tif (modeMap[val] > maxCount) {\n\t\t\t\tmodes = [val]\n\t\t\t\tmaxCount = modeMap[val]\n\t\t\t} else if (modeMap[val] === maxCount) {\n\t\t\t\tmodes.push(val)\n\t\t\t\tmaxCount = modeMap[val]\n\t\t\t}\n\t\t})\n\t\treturn modes\n\t},\n\n\tvariance: function(array: number[]) {\n\t\tvar mean = arrStats.mean(array)\n\t\treturn arrStats.mean(array.map(function(num) {\n\t\t\treturn Math.pow(num - mean, 2)\n\t\t}))\n\t},\n\n\tstandardDeviation: function(array: number[]) {\n\t\treturn Math.sqrt(arrStats.variance(array))\n\t},\n\n\tmeanAbsoluteDeviation: function(array: number[]) {\n\t\tvar mean = arrStats.mean(array)\n\t\treturn arrStats.mean(array.map(function(num) {\n\t\t\treturn Math.abs(num - mean)\n\t\t}))\n\t},\n\n\tzScores: function(array: number[]) {\n\t\tvar mean = arrStats.mean(array)\n\t\tvar standardDeviation = arrStats.standardDeviation(array)\n\t\treturn array.map(function(num) {\n\t\t\treturn (num - mean) / standardDeviation\n\t\t})\n\t},\n}\n\n// Function aliases:\narrStats.average = arrStats.mean\n\nexport const tsNearlySame = (timeA: string, timeB: string) => timeB.startsWith(timeA.slice(0, timeA.length - 4)) // HACK: to quickly check if same second\n\n/*\n\t\t\t\tcyrb53 (c) 2018 bryc (github.com/bryc)\n\t\t\t\tA fast and simple hash function with decent collision resistance.\n\t\t\t\tLargely inspired by MurmurHash2/3, but with a focus on speed/simplicity.\n\t\t\t\tPublic domain. Attribution appreciated.\n\n\tripped from https://github.com/bryc/code/blob/mast`er/jshash/experimental/cyrb53.js\n*/\nexport const cyrb53hash = function(\n\tstr: string,\n\tseed = 13,\n\tstrLength: number, /* = 0 */\n) {\n\tif (!str?.length) {\n\t\tthrow new Error(`Empty string: ${str}`)\n\t}\n\n\tlet h1 = 0xdeadbeef ^ seed\n\tlet h2 = 0x41c6ce57 ^ seed\n\tfor (let i = 0, ch; i < str.length; i++) {\n\t\tch = str.charCodeAt(i)\n\t\th1 = Math.imul(h1 ^ ch, 2654435761)\n\t\th2 = Math.imul(h2 ^ ch, 1597334677)\n\t}\n\th1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507) ^ Math.imul(h2 ^ (h2 >>> 13), 3266489909)\n\th2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507) ^ Math.imul(h1 ^ (h1 >>> 13), 3266489909)\n\t// if (strLength) {\n\tconst asHex = (4294967296 * (2097151 & h2) + (h1 >>> 0)).toString(16)\n\treturn asHex.slice(-strLength).padStart(strLength, '0')\n\t// }\n\t// // if not specified return as 16 digit integer\n\t// return 4294967296 * (2097151 & h2) + (h1 >>> 0)\n}\nexport function arraysContainSameElements(arr1, arr2) {\n\tif (arr1.length !== arr2.length) {\n\t\treturn false\n\t}\n\n\tconst sortedArr1 = [...arr1].sort()\n\tconst sortedArr2 = [...arr2].sort()\n\n\tfor (let i = 0; i < sortedArr1.length; i++) {\n\t\tif (sortedArr1[i] !== sortedArr2[i]) {\n\t\t\treturn false\n\t\t}\n\t}\n\n\treturn true\n}\nexport function dateNowIso(): string {\n\tconst now = new Date()\n\treturn now.toISOString()\n}\n","import { Logger } from 'besonders-logger'\nimport {\n\t_getGlobalState,\n\t_isComputingDerivation,\n\tcomparer,\n\tcomputed,\n\tconfigure,\n\tgetDependencyTree,\n\tgetObserverTree,\n\tIComputedValue,\n\tIObservableArray,\n\tisAction,\n\tobservable,\n\tonBecomeUnobserved,\n\tReaction,\n\trunInAction,\n\tspy,\n\ttrace,\n\tuntracked,\n} from 'mobx'\nimport { IComputedFnOptions } from 'mobx-utils/lib/computedFn'\nimport stringify from 'safe-stable-stringify'\nimport { DatalogQueryPattern } from '../data/datom-types'\nimport { QueryNodes } from '../queries/basic'\nimport { ApplogStream } from '../stream'\n\nconst { WARN, LOG, DEBUG, VERBOSE, ERROR } = Logger.setup(Logger.INFO) // eslint-disable-line no-unused-vars\n\n// mobx linting - https://mobx.js.org/configuration.html#linting-options\nconfigure({\n\tenforceActions: 'always',\n\t// disableErrorBoundaries: true // (i) this can be useful in case of exceptions to see where they were caused - https://mobx.js.org/configuration.html#disableerrorboundaries-boolean\n\t// computedRequiresReaction: true,\n\t// reactionRequiresObservable: true,\n\t// observableRequiresReaction: true,\n})\n// https://mobx.js.org/installation.html#use-spec-compliant-transpilation-for-class-properties\nif (\n\t!new class {\n\t\txyz\n\t}().hasOwnProperty('xyz')\n) throw new Error('Transpiler is not configured correctly')\n\nif (typeof window === 'object') {\n\t// @ts-expect-error window.\n\twindow.getDependencyTree = getDependencyTree\n\t// @ts-expect-error window.\n\twindow.getObserverTree = getObserverTree\n}\n\nVERBOSE.isDisabled || spy(event => {\n\tVERBOSE(`[mobx]`, event)\n})\n\nexport const createDebugName = ({ caller, stream, pattern: args }: {\n\tcaller?: string\n\tstream?: ApplogStream\n\tpattern?: DatalogQueryPattern | string // ? | any\n}) => {\n\tconst str = `${stream?.name ? stream.name + ' | ' : ''}${caller ?? 'caller?'}${\n\t\targs ? `{${typeof args === 'string' ? args : stringify(args)}}` : ''\n\t}`\n\treturn str\n}\nexport const createDebugNameObj = (args: Parameters<typeof createDebugName>[0]) => {\n\treturn { name: createDebugName(args) } as const\n}\n\nexport function computedStructuralComparer<T>(a: IComputedValue<T>, b: IComputedValue<T>) {\n\treturn untracked(() => comparer.structural(a.get(), b.get()))\n}\nexport function applogStreamComparer(a: ApplogStream, b: ApplogStream) {\n\treturn comparer.shallow(a.applogs, b.applogs)\n}\nexport function queryNodesComparer(a: QueryNodes, b: QueryNodes) {\n\tif (a.size !== b.size) return false\n\tfor (let i = 0; i < a.size; i++) {\n\t\tconst nodeA = a.nodes[i]\n\t\tconst nodeB = b.nodes[i]\n\t\tVERBOSE(`queryNodesComparer`, i, nodeA, nodeB)\n\t\tif (!comparer.structural(nodeA.variables, nodeB.variables)) {\n\t\t\treturn false\n\t\t}\n\t\tif (!applogStreamComparer(nodeA.logsOfThisNode, nodeB.logsOfThisNode)) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\nlet observableArrayMapID = 0\nexport function observableArrayMap<T>(fn: () => T[], { name, equals }: {\n\tname?: string\n\tequals?: typeof comparer.structural\n} = {}) {\n\t// if (!name) name = `${fn.name}_${fn.pattern}`\n\tVERBOSE(`[observableArrayMap] create`, { fnname: fn.name, fn, name, equals })\n\tconst debugName = `observableArrayMap@${++observableArrayMapID}{${name}}`\n\n\tlet observableArr: IObservableArray<T>\n\tlet items\n\n\tfunction runAndTrack() {\n\t\treaction.track(() => {\n\t\t\tDEBUG(`[${debugName}] runAndTrack:`, { name: name ?? fn.name, fn })\n\t\t\titems = fn()\n\t\t\tVERBOSE(`[${debugName}] runAndTrack =>`, items)\n\t\t})\n\t}\n\n\tconst reaction = new Reaction(debugName, (...args) => {\n\t\tVERBOSE(`[${debugName}] reaction.invalidate`, args)\n\t\trunAndTrack()\n\t\trunInAction(() => {\n\t\t\tif (!(equals ?? comparer.structural)(observableArr, items)) {\n\t\t\t\tobservableArr.replace(items)\n\t\t\t}\n\t\t})\n\t})\n\trunAndTrack() // initial run\n\n\tobservableArr = observable.array(items, /* ['NEVER'] as T[] */ { deep: false, name })\n\tVERBOSE(`[${debugName}] deps of reaction`, getDependencyTree(reaction), 'array:', getDependencyTree(observableArr), {\n\t\treaction,\n\t\tobservableArr,\n\t})\n\n\t// THIS STRATEGIES DON'T WORK BECAUSE:\n\t// - Affected reactions run by default immediately (synchronously) if an observable is changed.\n\t// However, they won't run before the end of the current outermost (trans)action.\n\t// (https://mobx.js.org/reactions.html#rules)\n\n\t// const disposer = reaction(\n\t// () => {\n\t// const items = fn();\n\t// VERBOSE(`[observableArrayMap] reaction.check`, items)\n\t// return items\n\t// }, // This function defines what to track\n\t// (items, reaction) => {\n\t// VERBOSE(`[observableArrayMap] reaction.react`, items, reaction)\n\t// runInAction(() => observableArr.replace(items))\n\t// },\n\t// {\n\t// fireImmediately: true // This ensures the reaction runs immediately upon creation\n\t// }\n\t// );\n\n\t// const disposer = autorun(() => {\n\t// const newItems = fn();\n\t// VERBOSE(`[observableArrayMap] items:`, newItems)\n\t// runInAction(() => observableArr.replace(newItems))\n\t// })\n\n\tconst unobserveUnobserving = onBecomeUnobserved(observableArr, () => {\n\t\tVERBOSE(`[observableArrayMap] dispose`)\n\t\t// disposer()\n\t\treaction.dispose()\n\t\tunobserveUnobserving()\n\t})\n\treturn observableArr\n}\n\n/**\n * ADAPTED from https://github.com/mobxjs/mobx-utils/blob/362cbbfb384820d416f253eddc532ebecba89bcb/src/computedFn.ts#L50 to\n * - deep-compare arguments\n * - allow dynamic/optional args\n * - not be so friggin complicated... DeepMap... closest... why?!\n *\n * // TODO: PR upstream\n *\n * computedFnDeepCompare takes a function with an arbitrary amount of arguments,\n * and memoizes the output of the function based on the arguments passed in.\n *\n * computedFnDeepCompare(fn) returns a function with the very same signature. There is no limit on the amount of arguments\n * that is accepted.\n *\n * By default the output of a function call will only be memoized as long as the\n * output is being observed.\n *\n * The function passes into `computedFnDeepCompare` should be pure, not be an action and only be relying on\n * observables.\n *\n * Setting `keepAlive` to `true` will cause the output to be forcefully cached forever.\n * Note that this might introduce memory leaks!\n *\n * @example\n * const store = observable({\n a: 1,\n b: 2,\n c: 3,\n m: computedFnDeepCompare(function(x) {\n return this.a * this.b * x\n })\n })\n\n const d = autorun(() => {\n // store.m(3) will be cached as long as this autorun is running\n console.log(store.m(3) * store.c)\n })\n *\n * @param fn\n * @param keepAliveOrOptions\n */\nexport function computedFnDeepCompare<T extends (...args: any[]) => any>(\n\tfn: T,\n\tkeepAliveOrOptions: (IComputedFnOptions<T> & { name?: string; argsDebugName?: (...args: Parameters<T>) => string }) | boolean = false,\n): T {\n\tif (isAction(fn)) throw new Error(\"computedFnDeepCompare shouldn't be used on actions\")\n\n\tlet memoWarned = false\n\tlet i = 0\n\tconst opts = typeof keepAliveOrOptions === 'boolean'\n\t\t? { keepAlive: keepAliveOrOptions }\n\t\t: keepAliveOrOptions\n\tconst map = new Map<Parameters<T>, IComputedValue<any>>()\n\n\treturn function(this: any, ...args: Parameters<T>): ReturnType<T> {\n\t\tlet existing\n\t\tconst untrackedArgs = untracked(() => args)\n\t\tconst debugName = `computedFnDeepCompare(${opts.name || fn.name}#${++i})${opts.argsDebugName ? `{${opts.argsDebugName(...args)}}` : ''}`\n\n\t\tfor (let [existingArgs, computation] of map.entries()) {\n\t\t\tif (comparer.structural(existingArgs, untrackedArgs)) {\n\t\t\t\texisting = computation\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\t// cache hit, return\n\t\tif (existing) {\n\t\t\tconst cachedResult = existing.get()\n\t\t\tVERBOSE(`[${debugName}] cache hit`, { untrackedArgs, cachedResult })\n\t\t\treturn cachedResult\n\t\t}\n\n\t\t// if function is invoked, and its a cache miss without reactive, there is no point in caching...\n\t\tif (!opts.keepAlive && !_isComputingDerivation()) {\n\t\t\tif (!memoWarned && _getGlobalState().computedRequiresReaction) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t\"invoking a computedFn from outside an reactive context won't be memoized, unless keepAlive is set\",\n\t\t\t\t)\n\t\t\t\tmemoWarned = true\n\t\t\t}\n\t\t\treturn fn.apply(this, args)\n\t\t}\n\n\t\t// create new entry\n\t\tVERBOSE(`[${debugName}] new computation`, { untrackedArgs })\n\t\tlet latestValue: ReturnType<T> | undefined\n\t\tconst computation = computed(\n\t\t\t() => {\n\t\t\t\tVERBOSE(`[${debugName}] update->rerun`, untracked(() => ({ args })), fn)\n\t\t\t\tVERBOSE.isDisabled || trace()\n\t\t\t\treturn (latestValue = fn.apply(this, args))\n\t\t\t},\n\t\t\t{\n\t\t\t\t...opts,\n\t\t\t\tname: debugName,\n\t\t\t},\n\t\t)\n\t\tVERBOSE(`[${debugName}] deps`, getDependencyTree(computation), { untrackedArgs })\n\t\tmap.set(untrackedArgs, computation)\n\n\t\t// clean up if no longer observed\n\t\tif (!opts.keepAlive) {\n\t\t\tconst unobserveUnobserving = onBecomeUnobserved(computation, () => {\n\t\t\t\tVERBOSE(`[${debugName}] dispose`, computation)\n\t\t\t\tmap.delete(untrackedArgs)\n\t\t\t\tif (opts.onCleanup) opts.onCleanup(latestValue, ...args)\n\t\t\t\tlatestValue = undefined\n\t\t\t\tunobserveUnobserving()\n\t\t\t})\n\t\t}\n\t\t// return current val\n\t\treturn computation.get()\n\t} as any\n}\n\nexport function prettifyStreamName(input: string): string {\n\tlet depth = 0\n\tlet result = ''\n\tlet insideCurlyBraces = 0\n\n\tfor (let i = 0; i < input.length; i++) {\n\t\tconst char = input[i]\n\n\t\tif (char === '(') {\n\t\t\tresult += char + '\\n' + '\\t'.repeat(++depth)\n\t\t} else if (char === ')') {\n\t\t\tresult += '\\n' + '\\t'.repeat(--depth) + char\n\t\t} else if (char === ',' && insideCurlyBraces === 0) {\n\t\t\tresult += char + '\\n' + '\\t'.repeat(depth)\n\t\t} else if (char === '{' && insideCurlyBraces === 0) {\n\t\t\tinsideCurlyBraces++\n\t\t\tresult += char + '\\n' + '\\t'.repeat(depth + 1)\n\t\t} else if (char === '}' && insideCurlyBraces === 1) {\n\t\t\tinsideCurlyBraces--\n\t\t\tresult += '\\n' + '\\t'.repeat(depth) + char\n\t\t} else if (char === '{' && insideCurlyBraces > 0) {\n\t\t\tinsideCurlyBraces++\n\t\t\tresult += char\n\t\t} else if (char === '}' && insideCurlyBraces > 1) {\n\t\t\tinsideCurlyBraces--\n\t\t\tresult += char\n\t\t} else {\n\t\t\tresult += char\n\t\t}\n\t}\n\n\treturn result\n}\n","import { computed, makeObservable, untracked } from 'mobx'\n\nimport { Logger } from 'besonders-logger'\nimport { arraysContainSameElements } from '../data/applog-utils'\nimport { areApplogsEqual } from '../data/applog-utils'\nimport { type Applog, ApplogForInsert } from '../data/datom-types'\nimport { prettifyStreamName } from '../mobx/mobx-utils'\n\nconst { WARN, LOG, DEBUG, VERBOSE, ERROR } = Logger.setup(Logger.INFO, { prefix: '[stream]' })\n\nexport type ApplogStreamEvent = { added: readonly Applog[]; removed: readonly Applog[] | null } | { init: readonly Applog[] }\nexport function isInitEvent(event: ApplogStreamEvent): event is { init: readonly Applog[] } {\n\treturn (event as any).init !== undefined\n}\n\nexport abstract class ApplogStream {\n\treadonly filters: string[]\n\treadonly parents: ApplogStream[] | null\n\tprotected _subscribers: ((event: ApplogStreamEvent) => void)[] = []\n\n\tconstructor(\n\t\tparents: ApplogStream | ApplogStream[] | null,\n\t\tfilters: string[],\n\t\tprotected _applogs: Applog[] = [],\n\t\treadonly name: string, /* = null */\n\t) {\n\t\tthis.parents = parents && !Array.isArray(parents) ? [parents] : (parents as ApplogStream[])\n\t\tthis.filters = filters // ? uniq([...parents?.map(p => p.filters), filters])\n\t\tif (this.parents?.length === 0) {\n\t\t\tthrow new Error(`Unhandled: empty parents`)\n\t\t}\n\t\tmakeObservable(this, {\n\t\t\t// applogs: computed, //observable.shallow,\n\t\t\t// applogsSorted: computed,\n\t\t\tsize: computed,\n\t\t\tisEmpty: computed,\n\t\t\tfirstLog: computed,\n\t\t\tlatestLog: computed,\n\t\t}, { name: `Stream{${name}}` })\n\t}\n\n\tabstract get readOnly(): boolean\n\n\tsubscribe(callback: (event: ApplogStreamEvent) => void) {\n\t\tthis._subscribers.push(callback)\n\t\treturn this.unsubscribe.bind(this, callback)\n\t}\n\n\tunsubscribe(callback: (event: ApplogStreamEvent) => void) {\n\t\tconst index = this._subscribers.indexOf(callback)\n\t\tif (index !== -1) {\n\t\t\tthis._subscribers.splice(index, 1)\n\t\t} else WARN(`unsubscribe called for non-existent`, callback)\n\t}\n\n\tprotected notifySubscribers(event: ApplogStreamEvent) {\n\t\tDEBUG(`[stream: ${this.name}] notifying`, this._subscribers.length, 'subscribers of', { ...event, subs: this._subscribers })\n\t\tfor (const subscriber of this._subscribers) {\n\t\t\tsubscriber(event)\n\t\t}\n\t}\n\n\tget applogs(): readonly Applog[] /* (i) only type hint, not actually immutable */ {\n\t\t// VERBOSE.isDisabled || trace()\n\t\treturn this._applogs\n\t}\n\n\tpublic map<R>(fn: (applog: Applog) => R) {\n\t\tif (!this.applogs.map) ERROR(`applogs arr?!`, this.applogs)\n\t\treturn this.applogs.map(fn)\n\t}\n\n\tget firstLog() {\n\t\treturn this.applogs[0]\n\t}\n\tget latestLog() {\n\t\treturn this.applogs[this.applogs.length - 1]\n\t}\n\tpublic hasApplog(applog: Applog, byRef: boolean) {\n\t\tif (byRef) {\n\t\t\treturn this.applogs.includes(applog)\n\t\t} else {\n\t\t\tconst keySet = Object.keys(applog) // HACK: sanity check to catch bugs\n\t\t\treturn !!this.applogs.find(log => {\n\t\t\t\tif (!arraysContainSameElements(keySet, Object.keys(log))) {\n\t\t\t\t\tthrow ERROR(`[hasApplog] field set mismatch:`, { applog, log })\n\t\t\t\t}\n\t\t\t\treturn areApplogsEqual(log, applog)\n\t\t\t})\n\t\t}\n\t}\n\n\tpublic hasApplogWithDiffTs(applog: ApplogForInsert) {\n\t\t// HACK this is basically as inefficient as it gets\n\t\treturn this.applogs.find(existing => (\n\t\t\texisting.en === applog.en\n\t\t\t&& existing.at === applog.at\n\t\t\t&& existing.vl === applog.vl\n\t\t\t&& existing.ag === applog.ag\n\t\t))\n\t}\n\n\tget isEmpty() {\n\t\treturn this.size === 0\n\t}\n\tget size() {\n\t\treturn this.applogs.length\n\t}\n\tget untrackedSize() {\n\t\treturn untracked(() => this.size)\n\t}\n\tget nameAndSizeUntracked() {\n\t\treturn untracked(() => `${this.name} (${this.size})`)\n\t}\n\tget prettyName() {\n\t\treturn prettifyStreamName(this.name)\n\t}\n}\n","import { Logger } from 'besonders-logger'\nimport { sortedIndexBy } from 'lodash-es'\nimport { action, getDependencyTree, IObservableArray, makeObservable, observable, toJS, untracked } from 'mobx'\nimport { Applog } from '../data/datom-types'\nimport { ApplogStream, ApplogStreamEvent, isInitEvent } from './basic'\n\nconst { WARN, LOG, DEBUG, VERBOSE, ERROR } = Logger.setup(Logger.INFO) // eslint-disable-line no-unused-vars\n\nexport type ApplogEventMapper = (this: MappedApplogStream, event: ApplogStreamEvent, sourceStream: ApplogStream) => ApplogStreamEvent\n\nexport class MappedApplogStream extends ApplogStream {\n\tprivate _parentSubscriptions: Map<ApplogStream, ((event: ApplogStreamEvent) => void)> = new Map()\n\n\tconstructor(\n\t\tparents: ApplogStream | ApplogStream[],\n\t\tfilters: string[],\n\t\treadonly _initialLogs: readonly Applog[],\n\t\tprivate _eventMapper: ApplogEventMapper,\n\t\treadonly name: string,\n\t) {\n\t\t// if (!isObservableArray(_initialLogs)) WARN(`[MappedApplogStream: ${name}] initialized with non-observable array`, _initialLogs)\n\t\tsuper(\n\t\t\tparents,\n\t\t\tfilters,\n\t\t\tobservable.array([..._initialLogs], { deep: false, name: `${name}.array` }), // ? not sure if array clone is totally necessary - but I also don't want to risk weird bugs\n\t\t\tname,\n\t\t)\n\n\t\tmakeObservable(this, {\n\t\t\t// @ts-expect-error bc it's private\n\t\t\tonParentUpdate: action,\n\t\t})\n\n\t\tthis.subscribeToParent()\n\t}\n\n\tget readOnly() {\n\t\tif (this.parents.length !== 1) return true\n\t\treturn this.parents[0].readOnly\n\t}\n\n\tprivate subscribeToParent() {\n\t\tif (!this.parents.length) {\n\t\t\tWARN(`MappedStream has no parents`, this)\n\t\t}\n\t\tif (this._parentSubscriptions.size) {\n\t\t\tthrow ERROR(`parents subs must not be called twice`, this)\n\t\t}\n\t\tVERBOSE(`[MappedStream: ${this.name}] subscribing to parents:`, this.parents.map(p => p.name))\n\t\tthis.parents.forEach(p => {\n\t\t\tconst sub = this.onParentUpdate.bind(this, p)\n\t\t\tp.subscribe(sub)\n\t\t\tthis._parentSubscriptions.set(p, sub)\n\t\t})\n\n\t\t// TODO: how to check when to dispose this?\n\t\t// onBecomeUnobserved(this as unknown as IObservable, '_applogs', () => {\n\t\t// DEBUG(`[MappedStream: ${this.name}] disposed - unsubscribing from parents:`, { parents: this.parents, subs: this._parentSubscriptions })\n\t\t// if (this._subscribers.length) WARN(`[MappedStream: ${this.name}] disposed but got subscriptions:`, this._subscribers)\n\t\t// this.parents.forEach(p => {\n\t\t// const sub = this.onParentUpdate.bind(this, p)\n\t\t// p.unsubscribe(sub)\n\t\t// this._parentSubscriptions.delete(p)\n\t\t// })\n\t\t// })\n\t}\n\n\t/**\n\t * // HACK to trigger remap on pattern change in rollingFilter\n\t * should not be used lightly\n\t */\n\ttriggerRemap() {\n\t\tVERBOSE(`MappedStream{${this.nameAndSizeUntracked}} triggerRemap`)\n\t\tthis.parents.forEach(p => {\n\t\t\tthis.onParentUpdate(p, { init: untracked(() => toJS(p.applogs)) })\n\t\t})\n\t}\n\n\tprotected onParentUpdate(stream: ApplogStream, event: ApplogStreamEvent) {\n\t\tVERBOSE(`MappedStream{${this.nameAndSizeUntracked}} parentUpdate`, event)\n\t\tconst mapResult = this._eventMapper(event, stream)\n\t\tVERBOSE(`MappedStream{${this.nameAndSizeUntracked}} parentUpdate => mapped`, mapResult)\n\t\tif (isInitEvent(mapResult)) {\n\t\t\t;(this._applogs as IObservableArray<Applog>).replace([...mapResult.init])\n\t\t} else {\n\t\t\tfor (const log of mapResult.added) {\n\t\t\t\t// insert at right location to maintain sort order\n\t\t\t\tthis._applogs.splice(sortedIndexBy(this._applogs, log, 'ts'), 0, log)\n\t\t\t}\n\t\t\tif (mapResult.removed) {\n\t\t\t\tfor (const toRemove of mapResult.removed) {\n\t\t\t\t\tif (!(this._applogs as IObservableArray<Applog>).remove(toRemove)) {\n\t\t\t\t\t\tif (!isInitEvent(event) && event.removed?.includes(toRemove)) {\n\t\t\t\t\t\t\tDEBUG(`Ignoring remove event for non-existent because it was part of parent event's removed`, toRemove, event) // ? convenience? - or is this a code smell?\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthrow ERROR(`MappedStream{${this.name}} toRemove contained log that doesn't exist`, toRemove, {\n\t\t\t\t\t\t\t\tstream: this,\n\t\t\t\t\t\t\t\tevent,\n\t\t\t\t\t\t\t\tmapResult,\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tVERBOSE(`MappedStream{${this.nameAndSizeUntracked}} parentUpdate => deps?`, getDependencyTree(this._applogs))\n\t\tthis.notifySubscribers(mapResult)\n\t}\n}\n","import { Logger } from 'besonders-logger'\nimport { action, IObservableArray, observable, ObservableMap, ObservableSet, onBecomeUnobserved, reaction, toJS, untracked } from 'mobx'\nimport stringify from 'safe-stable-stringify'\nimport { matchPartStatic } from '../data/applog-utils'\nimport { Applog, ApplogValue, DatalogQueryPattern, ValueOrMatcher } from '../data/datom-types'\nimport { applogStreamComparer, computedFnDeepCompare } from '../mobx/mobx-utils'\nimport { ApplogStream, ApplogStreamEvent, isInitEvent } from './basic'\nimport { ApplogEventMapper, MappedApplogStream } from './mapped'\n\nconst { WARN, LOG, DEBUG, VERBOSE, ERROR } = Logger.setup(Logger.INFO) // eslint-disable-line no-unused-vars\n\nexport const rollingFilter = computedFnDeepCompare(function rollingFilter(\n\tstream: ApplogStream,\n\tpattern: DatalogQueryPattern,\n\topts: { name?: string; extraFilterName?: string } = {},\n) {\n\tlet untrackedPattern = getUntrackedPattern(pattern) // updated in reaction\n\tlet filter = makeFilter(untrackedPattern) // updated in reaction\n\n\t// we are not tracking the filter results here as we are subscribing explicitly to the stream below\n\tconst observableArr = observable.array(\n\t\tuntracked(() => filter(stream.applogs)),\n\t\t{ deep: false, name: `${stream.name} | ${opts.name || `rollingFilter.array{${stringify(untrackedPattern)}}`}` },\n\t)\n\tconst filterAdded: ApplogEventMapper = (event) => {\n\t\tlet mappedEvent: ApplogStreamEvent\n\t\tif (isInitEvent(event)) {\n\t\t\tmappedEvent = { init: filter(event.init) }\n\t\t} else {\n\t\t\tmappedEvent = {\n\t\t\t\tadded: filter(event.added),\n\t\t\t\tremoved: event.removed, // whatever's removed shall be removed\n\t\t\t}\n\t\t}\n\t\tVERBOSE(\n\t\t\t`rollingFilter{${stream.nameAndSizeUntracked} | ${opts.name ? ` '${opts.name}'}` : ''} parentUpdate`,\n\t\t\tuntrackedPattern,\n\t\t\tevent,\n\t\t\t'=>',\n\t\t\tmappedEvent,\n\t\t)\n\t\t// console.trace('rollingFilter.addFiltered', getObserverTree(observableArr))\n\t\t// trace()\n\t\treturn mappedEvent\n\t}\n\tconst mappedStream = new MappedApplogStream(\n\t\tstream,\n\t\t[...stream.filters, ...(opts.extraFilterName ? [opts.extraFilterName] : [])],\n\t\tobservableArr,\n\t\tfilterAdded,\n\t\t`${stream.name} | ${opts.name || `rollingFilter{${stringify(untrackedPattern)}}`}`,\n\t)\n\n\t// observe pattern manually and invalidate stream in case it changes\n\tconst cancelPatternReaction = reaction(() => JSON.parse(JSON.stringify(pattern)), (pat) => {\n\t\tVERBOSE(\n\t\t\t`rollingFilter<${stream.nameAndSizeUntracked}>${opts.name ? ` '${opts.name}'` : ''} patternUpdate`,\n\t\t\tuntrackedPattern,\n\t\t\t'=>',\n\t\t\tpat, /* , getDependencyTree(pat) */\n\t\t)\n\t\tuntrackedPattern = pat\n\t\tfilter = makeFilter(untrackedPattern)\n\t\tmappedStream.triggerRemap() // HACK\n\t})\n\n\tconst unobserveUnobserving = onBecomeUnobserved(observableArr, () => {\n\t\tVERBOSE(`rollingFilter<${stream.nameAndSizeUntracked}>${opts.name ? ` '${opts.name}'` : ''} unobserve`, untrackedPattern)\n\t\tcancelPatternReaction()\n\t\tunobserveUnobserving()\n\t})\n\n\treturn mappedStream\n}, { equals: applogStreamComparer, argsDebugName: (_, pattern, opts) => `${stringify(pattern)}, ${stringify(opts)}` })\n\nexport const rollingMapper = computedFnDeepCompare(function rollingMapper(\n\tstream: ApplogStream,\n\teventMapper: ApplogEventMapper,\n\topts: { name?: string; extraFilterName?: string } = {},\n) {\n\tconst initialMapResult = untracked(() => eventMapper.call(null, { init: stream.applogs }, stream))\n\tif (!isInitEvent(initialMapResult)) {\n\t\tthrow ERROR('Initial run must return init event')\n\t}\n\tconst initialLogs = initialMapResult.init\n\n\treturn new MappedApplogStream(\n\t\tstream,\n\t\t[...stream.filters, ...(opts.extraFilterName ? [opts.extraFilterName] : [])],\n\t\tinitialLogs,\n\t\teventMapper,\n\t\t`${stream.name} | ${opts.name || `rollingMapper`}`,\n\t)\n}, { equals: applogStreamComparer, argsDebugName: (_, pattern, opts) => `${stringify(pattern)}, ${stringify(opts)}` })\n\nexport const rollingAcc = computedFnDeepCompare(function rollingAcc<ACC extends IObservableArray | ObservableMap | ObservableSet>(\n\tstream: ApplogStream,\n\tacc: ACC,\n\teventMapper: (event: ApplogStreamEvent, acc: ACC) => void,\n) {\n\teventMapper = action(eventMapper)\n\teventMapper({ init: stream.applogs }, acc)\n\tstream.subscribe(event => {\n\t\teventMapper(event, acc)\n\t})\n\n\treturn acc\n}, { argsDebugName: (stream) => `rollingAcc{${stream.nameAndSizeUntracked}}` })\n\n// function rollingFilter(\n// db: ApplogStreamIDB,\n// filter: (logs: Applog[]) => Applog[],\n// name: string,\n// ) {\n// const filtered = observable.array(filter(untracked(() => db.applogs)), { deep: false });\n\n// const observableArr = rollingFilter(filter, db)\n// const addFiltered = /* action( */(added: Applog[]) => {\n// VERBOSE(`rollingFilter<${db.nameAndSize}>.update`, pattern, added)\n// // filter(added).forEach(log => result.push(log)) //? no bulk insert?\n// observableArr.push(...added)\n// }/* ) */;\n\n// db.subscribe(addFiltered);\n// onBecomeUnobserved(filtered, () => {\n// VERBOSE(`rollingFilter<${db.nameAndSize}>.unobserve`, filter)\n// db.unsubscribe(addFiltered);\n// });\n// return new ApplogStream(filtered, `${db.name} | ${name}`)\n// }\n\nexport const getUntrackedPattern = function getUntrackedPattern(\n\tpattern: DatalogQueryPattern,\n) {\n\tconst untrackedPattern = untracked(() => Object.fromEntries(Object.entries(toJS(pattern)).map(([k, v]) => [toJS(k), toJS(v)])))\n\tif (!Object.entries(untrackedPattern).length) {\n\t\tthrow new Error(`Pattern is empty`)\n\t}\n\treturn untrackedPattern\n}\nexport function makeFilter(\n\tpattern: DatalogQueryPattern,\n) {\n\treturn (logs: readonly Applog[]) =>\n\t\tlogs.filter(applog => {\n\t\t\tfor (const [field, patternValue] of Object.entries(pattern)) {\n\t\t\t\tconst applogValue = applog[field.startsWith('!') ? field.slice(1) : field]\n\t\t\t\t// @ts-expect-error wtf no idea //HACK: ts weird\n\t\t\t\tconst patternValT: ValueOrMatcher<ApplogValue> = patternValue\n\t\t\t\tif (!matchPartStatic(field as keyof Applog, patternValT, applogValue)) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true\n\t\t})\n}\n\n/**\n * // ! think twice before using\n */\nexport const getUntrackedFilterResults = function getUntrackedFilterResults(\n\tstream: ApplogStream,\n\tpattern: DatalogQueryPattern,\n\topts: { name?: string } = {},\n) {\n\tconst untrackedPattern = getUntrackedPattern(pattern)\n\tconst filter = makeFilter(untrackedPattern)\n\treturn untracked(() => filter(stream.applogs))\n}\n\n///////////////////////////\n// FILTERED STREAM TYPES //\n///////////////////////////\nexport type ApplogStreamWithFilter<T extends string> = ApplogStream & {\n\tfilters: T[]\n}\nexport function hasFilter<T extends string>(stream: ApplogStream, filter: T): stream is ApplogStreamWithFilter<T> {\n\treturn stream.filters.includes(filter)\n}\nexport function assertRaw(stream: ApplogStream) /* : stream is ApplogStreamWithoutFilters */ {\n\tif (stream.filters.length) {\n\t\tthrow ERROR(`should be unfiltered stream, but is:`, stream.filters)\n\t}\n\treturn stream as ApplogStreamWithoutFilters\n}\nexport function assertOnlyCurrent(stream: ApplogStream) /* : stream is ApplogStreamOnlyCurrent */ {\n\tif (\n\t\t!hasFilter(stream, 'withoutHistory') ||\n\t\t!hasFilter(stream, 'withoutDeleted')\n\t) throw ERROR(`should be filtered stream, but is:`, stream.filters)\n\treturn stream\n}\nexport type ApplogStreamOnlyCurrent = ApplogStreamWithFilter<'withoutHistory' | 'withoutDeleted'>\nexport type ApplogStreamWithoutFilters = ApplogStream & { filters: [] }\n"]}
|
package/dist/index.cjs
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
|
-
|
|
3
|
-
var _chunkOOC3HK3Ecjs = require('./chunk-OOC3HK3E.cjs');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var _chunkZPOYKHY6cjs = require('./chunk-ZPOYKHY6.cjs');
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var _chunkGT5X2WN4cjs = require('./chunk-GT5X2WN4.cjs');
|
|
11
|
-
require('./chunk-UOPZAYFM.cjs');
|
|
12
|
-
|
|
13
|
-
// src/data/publication.ts
|
|
14
|
-
var _besonderslogger = require('besonders-logger');
|
|
15
|
-
var { WARN, LOG, DEBUG, VERBOSE, ERROR } = _besonderslogger.Logger.setup(_besonderslogger.Logger.INFO);
|
|
16
|
-
var neverEncryptAttrs = [
|
|
17
|
-
"agent/jwkd",
|
|
18
|
-
"agent/appAgent",
|
|
19
|
-
"pub/encryptedFor",
|
|
20
|
-
"pub/sharedKey"
|
|
21
|
-
];
|
|
22
|
-
async function preparePubForPush(agentHash, agentFullID, publication, dataStream, applogs) {
|
|
23
|
-
let maybeEncryptedApplogs = [];
|
|
24
|
-
const { sharedAgents, sharedKeyMap, sharedKey } = _nullishCoalesce(publication, () => ( {}));
|
|
25
|
-
const agentLogs = _chunkZPOYKHY6cjs.rollingFilter.call(void 0, dataStream, {
|
|
26
|
-
en: agentHash,
|
|
27
|
-
at: ["agent/ecdh", "agent/jwkd", "agent/appAgent"]
|
|
28
|
-
});
|
|
29
|
-
DEBUG(`[publish] adding agent logs:`, agentLogs);
|
|
30
|
-
applogs.push(...agentLogs.applogs);
|
|
31
|
-
let encPayload;
|
|
32
|
-
const encryptAndTestDecrypt = async (applog, keyToUse) => {
|
|
33
|
-
throw new Error(`todo: enc`);
|
|
34
|
-
};
|
|
35
|
-
DEBUG("[publish] applogs ", applogs);
|
|
36
|
-
if (sharedAgents) {
|
|
37
|
-
if (!sharedKey || !sharedKeyMap) {
|
|
38
|
-
DEBUG("weird state, publishing nonEncrypted", { sharedAgents, sharedKeyMap, sharedKey });
|
|
39
|
-
maybeEncryptedApplogs = applogs;
|
|
40
|
-
} else {
|
|
41
|
-
const agentSharedKeyLogs = [];
|
|
42
|
-
for (const [eachAgent, eachEncKey] of Array.from(sharedKeyMap.entries())) {
|
|
43
|
-
agentSharedKeyLogs.push({
|
|
44
|
-
ag: agentHash,
|
|
45
|
-
en: eachAgent,
|
|
46
|
-
at: "pub/sharedKey",
|
|
47
|
-
vl: eachEncKey
|
|
48
|
-
// these are encrypted with the derived key from the local agent private and remote agent public keys
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
for (const eachLog of applogs) {
|
|
52
|
-
VERBOSE("[crypto] encrypting ", eachLog);
|
|
53
|
-
if (neverEncryptAttrs.includes(eachLog.at)) {
|
|
54
|
-
maybeEncryptedApplogs.push(
|
|
55
|
-
/* prepareForPub( */
|
|
56
|
-
eachLog
|
|
57
|
-
/* ) */
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
try {
|
|
61
|
-
encPayload = await encryptAndTestDecrypt(eachLog, sharedKey);
|
|
62
|
-
} catch (err) {
|
|
63
|
-
}
|
|
64
|
-
maybeEncryptedApplogs.push(encPayload);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
} else
|
|
68
|
-
maybeEncryptedApplogs = applogs;
|
|
69
|
-
maybeEncryptedApplogs = maybeEncryptedApplogs.map((log) => log.en ? _chunkGT5X2WN4cjs.prepareForPub.call(void 0, log) : log);
|
|
70
|
-
const encodedApplogs = await Promise.all(maybeEncryptedApplogs.map(_chunkGT5X2WN4cjs.encodeBlockOriginal));
|
|
71
|
-
DEBUG("[publish] encoded root", { agentHash, agentFullID, encodedApplogs });
|
|
72
|
-
const cids = encodedApplogs.map((b) => _nullishCoalesce(b.cid, () => ( null)));
|
|
73
|
-
const root = { applogs: cids };
|
|
74
|
-
const encodedRoot = await _chunkGT5X2WN4cjs.encodeBlockOriginal.call(void 0, root);
|
|
75
|
-
DEBUG("[publish] encoded root", { cids, encodedRoot });
|
|
76
|
-
const car = await _chunkOOC3HK3Ecjs.makeCarBlob.call(void 0, encodedRoot.cid, [encodedRoot, ...encodedApplogs]);
|
|
77
|
-
return car;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// src/index.ts
|
|
81
|
-
var wovinCoreTest = 12345.7;
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
exports.neverEncryptAttrs = neverEncryptAttrs; exports.preparePubForPush = preparePubForPush; exports.wovinCoreTest = wovinCoreTest;
|
|
87
|
-
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/data/publication.ts","../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,SAAS,cAAc;AAUvB,IAAM,EAAE,MAAM,KAAK,OAAO,SAAS,MAAM,IAAI,OAAO,MAAM,OAAO,IAAI;AAE9D,IAAM,oBAAoB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAEA,eAAsB,kBACrB,WACA,aACA,aACA,YACA,SACC;AAKD,MAAI,wBAAsE,CAAC;AAE3E,QAAM,EAAE,cAAc,cAAc,UAAU,IAAI,eAAe,CAAC;AAClE,QAAM,YAAY,cAAc,YAAY;AAAA,IAC3C,IAAI;AAAA,IACJ,IAAI,CAAC,cAAc,cAAc,gBAAgB;AAAA,EAClD,CAAC;AACD,QAAM,gCAAgC,SAAS;AAC/C,UAAQ,KAAK,GAAG,UAAU,OAAO;AACjC,MAAI;AACJ,QAAM,wBAAwB,OAAO,QAAyB,aAAwB;AACrF,UAAM,IAAI,MAAM,WAAW;AAAA,EAiB5B;AACA,QAAM,sBAAsB,OAAO;AAEnC,MAAI,cAAc;AACjB,QAAI,CAAC,aAAa,CAAC,cAAc;AAChC,YAAM,wCAAwC,EAAE,cAAc,cAAc,UAAU,CAAC;AACvF,8BAAwB;AAAA,IACzB,OAAO;AACN,YAAM,qBAAqB,CAAC;AAC5B,iBAAW,CAAC,WAAW,UAAU,KAAK,MAAM,KAAK,aAAa,QAAQ,CAAC,GAAG;AACzE,2BAAmB,KAAK;AAAA,UACvB,IAAI;AAAA,UACJ,IAAI;AAAA,UACJ,IAAI;AAAA,UACJ,IAAI;AAAA;AAAA,QACL,CAAC;AAAA,MACF;AAKA,iBAAW,WAAW,SAAS;AAC9B,gBAAQ,wBAAwB,OAAO;AACvC,YAAI,kBAAkB,SAAS,QAAQ,EAAE,GAAG;AAC3C,gCAAsB;AAAA;AAAA,YAA0B;AAAA;AAAA,UAAe;AAAA,QAGhE;AACA,YAAI;AACH,uBAAa,MAAM,sBAAsB,SAAS,SAAS;AAAA,QAC5D,SAAS,KAAK;AAAA,QAGd;AACA,8BAAsB,KAAK,UAAU;AAAA,MACtC;AAAA,IACD;AAAA,EACD;AAAO,4BAAwB;AAE/B,0BAAwB,sBAAsB,IAAI,SAAQ,IAAe,KAAK,cAAc,GAAa,IAAI,GAAG;AAChH,QAAM,iBAAiB,MAAM,QAAQ,IAAI,sBAAsB,IAAI,mBAAmB,CAAC;AACvF,QAAM,0BAA0B,EAAE,WAAW,aAAa,eAAe,CAAC;AAE1E,QAAM,OAAO,eAAe,IAAI,OAAK,EAAE,OAAO,IAAI;AAClD,QAAM,OAAO,EAAE,SAAS,KAAK;AAC7B,QAAM,cAAc,MAAM,oBAAoB,IAAI;AAClD,QAAM,0BAA0B,EAAE,MAAM,YAAY,CAAC;AAErD,QAAM,MAAM,MAAM,YAAY,YAAY,KAAK,CAAC,aAAa,GAAG,cAAc,CAAC;AAC/E,SAAO;AACR;;;AC5GO,IAAM,gBAAgB","sourcesContent":["import { Logger } from 'besonders-logger'\nimport { stringify } from 'safe-stable-stringify'\nimport { makeCarBlob } from '../ipfs/car'\nimport { encodeBlockOriginal, prepareForPub } from '../ipfs/ipfs-utils'\nimport { ApplogStream } from '../stream'\nimport { rollingFilter } from '../stream/filters'\nimport { cyrb53hash } from './applog-utils'\nimport { Applog, ApplogForInsert, EntityID } from './datom-types'\nimport { IPublication } from './pubsub-types'\n\nconst { WARN, LOG, DEBUG, VERBOSE, ERROR } = Logger.setup(Logger.INFO) // eslint-disable-line no-unused-vars\n\nexport const neverEncryptAttrs = [\n\t'agent/jwkd',\n\t'agent/appAgent',\n\t'pub/encryptedFor',\n\t'pub/sharedKey',\n]\n\nexport async function preparePubForPush(\n\tagentHash: EntityID,\n\tagentFullID: string,\n\tpublication: IPublication,\n\tdataStream: ApplogStream,\n\tapplogs: ApplogForInsert[],\n) {\n\t// await initWasm()\n\t// const car_data = Wasm.make_car(applogs)\n\t// DEBUG('Car data:', car_data)\n\t// TODO prevent publish if there is no new info\n\tlet maybeEncryptedApplogs: Array<Applog | ApplogForInsert | Uint8Array> = []\n\n\tconst { sharedAgents, sharedKeyMap, sharedKey } = publication ?? {}\n\tconst agentLogs = rollingFilter(dataStream, {\n\t\ten: agentHash,\n\t\tat: ['agent/ecdh', 'agent/jwkd', 'agent/appAgent'],\n\t})\n\tDEBUG(`[publish] adding agent logs:`, agentLogs)\n\tapplogs.push(...agentLogs.applogs)\n\tlet encPayload\n\tconst encryptAndTestDecrypt = async (applog: ApplogForInsert, keyToUse: CryptoKey) => {\n\t\tthrow new Error(`todo: enc`) // TODO: ENC\n\t\t// const eachLog = prepareForPub(applog) // without cid\n\t\t// const enc = new TextEncoder()\n\t\t// const stringified = stringify(eachLog)\n\t\t// const stringifiedEncodedAppLogPayload = enc.encode(stringified) // TODO: consider encodeToDagJson instead\n\t\t// VERBOSE('[odd]', { eachLog, stringified, stringifiedEncodedAppLogPayload })\n\n\t\t// try {\n\t\t// \tencPayload = await agent.crypto?.aes.encrypt(stringifiedEncodedAppLogPayload, keyToUse, SymmAlg.AES_GCM)\n\t\t// } catch (err) {\n\t\t// \tthrow ERROR('FAILED TO ENC payload length:', stringifiedEncodedAppLogPayload.length, { err })\n\t\t// }\n\n\t\t// const decrypted = await decryptWithAesSharedKey(encPayload, keyToUse, 'string')\n\n\t\t// VERBOSE('[odd] encrypted length:', stringifiedEncodedAppLogPayload.length, { encPayload, decrypted })\n\t\t// return encPayload\n\t}\n\tDEBUG('[publish] applogs ', applogs)\n\n\tif (sharedAgents) { // encrypt all Applogs\n\t\tif (!sharedKey || !sharedKeyMap) {\n\t\t\tDEBUG('weird state, publishing nonEncrypted', { sharedAgents, sharedKeyMap, sharedKey }) // ? could this be a problem\n\t\t\tmaybeEncryptedApplogs = applogs\n\t\t} else {\n\t\t\tconst agentSharedKeyLogs = []\n\t\t\tfor (const [eachAgent, eachEncKey] of Array.from(sharedKeyMap.entries())) {\n\t\t\t\tagentSharedKeyLogs.push({\n\t\t\t\t\tag: agentHash,\n\t\t\t\t\ten: eachAgent,\n\t\t\t\t\tat: 'pub/sharedKey',\n\t\t\t\t\tvl: eachEncKey, // these are encrypted with the derived key from the local agent private and remote agent public keys\n\t\t\t\t})\n\t\t\t}\n\t\t\t// const encryptedForLogs = await insertApplogs(agentSharedKeyLogs)\n\t\t\t// DEBUG(`[publish] adding agentSharedKeyLogs:`, encryptedForLogs)\n\n\t\t\t// TODO ensure that all needed keys are in\n\t\t\tfor (const eachLog of applogs) {\n\t\t\t\tVERBOSE('[crypto] encrypting ', eachLog)\n\t\t\t\tif (neverEncryptAttrs.includes(eachLog.at)) {\n\t\t\t\t\tmaybeEncryptedApplogs.push(/* prepareForPub( */ eachLog /* ) */) // ? this seemed to double the below one - @gotjoshua?\n\n\t\t\t\t\t// continue\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tencPayload = await encryptAndTestDecrypt(eachLog, sharedKey)\n\t\t\t\t} catch (err) {\n\t\t\t\t\t// its already traced in encryptAndTestDecrypt\n\t\t\t\t\t// continue\n\t\t\t\t}\n\t\t\t\tmaybeEncryptedApplogs.push(encPayload)\n\t\t\t}\n\t\t}\n\t} else maybeEncryptedApplogs = applogs // publish nonEncrypted\n\n\tmaybeEncryptedApplogs = maybeEncryptedApplogs.map(log => (log as Applog).en ? prepareForPub(log as Applog) : log)\n\tconst encodedApplogs = await Promise.all(maybeEncryptedApplogs.map(encodeBlockOriginal))\n\tDEBUG('[publish] encoded root', { agentHash, agentFullID, encodedApplogs })\n\n\tconst cids = encodedApplogs.map(b => b.cid ?? null) // ? why would it be null\n\tconst root = { applogs: cids }\n\tconst encodedRoot = await encodeBlockOriginal(root)\n\tDEBUG('[publish] encoded root', { cids, encodedRoot })\n\n\tconst car = await makeCarBlob(encodedRoot.cid, [encodedRoot, ...encodedApplogs])\n\treturn car\n}\n","export const wovinCoreTest = 12345.7\n\nexport * from './data/publication'\n"]}
|
package/dist/index.d.cts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { h as EntityID, A as ApplogStream, d as ApplogForInsert } from './types-A9kYLtyU.cjs';
|
|
2
|
-
import { IPublication } from './pubsub.cjs';
|
|
3
|
-
import '@sinclair/typebox';
|
|
4
|
-
import '@sinclair/typebox/compiler';
|
|
5
|
-
import 'multiformats/cid';
|
|
6
|
-
|
|
7
|
-
declare const neverEncryptAttrs: string[];
|
|
8
|
-
declare function preparePubForPush(agentHash: EntityID, agentFullID: string, publication: IPublication, dataStream: ApplogStream, applogs: ApplogForInsert[]): Promise<Blob>;
|
|
9
|
-
|
|
10
|
-
declare const wovinCoreTest = 12345.7;
|
|
11
|
-
|
|
12
|
-
export { neverEncryptAttrs, preparePubForPush, wovinCoreTest };
|
package/dist/index.js
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
makeCarBlob
|
|
3
|
-
} from "./chunk-KDR7QXOQ.js";
|
|
4
|
-
import {
|
|
5
|
-
rollingFilter
|
|
6
|
-
} from "./chunk-KHY3SRML.js";
|
|
7
|
-
import {
|
|
8
|
-
encodeBlockOriginal,
|
|
9
|
-
prepareForPub
|
|
10
|
-
} from "./chunk-QXNFGJ5R.js";
|
|
11
|
-
import "./chunk-F3FYYIAV.js";
|
|
12
|
-
|
|
13
|
-
// src/data/publication.ts
|
|
14
|
-
import { Logger } from "besonders-logger";
|
|
15
|
-
var { WARN, LOG, DEBUG, VERBOSE, ERROR } = Logger.setup(Logger.INFO);
|
|
16
|
-
var neverEncryptAttrs = [
|
|
17
|
-
"agent/jwkd",
|
|
18
|
-
"agent/appAgent",
|
|
19
|
-
"pub/encryptedFor",
|
|
20
|
-
"pub/sharedKey"
|
|
21
|
-
];
|
|
22
|
-
async function preparePubForPush(agentHash, agentFullID, publication, dataStream, applogs) {
|
|
23
|
-
let maybeEncryptedApplogs = [];
|
|
24
|
-
const { sharedAgents, sharedKeyMap, sharedKey } = publication ?? {};
|
|
25
|
-
const agentLogs = rollingFilter(dataStream, {
|
|
26
|
-
en: agentHash,
|
|
27
|
-
at: ["agent/ecdh", "agent/jwkd", "agent/appAgent"]
|
|
28
|
-
});
|
|
29
|
-
DEBUG(`[publish] adding agent logs:`, agentLogs);
|
|
30
|
-
applogs.push(...agentLogs.applogs);
|
|
31
|
-
let encPayload;
|
|
32
|
-
const encryptAndTestDecrypt = async (applog, keyToUse) => {
|
|
33
|
-
throw new Error(`todo: enc`);
|
|
34
|
-
};
|
|
35
|
-
DEBUG("[publish] applogs ", applogs);
|
|
36
|
-
if (sharedAgents) {
|
|
37
|
-
if (!sharedKey || !sharedKeyMap) {
|
|
38
|
-
DEBUG("weird state, publishing nonEncrypted", { sharedAgents, sharedKeyMap, sharedKey });
|
|
39
|
-
maybeEncryptedApplogs = applogs;
|
|
40
|
-
} else {
|
|
41
|
-
const agentSharedKeyLogs = [];
|
|
42
|
-
for (const [eachAgent, eachEncKey] of Array.from(sharedKeyMap.entries())) {
|
|
43
|
-
agentSharedKeyLogs.push({
|
|
44
|
-
ag: agentHash,
|
|
45
|
-
en: eachAgent,
|
|
46
|
-
at: "pub/sharedKey",
|
|
47
|
-
vl: eachEncKey
|
|
48
|
-
// these are encrypted with the derived key from the local agent private and remote agent public keys
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
for (const eachLog of applogs) {
|
|
52
|
-
VERBOSE("[crypto] encrypting ", eachLog);
|
|
53
|
-
if (neverEncryptAttrs.includes(eachLog.at)) {
|
|
54
|
-
maybeEncryptedApplogs.push(
|
|
55
|
-
/* prepareForPub( */
|
|
56
|
-
eachLog
|
|
57
|
-
/* ) */
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
try {
|
|
61
|
-
encPayload = await encryptAndTestDecrypt(eachLog, sharedKey);
|
|
62
|
-
} catch (err) {
|
|
63
|
-
}
|
|
64
|
-
maybeEncryptedApplogs.push(encPayload);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
} else
|
|
68
|
-
maybeEncryptedApplogs = applogs;
|
|
69
|
-
maybeEncryptedApplogs = maybeEncryptedApplogs.map((log) => log.en ? prepareForPub(log) : log);
|
|
70
|
-
const encodedApplogs = await Promise.all(maybeEncryptedApplogs.map(encodeBlockOriginal));
|
|
71
|
-
DEBUG("[publish] encoded root", { agentHash, agentFullID, encodedApplogs });
|
|
72
|
-
const cids = encodedApplogs.map((b) => b.cid ?? null);
|
|
73
|
-
const root = { applogs: cids };
|
|
74
|
-
const encodedRoot = await encodeBlockOriginal(root);
|
|
75
|
-
DEBUG("[publish] encoded root", { cids, encodedRoot });
|
|
76
|
-
const car = await makeCarBlob(encodedRoot.cid, [encodedRoot, ...encodedApplogs]);
|
|
77
|
-
return car;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// src/index.ts
|
|
81
|
-
var wovinCoreTest = 12345.7;
|
|
82
|
-
export {
|
|
83
|
-
neverEncryptAttrs,
|
|
84
|
-
preparePubForPush,
|
|
85
|
-
wovinCoreTest
|
|
86
|
-
};
|
|
87
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/data/publication.ts","../src/index.ts"],"sourcesContent":["import { Logger } from 'besonders-logger'\nimport { stringify } from 'safe-stable-stringify'\nimport { makeCarBlob } from '../ipfs/car'\nimport { encodeBlockOriginal, prepareForPub } from '../ipfs/ipfs-utils'\nimport { ApplogStream } from '../stream'\nimport { rollingFilter } from '../stream/filters'\nimport { cyrb53hash } from './applog-utils'\nimport { Applog, ApplogForInsert, EntityID } from './datom-types'\nimport { IPublication } from './pubsub-types'\n\nconst { WARN, LOG, DEBUG, VERBOSE, ERROR } = Logger.setup(Logger.INFO) // eslint-disable-line no-unused-vars\n\nexport const neverEncryptAttrs = [\n\t'agent/jwkd',\n\t'agent/appAgent',\n\t'pub/encryptedFor',\n\t'pub/sharedKey',\n]\n\nexport async function preparePubForPush(\n\tagentHash: EntityID,\n\tagentFullID: string,\n\tpublication: IPublication,\n\tdataStream: ApplogStream,\n\tapplogs: ApplogForInsert[],\n) {\n\t// await initWasm()\n\t// const car_data = Wasm.make_car(applogs)\n\t// DEBUG('Car data:', car_data)\n\t// TODO prevent publish if there is no new info\n\tlet maybeEncryptedApplogs: Array<Applog | ApplogForInsert | Uint8Array> = []\n\n\tconst { sharedAgents, sharedKeyMap, sharedKey } = publication ?? {}\n\tconst agentLogs = rollingFilter(dataStream, {\n\t\ten: agentHash,\n\t\tat: ['agent/ecdh', 'agent/jwkd', 'agent/appAgent'],\n\t})\n\tDEBUG(`[publish] adding agent logs:`, agentLogs)\n\tapplogs.push(...agentLogs.applogs)\n\tlet encPayload\n\tconst encryptAndTestDecrypt = async (applog: ApplogForInsert, keyToUse: CryptoKey) => {\n\t\tthrow new Error(`todo: enc`) // TODO: ENC\n\t\t// const eachLog = prepareForPub(applog) // without cid\n\t\t// const enc = new TextEncoder()\n\t\t// const stringified = stringify(eachLog)\n\t\t// const stringifiedEncodedAppLogPayload = enc.encode(stringified) // TODO: consider encodeToDagJson instead\n\t\t// VERBOSE('[odd]', { eachLog, stringified, stringifiedEncodedAppLogPayload })\n\n\t\t// try {\n\t\t// \tencPayload = await agent.crypto?.aes.encrypt(stringifiedEncodedAppLogPayload, keyToUse, SymmAlg.AES_GCM)\n\t\t// } catch (err) {\n\t\t// \tthrow ERROR('FAILED TO ENC payload length:', stringifiedEncodedAppLogPayload.length, { err })\n\t\t// }\n\n\t\t// const decrypted = await decryptWithAesSharedKey(encPayload, keyToUse, 'string')\n\n\t\t// VERBOSE('[odd] encrypted length:', stringifiedEncodedAppLogPayload.length, { encPayload, decrypted })\n\t\t// return encPayload\n\t}\n\tDEBUG('[publish] applogs ', applogs)\n\n\tif (sharedAgents) { // encrypt all Applogs\n\t\tif (!sharedKey || !sharedKeyMap) {\n\t\t\tDEBUG('weird state, publishing nonEncrypted', { sharedAgents, sharedKeyMap, sharedKey }) // ? could this be a problem\n\t\t\tmaybeEncryptedApplogs = applogs\n\t\t} else {\n\t\t\tconst agentSharedKeyLogs = []\n\t\t\tfor (const [eachAgent, eachEncKey] of Array.from(sharedKeyMap.entries())) {\n\t\t\t\tagentSharedKeyLogs.push({\n\t\t\t\t\tag: agentHash,\n\t\t\t\t\ten: eachAgent,\n\t\t\t\t\tat: 'pub/sharedKey',\n\t\t\t\t\tvl: eachEncKey, // these are encrypted with the derived key from the local agent private and remote agent public keys\n\t\t\t\t})\n\t\t\t}\n\t\t\t// const encryptedForLogs = await insertApplogs(agentSharedKeyLogs)\n\t\t\t// DEBUG(`[publish] adding agentSharedKeyLogs:`, encryptedForLogs)\n\n\t\t\t// TODO ensure that all needed keys are in\n\t\t\tfor (const eachLog of applogs) {\n\t\t\t\tVERBOSE('[crypto] encrypting ', eachLog)\n\t\t\t\tif (neverEncryptAttrs.includes(eachLog.at)) {\n\t\t\t\t\tmaybeEncryptedApplogs.push(/* prepareForPub( */ eachLog /* ) */) // ? this seemed to double the below one - @gotjoshua?\n\n\t\t\t\t\t// continue\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tencPayload = await encryptAndTestDecrypt(eachLog, sharedKey)\n\t\t\t\t} catch (err) {\n\t\t\t\t\t// its already traced in encryptAndTestDecrypt\n\t\t\t\t\t// continue\n\t\t\t\t}\n\t\t\t\tmaybeEncryptedApplogs.push(encPayload)\n\t\t\t}\n\t\t}\n\t} else maybeEncryptedApplogs = applogs // publish nonEncrypted\n\n\tmaybeEncryptedApplogs = maybeEncryptedApplogs.map(log => (log as Applog).en ? prepareForPub(log as Applog) : log)\n\tconst encodedApplogs = await Promise.all(maybeEncryptedApplogs.map(encodeBlockOriginal))\n\tDEBUG('[publish] encoded root', { agentHash, agentFullID, encodedApplogs })\n\n\tconst cids = encodedApplogs.map(b => b.cid ?? null) // ? why would it be null\n\tconst root = { applogs: cids }\n\tconst encodedRoot = await encodeBlockOriginal(root)\n\tDEBUG('[publish] encoded root', { cids, encodedRoot })\n\n\tconst car = await makeCarBlob(encodedRoot.cid, [encodedRoot, ...encodedApplogs])\n\treturn car\n}\n","export const wovinCoreTest = 12345.7\n\nexport * from './data/publication'\n"],"mappings":";;;;;;;;;;;;;AAAA,SAAS,cAAc;AAUvB,IAAM,EAAE,MAAM,KAAK,OAAO,SAAS,MAAM,IAAI,OAAO,MAAM,OAAO,IAAI;AAE9D,IAAM,oBAAoB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAEA,eAAsB,kBACrB,WACA,aACA,aACA,YACA,SACC;AAKD,MAAI,wBAAsE,CAAC;AAE3E,QAAM,EAAE,cAAc,cAAc,UAAU,IAAI,eAAe,CAAC;AAClE,QAAM,YAAY,cAAc,YAAY;AAAA,IAC3C,IAAI;AAAA,IACJ,IAAI,CAAC,cAAc,cAAc,gBAAgB;AAAA,EAClD,CAAC;AACD,QAAM,gCAAgC,SAAS;AAC/C,UAAQ,KAAK,GAAG,UAAU,OAAO;AACjC,MAAI;AACJ,QAAM,wBAAwB,OAAO,QAAyB,aAAwB;AACrF,UAAM,IAAI,MAAM,WAAW;AAAA,EAiB5B;AACA,QAAM,sBAAsB,OAAO;AAEnC,MAAI,cAAc;AACjB,QAAI,CAAC,aAAa,CAAC,cAAc;AAChC,YAAM,wCAAwC,EAAE,cAAc,cAAc,UAAU,CAAC;AACvF,8BAAwB;AAAA,IACzB,OAAO;AACN,YAAM,qBAAqB,CAAC;AAC5B,iBAAW,CAAC,WAAW,UAAU,KAAK,MAAM,KAAK,aAAa,QAAQ,CAAC,GAAG;AACzE,2BAAmB,KAAK;AAAA,UACvB,IAAI;AAAA,UACJ,IAAI;AAAA,UACJ,IAAI;AAAA,UACJ,IAAI;AAAA;AAAA,QACL,CAAC;AAAA,MACF;AAKA,iBAAW,WAAW,SAAS;AAC9B,gBAAQ,wBAAwB,OAAO;AACvC,YAAI,kBAAkB,SAAS,QAAQ,EAAE,GAAG;AAC3C,gCAAsB;AAAA;AAAA,YAA0B;AAAA;AAAA,UAAe;AAAA,QAGhE;AACA,YAAI;AACH,uBAAa,MAAM,sBAAsB,SAAS,SAAS;AAAA,QAC5D,SAAS,KAAK;AAAA,QAGd;AACA,8BAAsB,KAAK,UAAU;AAAA,MACtC;AAAA,IACD;AAAA,EACD;AAAO,4BAAwB;AAE/B,0BAAwB,sBAAsB,IAAI,SAAQ,IAAe,KAAK,cAAc,GAAa,IAAI,GAAG;AAChH,QAAM,iBAAiB,MAAM,QAAQ,IAAI,sBAAsB,IAAI,mBAAmB,CAAC;AACvF,QAAM,0BAA0B,EAAE,WAAW,aAAa,eAAe,CAAC;AAE1E,QAAM,OAAO,eAAe,IAAI,OAAK,EAAE,OAAO,IAAI;AAClD,QAAM,OAAO,EAAE,SAAS,KAAK;AAC7B,QAAM,cAAc,MAAM,oBAAoB,IAAI;AAClD,QAAM,0BAA0B,EAAE,MAAM,YAAY,CAAC;AAErD,QAAM,MAAM,MAAM,YAAY,YAAY,KAAK,CAAC,aAAa,GAAG,cAAc,CAAC;AAC/E,SAAO;AACR;;;AC5GO,IAAM,gBAAgB;","names":[]}
|
package/dist/ipfs.cjs
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var _chunkOOC3HK3Ecjs = require('./chunk-OOC3HK3E.cjs');
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var _chunkGT5X2WN4cjs = require('./chunk-GT5X2WN4.cjs');
|
|
15
|
-
require('./chunk-UOPZAYFM.cjs');
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
exports.decodeCar = _chunkOOC3HK3Ecjs.decodeCar; exports.decodeCarToApplogs = _chunkOOC3HK3Ecjs.decodeCarToApplogs; exports.encodeApplog = _chunkGT5X2WN4cjs.encodeApplog; exports.encodeApplogAndGetCid = _chunkGT5X2WN4cjs.encodeApplogAndGetCid; exports.encodeBlock = _chunkGT5X2WN4cjs.encodeBlock; exports.encodeBlockOriginal = _chunkGT5X2WN4cjs.encodeBlockOriginal; exports.getCidSync = _chunkGT5X2WN4cjs.getCidSync; exports.makeCarBlob = _chunkOOC3HK3Ecjs.makeCarBlob; exports.makeCarOut = _chunkOOC3HK3Ecjs.makeCarOut; exports.prepareForPub = _chunkGT5X2WN4cjs.prepareForPub;
|
|
28
|
-
//# sourceMappingURL=ipfs.cjs.map
|
package/dist/ipfs.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":""}
|
package/dist/ipfs.d.cts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { CarWriter, CarReader } from '@ipld/car';
|
|
2
|
-
import { c as Applog, C as CidString, d as ApplogForInsert, f as ApplogNoCid } from './types-A9kYLtyU.cjs';
|
|
3
|
-
import * as multiformats from 'multiformats';
|
|
4
|
-
import { CID } from 'multiformats';
|
|
5
|
-
import * as dagJson from '@ipld/dag-json';
|
|
6
|
-
import '@sinclair/typebox';
|
|
7
|
-
import '@sinclair/typebox/compiler';
|
|
8
|
-
import 'multiformats/cid';
|
|
9
|
-
|
|
10
|
-
type CIDForCar = Exclude<Parameters<(typeof CarWriter)['create']>[0], void>;
|
|
11
|
-
type BlockForCar = Parameters<CarWriter['put']>[0];
|
|
12
|
-
declare function decodeCarToApplogs(car: CarReader): Promise<{
|
|
13
|
-
applogs: (Applog | Uint8Array)[];
|
|
14
|
-
}>;
|
|
15
|
-
declare function decodeCar(car: CarReader): Promise<{
|
|
16
|
-
roots: CidString[];
|
|
17
|
-
blocks: Map<CidString, any>;
|
|
18
|
-
}>;
|
|
19
|
-
declare function makeCarOut(roots: CIDForCar, blocks: BlockForCar[]): Promise<AsyncIterable<Uint8Array>>; /** create a new CarWriter, with the encoded block as the root */
|
|
20
|
-
declare function makeCarBlob(roots: CIDForCar, blocks: BlockForCar[]): Promise<Blob>;
|
|
21
|
-
|
|
22
|
-
declare function prepareForPub(log: Applog | ApplogForInsert, without?: string[]): Applog;
|
|
23
|
-
declare function encodeApplogAndGetCid(log: ApplogNoCid): CID<unknown, 297, 18, 1>;
|
|
24
|
-
declare function encodeApplog(log: ApplogNoCid): {
|
|
25
|
-
bytes: multiformats.ByteView<any>;
|
|
26
|
-
cid: CID<unknown, 297, 18, 1>;
|
|
27
|
-
};
|
|
28
|
-
declare function getCidSync(bytes: dagJson.ByteView<any>): CID<unknown, 297, 18, 1>;
|
|
29
|
-
/** encode the json object into an IPLD block */
|
|
30
|
-
declare function encodeBlock(jsonObject: any): {
|
|
31
|
-
bytes: multiformats.ByteView<any>;
|
|
32
|
-
cid: CID<unknown, 297, 18, 1>;
|
|
33
|
-
};
|
|
34
|
-
declare function encodeBlockOriginal(jsonObject: any): Promise<multiformats.BlockView<unknown, 297, 18, 1>>;
|
|
35
|
-
|
|
36
|
-
export { type BlockForCar, type CIDForCar, decodeCar, decodeCarToApplogs, encodeApplog, encodeApplogAndGetCid, encodeBlock, encodeBlockOriginal, getCidSync, makeCarBlob, makeCarOut, prepareForPub };
|
package/dist/ipfs.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
decodeCar,
|
|
3
|
-
decodeCarToApplogs,
|
|
4
|
-
makeCarBlob,
|
|
5
|
-
makeCarOut
|
|
6
|
-
} from "./chunk-KDR7QXOQ.js";
|
|
7
|
-
import {
|
|
8
|
-
encodeApplog,
|
|
9
|
-
encodeApplogAndGetCid,
|
|
10
|
-
encodeBlock,
|
|
11
|
-
encodeBlockOriginal,
|
|
12
|
-
getCidSync,
|
|
13
|
-
prepareForPub
|
|
14
|
-
} from "./chunk-QXNFGJ5R.js";
|
|
15
|
-
import "./chunk-F3FYYIAV.js";
|
|
16
|
-
export {
|
|
17
|
-
decodeCar,
|
|
18
|
-
decodeCarToApplogs,
|
|
19
|
-
encodeApplog,
|
|
20
|
-
encodeApplogAndGetCid,
|
|
21
|
-
encodeBlock,
|
|
22
|
-
encodeBlockOriginal,
|
|
23
|
-
getCidSync,
|
|
24
|
-
makeCarBlob,
|
|
25
|
-
makeCarOut,
|
|
26
|
-
prepareForPub
|
|
27
|
-
};
|
|
28
|
-
//# sourceMappingURL=ipfs.js.map
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { a as ApplogStreamEvent, A as ApplogStream, c as Applog } from './types-A9kYLtyU.cjs';
|
|
2
|
-
|
|
3
|
-
type ApplogEventMapper = (this: MappedApplogStream, event: ApplogStreamEvent, sourceStream: ApplogStream) => ApplogStreamEvent;
|
|
4
|
-
declare class MappedApplogStream extends ApplogStream {
|
|
5
|
-
readonly _initialLogs: readonly Applog[];
|
|
6
|
-
private _eventMapper;
|
|
7
|
-
readonly name: string;
|
|
8
|
-
private _parentSubscriptions;
|
|
9
|
-
constructor(parents: ApplogStream | ApplogStream[], filters: string[], _initialLogs: readonly Applog[], _eventMapper: ApplogEventMapper, name: string);
|
|
10
|
-
get readOnly(): boolean;
|
|
11
|
-
private subscribeToParent;
|
|
12
|
-
/**
|
|
13
|
-
* // HACK to trigger remap on pattern change in rollingFilter
|
|
14
|
-
* should not be used lightly
|
|
15
|
-
*/
|
|
16
|
-
triggerRemap(): void;
|
|
17
|
-
protected onParentUpdate(stream: ApplogStream, event: ApplogStreamEvent): void;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export { type ApplogEventMapper as A, MappedApplogStream as M };
|
package/dist/pubsub.cjs
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }require('./chunk-UOPZAYFM.cjs');
|
|
2
|
-
|
|
3
|
-
// src/data/pubsub-types.ts
|
|
4
|
-
function isPublication(obj) {
|
|
5
|
-
return _optionalChain([obj, 'optionalAccess', _ => _.pk]) !== void 0 && _optionalChain([obj, 'optionalAccess', _2 => _2.lastPush]) !== void 0;
|
|
6
|
-
}
|
|
7
|
-
function isSubscription(obj) {
|
|
8
|
-
return _optionalChain([obj, 'optionalAccess', _3 => _3.lastPull]) !== void 0;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
exports.isPublication = isPublication; exports.isSubscription = isSubscription;
|
|
14
|
-
//# sourceMappingURL=pubsub.cjs.map
|
package/dist/pubsub.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/data/pubsub-types.ts"],"names":[],"mappings":";;;AAuCO,SAAS,cAAc,KAA+B;AAC5D,SAAO,KAAK,OAAO,UAAa,KAAK,aAAa;AACnD;AACO,SAAS,eAAe,KAAgC;AAC9D,SAAO,KAAK,aAAa;AAC1B","sourcesContent":["import { AgentID } from './datom-types'\n\nexport interface IPublication {\n\tid?: string // string hash of pub (used as unique id in IDB) `W3Name.create().toString()` starts with k51qzi5uqu5d\n\tcreatedAt: string // ISO timestamp of creation\n\tname: string // nick name for the pub\n\tisDeleted?: boolean\n\n\tpk: Uint8Array // exported privatekey - needed to create WritableName for publishing\n\n\tautopush: boolean\n\tlastPush: string | null\n\tlastCID?: string\n\tlatestLogTs?: string\n\n\tpublishedBy: string // local user appAgent\n\tselectors?: string[] // to be used as a filter for which applogs to pub\n\tencryptedFor?: string | null // short agentHash\n\tencryptedWith?: CryptoKey | null // AES-GCM derived key from ECDH keys (local private and remote public)\n\n\t// HACK WIP #39 - shared encryption\n\tsharedKey?: CryptoKey | null // AES-GCM derived key from ECDH keys (local private and ipns public)\n\tsharedAgents?: AgentID[] | null // array of string EntityIDs for the chosen agents (we need public jwkd atoms for each of them)\n\tsharedKeyMap?: Map<AgentID, string> | null // uses public key from each agent to derive an aes key that is used to encrypt and btoa the sharedKey that is actually used to encrypt and decrypt the applogs\n}\nexport interface ISubscription {\n\tid: string // string hash of pub (used as unique id in IDB) `W3Name.create().toString()` starts with k51qzi5uqu5d\n\tcreatedAt: string // ISO timestamp of creation\n\tname: string // nick name for the pub\n\tisDeleted: boolean\n\n\tlastPull?: string | null\n\tlastPullAttempt?: string | null\n\tautopull: boolean\n\tlastCID?: string\n\tpublishedBy?: string // remote publisher short agentHash\n\tencryptedFor?: string | undefined // short agentHash\n\tencryptedWith?: CryptoKey | undefined // AES-GCM derived key from ECDH keys (local private and remote public)\n}\nexport function isPublication(obj: any): obj is IPublication {\n\treturn obj?.pk !== undefined && obj?.lastPush !== undefined\n}\nexport function isSubscription(obj: any): obj is ISubscription {\n\treturn obj?.lastPull !== undefined\n}\n\nexport type TSubPub = IPublication | ISubscription\n"]}
|
package/dist/pubsub.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import "./chunk-F3FYYIAV.js";
|
|
2
|
-
|
|
3
|
-
// src/data/pubsub-types.ts
|
|
4
|
-
function isPublication(obj) {
|
|
5
|
-
return obj?.pk !== void 0 && obj?.lastPush !== void 0;
|
|
6
|
-
}
|
|
7
|
-
function isSubscription(obj) {
|
|
8
|
-
return obj?.lastPull !== void 0;
|
|
9
|
-
}
|
|
10
|
-
export {
|
|
11
|
-
isPublication,
|
|
12
|
-
isSubscription
|
|
13
|
-
};
|
|
14
|
-
//# sourceMappingURL=pubsub.js.map
|
package/dist/pubsub.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/data/pubsub-types.ts"],"sourcesContent":["import { AgentID } from './datom-types'\n\nexport interface IPublication {\n\tid?: string // string hash of pub (used as unique id in IDB) `W3Name.create().toString()` starts with k51qzi5uqu5d\n\tcreatedAt: string // ISO timestamp of creation\n\tname: string // nick name for the pub\n\tisDeleted?: boolean\n\n\tpk: Uint8Array // exported privatekey - needed to create WritableName for publishing\n\n\tautopush: boolean\n\tlastPush: string | null\n\tlastCID?: string\n\tlatestLogTs?: string\n\n\tpublishedBy: string // local user appAgent\n\tselectors?: string[] // to be used as a filter for which applogs to pub\n\tencryptedFor?: string | null // short agentHash\n\tencryptedWith?: CryptoKey | null // AES-GCM derived key from ECDH keys (local private and remote public)\n\n\t// HACK WIP #39 - shared encryption\n\tsharedKey?: CryptoKey | null // AES-GCM derived key from ECDH keys (local private and ipns public)\n\tsharedAgents?: AgentID[] | null // array of string EntityIDs for the chosen agents (we need public jwkd atoms for each of them)\n\tsharedKeyMap?: Map<AgentID, string> | null // uses public key from each agent to derive an aes key that is used to encrypt and btoa the sharedKey that is actually used to encrypt and decrypt the applogs\n}\nexport interface ISubscription {\n\tid: string // string hash of pub (used as unique id in IDB) `W3Name.create().toString()` starts with k51qzi5uqu5d\n\tcreatedAt: string // ISO timestamp of creation\n\tname: string // nick name for the pub\n\tisDeleted: boolean\n\n\tlastPull?: string | null\n\tlastPullAttempt?: string | null\n\tautopull: boolean\n\tlastCID?: string\n\tpublishedBy?: string // remote publisher short agentHash\n\tencryptedFor?: string | undefined // short agentHash\n\tencryptedWith?: CryptoKey | undefined // AES-GCM derived key from ECDH keys (local private and remote public)\n}\nexport function isPublication(obj: any): obj is IPublication {\n\treturn obj?.pk !== undefined && obj?.lastPush !== undefined\n}\nexport function isSubscription(obj: any): obj is ISubscription {\n\treturn obj?.lastPull !== undefined\n}\n\nexport type TSubPub = IPublication | ISubscription\n"],"mappings":";;;AAuCO,SAAS,cAAc,KAA+B;AAC5D,SAAO,KAAK,OAAO,UAAa,KAAK,aAAa;AACnD;AACO,SAAS,eAAe,KAAgC;AAC9D,SAAO,KAAK,aAAa;AAC1B;","names":[]}
|