@wovin/core 0.0.1-RC11 → 0.0.1-RC13

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 (131) 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.cjs +5 -9
  8. package/dist/applog.d.ts +4 -70
  9. package/dist/applog.d.ts.map +1 -0
  10. package/dist/applog.js +6 -10
  11. package/dist/chunk-2AMSXRCE.cjs +44 -0
  12. package/dist/chunk-2AMSXRCE.cjs.map +1 -0
  13. package/dist/chunk-3A6EVJRM.cjs +1 -0
  14. package/dist/chunk-3DH5YICT.cjs +93 -0
  15. package/dist/chunk-3DH5YICT.cjs.map +1 -0
  16. package/dist/{queries.js → chunk-675WVAUK.js} +10 -58
  17. package/dist/chunk-675WVAUK.js.map +1 -0
  18. package/dist/{chunk-QXNFGJ5R.js → chunk-6ZDPEEFN.js} +9 -1
  19. package/dist/chunk-6ZDPEEFN.js.map +1 -0
  20. package/dist/chunk-DBACGNVR.js +1 -0
  21. package/dist/{queries.cjs → chunk-DCEWFFL2.cjs} +11 -59
  22. package/dist/chunk-DCEWFFL2.cjs.map +1 -0
  23. package/dist/{chunk-KHY3SRML.js → chunk-I5PELB4T.js} +6 -4
  24. package/dist/chunk-I5PELB4T.js.map +1 -0
  25. package/dist/chunk-JAQY3BDB.cjs +1 -0
  26. package/dist/chunk-JAQY3BDB.cjs.map +1 -0
  27. package/dist/{chunk-GT5X2WN4.cjs → chunk-JZECIYRO.cjs} +11 -3
  28. package/dist/chunk-JZECIYRO.cjs.map +1 -0
  29. package/dist/chunk-K2JRTCRC.js +44 -0
  30. package/dist/chunk-K2JRTCRC.js.map +1 -0
  31. package/dist/chunk-LJCAIQSI.js +93 -0
  32. package/dist/chunk-LJCAIQSI.js.map +1 -0
  33. package/dist/{chunk-DZT6AK5X.cjs → chunk-OQIAAGF3.cjs} +1 -1
  34. package/dist/chunk-OQIAAGF3.cjs.map +1 -0
  35. package/dist/chunk-TR5AJKIN.js +1 -0
  36. package/dist/chunk-TR5AJKIN.js.map +1 -0
  37. package/dist/{chunk-JSAJQXI2.cjs → chunk-UFTSMKIM.cjs} +58 -77
  38. package/dist/chunk-UFTSMKIM.cjs.map +1 -0
  39. package/dist/{chunk-FFOMTT6L.js → chunk-X23XAGRU.js} +1 -1
  40. package/dist/chunk-X23XAGRU.js.map +1 -0
  41. package/dist/{chunk-ZPOYKHY6.cjs → chunk-ZMBGF3RU.cjs} +12 -10
  42. package/dist/chunk-ZMBGF3RU.cjs.map +1 -0
  43. package/dist/{chunk-KGTU6PJ3.js → chunk-ZYTTTZUC.js} +7 -26
  44. package/dist/chunk-ZYTTTZUC.js.map +1 -0
  45. package/dist/index.cjs +223 -79
  46. package/dist/index.cjs.map +1 -1
  47. package/dist/index.d.ts +8 -12
  48. package/dist/index.d.ts.map +1 -0
  49. package/dist/index.js +217 -73
  50. package/dist/index.js.map +1 -1
  51. package/dist/ipfs/car.d.ts +15 -0
  52. package/dist/ipfs/car.d.ts.map +1 -0
  53. package/dist/ipfs/ipfs-utils.d.ts +17 -0
  54. package/dist/ipfs/ipfs-utils.d.ts.map +1 -0
  55. package/dist/ipfs.cjs +5 -5
  56. package/dist/ipfs.d.ts +3 -36
  57. package/dist/ipfs.d.ts.map +1 -0
  58. package/dist/ipfs.js +3 -3
  59. package/dist/mobx/mobx-utils.d.ts +67 -0
  60. package/dist/mobx/mobx-utils.d.ts.map +1 -0
  61. package/dist/pubsub/publication.d.ts +6 -0
  62. package/dist/pubsub/publication.d.ts.map +1 -0
  63. package/dist/{pubsub.d.cts → pubsub/pubsub-types.d.ts} +7 -12
  64. package/dist/pubsub/pubsub-types.d.ts.map +1 -0
  65. package/dist/pubsub.cjs +11 -9
  66. package/dist/pubsub.cjs.map +1 -1
  67. package/dist/pubsub.d.ts +3 -41
  68. package/dist/pubsub.d.ts.map +1 -0
  69. package/dist/pubsub.js +12 -10
  70. package/dist/pubsub.js.map +1 -1
  71. package/dist/query/basic.d.ts +58 -0
  72. package/dist/query/basic.d.ts.map +1 -0
  73. package/dist/query/divergences.d.ts +12 -0
  74. package/dist/query/divergences.d.ts.map +1 -0
  75. package/dist/query/matchers.d.ts +4 -0
  76. package/dist/query/matchers.d.ts.map +1 -0
  77. package/dist/query.cjs +66 -0
  78. package/dist/query.cjs.map +1 -0
  79. package/dist/query.d.ts +5 -0
  80. package/dist/query.d.ts.map +1 -0
  81. package/dist/query.js +66 -0
  82. package/dist/query.js.map +1 -0
  83. package/dist/stream/basic.d.ts +34 -0
  84. package/dist/stream/basic.d.ts.map +1 -0
  85. package/dist/stream/filters.d.ts +38 -0
  86. package/dist/stream/filters.d.ts.map +1 -0
  87. package/dist/{mapped-8h8bwRuM.d.ts → stream/mapped.d.ts} +5 -6
  88. package/dist/stream/mapped.d.ts.map +1 -0
  89. package/dist/{writeable-r_920qCb.d.ts → stream/writeable.d.ts} +5 -6
  90. package/dist/stream/writeable.d.ts.map +1 -0
  91. package/dist/stream.cjs +4 -5
  92. package/dist/stream.d.ts +5 -44
  93. package/dist/stream.d.ts.map +1 -0
  94. package/dist/stream.js +3 -4
  95. package/dist/types/typescript-utils.d.ts +33 -0
  96. package/dist/types/typescript-utils.d.ts.map +1 -0
  97. package/dist/types.cjs +15 -29
  98. package/dist/types.cjs.map +1 -1
  99. package/dist/types.d.ts +2 -4
  100. package/dist/types.d.ts.map +1 -0
  101. package/dist/types.js +16 -30
  102. package/dist/types.js.map +1 -1
  103. package/dist/utils.d.ts +1 -2
  104. package/dist/utils.d.ts.map +1 -0
  105. package/package.json +3 -3
  106. package/dist/applog.d.cts +0 -70
  107. package/dist/chunk-DZT6AK5X.cjs.map +0 -1
  108. package/dist/chunk-F3FYYIAV.js +0 -11
  109. package/dist/chunk-FFOMTT6L.js.map +0 -1
  110. package/dist/chunk-GT5X2WN4.cjs.map +0 -1
  111. package/dist/chunk-JSAJQXI2.cjs.map +0 -1
  112. package/dist/chunk-KGTU6PJ3.js.map +0 -1
  113. package/dist/chunk-KHY3SRML.js.map +0 -1
  114. package/dist/chunk-QXNFGJ5R.js.map +0 -1
  115. package/dist/chunk-UOPZAYFM.cjs +0 -11
  116. package/dist/chunk-ZPOYKHY6.cjs.map +0 -1
  117. package/dist/index.d.cts +0 -12
  118. package/dist/ipfs.d.cts +0 -36
  119. package/dist/mapped-mkKwhQgZ.d.cts +0 -20
  120. package/dist/queries.cjs.map +0 -1
  121. package/dist/queries.d.cts +0 -141
  122. package/dist/queries.d.ts +0 -141
  123. package/dist/queries.js.map +0 -1
  124. package/dist/stream.d.cts +0 -44
  125. package/dist/types-A9kYLtyU.d.cts +0 -153
  126. package/dist/types-A9kYLtyU.d.ts +0 -153
  127. package/dist/types.d.cts +0 -4
  128. package/dist/utils.d.cts +0 -2
  129. package/dist/writeable-0WbsIiQn.d.cts +0 -16
  130. /package/dist/{chunk-UOPZAYFM.cjs.map → chunk-3A6EVJRM.cjs.map} +0 -0
  131. /package/dist/{chunk-F3FYYIAV.js.map → chunk-DBACGNVR.js.map} +0 -0
