@ibgib/core-gib 0.0.113 → 0.1.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 (69) hide show
  1. package/dist/common/comment/comment-constants.d.mts +1 -1
  2. package/dist/common/comment/comment-constants.d.mts.map +1 -1
  3. package/dist/common/comment/comment-constants.mjs +1 -1
  4. package/dist/common/comment/comment-constants.mjs.map +1 -1
  5. package/dist/timeline/timeline-api.d.mts +297 -0
  6. package/dist/timeline/timeline-api.d.mts.map +1 -0
  7. package/dist/timeline/timeline-api.mjs +725 -0
  8. package/dist/timeline/timeline-api.mjs.map +1 -0
  9. package/dist/timeline/timeline-types.d.mts +42 -0
  10. package/dist/timeline/timeline-types.d.mts.map +1 -0
  11. package/dist/timeline/timeline-types.mjs +2 -0
  12. package/dist/timeline/timeline-types.mjs.map +1 -0
  13. package/dist/witness/space/filesystem-space/filesystem-space-v1.d.mts +0 -1
  14. package/dist/witness/space/filesystem-space/filesystem-space-v1.d.mts.map +1 -1
  15. package/dist/witness/space/filesystem-space/filesystem-space-v1.mjs +0 -3
  16. package/dist/witness/space/filesystem-space/filesystem-space-v1.mjs.map +1 -1
  17. package/dist/witness/space/inner-space/inner-space-constants.d.mts +2 -0
  18. package/dist/witness/space/inner-space/inner-space-constants.d.mts.map +1 -0
  19. package/dist/witness/space/inner-space/inner-space-constants.mjs +2 -0
  20. package/dist/witness/space/inner-space/inner-space-constants.mjs.map +1 -0
  21. package/dist/witness/space/inner-space/inner-space-types.d.mts +23 -0
  22. package/dist/witness/space/inner-space/inner-space-types.d.mts.map +1 -0
  23. package/dist/witness/space/inner-space/inner-space-types.mjs +32 -0
  24. package/dist/witness/space/inner-space/inner-space-types.mjs.map +1 -0
  25. package/dist/witness/space/inner-space/inner-space-v1.d.mts +13 -7
  26. package/dist/witness/space/inner-space/inner-space-v1.d.mts.map +1 -1
  27. package/dist/witness/space/inner-space/inner-space-v1.mjs +159 -8
  28. package/dist/witness/space/inner-space/inner-space-v1.mjs.map +1 -1
  29. package/dist/witness/space/inner-space/inner-space-v1.respec.mjs +206 -52
  30. package/dist/witness/space/inner-space/inner-space-v1.respec.mjs.map +1 -1
  31. package/dist/witness/space/metaspace/metaspace-base.d.mts.map +1 -1
  32. package/dist/witness/space/metaspace/metaspace-base.mjs +4 -2
  33. package/dist/witness/space/metaspace/metaspace-base.mjs.map +1 -1
  34. package/dist/witness/space/metaspace/metaspace-innerspace/metaspace-innerspace-helper.d.mts.map +1 -1
  35. package/dist/witness/space/metaspace/metaspace-innerspace/metaspace-innerspace-helper.mjs +28 -9
  36. package/dist/witness/space/metaspace/metaspace-innerspace/metaspace-innerspace-helper.mjs.map +1 -1
  37. package/dist/witness/space/metaspace/metaspace-innerspace/metaspace-innerspace.d.mts.map +1 -1
  38. package/dist/witness/space/metaspace/metaspace-innerspace/metaspace-innerspace.mjs +27 -3
  39. package/dist/witness/space/metaspace/metaspace-innerspace/metaspace-innerspace.mjs.map +1 -1
  40. package/dist/witness/space/reconciliation-space/reconciliation-space-base.d.mts +100 -0
  41. package/dist/witness/space/reconciliation-space/reconciliation-space-base.d.mts.map +1 -0
  42. package/dist/witness/space/reconciliation-space/reconciliation-space-base.mjs +758 -0
  43. package/dist/witness/space/reconciliation-space/reconciliation-space-base.mjs.map +1 -0
  44. package/dist/witness/space/reconciliation-space/reconciliation-space-helper.d.mts +40 -0
  45. package/dist/witness/space/reconciliation-space/reconciliation-space-helper.d.mts.map +1 -0
  46. package/dist/witness/space/reconciliation-space/reconciliation-space-helper.mjs +90 -0
  47. package/dist/witness/space/reconciliation-space/reconciliation-space-helper.mjs.map +1 -0
  48. package/dist/witness/space/space-helper.d.mts.map +1 -1
  49. package/dist/witness/space/space-helper.mjs +10 -2
  50. package/dist/witness/space/space-helper.mjs.map +1 -1
  51. package/dist/witness/space/space-respec-helper.d.mts.map +1 -1
  52. package/dist/witness/space/space-respec-helper.mjs +3 -0
  53. package/dist/witness/space/space-respec-helper.mjs.map +1 -1
  54. package/package.json +1 -1
  55. package/src/common/comment/comment-constants.mts +1 -1
  56. package/src/timeline/timeline-api.mts +943 -0
  57. package/src/timeline/timeline-types.mts +38 -0
  58. package/src/witness/space/filesystem-space/filesystem-space-v1.mts +0 -3
  59. package/src/witness/space/inner-space/inner-space-constants.mts +1 -0
  60. package/src/witness/space/inner-space/inner-space-types.mts +44 -0
  61. package/src/witness/space/inner-space/inner-space-v1.mts +157 -28
  62. package/src/witness/space/inner-space/inner-space-v1.respec.mts +242 -58
  63. package/src/witness/space/metaspace/metaspace-base.mts +7 -1
  64. package/src/witness/space/metaspace/metaspace-innerspace/metaspace-innerspace-helper.mts +32 -10
  65. package/src/witness/space/metaspace/metaspace-innerspace/metaspace-innerspace.mts +76 -53
  66. package/src/witness/space/reconciliation-space/reconciliation-space-base.mts +884 -0
  67. package/src/witness/space/reconciliation-space/reconciliation-space-helper.mts +125 -0
  68. package/src/witness/space/space-helper.mts +5 -2
  69. package/src/witness/space/space-respec-helper.mts +4 -4
