@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.
Files changed (143) hide show
  1. package/dist/applog/applog-helpers.d.ts +23 -0
  2. package/dist/applog/applog-helpers.d.ts.map +1 -0
  3. package/dist/applog/applog-utils.d.ts +41 -0
  4. package/dist/applog/applog-utils.d.ts.map +1 -0
  5. package/dist/applog/datom-types.d.ts +84 -0
  6. package/dist/applog/datom-types.d.ts.map +1 -0
  7. package/dist/applog.d.ts +4 -70
  8. package/dist/applog.d.ts.map +1 -0
  9. package/dist/applog.min.js +2 -0
  10. package/dist/chunk-5R2ELTEJ.min.js +40 -0
  11. package/dist/chunk-5R2ELTEJ.min.js.map +1 -0
  12. package/dist/chunk-7IDQIMQO.min.js +1 -0
  13. package/dist/chunk-F3MRAJXL.min.js +2 -0
  14. package/dist/{types.js.map → chunk-F3MRAJXL.min.js.map} +1 -1
  15. package/dist/chunk-HHXZXKNM.min.js +7 -0
  16. package/dist/chunk-HHXZXKNM.min.js.map +1 -0
  17. package/dist/chunk-KESATLM4.min.js +8 -0
  18. package/dist/chunk-KESATLM4.min.js.map +1 -0
  19. package/dist/chunk-LECZSORU.min.js +2 -0
  20. package/dist/chunk-LECZSORU.min.js.map +1 -0
  21. package/dist/chunk-NGPPHX5A.min.js +2 -0
  22. package/dist/chunk-NGPPHX5A.min.js.map +1 -0
  23. package/dist/chunk-PL6CNZTW.min.js +2 -0
  24. package/dist/chunk-PL6CNZTW.min.js.map +1 -0
  25. package/dist/chunk-RPPZKO5L.min.js +1 -0
  26. package/dist/index.d.ts +8 -12
  27. package/dist/index.d.ts.map +1 -0
  28. package/dist/index.min.js +2 -0
  29. package/dist/index.min.js.map +1 -0
  30. package/dist/ipfs/car.d.ts +15 -0
  31. package/dist/ipfs/car.d.ts.map +1 -0
  32. package/dist/ipfs/ipfs-utils.d.ts +17 -0
  33. package/dist/ipfs/ipfs-utils.d.ts.map +1 -0
  34. package/dist/ipfs.d.ts +3 -36
  35. package/dist/ipfs.d.ts.map +1 -0
  36. package/dist/ipfs.min.js +2 -0
  37. package/dist/mobx/mobx-utils.d.ts +67 -0
  38. package/dist/mobx/mobx-utils.d.ts.map +1 -0
  39. package/dist/pubsub/connector.d.ts +7 -0
  40. package/dist/pubsub/connector.d.ts.map +1 -0
  41. package/dist/pubsub/publication.d.ts +6 -0
  42. package/dist/pubsub/publication.d.ts.map +1 -0
  43. package/dist/{pubsub.d.cts → pubsub/pubsub-types.d.ts} +7 -12
  44. package/dist/pubsub/pubsub-types.d.ts.map +1 -0
  45. package/dist/pubsub.d.ts +4 -41
  46. package/dist/pubsub.d.ts.map +1 -0
  47. package/dist/pubsub.min.js +2 -0
  48. package/dist/query/basic.d.ts +65 -0
  49. package/dist/query/basic.d.ts.map +1 -0
  50. package/dist/query/divergences.d.ts +12 -0
  51. package/dist/query/divergences.d.ts.map +1 -0
  52. package/dist/query/matchers.d.ts +4 -0
  53. package/dist/query/matchers.d.ts.map +1 -0
  54. package/dist/query.d.ts +5 -0
  55. package/dist/query.d.ts.map +1 -0
  56. package/dist/query.min.js +2 -0
  57. package/dist/query.min.js.map +1 -0
  58. package/dist/stream/basic.d.ts +34 -0
  59. package/dist/stream/basic.d.ts.map +1 -0
  60. package/dist/stream/filters.d.ts +38 -0
  61. package/dist/stream/filters.d.ts.map +1 -0
  62. package/dist/{mapped-8h8bwRuM.d.ts → stream/mapped.d.ts} +5 -6
  63. package/dist/stream/mapped.d.ts.map +1 -0
  64. package/dist/{writeable-0WbsIiQn.d.cts → stream/writeable.d.ts} +7 -6
  65. package/dist/stream/writeable.d.ts.map +1 -0
  66. package/dist/stream.d.ts +5 -44
  67. package/dist/stream.d.ts.map +1 -0
  68. package/dist/stream.min.js +2 -0
  69. package/dist/stream.min.js.map +1 -0
  70. package/dist/types/typescript-utils.d.ts +33 -0
  71. package/dist/types/typescript-utils.d.ts.map +1 -0
  72. package/dist/types.d.ts +2 -4
  73. package/dist/types.d.ts.map +1 -0
  74. package/dist/types.min.js +2 -0
  75. package/dist/types.min.js.map +1 -0
  76. package/dist/utils.d.ts +1 -2
  77. package/dist/utils.d.ts.map +1 -0
  78. package/dist/utils.min.js +1 -0
  79. package/dist/utils.min.js.map +1 -0
  80. package/package.json +80 -46
  81. package/dist/applog.cjs +0 -85
  82. package/dist/applog.cjs.map +0 -1
  83. package/dist/applog.d.cts +0 -70
  84. package/dist/applog.js +0 -85
  85. package/dist/chunk-F3FYYIAV.js +0 -11
  86. package/dist/chunk-GT5X2WN4.cjs +0 -59
  87. package/dist/chunk-GT5X2WN4.cjs.map +0 -1
  88. package/dist/chunk-JSAJQXI2.cjs +0 -577
  89. package/dist/chunk-JSAJQXI2.cjs.map +0 -1
  90. package/dist/chunk-KDR7QXOQ.js +0 -56
  91. package/dist/chunk-KDR7QXOQ.js.map +0 -1
  92. package/dist/chunk-KGTU6PJ3.js +0 -577
  93. package/dist/chunk-KGTU6PJ3.js.map +0 -1
  94. package/dist/chunk-KHY3SRML.js +0 -768
  95. package/dist/chunk-KHY3SRML.js.map +0 -1
  96. package/dist/chunk-OOC3HK3E.cjs +0 -56
  97. package/dist/chunk-OOC3HK3E.cjs.map +0 -1
  98. package/dist/chunk-QXNFGJ5R.js +0 -59
  99. package/dist/chunk-QXNFGJ5R.js.map +0 -1
  100. package/dist/chunk-UOPZAYFM.cjs +0 -11
  101. package/dist/chunk-UOPZAYFM.cjs.map +0 -1
  102. package/dist/chunk-ZPOYKHY6.cjs +0 -768
  103. package/dist/chunk-ZPOYKHY6.cjs.map +0 -1
  104. package/dist/index.cjs +0 -87
  105. package/dist/index.cjs.map +0 -1
  106. package/dist/index.d.cts +0 -12
  107. package/dist/index.js +0 -87
  108. package/dist/index.js.map +0 -1
  109. package/dist/ipfs.cjs +0 -28
  110. package/dist/ipfs.cjs.map +0 -1
  111. package/dist/ipfs.d.cts +0 -36
  112. package/dist/ipfs.js +0 -28
  113. package/dist/mapped-mkKwhQgZ.d.cts +0 -20
  114. package/dist/pubsub.cjs +0 -14
  115. package/dist/pubsub.cjs.map +0 -1
  116. package/dist/pubsub.js +0 -14
  117. package/dist/pubsub.js.map +0 -1
  118. package/dist/queries.cjs +0 -112
  119. package/dist/queries.cjs.map +0 -1
  120. package/dist/queries.d.cts +0 -141
  121. package/dist/queries.d.ts +0 -141
  122. package/dist/queries.js +0 -112
  123. package/dist/queries.js.map +0 -1
  124. package/dist/stream.cjs +0 -37
  125. package/dist/stream.cjs.map +0 -1
  126. package/dist/stream.d.cts +0 -44
  127. package/dist/stream.js +0 -37
  128. package/dist/types-A9kYLtyU.d.cts +0 -153
  129. package/dist/types-A9kYLtyU.d.ts +0 -153
  130. package/dist/types.cjs +0 -46
  131. package/dist/types.cjs.map +0 -1
  132. package/dist/types.d.cts +0 -4
  133. package/dist/types.js +0 -46
  134. package/dist/utils.cjs +0 -1
  135. package/dist/utils.cjs.map +0 -1
  136. package/dist/utils.d.cts +0 -2
  137. package/dist/utils.js +0 -1
  138. package/dist/writeable-r_920qCb.d.ts +0 -16
  139. /package/dist/{applog.js.map → applog.min.js.map} +0 -0
  140. /package/dist/{chunk-F3FYYIAV.js.map → chunk-7IDQIMQO.min.js.map} +0 -0
  141. /package/dist/{ipfs.js.map → chunk-RPPZKO5L.min.js.map} +0 -0
  142. /package/dist/{stream.js.map → ipfs.min.js.map} +0 -0
  143. /package/dist/{utils.js.map → pubsub.min.js.map} +0 -0