@@ -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,EACnB,uBAAuB,EACvB,aAAa,EACb,aAAa,EACb,cAAc,EACd,MAAM,eAAe,CAAA;AAItB,eAAO,MAAM,iBAAiB,SAAU,MAAM,QAAQ,MAAM,QAAO,KAAK,GAAG,MAAM,WAG5C,CAAA;AACrC,eAAO,MAAM,kBAAkB,SAAU,MAAM,QAAQ,MAAM,QAAO,KAAK,GAAG,MAAM,WAAqD,CAAA;AACvI,yEAAyE;AACzE,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,EAAE,GAAG,GAAE,KAAK,GAAG,MAAc,YAEjF;AACD,eAAO,MAAM,UAAU,QAAS,MAAM,gBAAgB,MAAM,YAA0D,CAAA;AACtH,eAAO,MAAM,mBAAmB,gBAAiB,MAAM,EAAE,aAAyD,CAAA;AAClH,eAAO,MAAM,eAAe,SAAU,MAAM,QAAQ,MAAM,YAAoC,CAAA;AAE9F,eAAO,MAAM,sBAAsB,gBAAiB,MAAM,EAAE,UAU3D,CAAA;AAWD,eAAO,MAAM,SAAS,kBAAmB,GAAG,2BAAyE,CAAA;AAErH,wBAAgB,UAAU,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,IAAI,MAAM,CAE9C;AACD,wBAAgB,+BAA+B,CAAC,GAAG,EAAE,MAAM,UAE1D;AAID,wBAAgB,eAAe,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,IAAI,WAAW,CAGxD;AAaD,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,mBAAmB,EAAE,SAAS,EAAE,aAAa,QAmB9F;AAcD,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,MAAM,EAAE,WAAW,EAAE,cAAc,CAAC,WAAW,CAAC,EAAE,QAAQ,EAAE,WAAW,GAAG,OAAO,CAsB7H;AACD,wBAAgB,SAAS,CAAC,WAAW,EAAE,cAAc,CAAC,WAAW,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa,GAAG,aAAa,CAiBhI;AAED;;GAEG;AACH,wBAAgB,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,CA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MAAM,aAAa,GAAG,aAAa,GAAG,IAAI,CAAA;AAGhD,KAAK,WAAW,CACf,OAAO,SAAS,MAAM,EACtB,CAAC,SAAS,MAAM,IACb,CAAC,SAAS,GAAG,OAAO,GAAG,MAAM,CAAC,EAAE,GAAG,CAAC,GAAG,KAAK,CAAA;AAOhD,eAAO,MAAM,KAAK,qCAAsC,CAAA;AACxD,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,QAAQ,CAAC,CAAA;AAI3C,eAAO,MAAM,GAAG,qCAAiC,CAAA;AACjD,MAAM,MAAM,GAAG,GAAG,MAAM,CAAC,OAAO,GAAG,CAAC,CAAA;AAEpC,eAAO,MAAM,QAAQ;;;;;;EAMnB,CAAA;AACF,MAAM,MAAM,QAAQ,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"}
package/dist/applog.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('./chunk-3A6EVJRM.cjs');
2
2
 
