@wovin/core 0.0.1-RC2 → 0.0.1-RC20
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 -0
- package/dist/applog.d.ts.map +1 -0
- package/dist/applog.js +81 -0
- package/dist/applog.js.map +1 -0
- package/dist/chunk-6ZDPEEFN.js +67 -0
- package/dist/chunk-6ZDPEEFN.js.map +1 -0
- package/dist/chunk-DBACGNVR.js +1 -0
- package/dist/chunk-DBACGNVR.js.map +1 -0
- package/dist/chunk-I5PELB4T.js +770 -0
- package/dist/chunk-I5PELB4T.js.map +1 -0
- package/dist/chunk-K2JRTCRC.js +44 -0
- package/dist/chunk-K2JRTCRC.js.map +1 -0
- package/dist/chunk-RBXGBMA7.js +93 -0
- package/dist/chunk-RBXGBMA7.js.map +1 -0
- package/dist/chunk-TR5AJKIN.js +1 -0
- package/dist/chunk-TR5AJKIN.js.map +1 -0
- package/dist/chunk-VKQDEGWA.js +561 -0
- package/dist/chunk-VKQDEGWA.js.map +1 -0
- package/dist/chunk-X23XAGRU.js +60 -0
- package/dist/chunk-X23XAGRU.js.map +1 -0
- package/dist/chunk-XJPITJRE.js +64 -0
- package/dist/chunk-XJPITJRE.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +231 -0
- package/dist/index.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 -0
- package/dist/ipfs.d.ts.map +1 -0
- package/dist/ipfs.js +28 -0
- package/dist/ipfs.js.map +1 -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/pubsub-types.d.ts +36 -0
- package/dist/pubsub/pubsub-types.d.ts.map +1 -0
- package/dist/pubsub.d.ts +4 -0
- package/dist/pubsub.d.ts.map +1 -0
- package/dist/pubsub.js +16 -0
- package/dist/pubsub.js.map +1 -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.js +66 -0
- package/dist/query.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/stream/mapped.d.ts +19 -0
- package/dist/stream/mapped.d.ts.map +1 -0
- package/dist/stream/writeable.d.ts +15 -0
- package/dist/stream/writeable.d.ts.map +1 -0
- package/dist/stream.d.ts +5 -0
- package/dist/stream.d.ts.map +1 -0
- package/dist/stream.js +36 -0
- package/dist/stream.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 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +32 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +1 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +1 -0
- package/dist/utils.js.map +1 -0
- package/package.json +36 -20
- package/src/index.ts +0 -3
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ApplogStream } from '../stream';
|
|
2
|
+
import { WriteableApplogStream } from '../stream/writeable';
|
|
3
|
+
import { ApplogForInsert, ApplogForInsertOptionalAgent, ApplogNoCid, Timestamp } from './datom-types';
|
|
4
|
+
export declare function hasAg(log: ApplogForInsertOptionalAgent): log is ApplogForInsert;
|
|
5
|
+
export declare function hasTs(log: ApplogForInsert): log is Omit<ApplogForInsert, 'ts'> & {
|
|
6
|
+
ts: Timestamp;
|
|
7
|
+
};
|
|
8
|
+
export declare function hasPv(log: ApplogForInsert): log is ApplogForInsert & {
|
|
9
|
+
pv: string;
|
|
10
|
+
};
|
|
11
|
+
export declare function withTs(log: ApplogForInsert, ts: Timestamp): Omit<ApplogForInsert, "ts"> & {
|
|
12
|
+
ts: string;
|
|
13
|
+
};
|
|
14
|
+
export declare function withPv(log: ApplogNoCid, ds: WriteableApplogStream): {
|
|
15
|
+
pv: any;
|
|
16
|
+
ts: string;
|
|
17
|
+
ag: string;
|
|
18
|
+
en: string;
|
|
19
|
+
at: string;
|
|
20
|
+
vl: import("./datom-types").ApplogValue;
|
|
21
|
+
};
|
|
22
|
+
export declare function joinStreams(streams: ApplogStream[]): ApplogStream;
|
|
23
|
+
//# sourceMappingURL=applog-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"applog-helpers.d.ts","sourceRoot":"","sources":["../../src/applog/applog-helpers.ts"],"names":[],"mappings":"AAGA,OAAO,EAAqB,YAAY,EAAmC,MAAM,WAAW,CAAA;AAC5F,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAE3D,OAAO,EAAU,eAAe,EAAE,4BAA4B,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAI7G,wBAAgB,KAAK,CAAC,GAAG,EAAE,4BAA4B,GAAG,GAAG,IAAI,eAAe,CAE/E;AACD,wBAAgB,KAAK,CAAC,GAAG,EAAE,eAAe,GAAG,GAAG,IAAI,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,GAAG;IAAE,EAAE,EAAE,SAAS,CAAA;CAAE,CAElG;AACD,wBAAgB,KAAK,CAAC,GAAG,EAAE,eAAe,GAAG,GAAG,IAAI,eAAe,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAEnF;AAED,wBAAgB,MAAM,CAAC,GAAG,EAAE,eAAe,EAAE,EAAE,EAAE,SAAS;;EAEzD;AACD,wBAAgB,MAAM,CAAC,GAAG,EAAE,WAAW,EAAE,EAAE,EAAE,qBAAqB;;;;;;;EASjE;AACD,wBAAgB,WAAW,CAAC,OAAO,EAAE,YAAY,EAAE,gBAiClD"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Applog, ApplogValue, DatalogQueryPattern, DatalogQueryResultEntry, ResultContext, SearchContext, ValueOrMatcher } from './datom-types';
|
|
2
|
+
export declare const isoDateStrCompare: (strA: string, strB: string, dir?: 'asc' | 'desc') => number;
|
|
3
|
+
export declare const compareApplogsByTs: (logA: Applog, logB: Applog, dir?: 'asc' | 'desc') => number;
|
|
4
|
+
/** Sort by TS (modifies the array, but also returns for ease of use) */
|
|
5
|
+
export declare function sortApplogsByTs(appLogArray: Applog[], dir?: 'asc' | 'desc'): Applog[];
|
|
6
|
+
export declare const isTsBefore: (log: Applog, logToCompare: Applog) => boolean;
|
|
7
|
+
export declare const uniqueEnFromAppLogs: (appLogArray: Applog[]) => string[];
|
|
8
|
+
export declare const areApplogsEqual: (logA: Applog, logB: Applog) => boolean;
|
|
9
|
+
export declare const removeDuplicateAppLogs: (appLogArray: Applog[]) => any[];
|
|
10
|
+
export declare const getHashID: (stringifiable: any, lngth?: number) => string;
|
|
11
|
+
export declare function isVariable(x: any): x is string;
|
|
12
|
+
export declare function variableNameWithoutQuestionmark(str: string): string;
|
|
13
|
+
export declare function isStaticPattern(x: any): x is ApplogValue;
|
|
14
|
+
export declare function resolveOrRemoveVariables(pattern: DatalogQueryPattern, candidate: SearchContext): {}[];
|
|
15
|
+
export declare function matchPartStatic(field: keyof Applog, patternPart: ValueOrMatcher<ApplogValue>, atomPart: ApplogValue): boolean;
|
|
16
|
+
export declare function matchPart(patternPart: ValueOrMatcher<ApplogValue>, atomPart: ApplogValue, context: SearchContext): ResultContext;
|
|
17
|
+
/**
|
|
18
|
+
* Check if pattern matches triple with context substitutions
|
|
19
|
+
*/
|
|
20
|
+
export declare function matchPattern(pattern: DatalogQueryPattern, applog: Applog, context: SearchContext): ResultContext;
|
|
21
|
+
export declare function actualize<SELECT extends string>(context: ResultContext, find: readonly SELECT[]): DatalogQueryResultEntry<SELECT>;
|
|
22
|
+
export declare const arrStats: {
|
|
23
|
+
max: (array: number[]) => number;
|
|
24
|
+
min: (array: number[]) => number;
|
|
25
|
+
range: (array: number[]) => number;
|
|
26
|
+
midrange: (array: number[]) => number;
|
|
27
|
+
sum: (array: number[]) => number;
|
|
28
|
+
mean: (array: number[]) => number;
|
|
29
|
+
average: (array: number[]) => number;
|
|
30
|
+
median: (array: number[]) => number;
|
|
31
|
+
modes: (array: number[]) => any[];
|
|
32
|
+
variance: (array: number[]) => number;
|
|
33
|
+
standardDeviation: (array: number[]) => number;
|
|
34
|
+
meanAbsoluteDeviation: (array: number[]) => number;
|
|
35
|
+
zScores: (array: number[]) => number[];
|
|
36
|
+
};
|
|
37
|
+
export declare const tsNearlySame: (timeA: string, timeB: string) => boolean;
|
|
38
|
+
export declare const cyrb53hash: (str: string, seed: number, strLength: number) => string;
|
|
39
|
+
export declare function arraysContainSameElements(arr1: any, arr2: any): boolean;
|
|
40
|
+
export declare function dateNowIso(): string;
|
|
41
|
+
//# sourceMappingURL=applog-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"applog-utils.d.ts","sourceRoot":"","sources":["../../src/applog/applog-utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACX,MAAM,EACN,WAAW,EACX,mBAAmB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AAgB,YAAY,CAAC,OAAO,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,aAAa,CAOhH;AAED,wBAAgB,SAAS,CAAC,MAAM,SAAS,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,uBAAuB,CAAC,MAAM,CAAC,CAUjI;AASD,eAAO,MAAM,QAAQ;iBACC,MAAM,EAAE;iBAIR,MAAM,EAAE;mBAIN,MAAM,EAAE;sBAIL,MAAM,EAAE;iBArBH,MAAM,EAAE;kBAKN,MAAM,EAAE;qBAAR,MAAM,EAAE;oBA0BjB,MAAM,EAAE;mBAQT,MAAM,EAAE;sBAqBL,MAAM,EAAE;+BAOC,MAAM,EAAE;mCAIJ,MAAM,EAAE;qBAOtB,MAAM,EAAE;CAOjC,CAAA;AAKD,eAAO,MAAM,YAAY,UAAW,MAAM,SAAS,MAAM,YAAuD,CAAA;AAUhH,eAAO,MAAM,UAAU,QACjB,MAAM,2BAEA,MAAM,WAqBjB,CAAA;AACD,wBAAgB,yBAAyB,CAAC,IAAI,KAAA,EAAE,IAAI,KAAA,WAenD;AACD,wBAAgB,UAAU,IAAI,MAAM,CAGnC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { Static, TSchema } from '@sinclair/typebox';
|
|
2
|
+
import { CID } from 'multiformats/cid';
|
|
3
|
+
import { PartialBy, Tagged } from '../types/typescript-utils';
|
|
4
|
+
export declare const Nullable: <T extends TSchema>(schema: T) => import("@sinclair/typebox").TUnion<[T, import("@sinclair/typebox").TNull]>;
|
|
5
|
+
export declare const EntityID_LENGTH = 7;
|
|
6
|
+
export declare const EntityID: import("@sinclair/typebox").TString;
|
|
7
|
+
export type EntityID = Static<typeof EntityID>;
|
|
8
|
+
export type DatomPart = string;
|
|
9
|
+
export type CidString = Tagged<string, CID>;
|
|
10
|
+
export type AgentID = EntityID;
|
|
11
|
+
export type Attribute = string;
|
|
12
|
+
export type ApplogValue = string | boolean | Number | null;
|
|
13
|
+
export interface Atom {
|
|
14
|
+
en: EntityID;
|
|
15
|
+
at: Attribute;
|
|
16
|
+
vl: ApplogValue;
|
|
17
|
+
}
|
|
18
|
+
export type AgentHash = string;
|
|
19
|
+
export type Timestamp = string;
|
|
20
|
+
export interface Applog extends Atom {
|
|
21
|
+
cid: CidString;
|
|
22
|
+
pv?: CidString;
|
|
23
|
+
ts: Timestamp;
|
|
24
|
+
ag: AgentHash;
|
|
25
|
+
}
|
|
26
|
+
export type ApplogNoCid = Omit<Applog, 'cid'>;
|
|
27
|
+
export type ApplogOptionalCid = PartialBy<Applog, 'cid'>;
|
|
28
|
+
export type ApplogForInsert = PartialBy<ApplogNoCid, 'ts'>;
|
|
29
|
+
export type ApplogForInsertOptionalAgent = PartialBy<ApplogForInsert, 'ag'>;
|
|
30
|
+
export type AtomPattern = Atom | Applog;
|
|
31
|
+
export interface DatalogStateIdentifier {
|
|
32
|
+
lastTS: Timestamp;
|
|
33
|
+
}
|
|
34
|
+
export type ValueOrMatcher<T> = T | readonly T[] | ((value: T) => boolean);
|
|
35
|
+
export type WithMatchers<T extends Record<string, any>> = {
|
|
36
|
+
[K in keyof T & string as `${K}` | `!${K}`]?: ValueOrMatcher<T[K]>;
|
|
37
|
+
};
|
|
38
|
+
export type DatalogQueryPattern = Partial<WithMatchers<Applog>>;
|
|
39
|
+
export type DatalogQueryPatternArray = DatalogQueryPattern[];
|
|
40
|
+
export interface DatalogQuery<SELECT extends string> {
|
|
41
|
+
find: readonly SELECT[];
|
|
42
|
+
where: DatalogQueryPatternArray;
|
|
43
|
+
onlyLatest?: boolean;
|
|
44
|
+
}
|
|
45
|
+
export type DatalogQueryResultEntry<SELECT extends string> = Record<StripPrefix<'?', SELECT>, DatomPart>;
|
|
46
|
+
export type DatalogQueryResultRows<SELECT extends string> = DatalogQueryResultEntry<SELECT>[];
|
|
47
|
+
export interface SearchContext {
|
|
48
|
+
[key: string]: ApplogValue;
|
|
49
|
+
}
|
|
50
|
+
export interface SearchContextWithLog {
|
|
51
|
+
context: SearchContext;
|
|
52
|
+
applog?: Applog;
|
|
53
|
+
}
|
|
54
|
+
export type ResultContext = SearchContext | null;
|
|
55
|
+
type StripPrefix<TPrefix extends string, T extends string> = T extends `${TPrefix}${infer R}` ? R : never;
|
|
56
|
+
export declare const CIDTB: import("@sinclair/typebox").TString;
|
|
57
|
+
export type CIDTB = Static<typeof EntityID>;
|
|
58
|
+
export declare const URL: import("@sinclair/typebox").TString;
|
|
59
|
+
export type URL = Static<typeof URL>;
|
|
60
|
+
export declare const AppLogTB: import("@sinclair/typebox").TObject<{
|
|
61
|
+
en: import("@sinclair/typebox").TString;
|
|
62
|
+
at: import("@sinclair/typebox").TString;
|
|
63
|
+
vl: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TBoolean, import("@sinclair/typebox").TNumber]>, import("@sinclair/typebox").TNull]>;
|
|
64
|
+
ts: import("@sinclair/typebox").TString;
|
|
65
|
+
ag: import("@sinclair/typebox").TString;
|
|
66
|
+
}>;
|
|
67
|
+
export type AppLogTB = Static<typeof AppLogTB>;
|
|
68
|
+
export declare const AppLogTBC: import("@sinclair/typebox/compiler").TypeCheck<import("@sinclair/typebox").TObject<{
|
|
69
|
+
en: import("@sinclair/typebox").TString;
|
|
70
|
+
at: import("@sinclair/typebox").TString;
|
|
71
|
+
vl: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TBoolean, import("@sinclair/typebox").TNumber]>, import("@sinclair/typebox").TNull]>;
|
|
72
|
+
ts: import("@sinclair/typebox").TString;
|
|
73
|
+
ag: import("@sinclair/typebox").TString;
|
|
74
|
+
}>>;
|
|
75
|
+
export declare const getApplogTypeErrors: (obj: any) => import("@sinclair/typebox/compiler").ValueError[];
|
|
76
|
+
export declare const isValidApplog: (value: unknown) => value is {
|
|
77
|
+
ts: string;
|
|
78
|
+
ag: string;
|
|
79
|
+
en: string;
|
|
80
|
+
at: string;
|
|
81
|
+
vl: string | number | boolean;
|
|
82
|
+
};
|
|
83
|
+
export {};
|
|
84
|
+
//# sourceMappingURL=datom-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datom-types.d.ts","sourceRoot":"","sources":["../../src/applog/datom-types.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,MAAM,EAAE,OAAO,EAAQ,MAAM,mBAAmB,CAAA;AAEzE,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAE7D,eAAO,MAAM,QAAQ,8GAAsE,CAAA;AAC3F,eAAO,MAAM,eAAe,IAAI,CAAA;AAShC,eAAO,MAAM,QAAQ,qCAAgB,CAAA;AACrC,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,QAAQ,CAAC,CAAA;AAE9C,MAAM,MAAM,SAAS,GAAG,MAAM,CAAA;AAC9B,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;AAC3C,MAAM,MAAM,OAAO,GAAG,QAAQ,CAAA;AAC9B,MAAM,MAAM,SAAS,GAAG,MAAM,CAAA;AAC9B,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,IAAI,CAAA;AAG1D,MAAM,WAAW,IAAI;IACpB,EAAE,EAAE,QAAQ,CAAA;IACZ,EAAE,EAAE,SAAS,CAAA;IACb,EAAE,EAAE,WAAW,CAAA;CACf;AAED,MAAM,MAAM,SAAS,GAAG,MAAM,CAAA;AAC9B,MAAM,MAAM,SAAS,GAAG,MAAM,CAAA;AAC9B,MAAM,WAAW,MAAO,SAAQ,IAAI;IACnC,GAAG,EAAE,SAAS,CAAA;IACd,EAAE,CAAC,EAAE,SAAS,CAAA;IACd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@@
|
|
|
1
|
+
import "./chunk-TR5AJKIN.js";
|
|
2
|
+
import {
|
|
3
|
+
AppLogTB,
|
|
4
|
+
AppLogTBC,
|
|
5
|
+
CIDTB,
|
|
6
|
+
EntityID,
|
|
7
|
+
EntityID_LENGTH,
|
|
8
|
+
Nullable,
|
|
9
|
+
URL,
|
|
10
|
+
getApplogTypeErrors,
|
|
11
|
+
hasAg,
|
|
12
|
+
hasPv,
|
|
13
|
+
hasTs,
|
|
14
|
+
isValidApplog,
|
|
15
|
+
joinStreams,
|
|
16
|
+
withPv,
|
|
17
|
+
withTs
|
|
18
|
+
} from "./chunk-VKQDEGWA.js";
|
|
19
|
+
import {
|
|
20
|
+
actualize,
|
|
21
|
+
areApplogsEqual,
|
|
22
|
+
arrStats,
|
|
23
|
+
arraysContainSameElements,
|
|
24
|
+
compareApplogsByTs,
|
|
25
|
+
cyrb53hash,
|
|
26
|
+
dateNowIso,
|
|
27
|
+
getHashID,
|
|
28
|
+
isStaticPattern,
|
|
29
|
+
isTsBefore,
|
|
30
|
+
isVariable,
|
|
31
|
+
isoDateStrCompare,
|
|
32
|
+
matchPart,
|
|
33
|
+
matchPartStatic,
|
|
34
|
+
matchPattern,
|
|
35
|
+
removeDuplicateAppLogs,
|
|
36
|
+
resolveOrRemoveVariables,
|
|
37
|
+
sortApplogsByTs,
|
|
38
|
+
tsNearlySame,
|
|
39
|
+
uniqueEnFromAppLogs,
|
|
40
|
+
variableNameWithoutQuestionmark
|
|
41
|
+
} from "./chunk-I5PELB4T.js";
|
|
42
|
+
import "./chunk-6ZDPEEFN.js";
|
|
43
|
+
export {
|
|
44
|
+
AppLogTB,
|
|
45
|
+
AppLogTBC,
|
|
46
|
+
CIDTB,
|
|
47
|
+
EntityID,
|
|
48
|
+
EntityID_LENGTH,
|
|
49
|
+
Nullable,
|
|
50
|
+
URL,
|
|
51
|
+
actualize,
|
|
52
|
+
areApplogsEqual,
|
|
53
|
+
arrStats,
|
|
54
|
+
arraysContainSameElements,
|
|
55
|
+
compareApplogsByTs,
|
|
56
|
+
cyrb53hash,
|
|
57
|
+
dateNowIso,
|
|
58
|
+
getApplogTypeErrors,
|
|
59
|
+
getHashID,
|
|
60
|
+
hasAg,
|
|
61
|
+
hasPv,
|
|
62
|
+
hasTs,
|
|
63
|
+
isStaticPattern,
|
|
64
|
+
isTsBefore,
|
|
65
|
+
isValidApplog,
|
|
66
|
+
isVariable,
|
|
67
|
+
isoDateStrCompare,
|
|
68
|
+
joinStreams,
|
|
69
|
+
matchPart,
|
|
70
|
+
matchPartStatic,
|
|
71
|
+
matchPattern,
|
|
72
|
+
removeDuplicateAppLogs,
|
|
73
|
+
resolveOrRemoveVariables,
|
|
74
|
+
sortApplogsByTs,
|
|
75
|
+
tsNearlySame,
|
|
76
|
+
uniqueEnFromAppLogs,
|
|
77
|
+
variableNameWithoutQuestionmark,
|
|
78
|
+
withPv,
|
|
79
|
+
withTs
|
|
80
|
+
};
|
|
81
|
+
//# sourceMappingURL=applog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,67 @@
|
|
|
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
|
+
// src/ipfs/ipfs-utils.ts
|
|
9
|
+
import * as dagJson from "@ipld/dag-json";
|
|
10
|
+
import { sha256 } from "@noble/hashes/sha256";
|
|
11
|
+
import { Logger } from "besonders-logger";
|
|
12
|
+
import { CID, digest as Digest } from "multiformats";
|
|
13
|
+
import { encode as multiformatsEncode } from "multiformats/block";
|
|
14
|
+
import { sha256 as sha265Hasher } from "multiformats/hashes/sha2";
|
|
15
|
+
var { WARN, LOG, DEBUG, VERBOSE, ERROR } = Logger.setup(Logger.INFO);
|
|
16
|
+
function prepareForPub(log, without = ["cid"]) {
|
|
17
|
+
const logWithout = {};
|
|
18
|
+
for (let [key, val] of Object.entries(log)) {
|
|
19
|
+
if (val === void 0) {
|
|
20
|
+
WARN(`log.${key} is undefined, which is not allowed - encoding as null`, log);
|
|
21
|
+
val = null;
|
|
22
|
+
}
|
|
23
|
+
if (!without.includes(key)) {
|
|
24
|
+
logWithout[key] = val && key === "pv" ? CID.parse(val) : val;
|
|
25
|
+
} else {
|
|
26
|
+
VERBOSE("excluding app log", { key, val });
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return logWithout;
|
|
30
|
+
}
|
|
31
|
+
function encodeApplogAndGetCid(log) {
|
|
32
|
+
return getCidSync(encodeApplog(log).bytes);
|
|
33
|
+
}
|
|
34
|
+
function encodeApplog(log) {
|
|
35
|
+
return encodeBlock(prepareForPub(log));
|
|
36
|
+
}
|
|
37
|
+
function getCidSync(bytes) {
|
|
38
|
+
const hash = sha256(bytes);
|
|
39
|
+
const digest = Digest.create(sha265Hasher.code, hash);
|
|
40
|
+
const cid = CID.create(1, dagJson.code, digest);
|
|
41
|
+
VERBOSE(`[getCidSync]`, { bytes, hash, digest, cid });
|
|
42
|
+
return cid;
|
|
43
|
+
}
|
|
44
|
+
function encodeBlock(jsonObject) {
|
|
45
|
+
DEBUG("[encodeBlock]", jsonObject);
|
|
46
|
+
const byteView = dagJson.encode(jsonObject);
|
|
47
|
+
return { bytes: byteView, cid: getCidSync(byteView) };
|
|
48
|
+
}
|
|
49
|
+
async function encodeBlockOriginal(jsonObject) {
|
|
50
|
+
const encoded = await multiformatsEncode({ value: jsonObject, codec: dagJson, hasher: sha265Hasher });
|
|
51
|
+
const syncVariant = encodeBlock(jsonObject);
|
|
52
|
+
if (syncVariant.cid.toString() !== encoded.cid.toString()) {
|
|
53
|
+
ERROR(`[encodeBlockOriginal] sync cid mismatch`, { jsonObject, encoded, syncVariant });
|
|
54
|
+
}
|
|
55
|
+
return encoded;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export {
|
|
59
|
+
__publicField,
|
|
60
|
+
prepareForPub,
|
|
61
|
+
encodeApplogAndGetCid,
|
|
62
|
+
encodeApplog,
|
|
63
|
+
getCidSync,
|
|
64
|
+
encodeBlock,
|
|
65
|
+
encodeBlockOriginal
|
|
66
|
+
};
|
|
67
|
+
//# sourceMappingURL=chunk-6ZDPEEFN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/ipfs/ipfs-utils.ts"],"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 '../applog/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"],"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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