@@ -0,0 +1,125 @@
1
+ import { extractErrorMsg } from "@ibgib/helper-gib/dist/helpers/utils-helper.mjs";
2
+ import { getIbGibAddr } from "@ibgib/ts-gib/dist/helper.mjs";
3
+ import {
4
+ IbGibAddr, TransformOpts, TransformOpts_Mut8, TransformOpts_Rel8,
5
+ TransformResult,
6
+ } from "@ibgib/ts-gib/dist/types.mjs";
7
+ import { mut8 } from "@ibgib/ts-gib/dist/V1/transforms/mut8.mjs";
8
+ import { rel8 } from "@ibgib/ts-gib/dist/V1/transforms/rel8.mjs";
9
+ import { IbGib_V1 } from "@ibgib/ts-gib/dist/V1/types.mjs";
10
+
11
+ /**
12
+ * iteratively (recursively) apply transforms in
13
+ * `dnaAddrsToApplyToStoreVersion` to the store's version of the ibgib,
14
+ * keeping track of all dependencies used/created. ibgibs that we create
15
+ * along the way that we'll set to createdIbGibs to include dna,
16
+ * intermediate ibGibs, and newer versions of the source.
17
+ *
18
+ * populates the given `createdibGibs_Running` array, INCLUDING THE MOST
19
+ * RECENT IBGIB THAT WILL BE RETURNED BY THE FUNCTION.
20
+ *
21
+ * @returns the final ibgib produced from the transform applications.
22
+ */
23
+ export async function applyTransforms({
24
+ src,
25
+ createdIbGibs_Running,
26
+ dnaAddrsToApplyToStoreVersion,
27
+ allLocalIbGibs,
28
+ }: {
29
+ /**
30
+ * Most recent src to which we will apply the given
31
+ * `dnaAddrsToApplyToStoreVersion`.
32
+ */
33
+ src: IbGib_V1,
34
+ /**
35
+ * This will be populated through recursive iterations while applying
36
+ * dnas. Everything, including new dnas, new intermediate ibgibs, and
37
+ * new "src" ibgibs will be added to this before the final recursive
38
+ * call returns the final produced (out) ibgib.
39
+ */
40
+ createdIbGibs_Running: IbGib_V1[],
41
+ /**
42
+ * Transform addresses whose ibgib will be applied to the given `src`.
43
+ * This will be reduced by one per each recursive call to this function
44
+ * that is made.
45
+ */
46
+ dnaAddrsToApplyToStoreVersion: IbGibAddr[],
47
+ /**
48
+ * Should contain the dna ibGibs that are given in
49
+ * `dnaAddrsToApplyToStoreVersion`
50
+ */
51
+ allLocalIbGibs: IbGib_V1[],
52
+ }): Promise<IbGib_V1> {
53
+ const lc = `[${applyTransforms.name}]`;
54
+ try {
55
+ if (dnaAddrsToApplyToStoreVersion.length > 0) {
56
+ const dnaAddrToApply = dnaAddrsToApplyToStoreVersion.splice(0, 1)[0];
57
+ // we expect this dna ibgib to supplied to us, but need to check
58
+ const dnaIbGib_IntermediateArray =
59
+ allLocalIbGibs.filter(x => getIbGibAddr({ ibGib: x }) === dnaAddrToApply);
60
+ let dnaIbGib: IbGib_V1;
61
+ if (dnaIbGib_IntermediateArray.length === 1) {
62
+ dnaIbGib = dnaIbGib_IntermediateArray[0];
63
+ } else if (dnaIbGib_IntermediateArray.length === 0) {
64
+ throw new Error(`dna ibGib not found in supplied allLocalIbGibs. dnaAddr: ${dnaAddrToApply}. (E: 7f56826852cf48a79ab8af16bf27e284)`);
65
+ } else {
66
+ // more than one ibgib with the dna address?
67
+ throw new Error(`More than one ibGib in allLocalIbGibs with the dna address of ${dnaAddrToApply}? (E: a726134f4cc14a4fb2ed2d39d22af17c)(UNEXPECTED)`);
68
+ }
69
+
70
+ // we have our dna to apply, so do so against the incoming src
71
+ // any transform options is actually the dna.data plus src info.
72
+ let argTransform = dnaIbGib.data as TransformOpts<IbGib_V1>;
73
+ argTransform.src = src;
74
+ argTransform.srcAddr = getIbGibAddr({ ibGib: src });
75
+ let resTransform: TransformResult<IbGib_V1>;
76
+ switch (argTransform.type) {
77
+ case 'mut8':
78
+ resTransform = await mut8(argTransform as TransformOpts_Mut8<IbGib_V1, any>);
79
+ break;
80
+ case 'rel8':
81
+ resTransform = await rel8(argTransform as TransformOpts_Rel8<IbGib_V1>);
82
+ break;
83
+ case 'fork':
84
+ throw new Error(`fork transform not expected. atow only a single fork is expected at the beginning of the lifetime of a tjp ibgib. This fork defines the uniqueness of the tjp ibgib. When merging another tjp ibgib, we would only expect update transforms to be mut8 or rel8. (E: f8ad6996ac5545edad2d58a293d37d94)`);
85
+ default:
86
+ throw new Error(`unknown dna argTransform.type (${argTransform.type}) for dna address: ${dnaAddrToApply}. Expecting either mut8 or rel8. (fork transform is known but not expected either.) (E: 52a98db56e934e4cb42c64e2f45fa552)`);
87
+ }
88
+
89
+ // add intermediate ibgibs (including dna) to createdIbGibs_Running
90
+ (resTransform.intermediateIbGibs ?? []).forEach(x => createdIbGibs_Running.push(x));
91
+ (resTransform.dnas ?? []).forEach(x => createdIbGibs_Running.push(x));
92
+ createdIbGibs_Running.push(resTransform.newIbGib);
93
+
94
+ // not 100% but I believe the created dna should deep equal our
95
+ // incoming dna that we applied. so we'll warn if it doesn't.
96
+ // (ibgib addresses matching necessitates deep equal)
97
+ if ((resTransform.dnas ?? []).length > 0) {
98
+ if (!resTransform.dnas!.some(x => getIbGibAddr(x) === dnaAddrToApply)) {
99
+ console.warn(`${lc}(UNEXPECTED) Expected to generate exact dna that we applied in transform. dnaAddr: ${dnaAddrToApply} (W: 4a364c0b5d8d46c8af6bd540915fd973)`);
100
+ }
101
+ } else {
102
+ console.warn(`${lc}(UNEXPECTED) expected resTransform to include generated dna. dnaAddr: ${dnaAddrToApply}(W: 9648e2d5c40d42b7b9fb7efb09c5b13a)`)
103
+ }
104
+
105
+
106
+ // call recursively
107
+ return await applyTransforms({
108
+ src: resTransform.newIbGib,
109
+ createdIbGibs_Running,
110
+ dnaAddrsToApplyToStoreVersion,
111
+ allLocalIbGibs,
112
+ });
113
+ } else {
114
+ // no more dna to apply.
115
+ // createdIbGibs_Running should be populated
116
+ if (createdIbGibs_Running.length === 0) {
117
+ console.warn(`${lc} no dna transforms to apply but createdIbGibs_Running is empty. Dna is expected to start with at least one transform, otherwise don't call this function. (W: 52c7f2f6bd7e4bd0b31f53611b90268b)(UNEXPECTED)`)
118
+ }
119
+ return src;
120
+ }
121
+ } catch (error) {
122
+ console.error(`${lc} ${extractErrorMsg(error)}`);
123
+ throw error;
124
+ }
125
+ }
@@ -53,7 +53,7 @@ import { newUpMetaStone } from '../../common/meta-stone/meta-stone-helper.mjs';
53
53
  import { WITNESS_ATOM } from '../witness-constants.mjs';