3
3
 
4
4
 
@@ -15,9 +15,9 @@
15
15
 
16
16
 
17
17
 
18
+ var _chunkUFTSMKIMcjs = require('./chunk-UFTSMKIM.cjs');
18
19
 
19
20
 
20
- var _chunkJSAJQXI2cjs = require('./chunk-JSAJQXI2.cjs');
21
21
 
22
22
 
23
23
 
@@ -38,10 +38,9 @@ var _chunkJSAJQXI2cjs = require('./chunk-JSAJQXI2.cjs');
38
38
 
39
39
 
40
40
 
41
+ var _chunkZMBGF3RUcjs = require('./chunk-ZMBGF3RU.cjs');
42
+ require('./chunk-JZECIYRO.cjs');
41
43
 
42
- var _chunkZPOYKHY6cjs = require('./chunk-ZPOYKHY6.cjs');
43
- require('./chunk-GT5X2WN4.cjs');
44
- require('./chunk-UOPZAYFM.cjs');
45
44
 
46
45
 
47
46
 
@@ -78,8 +77,5 @@ require('./chunk-UOPZAYFM.cjs');
78
77
 
79
78
 
80
79
 
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;
80
+ exports.AppLogTB = _chunkUFTSMKIMcjs.AppLogTB; exports.AppLogTBC = _chunkUFTSMKIMcjs.AppLogTBC; exports.CIDTB = _chunkUFTSMKIMcjs.CIDTB; exports.EntityID = _chunkUFTSMKIMcjs.EntityID; exports.EntityID_LENGTH = _chunkUFTSMKIMcjs.EntityID_LENGTH; exports.Nullable = _chunkUFTSMKIMcjs.Nullable; exports.URL = _chunkUFTSMKIMcjs.URL; exports.actualize = _chunkZMBGF3RUcjs.actualize; exports.areApplogsEqual = _chunkZMBGF3RUcjs.areApplogsEqual; exports.arrStats = _chunkZMBGF3RUcjs.arrStats; exports.arraysContainSameElements = _chunkZMBGF3RUcjs.arraysContainSameElements; exports.compareApplogsByTs = _chunkZMBGF3RUcjs.compareApplogsByTs; exports.cyrb53hash = _chunkZMBGF3RUcjs.cyrb53hash; exports.dateNowIso = _chunkZMBGF3RUcjs.dateNowIso; exports.getApplogTypeErrors = _chunkUFTSMKIMcjs.getApplogTypeErrors; exports.getHashID = _chunkZMBGF3RUcjs.getHashID; exports.hasAg = _chunkUFTSMKIMcjs.hasAg; exports.hasPv = _chunkUFTSMKIMcjs.hasPv; exports.hasTs = _chunkUFTSMKIMcjs.hasTs; exports.isStaticPattern = _chunkZMBGF3RUcjs.isStaticPattern; exports.isTsBefore = _chunkZMBGF3RUcjs.isTsBefore; exports.isValidApplog = _chunkUFTSMKIMcjs.isValidApplog; exports.isVariable = _chunkZMBGF3RUcjs.isVariable; exports.isoDateStrCompare = _chunkZMBGF3RUcjs.isoDateStrCompare; exports.joinStreams = _chunkUFTSMKIMcjs.joinStreams; exports.matchPart = _chunkZMBGF3RUcjs.matchPart; exports.matchPartStatic = _chunkZMBGF3RUcjs.matchPartStatic; exports.matchPattern = _chunkZMBGF3RUcjs.matchPattern; exports.removeDuplicateAppLogs = _chunkZMBGF3RUcjs.removeDuplicateAppLogs; exports.resolveOrRemoveVariables = _chunkZMBGF3RUcjs.resolveOrRemoveVariables; exports.sortApplogsByTs = _chunkZMBGF3RUcjs.sortApplogsByTs; exports.tsNearlySame = _chunkZMBGF3RUcjs.tsNearlySame; exports.uniqueEnFromAppLogs = _chunkZMBGF3RUcjs.uniqueEnFromAppLogs; exports.variableNameWithoutQuestionmark = _chunkZMBGF3RUcjs.variableNameWithoutQuestionmark; exports.withPv = _chunkUFTSMKIMcjs.withPv; exports.withTs = _chunkUFTSMKIMcjs.withTs;
85
81
  //# sourceMappingURL=applog.cjs.map
