@wovin/core 0.0.1-RC2 → 0.0.1-RC4

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.
@@ -0,0 +1,24 @@
1
+ import { WriteableApplogStream } from '../stream/writeable';
2
+ import { Applog, ApplogForInsert, ApplogForInsertOptionalAgent, ApplogNoCid, Timestamp } from './datom-types';
3
+ export declare const sortApplogByTs: (p: Applog, n: Applog) => 0 | 1 | -1;
4
+ export declare const sortApplogByTsDec: (p: Applog, n: Applog) => 0 | 1 | -1;
5
+ export declare function filterOnlyLatest(logs: Applog[], onlyLatest: boolean): Applog[];
6
+ export declare function hasAg(log: ApplogForInsertOptionalAgent): log is ApplogForInsert;
7
+ export declare function hasTs(log: ApplogForInsert): log is Omit<ApplogForInsert, 'ts'> & {
8
+ ts: Timestamp;
9
+ };
10
+ export declare function hasPv(log: ApplogForInsert): log is ApplogForInsert & {
11
+ pv: string;
12
+ };
13
+ export declare function withTs(log: ApplogForInsert, ts: Timestamp): Omit<ApplogForInsert, "ts"> & {
14
+ ts: string;
15
+ };
16
+ export declare function withPv(log: ApplogNoCid, ds: WriteableApplogStream): {
17
+ pv: any;
18
+ at: string;
19
+ ts: string;
20
+ ag: string;
21
+ en: string;
22
+ vl: import("./datom-types").ApplogValue;
23
+ };
24
+ //# sourceMappingURL=applog-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"applog-helpers.d.ts","sourceRoot":"","sources":["../../src/data/applog-helpers.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAC3D,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,4BAA4B,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAI7G,eAAO,MAAM,cAAc,MAAO,MAAM,KAAK,MAAM,eAAiD,CAAA;AACpG,eAAO,MAAM,iBAAiB,MAAO,MAAM,KAAK,MAAM,eAAiD,CAAA;AAGvG,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,OAAO,GAAG,MAAM,EAAE,CAc9E;AAED,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"}
@@ -0,0 +1,42 @@
1
+ import { type ApplogStream } from '../stream/stream';
2
+ import type { Applog, ApplogValue, DatalogQueryPattern, DatalogQueryResultEntry, ResultContext, SearchContext, ValueOrMatcher } from './datom-types';
3
+ export declare const isoDateStrCompare: (strA: string, strB: string, 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 function joinStreams(streams: ApplogStream[]): ApplogStream;
10
+ export declare const removeDuplicateAppLogs: (appLogArray: Applog[]) => any[];
11
+ export declare const getHashID: (stringifiable: any, lngth?: number) => string;
12
+ export declare function isVariable(x: any): x is string;
13
+ export declare function variableNameWithoutQuestionmark(str: string): string;
14
+ export declare function isStaticPattern(x: any): x is ApplogValue;
15
+ export declare function resolveOrRemoveVariables(pattern: DatalogQueryPattern, candidate: SearchContext): {}[];
16
+ export declare function matchPartStatic(field: keyof Applog, patternPart: ValueOrMatcher<ApplogValue>, atomPart: ApplogValue): boolean;
17
+ export declare function matchPart(patternPart: ValueOrMatcher<ApplogValue>, atomPart: ApplogValue, context: SearchContext): ResultContext;
18
+ /**
19
+ * Check if pattern matches triple with context substitutions
20
+ */
21
+ export declare function matchPattern(pattern: DatalogQueryPattern, applog: Applog, context: SearchContext): ResultContext;
22
+ export declare function actualize<SELECT extends string>(context: ResultContext, find: readonly SELECT[]): DatalogQueryResultEntry<SELECT>;
23
+ export declare const arrStats: {
24
+ max: (array: number[]) => number;
25
+ min: (array: number[]) => number;
26
+ range: (array: number[]) => number;
27
+ midrange: (array: number[]) => number;
28
+ sum: (array: number[]) => number;
29
+ mean: (array: number[]) => number;
30
+ average: (array: number[]) => number;
31
+ median: (array: number[]) => number;
32
+ modes: (array: number[]) => any[];
33
+ variance: (array: number[]) => number;
34
+ standardDeviation: (array: number[]) => number;
35
+ meanAbsoluteDeviation: (array: number[]) => number;
36
+ zScores: (array: number[]) => number[];
37
+ };
38
+ export declare const tsNearlySame: (timeA: string, timeB: string) => boolean;
39
+ export declare const cyrb53hash: (str: string, seed: number, strLength: number) => string;
40
+ export declare function arraysContainSameElements(arr1: any, arr2: any): boolean;
41
+ export declare function dateNowIso(): string;
42
+ //# sourceMappingURL=applog-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"applog-utils.d.ts","sourceRoot":"","sources":["../../src/data/applog-utils.ts"],"names":[],"mappings":"AAKA,OAAO,EAA0B,KAAK,YAAY,EAAe,MAAM,kBAAkB,CAAA;AACzF,OAAO,KAAK,EACX,MAAM,EACN,WAAW,EACX,mBAAmB,EACnB,uBAAuB,EACvB,aAAa,EACb,aAAa,EACb,cAAc,EACd,MAAM,eAAe,CAAA;AAItB,eAAO,MAAM,iBAAiB,SAAU,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,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 } 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 = string;
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 | CID;
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<AtomPattern>>;
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
+ at: string;
78
+ ts: string;
79
+ ag: string;
80
+ en: 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/data/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,2BAA2B,CAAA;AAErD,eAAO,MAAM,QAAQ,8GAAsE,CAAA;AAC3F,eAAO,MAAM,eAAe,IAAI,CAAA;AAShC,eAAO,MAAM,QAAQ,qCAAsC,CAAA;AAC3D,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,QAAQ,CAAC,CAAA;AAE9C,MAAM,MAAM,SAAS,GAAG,MAAM,CAAA;AAC9B,MAAM,MAAM,SAAS,GAAG,MAAM,CAAA;AAC9B,MAAM,MAAM,OAAO,GAAG,QAAQ,CAAA;AAC9B,MAAM,MAAM,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GAAG,MAAM,CAAC,OAAO,QAAQ,CAAC,CAAA;AAE9C,eAAO,MAAM,SAAS;;;;;;GAAiC,CAAA;AACvD,eAAO,MAAM,mBAAmB,QAAS,GAAG,sDAAsC,CAAA;AAClF,eAAO,MAAM,aAAa;;;;;;CAAkC,CAAA"}
@@ -0,0 +1,3 @@
1
+ export declare const wovinCoreTest = 12345.7;
2
+ export * from './stream/stream';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,UAAU,CAAA;AAEpC,cAAc,iBAAiB,CAAA"}