package/dist/applog.cjs DELETED
@@ -1,85 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
- var _chunkJSAJQXI2cjs = require('./chunk-JSAJQXI2.cjs');
21
-
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
-
36
-
37
-
38
-
39
-
40
-
41
-
42
- var _chunkZPOYKHY6cjs = require('./chunk-ZPOYKHY6.cjs');
43
- require('./chunk-GT5X2WN4.cjs');
44
- require('./chunk-UOPZAYFM.cjs');
45
-
46
-
47
-
48
-
49
-
50
-
51
-
52
-
53
-
54
-
55
-
56
-
57
-
58
-
59
-
60
-
61
-
62
-
63
-
64
-
65
-
66
-
67
-
68
-
69
-
70
-
71
-
72
-
73
-
74
-
75
-
76
-
77
-
78
-
79
-
80
-
81
-
82
-
83
-
84
- exports.AppLogTB = _chunkJSAJQXI2cjs.AppLogTB; exports.AppLogTBC = _chunkJSAJQXI2cjs.AppLogTBC; exports.CIDTB = _chunkJSAJQXI2cjs.CIDTB; exports.EntityID = _chunkJSAJQXI2cjs.EntityID; exports.EntityID_LENGTH = _chunkJSAJQXI2cjs.EntityID_LENGTH; exports.Nullable = _chunkJSAJQXI2cjs.Nullable; exports.URL = _chunkJSAJQXI2cjs.URL; exports.actualize = _chunkZPOYKHY6cjs.actualize; exports.areApplogsEqual = _chunkZPOYKHY6cjs.areApplogsEqual; exports.arrStats = _chunkZPOYKHY6cjs.arrStats; exports.arraysContainSameElements = _chunkZPOYKHY6cjs.arraysContainSameElements; exports.cyrb53hash = _chunkZPOYKHY6cjs.cyrb53hash; exports.dateNowIso = _chunkZPOYKHY6cjs.dateNowIso; exports.filterOnlyLatest = _chunkJSAJQXI2cjs.filterOnlyLatest; exports.getApplogTypeErrors = _chunkJSAJQXI2cjs.getApplogTypeErrors; exports.getHashID = _chunkZPOYKHY6cjs.getHashID; exports.hasAg = _chunkJSAJQXI2cjs.hasAg; exports.hasPv = _chunkJSAJQXI2cjs.hasPv; exports.hasTs = _chunkJSAJQXI2cjs.hasTs; exports.isStaticPattern = _chunkZPOYKHY6cjs.isStaticPattern; exports.isTsBefore = _chunkZPOYKHY6cjs.isTsBefore; exports.isValidApplog = _chunkJSAJQXI2cjs.isValidApplog; exports.isVariable = _chunkZPOYKHY6cjs.isVariable; exports.isoDateStrCompare = _chunkZPOYKHY6cjs.isoDateStrCompare; exports.joinStreams = _chunkJSAJQXI2cjs.joinStreams; exports.matchPart = _chunkZPOYKHY6cjs.matchPart; exports.matchPartStatic = _chunkZPOYKHY6cjs.matchPartStatic; exports.matchPattern = _chunkZPOYKHY6cjs.matchPattern; exports.removeDuplicateAppLogs = _chunkZPOYKHY6cjs.removeDuplicateAppLogs; exports.resolveOrRemoveVariables = _chunkZPOYKHY6cjs.resolveOrRemoveVariables; exports.sortApplogByTs = _chunkJSAJQXI2cjs.sortApplogByTs; exports.sortApplogByTsDec = _chunkJSAJQXI2cjs.sortApplogByTsDec; exports.sortApplogsByTs = _chunkZPOYKHY6cjs.sortApplogsByTs; exports.tsNearlySame = _chunkZPOYKHY6cjs.tsNearlySame; exports.uniqueEnFromAppLogs = _chunkZPOYKHY6cjs.uniqueEnFromAppLogs; exports.variableNameWithoutQuestionmark = _chunkZPOYKHY6cjs.variableNameWithoutQuestionmark; exports.withPv = _chunkJSAJQXI2cjs.withPv; exports.withTs = _chunkJSAJQXI2cjs.withTs;
85
- //# sourceMappingURL=applog.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":""}
package/dist/applog.d.cts DELETED
@@ -1,70 +0,0 @@
1
- import { c as Applog, e as ApplogForInsertOptionalAgent, d as ApplogForInsert, T as Timestamp, f as ApplogNoCid, b as ApplogValue, A as ApplogStream, D as DatalogQueryPattern, S as SearchContext, V as ValueOrMatcher, R as ResultContext, g as DatalogQueryResultEntry } from './types-A9kYLtyU.cjs';
2
- export { n as AgentHash, k as AgentID, w as AppLogTB, x as AppLogTBC, o as ApplogOptionalCid, m as Atom, p as AtomPattern, l as Attribute, v as CIDTB, C as CidString, s as DatalogQuery, r as DatalogQueryPatternArray, t as DatalogQueryResultRows, q as DatalogStateIdentifier, j as DatomPart, h as EntityID, E as EntityID_LENGTH, N as Nullable, u as SearchContextWithLog, U as URL, W as WithMatchers, y as getApplogTypeErrors, z as isValidApplog } from './types-A9kYLtyU.cjs';
3
- import { W as WriteableApplogStream } from './writeable-0WbsIiQn.cjs';
4
- import '@sinclair/typebox';
5
- import '@sinclair/typebox/compiler';
6
- import 'multiformats/cid';
7
-
8
- declare const sortApplogByTs: (p: Applog, n: Applog) => 1 | 0 | -1;
9
- declare const sortApplogByTsDec: (p: Applog, n: Applog) => 1 | 0 | -1;
10
- declare function filterOnlyLatest(logs: Applog[], onlyLatest: boolean): Applog[];
11
- declare function hasAg(log: ApplogForInsertOptionalAgent): log is ApplogForInsert;
12
- declare function hasTs(log: ApplogForInsert): log is Omit<ApplogForInsert, 'ts'> & {
13
- ts: Timestamp;
14
- };
15
- declare function hasPv(log: ApplogForInsert): log is ApplogForInsert & {
16
- pv: string;
17
- };
18
- declare function withTs(log: ApplogForInsert, ts: Timestamp): Omit<ApplogForInsert, "ts"> & {
19
- ts: string;
20
- };
21
- declare function withPv(log: ApplogNoCid, ds: WriteableApplogStream): {
22
- pv: any;
23
- ts: string;
24
- ag: string;
25
- en: string;
26
- at: string;
27
- vl: ApplogValue;
28
- };
29
- declare function joinStreams(streams: ApplogStream[]): ApplogStream;
30
-
31
- declare const isoDateStrCompare: (strA: string, strB: string, dir?: 'asc' | 'desc') => number;
32
- /** Sort by TS (modifies the array, but also returns for ease of use) */
33
- declare function sortApplogsByTs(appLogArray: Applog[], dir?: 'asc' | 'desc'): Applog[];
34
- declare const isTsBefore: (log: Applog, logToCompare: Applog) => boolean;
35
- declare const uniqueEnFromAppLogs: (appLogArray: Applog[]) => string[];
36
- declare const areApplogsEqual: (logA: Applog, logB: Applog) => boolean;
37
- declare const removeDuplicateAppLogs: (appLogArray: Applog[]) => any[];
38
- declare const getHashID: (stringifiable: any, lngth?: number) => string;
39
- declare function isVariable(x: any): x is string;
40
- declare function variableNameWithoutQuestionmark(str: string): string;
41
- declare function isStaticPattern(x: any): x is ApplogValue;
42
- declare function resolveOrRemoveVariables(pattern: DatalogQueryPattern, candidate: SearchContext): {}[];
43
- declare function matchPartStatic(field: keyof Applog, patternPart: ValueOrMatcher<ApplogValue>, atomPart: ApplogValue): boolean;
44
- declare function matchPart(patternPart: ValueOrMatcher<ApplogValue>, atomPart: ApplogValue, context: SearchContext): ResultContext;
45
- /**
46
- * Check if pattern matches triple with context substitutions
47
- */
48
- declare function matchPattern(pattern: DatalogQueryPattern, applog: Applog, context: SearchContext): ResultContext;
49
- declare function actualize<SELECT extends string>(context: ResultContext, find: readonly SELECT[]): DatalogQueryResultEntry<SELECT>;
50
- declare const arrStats: {
51
- max: (array: number[]) => number;
52
- min: (array: number[]) => number;
53
- range: (array: number[]) => number;
54
- midrange: (array: number[]) => number;
55
- sum: (array: number[]) => number;
56
- mean: (array: number[]) => number;
57
- average: (array: number[]) => number;
58
- median: (array: number[]) => number;
59
- modes: (array: number[]) => any[];
60
- variance: (array: number[]) => number;
61
- standardDeviation: (array: number[]) => number;
62
- meanAbsoluteDeviation: (array: number[]) => number;
63
- zScores: (array: number[]) => number[];
64
- };
65
- declare const tsNearlySame: (timeA: string, timeB: string) => boolean;
66
- declare const cyrb53hash: (str: string, seed: number, strLength: number) => string;
67
- declare function arraysContainSameElements(arr1: any, arr2: any): boolean;
68
- declare function dateNowIso(): string;
69
-
70
- export { Applog, ApplogForInsert, ApplogForInsertOptionalAgent, ApplogNoCid, ApplogValue, DatalogQueryPattern, DatalogQueryResultEntry, ResultContext, SearchContext, Timestamp, ValueOrMatcher, actualize, areApplogsEqual, arrStats, arraysContainSameElements, cyrb53hash, dateNowIso, filterOnlyLatest, getHashID, hasAg, hasPv, hasTs, isStaticPattern, isTsBefore, isVariable, isoDateStrCompare, joinStreams, matchPart, matchPartStatic, matchPattern, removeDuplicateAppLogs, resolveOrRemoveVariables, sortApplogByTs, sortApplogByTsDec, sortApplogsByTs, tsNearlySame, uniqueEnFromAppLogs, variableNameWithoutQuestionmark, withPv, withTs };
package/dist/applog.js DELETED
@@ -1,85 +0,0 @@
1
- import {
2
- AppLogTB,
3
- AppLogTBC,
4
- CIDTB,
5
- EntityID,
6
- EntityID_LENGTH,
7
- Nullable,
8
- URL,
9
- filterOnlyLatest,
10
- getApplogTypeErrors,
11
- hasAg,
12
- hasPv,
13
- hasTs,
14
- isValidApplog,
15
- joinStreams,
16
- sortApplogByTs,
17
- sortApplogByTsDec,
18
- withPv,
19
- withTs
20
- } from "./chunk-KGTU6PJ3.js";
21
- import {
22
- actualize,
23
- areApplogsEqual,
24
- arrStats,
25
- arraysContainSameElements,
26
- cyrb53hash,
27
- dateNowIso,
28
- getHashID,
29
- isStaticPattern,
30
- isTsBefore,
31
- isVariable,
32
- isoDateStrCompare,
33
- matchPart,
34
- matchPartStatic,
35
- matchPattern,
36
- removeDuplicateAppLogs,
37
- resolveOrRemoveVariables,
38
- sortApplogsByTs,
39
- tsNearlySame,
40
- uniqueEnFromAppLogs,
41
- variableNameWithoutQuestionmark
42
- } from "./chunk-KHY3SRML.js";
43
- import "./chunk-QXNFGJ5R.js";
44
- import "./chunk-F3FYYIAV.js";
45
- export {
46
- AppLogTB,
47
- AppLogTBC,
48
- CIDTB,
49
- EntityID,
50
- EntityID_LENGTH,
51
- Nullable,
52
- URL,
53
- actualize,
54
- areApplogsEqual,
55
- arrStats,
56
- arraysContainSameElements,
57
- cyrb53hash,
58
- dateNowIso,
59
- filterOnlyLatest,
60
- getApplogTypeErrors,
61
- getHashID,
62
- hasAg,
63
- hasPv,
64
- hasTs,
65
- isStaticPattern,
66
- isTsBefore,
67
- isValidApplog,
68
- isVariable,
69
- isoDateStrCompare,
70
- joinStreams,
71
- matchPart,
72
- matchPartStatic,
73
- matchPattern,
74
- removeDuplicateAppLogs,
75
- resolveOrRemoveVariables,
76
- sortApplogByTs,
77
- sortApplogByTsDec,
78
- sortApplogsByTs,
79
- tsNearlySame,
80
- uniqueEnFromAppLogs,
81
- variableNameWithoutQuestionmark,
82
- withPv,
83
- withTs
84
- };
85
- //# sourceMappingURL=applog.js.map
@@ -1,11 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => {
4
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- return value;
6
- };
7
-
8
- export {
9
- __publicField
10
- };
11
- //# sourceMappingURL=chunk-F3FYYIAV.js.map
@@ -1,59 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } }// src/ipfs/ipfs-utils.ts
2
- var _dagjson = require('@ipld/dag-json'); var dagJson = _interopRequireWildcard(_dagjson);
3
- var _sha256 = require('@noble/hashes/sha256');
4
- var _besonderslogger = require('besonders-logger');
5
- var _multiformats = require('multiformats');
6
- var _block = require('multiformats/block');
7
- var _sha2 = require('multiformats/hashes/sha2');
8
- var { WARN, LOG, DEBUG, VERBOSE, ERROR } = _besonderslogger.Logger.setup(_besonderslogger.Logger.INFO);
9
- function prepareForPub(log, without = ["cid"]) {
10
- const logWithout = {};
11
- for (let [key, val] of Object.entries(log)) {
12
- if (val === void 0) {
13
- WARN(`log.${key} is undefined, which is not allowed - encoding as null`, log);
14
- val = null;
15
- }
16
- if (!without.includes(key)) {
17
- logWithout[key] = val && key === "pv" ? _multiformats.CID.parse(val) : val;
18
- } else {
19
- VERBOSE("excluding app log", { key, val });
20
- }
21
- }
22
- return logWithout;
23
- }
24
- function encodeApplogAndGetCid(log) {
25
- return getCidSync(encodeApplog(log).bytes);
26
- }
27
- function encodeApplog(log) {
28
- return encodeBlock(prepareForPub(log));
29
- }
30
- function getCidSync(bytes) {
31
- const hash = _sha256.sha256.call(void 0, bytes);
32
- const digest = _multiformats.digest.create(_sha2.sha256.code, hash);
33
- const cid = _multiformats.CID.create(1, dagJson.code, digest);
34
- VERBOSE(`[getCidSync]`, { bytes, hash, digest, cid });
35
- return cid;
36
- }
37
- function encodeBlock(jsonObject) {
38
- DEBUG("[encodeBlock]", jsonObject);
39
- const byteView = dagJson.encode(jsonObject);
40
- return { bytes: byteView, cid: getCidSync(byteView) };
41
- }
42
- async function encodeBlockOriginal(jsonObject) {
43
- const encoded = await _block.encode.call(void 0, { value: jsonObject, codec: dagJson, hasher: _sha2.sha256 });
44
- const syncVariant = encodeBlock(jsonObject);
45
- if (syncVariant.cid.toString() !== encoded.cid.toString()) {
46
- ERROR(`[encodeBlockOriginal] sync cid mismatch`, { jsonObject, encoded, syncVariant });
47
- }
48
- return encoded;
49
- }
50
-
51
-
52
-
53
-
54
-
55
-
56
-
57
-
58
- exports.prepareForPub = prepareForPub; exports.encodeApplogAndGetCid = encodeApplogAndGetCid; exports.encodeApplog = encodeApplog; exports.getCidSync = getCidSync; exports.encodeBlock = encodeBlock; exports.encodeBlockOriginal = encodeBlockOriginal;
59
- //# sourceMappingURL=chunk-GT5X2WN4.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/ipfs/ipfs-utils.ts"],"names":[],"mappings":";AAAA,YAAY,aAAa;AACzB,SAAS,cAAc;AACvB,SAAS,cAAc;AACvB,SAAS,KAAK,UAAU,cAAc;AACtC,SAAS,UAAU,0BAA0B;AAI7C,SAAS,UAAU,oBAAoB;AAIvC,IAAM,EAAE,MAAM,KAAK,OAAO,SAAS,MAAM,IAAI,OAAO,MAAM,OAAO,IAAI;AAE9D,SAAS,cAAc,KAA+B,UAAoB,CAAC,KAAK,GAAG;AACzF,QAAM,aAAa,CAAC;AACpB,WAAS,CAAC,KAAK,GAAG,KAAK,OAAO,QAAQ,GAAG,GAAG;AAC3C,QAAI,QAAQ,QAAW;AACtB,WAAK,OAAO,GAAG,0DAA0D,GAAG;AAC5E,YAAM;AAAA,IACP;AACA,QAAI,CAAC,QAAQ,SAAS,GAAG,GAAG;AAC3B,iBAAW,GAAG,IAAI,OAAO,QAAQ,OAAO,IAAI,MAAM,GAAG,IAAI;AAAA,IAC1D,OAAO;AACN,cAAQ,qBAAqB,EAAE,KAAK,IAAI,CAAC;AAAA,IAC1C;AAAA,EACD;AACA,SAAO;AACR;AAEO,SAAS,sBAAsB,KAAkB;AACvD,SAAO,WAAW,aAAa,GAAG,EAAE,KAAK;AAC1C;AACO,SAAS,aAAa,KAAkB;AAC9C,SAAO,YAAY,cAAc,GAAG,CAAC;AACtC;AAEO,SAAS,WAAW,OAA8B;AAExD,QAAM,OAAO,OAAO,KAAK;AACzB,QAAM,SAAS,OAAO,OAAO,aAAa,MAAM,IAAI;AACpD,QAAM,MAAM,IAAI,OAAO,GAAW,cAAM,MAAM;AAC9C,UAAQ,gBAAgB,EAAE,OAAO,MAAM,QAAQ,IAAI,CAAC;AACpD,SAAO;AACR;AAEO,SAAS,YAAY,YAAiB;AAC5C,QAAM,iBAAiB,UAAU;AACjC,QAAM,WAAmB,eAAO,UAAU;AAC1C,SAAO,EAAE,OAAO,UAAU,KAAK,WAAW,QAAQ,EAAE;AACrD;AAEA,eAAsB,oBAAoB,YAAiB;AAE1D,QAAM,UAAU,MAAM,mBAAmB,EAAE,OAAO,YAAY,OAAO,SAAS,QAAQ,aAAa,CAAC;AACpG,QAAM,cAAc,YAAY,UAAU;AAC1C,MAAI,YAAY,IAAI,SAAS,MAAM,QAAQ,IAAI,SAAS,GAAG;AAC1D,UAAM,2CAA2C,EAAE,YAAY,SAAS,YAAY,CAAC;AAAA,EACtF;AACA,SAAO;AACR","sourcesContent":["import * as dagJson from '@ipld/dag-json'\nimport { sha256 } from '@noble/hashes/sha256'\nimport { Logger } from 'besonders-logger'\nimport { CID, digest as Digest } from 'multiformats'\nimport { encode as multiformatsEncode } from 'multiformats/block'\n// import { encode } from 'multiformats/block';\nimport { Applog, ApplogForInsert, ApplogNoCid } from '../data/datom-types'\n\nimport { sha256 as sha265Hasher } from 'multiformats/hashes/sha2'\n\n/* THIS FILE SHOULD NOT DEPEND ON UI STUFF, SO THAT TESTS CAN RUN WITH MINIMAL DEPENDENCIES */\n\nconst { WARN, LOG, DEBUG, VERBOSE, ERROR } = Logger.setup(Logger.INFO) // eslint-disable-line no-unused-vars\n\nexport function prepareForPub(log: Applog | ApplogForInsert, without: string[] = ['cid']) {\n\tconst logWithout = {}\n\tfor (let [key, val] of Object.entries(log)) {\n\t\tif (val === undefined) {\n\t\t\tWARN(`log.${key} is undefined, which is not allowed - encoding as null`, log)\n\t\t\tval = null\n\t\t}\n\t\tif (!without.includes(key)) {\n\t\t\tlogWithout[key] = val && key === 'pv' ? CID.parse(val) : val\n\t\t} else {\n\t\t\tVERBOSE('excluding app log', { key, val })\n\t\t}\n\t}\n\treturn logWithout as Applog\n}\n\nexport function encodeApplogAndGetCid(log: ApplogNoCid) {\n\treturn getCidSync(encodeApplog(log).bytes)\n}\nexport function encodeApplog(log: ApplogNoCid) {\n\treturn encodeBlock(prepareForPub(log))\n}\n\nexport function getCidSync(bytes: dagJson.ByteView<any>) {\n\t// Hacky way to use a sync sha265 lib to create a CID - code inspired by https://github.com/multiformats/js-multiformats#multihash-hashers\n\tconst hash = sha256(bytes)\n\tconst digest = Digest.create(sha265Hasher.code, hash)\n\tconst cid = CID.create(1, dagJson.code, digest)\n\tVERBOSE(`[getCidSync]`, { bytes, hash, digest, cid })\n\treturn cid\n}\n/** encode the json object into an IPLD block */\nexport function encodeBlock(jsonObject: any) {\n\tDEBUG('[encodeBlock]', jsonObject)\n\tconst byteView = dagJson.encode(jsonObject)\n\treturn { bytes: byteView, cid: getCidSync(byteView) }\n}\n\nexport async function encodeBlockOriginal(jsonObject: any) {\n\t// HACK re-added this to verify the sync variant is sane\n\tconst encoded = await multiformatsEncode({ value: jsonObject, codec: dagJson, hasher: sha265Hasher })\n\tconst syncVariant = encodeBlock(jsonObject)\n\tif (syncVariant.cid.toString() !== encoded.cid.toString()) {\n\t\tERROR(`[encodeBlockOriginal] sync cid mismatch`, { jsonObject, encoded, syncVariant })\n\t}\n\treturn encoded\n}\n"]}