package/dist/applog.d.ts CHANGED
@@ -1,70 +1,4 @@
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.js';
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.js';
3
- import { W as WriteableApplogStream } from './writeable-r_920qCb.js';
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 };
1
+ export * from './applog/applog-helpers';
2
+ export * from './applog/applog-utils';
3
+ export * from './applog/datom-types';
4
+ //# sourceMappingURL=applog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"applog.d.ts","sourceRoot":"","sources":["../src/applog.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAA;AACvC,cAAc,uBAAuB,CAAA;AACrC,cAAc,sBAAsB,CAAA"}
package/dist/applog.js CHANGED
@@ -1,3 +1,4 @@
1
+ import "./chunk-TR5AJKIN.js";
1
2
  import {
2
3
  AppLogTB,
3
4
  AppLogTBC,
@@ -6,23 +7,21 @@ import {
6
7
  EntityID_LENGTH,
7
8
  Nullable,
8
9
  URL,
9
- filterOnlyLatest,
10
10
  getApplogTypeErrors,
11
11
  hasAg,
12
12
  hasPv,
13
13
  hasTs,
14
14
  isValidApplog,
15
15
  joinStreams,
16
- sortApplogByTs,
17
- sortApplogByTsDec,
18
16
  withPv,
19
17
  withTs
20
- } from "./chunk-KGTU6PJ3.js";
18
+ } from "./chunk-ZYTTTZUC.js";
21
19
  import {
22
20
  actualize,
23
21
  areApplogsEqual,
24
22
  arrStats,
25
23
  arraysContainSameElements,
24
+ compareApplogsByTs,
26
25
  cyrb53hash,
27
26
  dateNowIso,
28
27
  getHashID,
@@ -39,9 +38,8 @@ import {
39
38
  tsNearlySame,
40
39
  uniqueEnFromAppLogs,
41
40
  variableNameWithoutQuestionmark
42
- } from "./chunk-KHY3SRML.js";
43
- import "./chunk-QXNFGJ5R.js";
44
- import "./chunk-F3FYYIAV.js";
41
+ } from "./chunk-I5PELB4T.js";
42
+ import "./chunk-6ZDPEEFN.js";
45
43
  export {
46
44
  AppLogTB,
47
45
  AppLogTBC,
@@ -54,9 +52,9 @@ export {
54
52
  areApplogsEqual,
55
53
  arrStats,
56
54
  arraysContainSameElements,
55
+ compareApplogsByTs,
57
56
  cyrb53hash,
58
57
  dateNowIso,
59
- filterOnlyLatest,
60
58
  getApplogTypeErrors,
61
59
  getHashID,
62
60
  hasAg,
@@ -73,8 +71,6 @@ export {
73
71
  matchPattern,
74
72
  removeDuplicateAppLogs,
75
73
  resolveOrRemoveVariables,
76
- sortApplogByTs,
77
- sortApplogByTsDec,
78
74
  sortApplogsByTs,
79
75
  tsNearlySame,
80
76
  uniqueEnFromAppLogs,
@@ -0,0 +1,44 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkZMBGF3RUcjs = require('./chunk-ZMBGF3RU.cjs');
4
+
5
+ // src/types/typescript-utils.ts
6
+ var _typebox = require('@sinclair/typebox');
7
+ var _system = require('@sinclair/typebox/system');
8
+ var ApplogStreamTB = _system.TypeSystem.Type("ApplogStream", (options, value) => {
9
+ return value instanceof _chunkZMBGF3RUcjs.ApplogStream;
10
+ })();
11
+ var { String: StringTB, Optional: OptionalTB, Boolean: BooleanTB, Object: ObjectTB, Number: NumberTB } = _typebox.Type;
12
+ var Str = StringTB.bind(_typebox.Type);
13
+ var Num = NumberTB.bind(_typebox.Type);
14
+ var Obj = ObjectTB.bind(_typebox.Type);
15
+ var Opt = OptionalTB.bind(_typebox.Type);
16
+ var Bool = BooleanTB.bind(_typebox.Type);
17
+ var STR = Str();
18
+ var NUM = Num();
19
+ var BOOL = Bool();
20
+ var DefaultTrue = true;
21
+ var DefaultFalse = false;
22
+ function checkParityTB() {
23
+ const s1 = Str();
24
+ const s2 = Str();
25
+ const n1 = Num();
26
+ const n2 = Num();
27
+ console.log({ s1, s2, n1, n2 });
28
+ }
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+ exports.ApplogStreamTB = ApplogStreamTB; exports.Str = Str; exports.Num = Num; exports.Obj = Obj; exports.Opt = Opt; exports.Bool = Bool; exports.STR = STR; exports.NUM = NUM; exports.BOOL = BOOL; exports.DefaultTrue = DefaultTrue; exports.DefaultFalse = DefaultFalse; exports.checkParityTB = checkParityTB;
44
+ //# sourceMappingURL=chunk-2AMSXRCE.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/types/typescript-utils.ts"],"names":[],"mappings":";;;;;AAAA,SAAS,QAAQ,SAAS;AAC1B,SAAS,kBAAkB;AAIpB,IAAM,iBAAiB,WAAW,KAAmB,gBAAgB,CAAC,SAAS,UAAU;AAC/F,SAAO,iBAAiB;AACzB,CAAC,EAAE;AACH,IAAM,EAAE,QAAQ,UAAU,UAAU,YAAY,SAAS,WAAW,QAAQ,UAAU,QAAQ,SAAS,IAAI;AACpG,IAAM,MAAuB,SAAS,KAAK,CAAC;AAC5C,IAAM,MAAuB,SAAS,KAAK,CAAC;AAC5C,IAAM,MAAuB,SAAS,KAAK,CAAC;AAC5C,IAAM,MAAyB,WAAW,KAAK,CAAC;AAChD,IAAM,OAAyB,UAAU,KAAK,CAAC;AAE/C,IAAM,MAAmC,IAAI;AAC7C,IAAM,MAAmC,IAAI;AAC7C,IAAM,OAAqC,KAAK;AAGhD,IAAM,cAA2B;AAGjC,IAAM,eAA6B;AAwBnC,SAAS,gBAAgB;AAI/B,QAAM,KAAK,IAAI;AACf,QAAM,KAAK,IAAI;AACf,QAAM,KAAK,IAAI;AACf,QAAM,KAAK,IAAI;AACf,UAAQ,IAAI,EAAE,IAAI,IAAI,IAAI,GAAG,CAAC;AAC/B","sourcesContent":["import { Type as T } from '@sinclair/typebox'\nimport { TypeSystem } from '@sinclair/typebox/system'\nimport type { CID } from 'multiformats'\nimport { ApplogStream } from '../stream'\n\nexport const ApplogStreamTB = TypeSystem.Type<ApplogStream>('ApplogStream', (options, value) => {\n\treturn value instanceof ApplogStream\n})()\nconst { String: StringTB, Optional: OptionalTB, Boolean: BooleanTB, Object: ObjectTB, Number: NumberTB } = T\nexport const Str: typeof StringTB = StringTB.bind(T)\nexport const Num: typeof NumberTB = NumberTB.bind(T)\nexport const Obj: typeof ObjectTB = ObjectTB.bind(T)\nexport const Opt: typeof OptionalTB = OptionalTB.bind(T)\nexport const Bool: typeof BooleanTB = BooleanTB.bind(T)\n\nexport const STR: ReturnType<typeof T.String> = Str()\nexport const NUM: ReturnType<typeof T.Number> = Num()\nexport const BOOL: ReturnType<typeof T.Boolean> = Bool()\n\nexport type DefaultTrue = true | boolean\nexport const DefaultTrue: DefaultTrue = true\n\nexport type DefaultFalse = false | boolean\nexport const DefaultFalse: DefaultFalse = false\n\nexport type GenericObject = Record<string, any>\nexport type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>\nexport type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>\nexport type PromiseType<T extends Promise<any>> = T extends Promise<infer U> ? U : never\n\nexport type CoerceToString<T> = T extends string ? T : never\n\n/**\n * Define nominal type of U based on type of T. Similar to Opaque types in Flow\n */\nexport type Tagged<T, Tag> = T & { tag?: Tag }\n\n// export interface Service {\n// \tendpoint?: URL\n// \ttoken: string\n// \trateLimiter?: RateLimiter\n// \tfetch?: typeof _fetch\n// }\n\n// https://stackoverflow.com/a/76276541\nexport type LastElementOf<T extends readonly unknown[]> = T extends readonly [...unknown[], infer Last] ? Last : never\n\nexport function checkParityTB() {\n\t/* Most examples are constantly calling Type.*() - needed to check if its really needed\n https://github.com/sinclairzx81/typebox/issues/587#issuecomment-1712457623\n */\n\tconst s1 = Str()\n\tconst s2 = Str()\n\tconst n1 = Num()\n\tconst n2 = Num()\n\tconsole.log({ s1, s2, n1, n2 })\n}\n\n/** solidjs Setter requires returning something, which I often don't */\nexport type GenericSetter<T> = (newValue: T) => void\n"]}
@@ -0,0 +1 @@
1
+ "use strict";//# sourceMappingURL=chunk-3A6EVJRM.cjs.map
@@ -0,0 +1,93 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } 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; }
2
+
3
+ var _chunkOQIAAGF3cjs = require('./chunk-OQIAAGF3.cjs');
4
+
5
+
6
+ var _chunkZMBGF3RUcjs = require('./chunk-ZMBGF3RU.cjs');
7
+
8
+
9
+
10
+ var _chunkJZECIYROcjs = require('./chunk-JZECIYRO.cjs');
11
+
12
+ // src/pubsub/publication.ts
13
+ var _besonderslogger = require('besonders-logger');
14
+ var { WARN, LOG, DEBUG, VERBOSE, ERROR } = _besonderslogger.Logger.setup(_besonderslogger.Logger.INFO);
15
+ var neverEncryptAttrs = [
16
+ "agent/jwkd",
17
+ "agent/appAgent",
18
+ "pub/encryptedFor",
19
+ "pub/sharedKey"
20
+ ];
21
+ async function preparePubForPush(agentHash, agentFullID, publication, dataStream, applogs) {
22
+ let maybeEncryptedApplogs = [];
23
+ const { sharedAgents, sharedKeyMap, sharedKey } = _nullishCoalesce(publication, () => ( {}));
24
+ const agentLogs = _chunkZMBGF3RUcjs.rollingFilter.call(void 0, dataStream, {
25
+ en: agentHash,
26
+ at: ["agent/ecdh", "agent/jwkd", "agent/appAgent"]
27
+ });
28
+ DEBUG(`[publish] adding agent logs:`, agentLogs);
29
+ applogs.push(...agentLogs.applogs);
30
+ let encPayload;
31
+ const encryptAndTestDecrypt = async (applog, keyToUse) => {
32
+ throw new Error(`todo: enc`);
33
+ };
34
+ DEBUG("[publish] applogs ", applogs);
35
+ if (sharedAgents) {
36
+ if (!sharedKey || !sharedKeyMap) {
37
+ DEBUG("weird state, publishing nonEncrypted", { sharedAgents, sharedKeyMap, sharedKey });
38
+ maybeEncryptedApplogs = applogs;
39
+ } else {
40
+ const agentSharedKeyLogs = [];
41
+ for (const [eachAgent, eachEncKey] of Array.from(sharedKeyMap.entries())) {
42
+ agentSharedKeyLogs.push({
43
+ ag: agentHash,
44
+ en: eachAgent,
45
+ at: "pub/sharedKey",
46
+ vl: eachEncKey
47
+ // these are encrypted with the derived key from the local agent private and remote agent public keys
48
+ });
49
+ }
50
+ for (const eachLog of applogs) {
51
+ VERBOSE("[crypto] encrypting ", eachLog);
52
+ if (neverEncryptAttrs.includes(eachLog.at)) {
53
+ maybeEncryptedApplogs.push(
54
+ /* prepareForPub( */
55
+ eachLog
56
+ /* ) */
57
+ );
58
+ }
59
+ try {
60
+ encPayload = await encryptAndTestDecrypt(eachLog, sharedKey);
61
+ } catch (err) {
62
+ }
63
+ maybeEncryptedApplogs.push(encPayload);
64
+ }
65
+ }
66
+ } else
67
+ maybeEncryptedApplogs = applogs;
68
+ maybeEncryptedApplogs = maybeEncryptedApplogs.map((log) => log.en ? _chunkJZECIYROcjs.prepareForPub.call(void 0, log) : log);
69
+ const encodedApplogs = await Promise.all(maybeEncryptedApplogs.map(_chunkJZECIYROcjs.encodeBlockOriginal));
70
+ DEBUG("[publish] encoded root", { agentHash, agentFullID, encodedApplogs });
71
+ const cids = encodedApplogs.map((b) => _nullishCoalesce(b.cid, () => ( null)));
72
+ const root = { applogs: cids };
73
+ const encodedRoot = await _chunkJZECIYROcjs.encodeBlockOriginal.call(void 0, root);
74
+ DEBUG("[publish] encoded root", { cids, encodedRoot });
75
+ const car = await _chunkOQIAAGF3cjs.makeCarBlob.call(void 0, encodedRoot.cid, [encodedRoot, ...encodedApplogs]);
76
+ return car;
77
+ }
78
+
79
+ // src/pubsub/pubsub-types.ts
80
+ function isPublication(obj) {
81
+ return _optionalChain([obj, 'optionalAccess', _ => _.pk]) !== void 0 && _optionalChain([obj, 'optionalAccess', _2 => _2.lastPush]) !== void 0;
82
+ }
83
+ function isSubscription(obj) {
84
+ return _optionalChain([obj, 'optionalAccess', _3 => _3.lastPull]) !== void 0;
85
+ }
86
+
87
+
88
+
89
+
90
+
91
+
92
+ exports.neverEncryptAttrs = neverEncryptAttrs; exports.preparePubForPush = preparePubForPush; exports.isPublication = isPublication; exports.isSubscription = isSubscription;
93
+ //# sourceMapp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A,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;;;ACrEO,SAAS,cAAc,KAA+B;AAC5D,SAAO,KAAK,OAAO,UAAa,KAAK,aAAa;AACnD;AACO,SAAS,eAAe,KAAgC;AAC9D,SAAO,KAAK,aAAa;AAC1B","sourcesContent":["import { Logger } from 'besonders-logger'\nimport { stringify } from 'safe-stable-stringify'\nimport { cyrb53hash } from '../applog/applog-utils'\nimport { Applog, ApplogForInsert, EntityID } from '../applog/datom-types'\nimport { makeCarBlob } from '../ipfs/car'\nimport { encodeBlockOriginal, prepareForPub } from '../ipfs/ipfs-utils'\nimport { ApplogStream } from '../stream'\nimport { rollingFilter } from '../stream/filters'\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","import { AgentID } from '../applog/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"]}
@@ -1,37 +1,13 @@
1
1
  import {
2
- ApplogStreamInMemory,
3
- QueryNode,
4
- QueryNodes,
5
- agentsOfStream,
6
- entityOverlap,
7
- entityOverlapCount,
8
- filterAndMap,
9
- mapTo,
10
- prefixAt,
11
- prefixAttrs,
12
- query,
13
- queryAndMap,
14
- queryEntity,
15
- queryNot,
16
- queryStep,
17
- startsWith,
18
- withoutDeleted,
19
- withoutHistory
20
- } from "./chunk-KGTU6PJ3.js";
2
+ ApplogStreamInMemory
3
+ } from "./chunk-ZYTTTZUC.js";
21
4
  import {
22
- applogStreamComparer,
23
5
  computedFnDeepCompare,
24
- computedStructuralComparer,
25
6
  createDebugName,
26
- createDebugNameObj,
27
- observableArrayMap,
28
- prettifyStreamName,
29
- queryNodesComparer
30
- } from "./chunk-KHY3SRML.js";
31
- import "./chunk-QXNFGJ5R.js";
32
- import "./chunk-F3FYYIAV.js";
7
+ observableArrayMap
8
+ } from "./chunk-I5PELB4T.js";
33
9
 