54
54
  import { SyncSpaceIbGib } from './outer-space/outer-space-types.mjs';
55
55
 
56
- let logalot = GLOBAL_LOG_A_LOT;
56
+ let logalot = GLOBAL_LOG_A_LOT || true;
57
57
 
58
58
 
59
59
  /**
@@ -669,6 +669,7 @@ export async function setCurrentRoot({
669
669
  }): Promise<void> {
670
670
  const lc = `[${setCurrentRoot.name}]`;
671
671
  try {
672
+ if (logalot) { console.log(`${lc} starting... (I: 7f16e845a80fe95d28923e4170f0c825)`); }
672
673
  if (!root) { throw new Error(`root required.`); }
673
674
 
674
675
  if (!space) { throw new Error(`space required. (E: 186af2731c5342a78b063a0a4346f3db)`); }
@@ -677,7 +678,7 @@ export async function setCurrentRoot({
677
678
 
678
679
  // get the roots and update its "current" rel8n
679
680
  const roots = await getSpecialIbGib({ type: "roots", space });
680
- if (!roots) { throw new Error(`Roots not initialized.`); }
681
+ if (!roots) { throw new Error(`Roots not initialized. (E: a8232b9afac89d0d189534480b7a9825)`); }
681
682
 
682
683
  // we'll rel8 current with a linkedRel8n, thus ensuring a maximum of only
683
684
  // one rel8d addr (the one we're adding here)
@@ -701,6 +702,8 @@ export async function setCurrentRoot({
701
702
  } catch (error) {
702
703
  console.error(`${lc} ${error.message}`);
703
704
  throw error;
705
+ } finally {
706
+ if (logalot) { console.log(`${lc} complete. (I: 7f16e845a80fe95d28923e4170f0c825)`); }
704
707
  }
705
708
  }
706
709
 
@@ -32,10 +32,7 @@ import {
32
32
  persistTransformResult, putInSpace, registerNewIbGib
33
33
  } from "./space-helper.mjs";
34
34
  import { IbGibSpaceAny } from "./space-base-v1.mjs";
35
- import { GetIbGibResult, IbGibTimelineUpdateInfo } from '../../common/other/other-types.mjs';
36
- import { Subject_V1_Factory } from '../../common/pubsub/subject/subject-v1.mjs';
37
- import { newupSubject } from '../../common/pubsub/subject/subject-helper.mjs';
38
- import { fnObs } from '../../common/pubsub/observer/observer-helper.mjs';
35
+ import { IbGibTimelineUpdateInfo } from '../../common/other/other-types.mjs';
39
36
  import { getGib } from '@ibgib/ts-gib/dist/V1/transforms/transform-helper.mjs';
40
37
  import { mut8 } from '@ibgib/ts-gib/dist/V1/transforms/mut8.mjs';
41
38
 
@@ -588,6 +585,9 @@ export async function testSpace_registerNewIbGib_GetLatest({
588
585
  const allPointToLatest =
589
586
  latestAddrsValues.every(x => x === newIbGibAddr_n_i);
590
587
  iReckon(sir, allPointToLatest).asTo('allPointToLatest').isGonnaBeTrue();
588
+ if (!allPointToLatest) {
589
+ console.error(`${lc} latestAddrsValues: ${pretty(latestAddrsValues)} (E: e60cd36435882b5d18b577d8cd51f825)`);
590
+ }
591
591
 
592
592
  // prepare for next iteration
593
593
  src = newIbGib_n_i;