@ibgib/core-gib 0.1.12 → 0.1.14
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/keystone/keystone-helpers.mjs +3 -3
- package/dist/keystone/keystone-helpers.mjs.map +1 -1
- package/dist/sync/sync-constants.d.mts +4 -1
- package/dist/sync/sync-constants.d.mts.map +1 -1
- package/dist/sync/sync-constants.mjs +3 -0
- package/dist/sync/sync-constants.mjs.map +1 -1
- package/dist/sync/sync-helpers.d.mts +18 -2
- package/dist/sync/sync-helpers.d.mts.map +1 -1
- package/dist/sync/sync-helpers.mjs +84 -3
- package/dist/sync/sync-helpers.mjs.map +1 -1
- package/dist/sync/sync-innerspace.respec.d.mts +0 -6
- package/dist/sync/sync-innerspace.respec.d.mts.map +1 -1
- package/dist/sync/sync-innerspace.respec.mjs +395 -241
- package/dist/sync/sync-innerspace.respec.mjs.map +1 -1
- package/dist/sync/sync-peer/sync-peer-types.d.mts +31 -0
- package/dist/sync/sync-peer/sync-peer-types.d.mts.map +1 -0
- package/dist/sync/sync-peer/sync-peer-types.mjs +5 -0
- package/dist/sync/sync-peer/sync-peer-types.mjs.map +1 -0
- package/dist/sync/sync-peer/sync-peer-v1.d.mts +22 -0
- package/dist/sync/sync-peer/sync-peer-v1.d.mts.map +1 -0
- package/dist/sync/sync-peer/sync-peer-v1.mjs +13 -0
- package/dist/sync/sync-peer/sync-peer-v1.mjs.map +1 -0
- package/dist/sync/sync-saga-context/sync-saga-context-constants.d.mts +8 -0
- package/dist/sync/sync-saga-context/sync-saga-context-constants.d.mts.map +1 -0
- package/dist/sync/sync-saga-context/sync-saga-context-constants.mjs +8 -0
- package/dist/sync/sync-saga-context/sync-saga-context-constants.mjs.map +1 -0
- package/dist/sync/sync-saga-context/sync-saga-context-helpers.d.mts +54 -0
- package/dist/sync/sync-saga-context/sync-saga-context-helpers.d.mts.map +1 -0
- package/dist/sync/sync-saga-context/sync-saga-context-helpers.mjs +87 -0
- package/dist/sync/sync-saga-context/sync-saga-context-helpers.mjs.map +1 -0
- package/dist/sync/sync-saga-context/sync-saga-context-types.d.mts +66 -0
- package/dist/sync/sync-saga-context/sync-saga-context-types.d.mts.map +1 -0
- package/dist/sync/sync-saga-context/sync-saga-context-types.mjs +12 -0
- package/dist/sync/sync-saga-context/sync-saga-context-types.mjs.map +1 -0
- package/dist/sync/sync-saga-coordinator.d.mts +136 -91
- package/dist/sync/sync-saga-coordinator.d.mts.map +1 -1
- package/dist/sync/sync-saga-coordinator.mjs +563 -287
- package/dist/sync/sync-saga-coordinator.mjs.map +1 -1
- package/dist/sync/sync-saga-coordinator.respec.mjs +7 -7
- package/dist/sync/sync-saga-coordinator.respec.mjs.map +1 -1
- package/dist/sync/sync-saga-message/sync-saga-message-constants.d.mts +2 -0
- package/dist/sync/sync-saga-message/sync-saga-message-constants.d.mts.map +1 -0
- package/dist/sync/sync-saga-message/sync-saga-message-constants.mjs +2 -0
- package/dist/sync/sync-saga-message/sync-saga-message-constants.mjs.map +1 -0
- package/dist/sync/sync-saga-message/sync-saga-message-helpers.d.mts +15 -0
- package/dist/sync/sync-saga-message/sync-saga-message-helpers.d.mts.map +1 -0
- package/dist/sync/sync-saga-message/sync-saga-message-helpers.mjs +43 -0
- package/dist/sync/sync-saga-message/sync-saga-message-helpers.mjs.map +1 -0
- package/dist/sync/sync-saga-message/sync-saga-message-types.d.mts +39 -0
- package/dist/sync/sync-saga-message/sync-saga-message-types.d.mts.map +1 -0
- package/dist/sync/sync-saga-message/sync-saga-message-types.mjs +2 -0
- package/dist/sync/sync-saga-message/sync-saga-message-types.mjs.map +1 -0
- package/dist/sync/sync-types.d.mts +81 -3
- package/dist/sync/sync-types.d.mts.map +1 -1
- package/dist/sync/sync-types.mjs +27 -1
- package/dist/sync/sync-types.mjs.map +1 -1
- package/dist/timeline/timeline-api.d.mts +16 -3
- package/dist/timeline/timeline-api.d.mts.map +1 -1
- package/dist/timeline/timeline-api.mjs +7 -7
- package/dist/timeline/timeline-api.mjs.map +1 -1
- package/dist/witness/space/inner-space/inner-space-v1.d.mts.map +1 -1
- package/dist/witness/space/inner-space/inner-space-v1.mjs +3 -4
- package/dist/witness/space/inner-space/inner-space-v1.mjs.map +1 -1
- package/dist/witness/space/outer-space/outer-space-types.d.mts +2 -0
- package/dist/witness/space/outer-space/outer-space-types.d.mts.map +1 -1
- package/dist/witness/space/space-base-v1.d.mts +19 -1
- package/dist/witness/space/space-base-v1.d.mts.map +1 -1
- package/dist/witness/space/space-base-v1.mjs +66 -6
- package/dist/witness/space/space-base-v1.mjs.map +1 -1
- package/dist/witness/space/space-helper.d.mts +14 -0
- package/dist/witness/space/space-helper.d.mts.map +1 -1
- package/dist/witness/space/space-helper.mjs +44 -1
- package/dist/witness/space/space-helper.mjs.map +1 -1
- package/dist/witness/space/space-respec-helper.d.mts.map +1 -1
- package/dist/witness/space/space-respec-helper.mjs +1 -1
- package/dist/witness/space/space-respec-helper.mjs.map +1 -1
- package/dist/witness/space/space-types.d.mts +12 -1
- package/dist/witness/space/space-types.d.mts.map +1 -1
- package/dist/witness/space/space-types.mjs +4 -0
- package/dist/witness/space/space-types.mjs.map +1 -1
- package/package.json +2 -2
- package/src/keystone/keystone-helpers.mts +3 -3
- package/src/sync/README.md +275 -0
- package/src/sync/sync-constants.mts +5 -0
- package/src/sync/sync-helpers.mts +105 -6
- package/src/sync/sync-innerspace.respec.mts +458 -289
- package/src/sync/sync-peer/sync-peer-types.mts +43 -0
- package/src/sync/sync-peer/sync-peer-v1.mts +28 -0
- package/src/sync/sync-saga-context/sync-saga-context-constants.mts +8 -0
- package/src/sync/sync-saga-context/sync-saga-context-helpers.mts +147 -0
- package/src/sync/sync-saga-context/sync-saga-context-types.mts +80 -0
- package/src/sync/sync-saga-coordinator.mts +762 -329
- package/src/sync/sync-saga-coordinator.respec.mts +7 -7
- package/src/sync/sync-saga-message/sync-saga-message-constants.mts +1 -0
- package/src/sync/sync-saga-message/sync-saga-message-helpers.mts +59 -0
- package/src/sync/sync-saga-message/sync-saga-message-types.mts +53 -0
- package/src/sync/sync-types.mts +103 -3
- package/src/timeline/timeline-api.mts +20 -4
- package/src/witness/space/inner-space/inner-space-v1.mts +3 -2
- package/src/witness/space/reconciliation-space/reconciliation-space-base.mts.OLD.md +884 -0
- package/src/witness/space/reconciliation-space/reconciliation-space-helper.mts.OLD.md +125 -0
- package/src/witness/space/space-base-v1.mts +62 -12
- package/src/witness/space/space-helper.mts +50 -1
- package/src/witness/space/space-respec-helper.mts +2 -1
- package/src/witness/space/space-types.mts +13 -1
- package/tmp.md +3 -9
|
@@ -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
|
+
}
|
|
@@ -1,21 +1,20 @@
|
|
|
1
|
+
import { extractErrorMsg } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
1
2
|
import { getIbGibAddr } from '@ibgib/ts-gib/dist/helper.mjs';
|
|
2
3
|
import { IbGib_V1 } from '@ibgib/ts-gib/dist/V1/index.mjs';
|
|
4
|
+
import { validateIbGibIntrinsically } from '@ibgib/ts-gib/dist/V1/validate-helper.mjs';
|
|
3
5
|
|
|
4
|
-
|
|
6
|
+
import { GLOBAL_LOG_A_LOT } from '../../core-constants.mjs';
|
|
5
7
|
import { WitnessBase_V1, } from '../witness-base-v1.mjs';
|
|
6
8
|
import {
|
|
7
|
-
IbGibSpace, IbGibSpaceData,
|
|
8
|
-
IbGibSpaceOptionsCmdModifier, IbGibSpaceOptionsData,
|
|
9
|
-
IbGibSpaceOptionsRel8ns, IbGibSpaceRel8ns,
|
|
10
|
-
IbGibSpaceResultIbGib, IbGibSpaceResultRel8ns
|
|
11
|
-
} from '
|
|
12
|
-
import { getSpaceResultMetadata } from '
|
|
13
|
-
import {
|
|
14
|
-
// import { argy_, resulty_ } from '../witness-helper.mjs';
|
|
9
|
+
GetDependencyGraphResultData, IbGibSpace, IbGibSpaceData,
|
|
10
|
+
IbGibSpaceOptionsCmd, IbGibSpaceOptionsCmdModifier, IbGibSpaceOptionsData,
|
|
11
|
+
IbGibSpaceOptionsIbGib, IbGibSpaceOptionsRel8ns, IbGibSpaceRel8ns,
|
|
12
|
+
IbGibSpaceResultData, IbGibSpaceResultIbGib, IbGibSpaceResultRel8ns
|
|
13
|
+
} from './space-types.mjs';
|
|
14
|
+
import { getSpaceResultMetadata } from './space-helper.mjs';
|
|
15
|
+
import { getDependencyGraph, GetGraphOptions } from '../../common/other/graph-helper.mjs';
|
|
15
16
|
import { argy_, resulty_ } from '../../witness/witness-helper.mjs';
|
|
16
|
-
// import { IbGibCacheService } from '../../types/ibgib.mjs';
|
|
17
17
|
import { IbGibCacheService } from '../../common/cache/cache-types.mjs';
|
|
18
|
-
import { GLOBAL_LOG_A_LOT } from '../../core-constants.mjs';
|
|
19
18
|
|
|
20
19
|
const logalot = GLOBAL_LOG_A_LOT;
|
|
21
20
|
|
|
@@ -139,6 +138,8 @@ export abstract class SpaceBase_V1<
|
|
|
139
138
|
}
|
|
140
139
|
} else if (cmdModifiers.includes('addrs')) {
|
|
141
140
|
return this.getAddrs(arg);
|
|
141
|
+
} else if (cmdModifiers.includes('dependency-graph')) {
|
|
142
|
+
return this.getDependencyGraph(arg);
|
|
142
143
|
} else {
|
|
143
144
|
return this.get(arg);
|
|
144
145
|
}
|
|
@@ -280,6 +281,55 @@ export abstract class SpaceBase_V1<
|
|
|
280
281
|
throw new Error(`${lc} not implemented in base class`);
|
|
281
282
|
}
|
|
282
283
|
|
|
284
|
+
/**
|
|
285
|
+
* gets the entire dependency graph(s) of incoming addr(s).
|
|
286
|
+
*
|
|
287
|
+
* NOTE: Caller will have to manually convert the result.ibGibs to a flag
|
|
288
|
+
* ibgib graph to match the existing {@link getDependencyGraph} return if
|
|
289
|
+
* desired. This should be a trivial conversion though, as the keys to the
|
|
290
|
+
* flat graph are just the {@link getIbGibAddr} on the ibGib itself.
|
|
291
|
+
*
|
|
292
|
+
* @returns resulty ibgib with {@link GetDependencyGraphResultData}
|
|
293
|
+
*/
|
|
294
|
+
protected getDependencyGraph(arg: TOptionsIbGib): Promise<TResultIbGib | undefined> { return this.getDependencyGraphImpl(arg); }
|
|
295
|
+
/**
|
|
296
|
+
* Default implementation of getDependencyGraph uses the helper function
|
|
297
|
+
* {@link getDependencyGraph} in space-helpers.mts.
|
|
298
|
+
*
|
|
299
|
+
* Override this in subclasses for optimized behavior (e.g. Postgres).
|
|
300
|
+
*/
|
|
301
|
+
protected async getDependencyGraphImpl(arg: TOptionsIbGib): Promise<TResultIbGib | undefined> {
|
|
302
|
+
const lc = `${this.lc}[${this.getDependencyGraphImpl.name}]`;
|
|
303
|
+
try {
|
|
304
|
+
if (logalot) { console.log(`${lc} starting... (I: 0e5fe807a0169224781f6c2833f34826)`); }
|
|
305
|
+
if (!arg.data) { throw new Error(`(UNEXPECTED) arg.data falsy? (E: 45eba816295a97a0e55f981861a03f26)`); }
|
|
306
|
+
if ((arg.data.ibGibAddrs ?? []).length === 0) {
|
|
307
|
+
throw new Error(`arg.data.ibGibAddrs is falsy/empty (E: 70adc939c7b80c9938d8fa18fd7c5826)`);
|
|
308
|
+
}
|
|
309
|
+
const opts: GetGraphOptions = {
|
|
310
|
+
space: this,
|
|
311
|
+
ibGibAddrs: arg.data.ibGibAddrs!,
|
|
312
|
+
live: (arg.data as any).live || true,
|
|
313
|
+
};
|
|
314
|
+
const graph = await getDependencyGraph(opts);
|
|
315
|
+
const ibGibs = Object.values(graph) as TIbGib[];
|
|
316
|
+
const resultData: GetDependencyGraphResultData = {
|
|
317
|
+
optsAddr: getIbGibAddr({ ibGib: arg }),
|
|
318
|
+
count: ibGibs.length,
|
|
319
|
+
addrs: Object.keys(graph),
|
|
320
|
+
};
|
|
321
|
+
return this.resulty({
|
|
322
|
+
resultData: resultData as any as TResultData,
|
|
323
|
+
ibGibs,
|
|
324
|
+
});
|
|
325
|
+
} catch (error) {
|
|
326
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
327
|
+
throw error;
|
|
328
|
+
} finally {
|
|
329
|
+
if (logalot) { console.log(`${lc} complete.`); }
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
283
333
|
/**
|
|
284
334
|
* Centralized location for general argument validation for a given witness.
|
|
285
335
|
*
|
|
@@ -362,7 +412,7 @@ export abstract class SpaceBase_V1<
|
|
|
362
412
|
}
|
|
363
413
|
return errors;
|
|
364
414
|
} catch (error) {
|
|
365
|
-
console.error(`${lc} ${error
|
|
415
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
366
416
|
throw error;
|
|
367
417
|
} finally {
|
|
368
418
|
if (errors?.length > 0) { console.error(`${lc} errors: ${errors}`); }
|
|
@@ -25,7 +25,8 @@ import { TagData_V1, TagIbGib_V1 } from '../../common/tag/tag-types.mjs';
|
|
|
25
25
|
import { BOOTSTRAP_DATA_DEFAULT_SPACE_ID_KEY, BOOTSTRAP_DATA_KNOWN_SPACE_IDS_KEY, BOOTSTRAP_IBGIB_ADDR } from './bootstrap/bootstrap-constants.mjs';
|
|
26
26
|
import {
|
|
27
27
|
SpaceLockScope, IbGibSpaceLockIbGib, SpaceId, IbGibSpaceLockOptions, TxId,
|
|
28
|
-
IbGibSpaceResultIbGib, IbGibSpaceResultData, IbGibSpaceResultRel8ns, SpaceType, SpaceSubtype, VALID_SPACE_TYPES, VALID_SPACE_SUBTYPES, IbGibSpaceData
|
|
28
|
+
IbGibSpaceResultIbGib, IbGibSpaceResultData, IbGibSpaceResultRel8ns, SpaceType, SpaceSubtype, VALID_SPACE_TYPES, VALID_SPACE_SUBTYPES, IbGibSpaceData,
|
|
29
|
+
IbGibSpaceOptionsCmd, IbGibSpaceOptionsCmdModifier,
|
|
29
30
|
} from './space-types.mjs';
|
|
30
31
|
import { getAppIb, } from '../app/app-helper.mjs';
|
|
31
32
|
import { AppData_V1, AppIbGib_V1 } from '../app/app-types.mjs';
|
|
@@ -3430,3 +3431,51 @@ export function spaceNameIsValid(name: string): boolean {
|
|
|
3430
3431
|
return false;
|
|
3431
3432
|
}
|
|
3432
3433
|
}
|
|
3434
|
+
|
|
3435
|
+
/**
|
|
3436
|
+
* wrapper for getting dependency graph from a space.
|
|
3437
|
+
*
|
|
3438
|
+
* NOTE: This calls the witness space with the command. This is NOT the
|
|
3439
|
+
* same as the logic helper in graph-helper.mts which performs the graph
|
|
3440
|
+
* traversal logic potentially in-memory or naively.
|
|
3441
|
+
*/
|
|
3442
|
+
export async function getDependencyGraph({
|
|
3443
|
+
space,
|
|
3444
|
+
ibGibAddrs,
|
|
3445
|
+
live,
|
|
3446
|
+
}: {
|
|
3447
|
+
space: IbGibSpaceAny,
|
|
3448
|
+
ibGibAddrs: IbGibAddr[],
|
|
3449
|
+
live?: boolean,
|
|
3450
|
+
}): Promise<{ [addr: string]: IbGib_V1 } | null> {
|
|
3451
|
+
const lc = `[${getDependencyGraph.name}]`;
|
|
3452
|
+
try {
|
|
3453
|
+
if (!space) { throw new Error(`space required (E: 8f2441c099084898953153549725f778)`); }
|
|
3454
|
+
if ((ibGibAddrs ?? []).length === 0) { throw new Error(`ibGibAddrs required (E: 9c3b8853609841808093153927649526)`); }
|
|
3455
|
+
|
|
3456
|
+
const argData: any = {
|
|
3457
|
+
cmd: IbGibSpaceOptionsCmd.get,
|
|
3458
|
+
cmdModifiers: [IbGibSpaceOptionsCmdModifier.dependencyGraph],
|
|
3459
|
+
ibGibAddrs,
|
|
3460
|
+
live,
|
|
3461
|
+
};
|
|
3462
|
+
const arg = await space.argy({ argData });
|
|
3463
|
+
|
|
3464
|
+
const result = await space.witness(arg);
|
|
3465
|
+
if (result?.data?.success) {
|
|
3466
|
+
const graph: { [addr: string]: IbGib_V1 } = {};
|
|
3467
|
+
if (result.ibGibs) {
|
|
3468
|
+
for (const ibGib of result.ibGibs) {
|
|
3469
|
+
const addr = getIbGibAddr({ ibGib });
|
|
3470
|
+
graph[addr] = ibGib;
|
|
3471
|
+
}
|
|
3472
|
+
}
|
|
3473
|
+
return graph;
|
|
3474
|
+
} else {
|
|
3475
|
+
return null;
|
|
3476
|
+
}
|
|
3477
|
+
} catch (error) {
|
|
3478
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
3479
|
+
throw error;
|
|
3480
|
+
}
|
|
3481
|
+
}
|
|
@@ -29,7 +29,8 @@ import { Factory_V1 as factory } from '@ibgib/ts-gib/dist/V1/factory.mjs';
|
|
|
29
29
|
|
|
30
30
|
import {
|
|
31
31
|
deleteFromSpace, getFromSpace, getLatestAddrs, parseSpaceIb,
|
|
32
|
-
persistTransformResult, putInSpace, registerNewIbGib
|
|
32
|
+
persistTransformResult, putInSpace, registerNewIbGib,
|
|
33
|
+
getDependencyGraph,
|
|
33
34
|
} from "./space-helper.mjs";
|
|
34
35
|
import { IbGibSpaceAny } from "./space-base-v1.mjs";
|
|
35
36
|
import { IbGibTimelineUpdateInfo } from '../../common/other/other-types.mjs';
|
|
@@ -226,7 +226,7 @@ export const IbGibSpaceOptionsCmd = {
|
|
|
226
226
|
* Flags to affect the command's interpretation.
|
|
227
227
|
*/
|
|
228
228
|
export type IbGibSpaceOptionsCmdModifier =
|
|
229
|
-
'can' | 'addrs' | 'latest' | 'watch' | 'unwatch' | 'tjps';
|
|
229
|
+
'can' | 'addrs' | 'latest' | 'watch' | 'unwatch' | 'tjps' | 'dependency-graph';
|
|
230
230
|
/**
|
|
231
231
|
* Flags to affect the command's interpretation.
|
|
232
232
|
*/
|
|
@@ -266,6 +266,10 @@ export const IbGibSpaceOptionsCmdModifier = {
|
|
|
266
266
|
* Get the tjp ibgibs/addrs for given ibgib(s)
|
|
267
267
|
*/
|
|
268
268
|
tjps: 'tjps' as IbGibSpaceOptionsCmdModifier,
|
|
269
|
+
/**
|
|
270
|
+
* Modifies the get command to retrieve a dependency graph.
|
|
271
|
+
*/
|
|
272
|
+
dependencyGraph: 'dependency-graph' as IbGibSpaceOptionsCmdModifier,
|
|
269
273
|
}
|
|
270
274
|
|
|
271
275
|
/** Information for interacting with spaces. */
|
|
@@ -485,3 +489,11 @@ export interface IbGibSpaceLockIbGib
|
|
|
485
489
|
* Marker type to indicate that a string is meant to be a transmission id.
|
|
486
490
|
*/
|
|
487
491
|
export type TxId = 'string';
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* we have a getDependencyGraph wrapper in the space base. This is the type of
|
|
495
|
+
* that's result data.
|
|
496
|
+
*/
|
|
497
|
+
export interface GetDependencyGraphResultData extends IbGibSpaceResultData {
|
|
498
|
+
count: number;
|
|
499
|
+
}
|
package/tmp.md
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
OK
|
|
1
|
+
OK nice sketch! We need to drastically wrangle in the complexity to nice methods, like we have with `createSyncMsgStone`, `evolveSyncSagaIbGib`, etc.
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
```
|
|
6
|
-
/**
|
|
7
|
-
* Map of addr -> ibGib
|
|
8
|
-
*/
|
|
9
|
-
export type FlatIbGibGraph = { [addr: string]: IbGib_V1 };
|
|
10
|
-
```
|
|
3
|
+
Also, we need to get this to a finite state machine-like execution. The `sync` method should do the initial setup regarding the saga info object, the temp space, and the session identity. But the analyzeTimelines is specific to the init frame and should be refactored into the FSM method specific to init. So we need to separate the saga meta-setup and the saga initial frame.
|
|
11
4
|
|
|
5
|
+
Also, I don't think we can just naively call `updates$.complete()` like that at the end. This will end up being a recursive or do/while loop with msg/response with the peer.
|