34
- // src/queries/divergences.ts
10
+ // src/query/divergences.ts
35
11
  import { Logger } from "besonders-logger";
36
12
  import { autorun, comparer, toJS } from "mobx";
37
13
  var { WARN, LOG, DEBUG, VERBOSE, ERROR } = Logger.setup(Logger.INFO);
@@ -72,41 +48,17 @@ var queryDivergencesByPrev = computedFnDeepCompare(function queryConflictingByPr
72
48
  return divergences;
73
49
  }, { equals: comparer.structural });
74
50
 
75
- // src/queries/matchers.ts
51
+ // src/query/matchers.ts
76
52
  function includes(str) {
77
53
  return (vl) => vl?.includes?.(str);
78
54
  }
79
55
  function includedIn(arr) {
80
56
  return (vl) => arr?.includes?.(vl);
81
57
  }
58
+
82
59
  export {
83
- QueryNode,
84
- QueryNodes,
85
- agentsOfStream,
86
- applogStreamComparer,
87
- computedFnDeepCompare,
88
- computedStructuralComparer,
89
- createDebugName,
90
- createDebugNameObj,
91
- entityOverlap,
92
- entityOverlapCount,
93
- filterAndMap,
94
- includedIn,
95
- includes,
96
- mapTo,
97
- observableArrayMap,
98
- prefixAt,
99
- prefixAttrs,
100
- prettifyStreamName,
101
- query,
102
- queryAndMap,
103
60
  queryDivergencesByPrev,
104
- queryEntity,
105
- queryNodesComparer,
106
- queryNot,
107
- queryStep,
108
- startsWith,
109
- withoutDeleted,
110
- withoutHistory
61
+ includes,
62
+ includedIn
111
63
  };
112
- //# sourceMappingURL=queries.js.map
64
+ //# sourceMappingURL=chunk-675WVAUK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/query/divergences.ts","../src/query/matchers.ts"],"sourcesContent":["import { Logger } from 'besonders-logger'\nimport { autorun, comparer, toJS } from 'mobx'\nimport { Applog } from '../applog/datom-types'\nimport { computedFnDeepCompare, createDebugName, observableArrayMap } from '../mobx/mobx-utils'\nimport { ApplogStream } from '../stream'\nimport { ApplogStreamInMemory } from '../stream/writeable'\n\nconst { WARN, LOG, DEBUG, VERBOSE, ERROR } = Logger.setup(Logger.INFO) // eslint-disable-line no-unused-vars\n\nexport interface DivergenceLeaf {\n\tlog: Applog\n\tstream: ApplogStream\n}\n\nexport const queryDivergencesByPrev = computedFnDeepCompare(function queryConflictingByPrev(\n\tsourceStream: ApplogStream,\n) {\n\tDEBUG(`queryDivergencesByPrev<${sourceStream.nameAndSizeUntracked}>`)\n\tif (sourceStream.filters.includes('withoutHistory')) WARN(`queryDivergencesByPrev on stream withoutHistory`, sourceStream)\n\n\tconst divergences = observableArrayMap(() => {\n\t\tconst logsForNode = new Map<string, Applog[]>()\n\t\tconst leafs = new Set<string>()\n\t\tVERBOSE('all applogs:', sourceStream.applogs)\n\t\tfor (const log of sourceStream.applogs) {\n\t\t\tlet prevLogs\n\t\t\tif (log.pv) {\n\t\t\t\tprevLogs = log.pv && logsForNode.get(log.pv.toString())\n\t\t\t\tleafs.delete(log.pv.toString())\n\t\t\t}\n\t\t\tVERBOSE('traversing log', { log, prevLogs, leafs: Array.from(leafs) })\n\t\t\tlogsForNode.set(log.cid, prevLogs ? [...prevLogs, log] : [log])\n\t\t\tleafs.add(log.cid)\n\t\t}\n\t\treturn Array.from(leafs).map(leafID => {\n\t\t\t// ? use MappedApplogStream?\n\t\t\tconst stream = new ApplogStreamInMemory(\n\t\t\t\tlogsForNode.get(leafID),\n\t\t\t\tsourceStream.filters,\n\t\t\t\tcreateDebugName({\n\t\t\t\t\tcaller: 'DivergenceLeaf',\n\t\t\t\t\tstream: sourceStream,\n\t\t\t\t\tpattern: `leaf: ${leafID}`,\n\t\t\t\t}),\n\t\t\t\ttrue,\n\t\t\t\tsourceStream,\n\t\t\t)\n\t\t\treturn ({ log: stream.latestLog, stream })\n\t\t})\n\t}, { name: createDebugName({ caller: 'queryDivergencesByPrev', stream: sourceStream }) })\n\tVERBOSE.isDisabled || autorun(() => VERBOSE(`[queryDivergencesByPrev] result:`, toJS(divergences)))\n\treturn divergences\n}, { equals: comparer.structural })\n","import { DatomPart } from '../applog/datom-types'\n\nexport function includes(str: string) {\n\treturn (vl: DatomPart) => vl?.includes?.(str)\n}\nexport function includedIn(arr: string[]) {\n\treturn (vl: DatomPart) => arr?.includes?.(vl)\n}\n"],"mappings":";;;;;;;;;;AAAA,SAAS,cAAc;AACvB,SAAS,SAAS,UAAU,YAAY;AAMxC,IAAM,EAAE,MAAM,KAAK,OAAO,SAAS,MAAM,IAAI,OAAO,MAAM,OAAO,IAAI;AAO9D,IAAM,yBAAyB,sBAAsB,SAAS,uBACpE,cACC;AACD,QAAM,0BAA0B,aAAa,oBAAoB,GAAG;AACpE,MAAI,aAAa,QAAQ,SAAS,gBAAgB;AAAG,SAAK,mDAAmD,YAAY;AAEzH,QAAM,cAAc,mBAAmB,MAAM;AAC5C,UAAM,cAAc,oBAAI,IAAsB;AAC9C,UAAM,QAAQ,oBAAI,IAAY;AAC9B,YAAQ,gBAAgB,aAAa,OAAO;AAC5C,eAAW,OAAO,aAAa,SAAS;AACvC,UAAI;AACJ,UAAI,IAAI,IAAI;AACX,mBAAW,IAAI,MAAM,YAAY,IAAI,IAAI,GAAG,SAAS,CAAC;AACtD,cAAM,OAAO,IAAI,GA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