@ibgib/core-gib 0.0.4
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/.vscode/core-gib-snippets.code-snippets +189 -0
- package/.vscode/launch.json +24 -0
- package/.vscode/settings.json +56 -0
- package/.vscode/tasks.json +37 -0
- package/CHANGELOG.md +11 -0
- package/README.md +215 -0
- package/dist/common/aws-constants.d.mts +7 -0
- package/dist/common/aws-constants.d.mts.map +1 -0
- package/dist/common/aws-constants.mjs +7 -0
- package/dist/common/aws-constants.mjs.map +1 -0
- package/dist/common/bin/bin-types.d.mts +17 -0
- package/dist/common/bin/bin-types.d.mts.map +1 -0
- package/dist/common/bin/bin-types.mjs +3 -0
- package/dist/common/bin/bin-types.mjs.map +1 -0
- package/dist/common/cache/cache-types.d.mts +57 -0
- package/dist/common/cache/cache-types.d.mts.map +1 -0
- package/dist/common/cache/cache-types.mjs +2 -0
- package/dist/common/cache/cache-types.mjs.map +1 -0
- package/dist/common/comment/comment-constants.d.mts +11 -0
- package/dist/common/comment/comment-constants.d.mts.map +1 -0
- package/dist/common/comment/comment-constants.mjs +11 -0
- package/dist/common/comment/comment-constants.mjs.map +1 -0
- package/dist/common/comment/comment-helper.d.mts +59 -0
- package/dist/common/comment/comment-helper.d.mts.map +1 -0
- package/dist/common/comment/comment-helper.mjs +173 -0
- package/dist/common/comment/comment-helper.mjs.map +1 -0
- package/dist/common/comment/comment-types.d.mts +16 -0
- package/dist/common/comment/comment-types.d.mts.map +1 -0
- package/dist/common/comment/comment-types.mjs +2 -0
- package/dist/common/comment/comment-types.mjs.map +1 -0
- package/dist/common/display/display-helper.d.mts +19 -0
- package/dist/common/display/display-helper.d.mts.map +1 -0
- package/dist/common/display/display-helper.mjs +68 -0
- package/dist/common/display/display-helper.mjs.map +1 -0
- package/dist/common/display/display-types.d.mts +97 -0
- package/dist/common/display/display-types.d.mts.map +1 -0
- package/dist/common/display/display-types.mjs +37 -0
- package/dist/common/display/display-types.mjs.map +1 -0
- package/dist/common/encrypt/encrypt-constants.d.mts +27 -0
- package/dist/common/encrypt/encrypt-constants.d.mts.map +1 -0
- package/dist/common/encrypt/encrypt-constants.mjs +27 -0
- package/dist/common/encrypt/encrypt-constants.mjs.map +1 -0
- package/dist/common/encrypt/encrypt-types.d.mts +116 -0
- package/dist/common/encrypt/encrypt-types.d.mts.map +1 -0
- package/dist/common/encrypt/encrypt-types.mjs +9 -0
- package/dist/common/encrypt/encrypt-types.mjs.map +1 -0
- package/dist/common/error/error-constants.d.mts +9 -0
- package/dist/common/error/error-constants.d.mts.map +1 -0
- package/dist/common/error/error-constants.mjs +9 -0
- package/dist/common/error/error-constants.mjs.map +1 -0
- package/dist/common/error/error-helper.d.mts +43 -0
- package/dist/common/error/error-helper.d.mts.map +1 -0
- package/dist/common/error/error-helper.mjs +167 -0
- package/dist/common/error/error-helper.mjs.map +1 -0
- package/dist/common/error/error-types.d.mts +58 -0
- package/dist/common/error/error-types.d.mts.map +1 -0
- package/dist/common/error/error-types.mjs +2 -0
- package/dist/common/error/error-types.mjs.map +1 -0
- package/dist/common/form/form-helper.d.mts +97 -0
- package/dist/common/form/form-helper.d.mts.map +1 -0
- package/dist/common/form/form-helper.mjs +185 -0
- package/dist/common/form/form-helper.mjs.map +1 -0
- package/dist/common/form/form-items.d.mts +229 -0
- package/dist/common/form/form-items.d.mts.map +1 -0
- package/dist/common/form/form-items.mjs +63 -0
- package/dist/common/form/form-items.mjs.map +1 -0
- package/dist/common/import-export/import-export-types.d.mts +18 -0
- package/dist/common/import-export/import-export-types.d.mts.map +1 -0
- package/dist/common/import-export/import-export-types.mjs +2 -0
- package/dist/common/import-export/import-export-types.mjs.map +1 -0
- package/dist/common/legacy/legacy-types.d.mts +2 -0
- package/dist/common/legacy/legacy-types.d.mts.map +1 -0
- package/dist/common/legacy/legacy-types.mjs +2 -0
- package/dist/common/legacy/legacy-types.mjs.map +1 -0
- package/dist/common/link/link-constants.d.mts +2 -0
- package/dist/common/link/link-constants.d.mts.map +1 -0
- package/dist/common/link/link-constants.mjs +2 -0
- package/dist/common/link/link-constants.mjs.map +1 -0
- package/dist/common/link/link-helper.d.mts +37 -0
- package/dist/common/link/link-helper.d.mts.map +1 -0
- package/dist/common/link/link-helper.mjs +143 -0
- package/dist/common/link/link-helper.mjs.map +1 -0
- package/dist/common/link/link-types.d.mts +14 -0
- package/dist/common/link/link-types.d.mts.map +1 -0
- package/dist/common/link/link-types.mjs +2 -0
- package/dist/common/link/link-types.mjs.map +1 -0
- package/dist/common/other/graph-helper.d.mts +166 -0
- package/dist/common/other/graph-helper.d.mts.map +1 -0
- package/dist/common/other/graph-helper.mjs +710 -0
- package/dist/common/other/graph-helper.mjs.map +1 -0
- package/dist/common/other/ibgib-helper.d.mts +245 -0
- package/dist/common/other/ibgib-helper.d.mts.map +1 -0
- package/dist/common/other/ibgib-helper.mjs +641 -0
- package/dist/common/other/ibgib-helper.mjs.map +1 -0
- package/dist/common/other/other-constants.d.mts +53 -0
- package/dist/common/other/other-constants.d.mts.map +1 -0
- package/dist/common/other/other-constants.mjs +67 -0
- package/dist/common/other/other-constants.mjs.map +1 -0
- package/dist/common/other/other-types.d.mts +166 -0
- package/dist/common/other/other-types.d.mts.map +1 -0
- package/dist/common/other/other-types.mjs +30 -0
- package/dist/common/other/other-types.mjs.map +1 -0
- package/dist/common/other/svg-constants.d.mts +2 -0
- package/dist/common/other/svg-constants.d.mts.map +1 -0
- package/dist/common/other/svg-constants.mjs +2 -0
- package/dist/common/other/svg-constants.mjs.map +1 -0
- package/dist/common/other/svg-helper.d.mts +54 -0
- package/dist/common/other/svg-helper.d.mts.map +1 -0
- package/dist/common/other/svg-helper.mjs +170 -0
- package/dist/common/other/svg-helper.mjs.map +1 -0
- package/dist/common/pic/pic-constants.d.mts +13 -0
- package/dist/common/pic/pic-constants.d.mts.map +1 -0
- package/dist/common/pic/pic-constants.mjs +13 -0
- package/dist/common/pic/pic-constants.mjs.map +1 -0
- package/dist/common/pic/pic-helper.d.mts +70 -0
- package/dist/common/pic/pic-helper.d.mts.map +1 -0
- package/dist/common/pic/pic-helper.mjs +235 -0
- package/dist/common/pic/pic-helper.mjs.map +1 -0
- package/dist/common/pic/pic-types.d.mts +23 -0
- package/dist/common/pic/pic-types.d.mts.map +1 -0
- package/dist/common/pic/pic-types.mjs +2 -0
- package/dist/common/pic/pic-types.mjs.map +1 -0
- package/dist/common/root/root-constants.d.mts +40 -0
- package/dist/common/root/root-constants.d.mts.map +1 -0
- package/dist/common/root/root-constants.mjs +40 -0
- package/dist/common/root/root-constants.mjs.map +1 -0
- package/dist/common/root/root-types.d.mts +9 -0
- package/dist/common/root/root-types.d.mts.map +1 -0
- package/dist/common/root/root-types.mjs +2 -0
- package/dist/common/root/root-types.mjs.map +1 -0
- package/dist/common/tag/tag-constants.d.mts +21 -0
- package/dist/common/tag/tag-constants.d.mts.map +1 -0
- package/dist/common/tag/tag-constants.mjs +28 -0
- package/dist/common/tag/tag-constants.mjs.map +1 -0
- package/dist/common/tag/tag-types.d.mts +14 -0
- package/dist/common/tag/tag-types.d.mts.map +1 -0
- package/dist/common/tag/tag-types.mjs +2 -0
- package/dist/common/tag/tag-types.mjs.map +1 -0
- package/dist/core-constants.d.mts +89 -0
- package/dist/core-constants.d.mts.map +1 -0
- package/dist/core-constants.mjs +484 -0
- package/dist/core-constants.mjs.map +1 -0
- package/dist/core-helper.d.mts +6 -0
- package/dist/core-helper.d.mts.map +1 -0
- package/dist/core-helper.mjs +28 -0
- package/dist/core-helper.mjs.map +1 -0
- package/dist/core-types.d.mts +520 -0
- package/dist/core-types.d.mts.map +1 -0
- package/dist/core-types.mjs +2 -0
- package/dist/core-types.mjs.map +1 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +3 -0
- package/dist/index.mjs.map +1 -0
- package/dist/witness/app/app-base-v1.d.mts +130 -0
- package/dist/witness/app/app-base-v1.d.mts.map +1 -0
- package/dist/witness/app/app-base-v1.mjs +462 -0
- package/dist/witness/app/app-base-v1.mjs.map +1 -0
- package/dist/witness/app/app-constants.d.mts +10 -0
- package/dist/witness/app/app-constants.d.mts.map +1 -0
- package/dist/witness/app/app-constants.mjs +13 -0
- package/dist/witness/app/app-constants.mjs.map +1 -0
- package/dist/witness/app/app-helper.d.mts +85 -0
- package/dist/witness/app/app-helper.d.mts.map +1 -0
- package/dist/witness/app/app-helper.mjs +258 -0
- package/dist/witness/app/app-helper.mjs.map +1 -0
- package/dist/witness/app/app-types.d.mts +211 -0
- package/dist/witness/app/app-types.d.mts.map +1 -0
- package/dist/witness/app/app-types.mjs +49 -0
- package/dist/witness/app/app-types.mjs.map +1 -0
- package/dist/witness/app/chat-app/chat-app-types.d.mts +18 -0
- package/dist/witness/app/chat-app/chat-app-types.d.mts.map +1 -0
- package/dist/witness/app/chat-app/chat-app-types.mjs +25 -0
- package/dist/witness/app/chat-app/chat-app-types.mjs.map +1 -0
- package/dist/witness/app/flash-app/flash-app-types.d.mts +16 -0
- package/dist/witness/app/flash-app/flash-app-types.d.mts.map +1 -0
- package/dist/witness/app/flash-app/flash-app-types.mjs +23 -0
- package/dist/witness/app/flash-app/flash-app-types.mjs.map +1 -0
- package/dist/witness/app/raw-app/raw-app-types.d.mts +18 -0
- package/dist/witness/app/raw-app/raw-app-types.d.mts.map +1 -0
- package/dist/witness/app/raw-app/raw-app-types.mjs +25 -0
- package/dist/witness/app/raw-app/raw-app-types.mjs.map +1 -0
- package/dist/witness/app/todo-app/todo-app-types.d.ts +33 -0
- package/dist/witness/app/todo-app/todo-app-types.d.ts.map +1 -0
- package/dist/witness/app/todo-app/todo-app-types.js +31 -0
- package/dist/witness/app/todo-app/todo-app-types.js.map +1 -0
- package/dist/witness/robbot/robbot-base-v1.d.ts +432 -0
- package/dist/witness/robbot/robbot-base-v1.d.ts.map +1 -0
- package/dist/witness/robbot/robbot-base-v1.js +1407 -0
- package/dist/witness/robbot/robbot-base-v1.js.map +1 -0
- package/dist/witness/robbot/robbot-constants.d.mts +24 -0
- package/dist/witness/robbot/robbot-constants.d.mts.map +1 -0
- package/dist/witness/robbot/robbot-constants.mjs +24 -0
- package/dist/witness/robbot/robbot-constants.mjs.map +1 -0
- package/dist/witness/robbot/robbot-helper.d.mts +152 -0
- package/dist/witness/robbot/robbot-helper.d.mts.map +1 -0
- package/dist/witness/robbot/robbot-helper.mjs +609 -0
- package/dist/witness/robbot/robbot-helper.mjs.map +1 -0
- package/dist/witness/robbot/robbot-types.d.mts +539 -0
- package/dist/witness/robbot/robbot-types.d.mts.map +1 -0
- package/dist/witness/robbot/robbot-types.mjs +294 -0
- package/dist/witness/robbot/robbot-types.mjs.map +1 -0
- package/dist/witness/space/bootstrap/bootstrap-constants.d.mts +14 -0
- package/dist/witness/space/bootstrap/bootstrap-constants.d.mts.map +1 -0
- package/dist/witness/space/bootstrap/bootstrap-constants.mjs +15 -0
- package/dist/witness/space/bootstrap/bootstrap-constants.mjs.map +1 -0
- package/dist/witness/space/inner-space-v1.d.ts +63 -0
- package/dist/witness/space/inner-space-v1.d.ts.map +1 -0
- package/dist/witness/space/inner-space-v1.js +356 -0
- package/dist/witness/space/inner-space-v1.js.map +1 -0
- package/dist/witness/space/outer-space/outer-space-constants.d.mts +2 -0
- package/dist/witness/space/outer-space/outer-space-constants.d.mts.map +1 -0
- package/dist/witness/space/outer-space/outer-space-constants.mjs +2 -0
- package/dist/witness/space/outer-space/outer-space-constants.mjs.map +1 -0
- package/dist/witness/space/outer-space/outer-space-helper.d.mts +28 -0
- package/dist/witness/space/outer-space/outer-space-helper.d.mts.map +1 -0
- package/dist/witness/space/outer-space/outer-space-helper.mjs +87 -0
- package/dist/witness/space/outer-space/outer-space-helper.mjs.map +1 -0
- package/dist/witness/space/outer-space/outer-space-types.d.mts +548 -0
- package/dist/witness/space/outer-space/outer-space-types.d.mts.map +1 -0
- package/dist/witness/space/outer-space/outer-space-types.mjs +118 -0
- package/dist/witness/space/outer-space/outer-space-types.mjs.map +1 -0
- package/dist/witness/space/space-base-v1.d.mts +147 -0
- package/dist/witness/space/space-base-v1.d.mts.map +1 -0
- package/dist/witness/space/space-base-v1.mjs +350 -0
- package/dist/witness/space/space-base-v1.mjs.map +1 -0
- package/dist/witness/space/space-constants.d.mts +181 -0
- package/dist/witness/space/space-constants.d.mts.map +1 -0
- package/dist/witness/space/space-constants.mjs +192 -0
- package/dist/witness/space/space-constants.mjs.map +1 -0
- package/dist/witness/space/space-helper.d.mts +666 -0
- package/dist/witness/space/space-helper.d.mts.map +1 -0
- package/dist/witness/space/space-helper.mjs +2830 -0
- package/dist/witness/space/space-helper.mjs.map +1 -0
- package/dist/witness/space/space-types.d.mts +422 -0
- package/dist/witness/space/space-types.d.mts.map +1 -0
- package/dist/witness/space/space-types.mjs +52 -0
- package/dist/witness/space/space-types.mjs.map +1 -0
- package/dist/witness/witness-base-v1.d.ts +144 -0
- package/dist/witness/witness-base-v1.d.ts.map +1 -0
- package/dist/witness/witness-base-v1.js +300 -0
- package/dist/witness/witness-base-v1.js.map +1 -0
- package/dist/witness/witness-constants.d.mts +3 -0
- package/dist/witness/witness-constants.d.mts.map +1 -0
- package/dist/witness/witness-constants.mjs +3 -0
- package/dist/witness/witness-constants.mjs.map +1 -0
- package/dist/witness/witness-form-builder.d.mts +45 -0
- package/dist/witness/witness-form-builder.d.mts.map +1 -0
- package/dist/witness/witness-form-builder.mjs +95 -0
- package/dist/witness/witness-form-builder.mjs.map +1 -0
- package/dist/witness/witness-helper.d.mts +89 -0
- package/dist/witness/witness-helper.d.mts.map +1 -0
- package/dist/witness/witness-helper.mjs +229 -0
- package/dist/witness/witness-helper.mjs.map +1 -0
- package/dist/witness/witness-types.d.mts +211 -0
- package/dist/witness/witness-types.d.mts.map +1 -0
- package/dist/witness/witness-types.mjs +2 -0
- package/dist/witness/witness-types.mjs.map +1 -0
- package/jasmine-browser.json +18 -0
- package/jasmine.json +6 -0
- package/package.json +67 -0
- package/src/assumptions.spec.mts +45 -0
- package/src/common/aws-constants.mts +5 -0
- package/src/common/bin/bin-types.mts +17 -0
- package/src/common/cache/cache-types.mts +53 -0
- package/src/common/comment/comment-constants.mts +10 -0
- package/src/common/comment/comment-helper.mts +211 -0
- package/src/common/comment/comment-types.mts +19 -0
- package/src/common/display/display-helper.mts +88 -0
- package/src/common/display/display-types.mts +108 -0
- package/src/common/encrypt/encrypt-constants.mts +28 -0
- package/src/common/encrypt/encrypt-types.mts +130 -0
- package/src/common/error/error-constants.mts +8 -0
- package/src/common/error/error-helper.mts +155 -0
- package/src/common/error/error-types.mts +62 -0
- package/src/common/form/form-helper.mts +253 -0
- package/src/common/form/form-items.mts +236 -0
- package/src/common/import-export/import-export-types.mts +18 -0
- package/src/common/legacy/about-legacy.md +0 -0
- package/src/common/legacy/legacy-types.mts +0 -0
- package/src/common/link/link-constants.mts +1 -0
- package/src/common/link/link-helper.mts +155 -0
- package/src/common/link/link-types.mts +16 -0
- package/src/common/other/graph-helper.mts +853 -0
- package/src/common/other/ibgib-helper.mts +671 -0
- package/src/common/other/other-constants.mts +76 -0
- package/src/common/other/other-types.mts +186 -0
- package/src/common/other/svg-constants.mts +1 -0
- package/src/common/other/svg-helper.mts +238 -0
- package/src/common/pic/pic-constants.mts +13 -0
- package/src/common/pic/pic-helper.mts +295 -0
- package/src/common/pic/pic-types.mts +29 -0
- package/src/common/root/root-constants.mts +41 -0
- package/src/common/root/root-types.mts +8 -0
- package/src/common/tag/tag-constants.mts +34 -0
- package/src/common/tag/tag-types.mts +19 -0
- package/src/core-constants.mts +506 -0
- package/src/core-helper.mts +33 -0
- package/src/core-types.mts +519 -0
- package/src/helper.spec.mts +64 -0
- package/src/index.mts +1 -0
- package/src/witness/app/app-base-v1.mts +584 -0
- package/src/witness/app/app-constants.mts +16 -0
- package/src/witness/app/app-helper.mts +322 -0
- package/src/witness/app/app-types.mts +252 -0
- package/src/witness/app/chat-app/chat-app-types.mts +40 -0
- package/src/witness/app/flash-app/flash-app-types.mts +38 -0
- package/src/witness/app/raw-app/raw-app-types.mts +40 -0
- package/src/witness/app/todo-app/todo-app-types.ts +59 -0
- package/src/witness/robbot/robbot-base-v1.ts +1531 -0
- package/src/witness/robbot/robbot-constants.mts +25 -0
- package/src/witness/robbot/robbot-helper.mts +676 -0
- package/src/witness/robbot/robbot-helper.spec.mts +135 -0
- package/src/witness/robbot/robbot-types.mts +797 -0
- package/src/witness/space/bootstrap/bootstrap-constants.mts +15 -0
- package/src/witness/space/inner-space-v1.ts +372 -0
- package/src/witness/space/outer-space/outer-space-constants.mts +1 -0
- package/src/witness/space/outer-space/outer-space-helper.mts +91 -0
- package/src/witness/space/outer-space/outer-space-types.mts +627 -0
- package/src/witness/space/space-base-v1.mts +414 -0
- package/src/witness/space/space-constants.mts +208 -0
- package/src/witness/space/space-helper.mts +3242 -0
- package/src/witness/space/space-types.mts +476 -0
- package/src/witness/witness-base-v1.ts +325 -0
- package/src/witness/witness-constants.mts +2 -0
- package/src/witness/witness-form-builder.mts +128 -0
- package/src/witness/witness-helper.mts +256 -0
- package/src/witness/witness-types.mts +249 -0
- package/tsconfig.json +15 -0
- package/tsconfig.test.json +10 -0
|
@@ -0,0 +1,853 @@
|
|
|
1
|
+
import { IbGibAddr, TjpIbGibAddr, getIbAndGib, getIbGibAddr, } from '@ibgib/ts-gib';
|
|
2
|
+
import {
|
|
3
|
+
GIB, IbGib_V1,
|
|
4
|
+
isPrimitive,
|
|
5
|
+
IBGIB_DELIMITER,
|
|
6
|
+
} from '@ibgib/ts-gib/dist/V1/index.mjs';
|
|
7
|
+
|
|
8
|
+
import { GLOBAL_LOG_A_LOT } from '../../core-constants.mjs';
|
|
9
|
+
import { getFromSpace, getLatestAddrs } from '../../witness/space/space-helper.mjs';
|
|
10
|
+
import { getTimelinesGroupedByTjp } from './ibgib-helper.mjs';
|
|
11
|
+
import { validateIbGibAddr } from '@ibgib/ts-gib/dist/V1/validate-helper.mjs';
|
|
12
|
+
import { IbGibSpaceAny } from '../../witness/space/space-base-v1.mjs';
|
|
13
|
+
import { delay, pretty, unique } from '@ibgib/helper-gib';
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
const logalot = GLOBAL_LOG_A_LOT || false;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Options when getting dependency graph for ibGib(s).
|
|
20
|
+
*
|
|
21
|
+
* Note that this is used both in local and outer space contexts.
|
|
22
|
+
* When you want to default to the local user space in the local context,
|
|
23
|
+
* i.e. in `IbgibsService` atow, pass in `null` for {@link space}.
|
|
24
|
+
*/
|
|
25
|
+
export interface GetGraphOptions {
|
|
26
|
+
/**
|
|
27
|
+
* source ibGib to grab dependencies of.
|
|
28
|
+
*
|
|
29
|
+
* caller can pass in `ibGib` or `ibGibs` or `ibGibAddr` or `ibGibAddrs`.
|
|
30
|
+
*/
|
|
31
|
+
ibGib?: IbGib_V1,
|
|
32
|
+
/**
|
|
33
|
+
* source ibGibs to grab dependencies of.
|
|
34
|
+
*
|
|
35
|
+
* caller can pass in `ibGib` or `ibGibs` or `ibGibAddr` or `ibGibAddrs`.
|
|
36
|
+
*/
|
|
37
|
+
ibGibs?: IbGib_V1[],
|
|
38
|
+
/**
|
|
39
|
+
* source ibGib address to grab dependencies of.
|
|
40
|
+
*
|
|
41
|
+
* caller can pass in `ibGib` or `ibGibs` or `ibGibAddr` or `ibGibAddrs`.
|
|
42
|
+
*/
|
|
43
|
+
ibGibAddr?: IbGibAddr,
|
|
44
|
+
/**
|
|
45
|
+
* source ibGib addresses to grab dependencies of.
|
|
46
|
+
*
|
|
47
|
+
* caller can pass in `ibGib` or `ibGibs` or `ibGibAddr` or `ibGibAddrs`.
|
|
48
|
+
*/
|
|
49
|
+
ibGibAddrs?: IbGibAddr[],
|
|
50
|
+
/**
|
|
51
|
+
* If true, for each timeline in each "frozen" ibgib graph we will get the
|
|
52
|
+
* latest address in the timeline and recheck rel8d ibgibs for newly
|
|
53
|
+
* added timeline branches.
|
|
54
|
+
*
|
|
55
|
+
* If false, this will only look in the past for each rel8d ibgib.
|
|
56
|
+
*
|
|
57
|
+
* ## notes
|
|
58
|
+
*
|
|
59
|
+
* Say you have a source ibgib with a comment "child" (relative to our
|
|
60
|
+
* source ibgib). Now say you add an ibgib to that child comment. The rel8d
|
|
61
|
+
* addr in the source ibgib will still point to the child comment's initial
|
|
62
|
+
* addr - before it was changed by adding its own "child" ("grandchild" to
|
|
63
|
+
* the source). So if you get a live dependency graph on the parent, it will
|
|
64
|
+
* come across the child's timeline and get the latest for that timeline
|
|
65
|
+
* (and associated ibgibs like the child's dna transforms that add the
|
|
66
|
+
* grandchild). This will include the grandchild. If it's not a live graph,
|
|
67
|
+
* then the parent will only have the child and will exclude the grandchild.
|
|
68
|
+
*/
|
|
69
|
+
live?: boolean,
|
|
70
|
+
/**
|
|
71
|
+
* object that will be populated through recursive calls to this function.
|
|
72
|
+
*
|
|
73
|
+
* First caller of this function should not provide this and I'm not atow
|
|
74
|
+
* coding a separate implementation function to ensure this.
|
|
75
|
+
*
|
|
76
|
+
* @see {@link skipAddrs}
|
|
77
|
+
*/
|
|
78
|
+
gotten?: { [addr: string]: IbGib_V1 },
|
|
79
|
+
/**
|
|
80
|
+
* used when doing {@link live} dependency graph gets. Same use as
|
|
81
|
+
* {@link gotten}, but with regards to timelines.
|
|
82
|
+
*/
|
|
83
|
+
tjpAddrsAlreadyAnalyzed?: TjpIbGibAddr[],
|
|
84
|
+
/**
|
|
85
|
+
* List of ibgib addresses to skip not retrive in the dependency graph.
|
|
86
|
+
*
|
|
87
|
+
* This will also skip any ibgib addresses that would have occurred in the
|
|
88
|
+
* past of these ibgibs, as when skipping an ibgib, you are also skipping
|
|
89
|
+
* its dependencies implicitly as well (unless those others are related via
|
|
90
|
+
* another ibgib that is not skipped of course).
|
|
91
|
+
*
|
|
92
|
+
* ## driving use case
|
|
93
|
+
*
|
|
94
|
+
* We don't want to get ibgibs that we already have, and this is cleaner
|
|
95
|
+
* than pre-populating the `gotten` parameter for double-duty. That property
|
|
96
|
+
* should be strictly used within this call recursively.
|
|
97
|
+
*
|
|
98
|
+
* @see {@link gotten}
|
|
99
|
+
*/
|
|
100
|
+
skipAddrs?: IbGibAddr[],
|
|
101
|
+
/**
|
|
102
|
+
* Skip these particular rel8n names.
|
|
103
|
+
*
|
|
104
|
+
* ## driving intent
|
|
105
|
+
*
|
|
106
|
+
* I'm adding this to be able to skip getting dna ibgibs.
|
|
107
|
+
*
|
|
108
|
+
* ## see also
|
|
109
|
+
*
|
|
110
|
+
* @see {@link onlyRel8nNames} for whitelist of rel8n names for traversal
|
|
111
|
+
*/
|
|
112
|
+
skipRel8nNames?: string[],
|
|
113
|
+
/**
|
|
114
|
+
* whitelist of rel8nNames to traverse.
|
|
115
|
+
*
|
|
116
|
+
* ## see also
|
|
117
|
+
*
|
|
118
|
+
* @see {@link skipRel8nNames} for a blacklist of rel8n names for traversal
|
|
119
|
+
*/
|
|
120
|
+
onlyRel8nNames?: string[],
|
|
121
|
+
/**
|
|
122
|
+
* If not found when getting dependency graph, do we retry? This is the
|
|
123
|
+
* max number of retries.
|
|
124
|
+
*/
|
|
125
|
+
maxRetries?: number,
|
|
126
|
+
/**
|
|
127
|
+
* If provided and {@link maxRetries} is non-zero, the next retry will be
|
|
128
|
+
* delayed this amount of time if one or more addrs are not found.
|
|
129
|
+
*/
|
|
130
|
+
msBetweenRetries?: number,
|
|
131
|
+
/**
|
|
132
|
+
* Space within which we should be looking for ibGibs.
|
|
133
|
+
*
|
|
134
|
+
* ## NOTE on providing space vs local user space
|
|
135
|
+
*
|
|
136
|
+
* I'm reusing this interface for both generic space function and ibgib service
|
|
137
|
+
* function, which has an implicit default space of the local user space if this
|
|
138
|
+
* is falsy. So just pass in `null` if you are using this with ibgibs service and
|
|
139
|
+
* want it to default to the local user space.
|
|
140
|
+
*/
|
|
141
|
+
space: IbGibSpaceAny | null,
|
|
142
|
+
/**
|
|
143
|
+
* If supplied, will make intermittent calls to console.timeLog using this name.
|
|
144
|
+
*/
|
|
145
|
+
timeLogName?: string,
|
|
146
|
+
/**
|
|
147
|
+
* When getting the live dependency graph, this is used so we don't
|
|
148
|
+
* duplicate work in recursive calls.
|
|
149
|
+
*
|
|
150
|
+
* IOW, in the first run of{@link getGraphProjection_Live}, we call
|
|
151
|
+
* getLatestAddrs which maps some addrs to the latest addrs in the space. So
|
|
152
|
+
* we now have a reference to the latest and if we need to call the function
|
|
153
|
+
* {@link getGraphProjection_Live} recursively, then we can provide this
|
|
154
|
+
* info to reduce unnecessary computation.
|
|
155
|
+
*/
|
|
156
|
+
mapTjpAddrToLatestAddrsInSpace?: { [tjpAddr: string]: IbGibAddr }
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export type GetGraphResult = { [addr: string]: IbGib_V1 };
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
export interface GetGraphProjectionOptions extends GetGraphOptions {
|
|
163
|
+
// /**
|
|
164
|
+
// * max depth away from source ibgibs to traverse
|
|
165
|
+
// */
|
|
166
|
+
// depth?: number;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export interface GetDependencyGraphOptions extends GetGraphProjectionOptions {
|
|
170
|
+
// depth?: undefined;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
*
|
|
175
|
+
* @returns dependency graph, live or non-live depending on {@link GetDependencyGraphOptions}
|
|
176
|
+
*
|
|
177
|
+
* Getting a `live` dependency graph means that we will be looking in the given
|
|
178
|
+
* @see {@link GetDependencyGraphOptions.space} for updates to ibGibs' timelines
|
|
179
|
+
* (those ibGibs that have timelines/tjps). This is more costly computationally
|
|
180
|
+
* in the short-term, but often cheaper in the long-term.
|
|
181
|
+
*/
|
|
182
|
+
export async function getDependencyGraph({
|
|
183
|
+
ibGib, ibGibs, ibGibAddr, ibGibAddrs,
|
|
184
|
+
live,
|
|
185
|
+
gotten, tjpAddrsAlreadyAnalyzed,
|
|
186
|
+
skipAddrs, skipRel8nNames, onlyRel8nNames,
|
|
187
|
+
maxRetries, msBetweenRetries,
|
|
188
|
+
space,
|
|
189
|
+
timeLogName,
|
|
190
|
+
mapTjpAddrToLatestAddrsInSpace,
|
|
191
|
+
}: GetGraphProjectionOptions): Promise<GetGraphResult> {
|
|
192
|
+
const lc = `[${getGraphProjection.name}]`;
|
|
193
|
+
try {
|
|
194
|
+
if (logalot) { console.log(`${lc} starting... (I: c2a4426c22e849611ca0cedabe683a22)`); }
|
|
195
|
+
|
|
196
|
+
const graph = await getGraphProjection({
|
|
197
|
+
ibGib, ibGibs, ibGibAddr, ibGibAddrs,
|
|
198
|
+
live,
|
|
199
|
+
gotten, tjpAddrsAlreadyAnalyzed,
|
|
200
|
+
skipAddrs, skipRel8nNames, onlyRel8nNames,
|
|
201
|
+
maxRetries, msBetweenRetries,
|
|
202
|
+
space,
|
|
203
|
+
timeLogName,
|
|
204
|
+
mapTjpAddrToLatestAddrsInSpace,
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
Object.values(graph).filter(ibGib => ibGib.ib.startsWith('comment ')).forEach(ibGib => { console.table(ibGib); });
|
|
208
|
+
if (logalot) {
|
|
209
|
+
console.log(`${lc} graph size: ${Object.keys(graph).length} (I: c6cb5e7e1e2611d35b9006fac6503d22)`);
|
|
210
|
+
const ibs =
|
|
211
|
+
Object.values(graph).filter(ibGib => ibGib.ib.startsWith('comment ') || ibGib.ib.startsWith('pic '))
|
|
212
|
+
.map(ibGib => ibGib.ib);
|
|
213
|
+
unique(ibs).forEach(ib => console.log(ib));
|
|
214
|
+
}
|
|
215
|
+
return graph;
|
|
216
|
+
} catch (error) {
|
|
217
|
+
console.error(`${lc} ${error.message}`);
|
|
218
|
+
throw error;
|
|
219
|
+
} finally {
|
|
220
|
+
if (logalot) { console.log(`${lc} complete.`); }
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
async function getGraphProjection_initializeOpts({
|
|
225
|
+
ibGib, ibGibs, ibGibAddr, ibGibAddrs,
|
|
226
|
+
live,
|
|
227
|
+
gotten, tjpAddrsAlreadyAnalyzed,
|
|
228
|
+
skipAddrs, skipRel8nNames, onlyRel8nNames,
|
|
229
|
+
maxRetries, msBetweenRetries,
|
|
230
|
+
space,
|
|
231
|
+
timeLogName,
|
|
232
|
+
mapTjpAddrToLatestAddrsInSpace,
|
|
233
|
+
}: GetDependencyGraphOptions): Promise<GetDependencyGraphOptions> {
|
|
234
|
+
const lc = `[${getGraphProjection_initializeOpts.name}]`;
|
|
235
|
+
try {
|
|
236
|
+
if (logalot) { console.log(`${lc} starting... (I: bd6807477f679345df9dddefe0b4e922)`); }
|
|
237
|
+
|
|
238
|
+
if (!space) { throw new Error(`space required. (E: 9f38166ab70340cb919174f8d26af909)`); }
|
|
239
|
+
if (!ibGib && !ibGibAddr && (ibGibs ?? []).length === 0 && (ibGibAddrs ?? []).length === 0) {
|
|
240
|
+
throw new Error(`either ibGib/s or ibGibAddr/s required. (E: b6d08699651f455697f0d05a41edb039)`);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
skipRel8nNames = skipRel8nNames || [];
|
|
244
|
+
// do NOT initialize onlyRel8nNames because we do logic based on falsy value
|
|
245
|
+
skipAddrs = skipAddrs || [];
|
|
246
|
+
gotten = gotten || {};
|
|
247
|
+
tjpAddrsAlreadyAnalyzed = tjpAddrsAlreadyAnalyzed || [];
|
|
248
|
+
|
|
249
|
+
// convert single args (ibGib, ibGibAddr) into the array args, filtering
|
|
250
|
+
// out primitives that we don't want. The `filter` function creates the
|
|
251
|
+
// copy here, so we won't mutate the incoming arrays. (The ibgibs and
|
|
252
|
+
// addrs themselves are immutable).
|
|
253
|
+
ibGibAddrs = (ibGibAddrs ?? [])
|
|
254
|
+
.filter(x => !isPrimitive({ gib: getIbAndGib({ ibGibAddr: x }).gib })) // no primitives
|
|
255
|
+
.filter(x => !skipAddrs!.includes(x));
|
|
256
|
+
ibGibs =
|
|
257
|
+
(ibGibs ?? [])
|
|
258
|
+
.filter(x => !isPrimitive({ ibGib: x })) // no primitives
|
|
259
|
+
.filter(x => !skipAddrs!.includes(getIbGibAddr({ ibGib: x })));
|
|
260
|
+
// if we're passed in a single ibGib, add it to the ibGibs array because
|
|
261
|
+
// we're going to work off of that.
|
|
262
|
+
if (ibGib &&
|
|
263
|
+
!isPrimitive({ ibGib }) &&
|
|
264
|
+
!ibGibs.some(x => x.gib === ibGib.gib) &&
|
|
265
|
+
!skipAddrs.includes(getIbGibAddr({ ibGib }))
|
|
266
|
+
) {
|
|
267
|
+
ibGibs.push(ibGib);
|
|
268
|
+
}
|
|
269
|
+
// if we're passed in a single ibGibAddr, add it to the ibGibAddrs array because
|
|
270
|
+
// we're going to work off of that.
|
|
271
|
+
if (ibGibAddr &&
|
|
272
|
+
!isPrimitive({ gib: getIbAndGib({ ibGibAddr }).gib }) &&
|
|
273
|
+
!ibGibAddrs.includes(ibGibAddr) &&
|
|
274
|
+
!skipAddrs.includes(ibGibAddr)
|
|
275
|
+
) {
|
|
276
|
+
ibGibAddrs.push(ibGibAddr);
|
|
277
|
+
}
|
|
278
|
+
return {
|
|
279
|
+
ibGib, ibGibs, ibGibAddr, ibGibAddrs,
|
|
280
|
+
live,
|
|
281
|
+
gotten, tjpAddrsAlreadyAnalyzed,
|
|
282
|
+
skipAddrs, skipRel8nNames, onlyRel8nNames,
|
|
283
|
+
maxRetries, msBetweenRetries,
|
|
284
|
+
space,
|
|
285
|
+
timeLogName,
|
|
286
|
+
mapTjpAddrToLatestAddrsInSpace,
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
} catch (error) {
|
|
290
|
+
console.error(`${lc} ${error.message}`);
|
|
291
|
+
throw error;
|
|
292
|
+
} finally {
|
|
293
|
+
if (logalot) { console.log(`${lc} complete.`); }
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
async function getGraphProjection_getIbGibsInIbGibAddrs({
|
|
298
|
+
ibGibs,
|
|
299
|
+
ibGibAddrs,
|
|
300
|
+
gotten,
|
|
301
|
+
skipAddrs,
|
|
302
|
+
maxRetries, msBetweenRetries,
|
|
303
|
+
timeLogName,
|
|
304
|
+
space,
|
|
305
|
+
}: GetGraphProjectionOptions): Promise<IbGib_V1[]> {
|
|
306
|
+
const lc = `[${getGraphProjection_getIbGibsInIbGibAddrs.name}]`;
|
|
307
|
+
try {
|
|
308
|
+
if (logalot) { console.log(`${lc} starting... (I: 67b2be37ff24393fff56e229304da122)`); }
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* ibgibs that we'll return
|
|
312
|
+
*/
|
|
313
|
+
const resIbGibs: IbGib_V1[] = [];
|
|
314
|
+
ibGibs ??= [];
|
|
315
|
+
ibGibAddrs ??= [];
|
|
316
|
+
skipAddrs ??= [];
|
|
317
|
+
gotten ??= {};
|
|
318
|
+
|
|
319
|
+
const addrsToGetFromSpace: IbGibAddr[] = [];
|
|
320
|
+
const gottenAddrs: IbGibAddr[] = Object.keys(gotten ?? {}); // compute once in this closure
|
|
321
|
+
const incomingIbGibAddrs = ibGibs.map(x => getIbGibAddr({ ibGib: x }));
|
|
322
|
+
// const noNeedAddrs = [...gottenAddrs, ...incomingIbGibAddrs, ...skipAddrs,];
|
|
323
|
+
for (let i = 0; i < ibGibAddrs.length; i++) {
|
|
324
|
+
const addr = ibGibAddrs[i];
|
|
325
|
+
if (skipAddrs.includes(addr) || incomingIbGibAddrs.includes(addr)) {
|
|
326
|
+
continue;
|
|
327
|
+
} else if (gottenAddrs.includes(addr)) {
|
|
328
|
+
// we've already gotten this addr previously and put it into the
|
|
329
|
+
// gotten object, so we don't need to retrieve it from space
|
|
330
|
+
resIbGibs.push(gotten[addr]);
|
|
331
|
+
} else {
|
|
332
|
+
// if (!noNeedAddrs.includes(ibGibAddrs[i])) {
|
|
333
|
+
addrsToGetFromSpace.push(ibGibAddrs[i]);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
if (logalot) { console.log(`${lc}[analyze debugging] addrsToGetFromSpace (${addrsToGetFromSpace.length}):\n${addrsToGetFromSpace.join('\n')} (I: b45a2614184b48b694becfd377c789f5)`); }
|
|
338
|
+
|
|
339
|
+
if (addrsToGetFromSpace.length > 0) {
|
|
340
|
+
// get from space, with retries if applicable
|
|
341
|
+
let addrsToGet = addrsToGetFromSpace.concat();
|
|
342
|
+
let retryCount = 0;
|
|
343
|
+
maxRetries = maxRetries ?? 0;
|
|
344
|
+
while (retryCount <= maxRetries && addrsToGet.length > 0) {
|
|
345
|
+
if (timeLogName && retryCount === 0) { console.timeLog(timeLogName, `${lc} FIRST try starting...`) }
|
|
346
|
+
if (timeLogName && retryCount > 0) { console.timeLog(timeLogName, `${lc} RETRY starting...`) }
|
|
347
|
+
// delay if applicable
|
|
348
|
+
if (retryCount > 0 && msBetweenRetries) {
|
|
349
|
+
if (timeLogName) { console.timeLog(timeLogName, `${lc} delaying ${msBetweenRetries}ms for retry`); }
|
|
350
|
+
if (logalot) { console.log(`${lc} retrying. addrsToGet (${addrsToGet.length}): ${addrsToGet} (I: 8460694cdd5518472680784c3b96a822)`); }
|
|
351
|
+
await delay(msBetweenRetries);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
// do the get
|
|
355
|
+
if (timeLogName) { console.timeLog(timeLogName, `${lc} getFromSpace (${addrsToGet?.length}) starting...`); }
|
|
356
|
+
if (!space) { throw new Error(`(UNEXPECTED) space falsy? (E: aa9f657695717034b3581066932d7d23)`); }
|
|
357
|
+
let resGetThese = await getFromSpace({ addrs: addrsToGet, space });
|
|
358
|
+
if (timeLogName) { console.timeLog(timeLogName, `${lc} getFromSpace complete.`); }
|
|
359
|
+
if (resGetThese.success && (resGetThese.ibGibs?.length ?? 0) > 0) {
|
|
360
|
+
resGetThese.ibGibs!.forEach(x => resIbGibs.push(x));
|
|
361
|
+
// resGetThese.ibGibs.forEach(x => ibGibs.push(x));
|
|
362
|
+
const gottenAddrs = resGetThese.ibGibs!.map(x => getIbGibAddr({ ibGib: x }));
|
|
363
|
+
if (gottenAddrs.length === addrsToGet.length) {
|
|
364
|
+
if (timeLogName) { console.timeLog(timeLogName, `${lc} got all.`) }
|
|
365
|
+
// got them all, so we're done
|
|
366
|
+
addrsToGet = [];
|
|
367
|
+
break;
|
|
368
|
+
} else {
|
|
369
|
+
if (timeLogName) { console.timeLog(timeLogName, `${lc} got some.`) }
|
|
370
|
+
// got only some, prune addrsToGet for next retry (if any)
|
|
371
|
+
addrsToGet = addrsToGet.filter(x => !gottenAddrs.includes(x));
|
|
372
|
+
}
|
|
373
|
+
} else {
|
|
374
|
+
// failed, addrsToGet stays the same
|
|
375
|
+
if (timeLogName) { console.timeLog(timeLogName, `${lc} failed. addrs: ${addrsToGet?.join(',')}`) }
|
|
376
|
+
}
|
|
377
|
+
retryCount++;
|
|
378
|
+
}
|
|
379
|
+
if (addrsToGet?.length > 0) {
|
|
380
|
+
// console.dir(primaryKeysDebug);
|
|
381
|
+
throw new Error(`unable to retrieve dependency ibgibs from space.\n\nThis is often because downloading failed due to the sync space's server getting temporarily overloaded, OR...it sometimes happens when an ibgib doesn't get fully published to the sync space in the first place.\n\nYou could retry immediately or later, but if the problem persists, then retry from the publishers end (have the publisher sync again). (E: 8413594b6c1b447988781cf3f3e1729d)`);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
return resIbGibs;
|
|
386
|
+
} catch (error) {
|
|
387
|
+
console.error(`${lc} ${error.message}`);
|
|
388
|
+
throw error;
|
|
389
|
+
} finally {
|
|
390
|
+
if (logalot) { console.log(`${lc} complete.`); }
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
export async function getGraphProjection(opts: GetDependencyGraphOptions): Promise<GetGraphResult> {
|
|
395
|
+
const lc = `[${getGraphProjection.name}]`;
|
|
396
|
+
try {
|
|
397
|
+
if (logalot) { console.log(`${lc} starting... (I: 70508d7a5c63eae1f22ae851b32b3d22)`); }
|
|
398
|
+
|
|
399
|
+
if (!opts.ibGib && !opts.ibGibAddr && (opts.ibGibs ?? []).length === 0 && (opts.ibGibAddrs ?? []).length === 0) {
|
|
400
|
+
// no ibgibs/addrs, return empty - don't throw
|
|
401
|
+
return {} as GetGraphResult; /* <<<< returns early */
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
// ibGib and ibGibAddr get condensed into ibGibs and ibGibAddrs
|
|
405
|
+
let {
|
|
406
|
+
/*ibGib,*/ ibGibs, /*ibGibAddr,*/ ibGibAddrs,
|
|
407
|
+
live,
|
|
408
|
+
gotten, tjpAddrsAlreadyAnalyzed,
|
|
409
|
+
skipAddrs, skipRel8nNames, onlyRel8nNames,
|
|
410
|
+
maxRetries, msBetweenRetries,
|
|
411
|
+
space,
|
|
412
|
+
timeLogName,
|
|
413
|
+
mapTjpAddrToLatestAddrsInSpace,
|
|
414
|
+
} = await getGraphProjection_initializeOpts(opts);
|
|
415
|
+
|
|
416
|
+
if (timeLogName) { console.timeLog(timeLogName, `${lc} starting...`) }
|
|
417
|
+
|
|
418
|
+
// retrieve ibgibs listed in incoming ibGibAddrs (if any) and put them
|
|
419
|
+
// in our incoming ibGibs array
|
|
420
|
+
if (ibGibAddrs?.length ?? 0 > 0) {
|
|
421
|
+
const supplementalIbGibs = await getGraphProjection_getIbGibsInIbGibAddrs({
|
|
422
|
+
ibGibs, ibGibAddrs,
|
|
423
|
+
gotten,
|
|
424
|
+
skipAddrs,
|
|
425
|
+
maxRetries, msBetweenRetries,
|
|
426
|
+
timeLogName,
|
|
427
|
+
space,
|
|
428
|
+
});
|
|
429
|
+
ibGibs = ibGibs ?
|
|
430
|
+
[...ibGibs, ...supplementalIbGibs] :
|
|
431
|
+
[...supplementalIbGibs]
|
|
432
|
+
}
|
|
433
|
+
ibGibAddrs = ibGibs!.map(x => getIbGibAddr({ ibGib: x }));
|
|
434
|
+
|
|
435
|
+
|
|
436
|
+
// at this point, there are two different strategies for diving deeper,
|
|
437
|
+
// depending on if we are building a `live` graph or not.
|
|
438
|
+
|
|
439
|
+
let commentIbs = unique(ibGibs!.map(x => x.ib).filter(x => x.startsWith('comment ')));
|
|
440
|
+
if (logalot) { console.log(`${lc}[analyze debugging] ibGibs commentIbs: ${commentIbs.join('\n')} (I: c89dc951315f746954f9bddbe8941122)`); }
|
|
441
|
+
|
|
442
|
+
if (live) {
|
|
443
|
+
return getGraphProjection_Live({
|
|
444
|
+
ibGibs, ibGibAddrs,
|
|
445
|
+
gotten, tjpAddrsAlreadyAnalyzed,
|
|
446
|
+
skipAddrs, skipRel8nNames, onlyRel8nNames,
|
|
447
|
+
maxRetries, msBetweenRetries,
|
|
448
|
+
space, timeLogName,
|
|
449
|
+
mapTjpAddrToLatestAddrsInSpace,
|
|
450
|
+
});
|
|
451
|
+
} else {
|
|
452
|
+
return getGraphProjection_NonLive({
|
|
453
|
+
ibGibs, ibGibAddrs,
|
|
454
|
+
gotten, /* tjpAddrsAlreadyAnalyzed not used */
|
|
455
|
+
skipAddrs, skipRel8nNames, onlyRel8nNames,
|
|
456
|
+
maxRetries, msBetweenRetries,
|
|
457
|
+
space, timeLogName,
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
} catch (error) {
|
|
461
|
+
console.error(`${lc} ${error.message}`);
|
|
462
|
+
throw error;
|
|
463
|
+
} finally {
|
|
464
|
+
if (logalot) { console.log(`${lc} complete.`); }
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
*
|
|
470
|
+
* live dependency graph searching requires a timeline-centric approach.
|
|
471
|
+
* for each incoming ibGib, we must first determine if it has a
|
|
472
|
+
* timeline. if it does, then we get the latest in that timeline and
|
|
473
|
+
* get all ibgibs in that lineage only. we do NOT YET go through any
|
|
474
|
+
* rel8d ibgibs that also have timelines
|
|
475
|
+
*
|
|
476
|
+
* what we can do is compile our list of ibGib addrs according to each
|
|
477
|
+
* timeline and then call the nonlive version of the dependency graph.
|
|
478
|
+
* but we must get the latest in the timeline, then get all associated
|
|
479
|
+
* timelines and get the latest of those. Then we can call get
|
|
480
|
+
* dependency graph on the non-live version, passing in all of those
|
|
481
|
+
* latest ibgibs in the timelines (and everything we've gotten in the
|
|
482
|
+
* interim so we don't waste time getting more).
|
|
483
|
+
*
|
|
484
|
+
* @see {@link getGraphProjection}
|
|
485
|
+
* @see {@link getDependencyGraph}
|
|
486
|
+
*/
|
|
487
|
+
async function getGraphProjection_Live({
|
|
488
|
+
ibGibs, ibGibAddrs,
|
|
489
|
+
gotten, tjpAddrsAlreadyAnalyzed,
|
|
490
|
+
mapTjpAddrToLatestAddrsInSpace,
|
|
491
|
+
skipAddrs, skipRel8nNames, onlyRel8nNames,
|
|
492
|
+
maxRetries, msBetweenRetries,
|
|
493
|
+
space,
|
|
494
|
+
timeLogName,
|
|
495
|
+
}: GetGraphProjectionOptions): Promise<GetGraphResult> {
|
|
496
|
+
const lc = `[${getGraphProjection_Live.name}]`;
|
|
497
|
+
try {
|
|
498
|
+
mapTjpAddrToLatestAddrsInSpace = mapTjpAddrToLatestAddrsInSpace ?? {};
|
|
499
|
+
tjpAddrsAlreadyAnalyzed = tjpAddrsAlreadyAnalyzed ?? [];
|
|
500
|
+
|
|
501
|
+
// ibGibs contains the ones we explicitly are still working on getting
|
|
502
|
+
// projections within, gotten are the ones we have completed. so we want
|
|
503
|
+
// to get all of them together so we have a complete (up to this point)
|
|
504
|
+
// picture of timelines, because we're looking for timelines that we
|
|
505
|
+
// haven't yet analyzed
|
|
506
|
+
let allIbGibsSoFar = { ...gotten };
|
|
507
|
+
(ibGibs ?? []).forEach(x => allIbGibsSoFar[getIbGibAddr({ ibGib: x })] = x);
|
|
508
|
+
const allKnownTimelinesAtThisPoint = getTimelinesGroupedByTjp({
|
|
509
|
+
ibGibs: Object.values(allIbGibsSoFar),
|
|
510
|
+
});
|
|
511
|
+
if (logalot) { console.log(`${lc}[analyze debugging] timeline tjps(${Object.keys(allKnownTimelinesAtThisPoint).length}): ${Object.keys(allKnownTimelinesAtThisPoint)} (I: 509f04ac15ca08c5a3f0777b48934622)`); }
|
|
512
|
+
|
|
513
|
+
const timelinesNotAnalyzed: { [addr: string]: IbGib_V1[] } = {};
|
|
514
|
+
Object.keys(allKnownTimelinesAtThisPoint).forEach(tjpAddr => {
|
|
515
|
+
if (!tjpAddrsAlreadyAnalyzed!.includes(tjpAddr)) {
|
|
516
|
+
timelinesNotAnalyzed[tjpAddr] = allKnownTimelinesAtThisPoint[tjpAddr];
|
|
517
|
+
}
|
|
518
|
+
});
|
|
519
|
+
if (logalot) { console.log(`${lc}[analyze debugging] timelinesNotAnalyzed: ${pretty(timelinesNotAnalyzed)} (I: a4b67d95fdd6b98d3241c0a7d0a93c22)`); }
|
|
520
|
+
|
|
521
|
+
const mapTjpAddrToLatestIbGibInTimelineThatWeHaventAlreadyAnalyzed: { [tjpAddr: IbGibAddr]: IbGib_V1 } = {};
|
|
522
|
+
/**
|
|
523
|
+
* Convience mapping back from latest addr already gotten back to the tjp addr.
|
|
524
|
+
* Convenience = not strictly necessary, but makes it easier later.
|
|
525
|
+
*/
|
|
526
|
+
const mapLatestAddrAlreadyGottenToTjpAddr: { [latestAddrAlreadyGotten: IbGibAddr]: IbGibAddr } = {};
|
|
527
|
+
|
|
528
|
+
Object.keys(allKnownTimelinesAtThisPoint)
|
|
529
|
+
.filter(tjpAddr => !tjpAddrsAlreadyAnalyzed!.includes(tjpAddr))
|
|
530
|
+
.forEach(tjpAddr => {
|
|
531
|
+
const timeline = allKnownTimelinesAtThisPoint[tjpAddr];
|
|
532
|
+
// add to the array we'll send below
|
|
533
|
+
const latestIbGibAlreadyGotten = timeline[timeline.length - 1];
|
|
534
|
+
mapTjpAddrToLatestIbGibInTimelineThatWeHaventAlreadyAnalyzed[tjpAddr] = latestIbGibAlreadyGotten;
|
|
535
|
+
// add to mapping back from addr to tjpaddr for convenience below
|
|
536
|
+
const latestAddrAlreadyGotten = getIbGibAddr({ ibGib: latestIbGibAlreadyGotten });
|
|
537
|
+
mapLatestAddrAlreadyGottenToTjpAddr[latestAddrAlreadyGotten] = tjpAddr;
|
|
538
|
+
});
|
|
539
|
+
let countOfTimelinesNotYetGotten =
|
|
540
|
+
Object.keys(mapTjpAddrToLatestIbGibInTimelineThatWeHaventAlreadyAnalyzed).length;
|
|
541
|
+
|
|
542
|
+
if (countOfTimelinesNotYetGotten > 0) {
|
|
543
|
+
// we have more timelines still to do. get the latest ibGib in each timeline,
|
|
544
|
+
// add it, check for more timelines. But we may have already gotten a latestAddrsMap
|
|
545
|
+
// in a previous call, so account for this.
|
|
546
|
+
|
|
547
|
+
// query only latest ibgibs that we haven't already gotten AND whose
|
|
548
|
+
// timelines we've not already analyzed, per
|
|
549
|
+
// mapTjpAddrToLatestAddrsInSpace.
|
|
550
|
+
/**
|
|
551
|
+
* build this map of latest addr given -> latest addr in space (per timeline/tjp).
|
|
552
|
+
*/
|
|
553
|
+
let latestAddrsMap: { [addr: string]: IbGibAddr | null } = {};
|
|
554
|
+
Object.keys(mapTjpAddrToLatestAddrsInSpace)
|
|
555
|
+
.filter(tjpAddr => !tjpAddrsAlreadyAnalyzed!.includes(tjpAddr))
|
|
556
|
+
.forEach(tjpAddr => {
|
|
557
|
+
const latestIbGibCorrespondingToTjpAddr =
|
|
558
|
+
mapTjpAddrToLatestIbGibInTimelineThatWeHaventAlreadyAnalyzed[tjpAddr];
|
|
559
|
+
if (latestIbGibCorrespondingToTjpAddr) {
|
|
560
|
+
const latestAddrCorrespondingToTjpAddr =
|
|
561
|
+
getIbGibAddr({ ibGib: latestIbGibCorrespondingToTjpAddr });
|
|
562
|
+
latestAddrsMap[latestAddrCorrespondingToTjpAddr] = mapTjpAddrToLatestAddrsInSpace![tjpAddr];
|
|
563
|
+
} else {
|
|
564
|
+
console.error(`${lc} latestIbGibCorrespondingToTjpAddr is falsy`)
|
|
565
|
+
}
|
|
566
|
+
});
|
|
567
|
+
if (logalot) { console.log(`${lc} latestAddrsMap *before* getLatestAddrs: ${pretty(latestAddrsMap)} (I: 427b4bb78595e9e521ecf2c5e5c80722)`); }
|
|
568
|
+
const ibGibsToQuery =
|
|
569
|
+
Object.values(mapTjpAddrToLatestIbGibInTimelineThatWeHaventAlreadyAnalyzed);
|
|
570
|
+
// .filter(x => !Object.keys(latestAddrsMap).includes(getIbGibAddr({ ibGib: x })));
|
|
571
|
+
|
|
572
|
+
let queriedLatestAddrsMap: { [addr: string]: IbGibAddr | null } = {};
|
|
573
|
+
if (ibGibsToQuery.length > 0) {
|
|
574
|
+
if (!space) { throw new Error(`(UNEXPECTED) space falsy? (E: 8e878975e3561df9a8dc4c628b0abc23)`); }
|
|
575
|
+
/** This is result with the map of the latest addrs in the space */
|
|
576
|
+
const resLatestAddrsMapInEntireSpace = await getLatestAddrs({
|
|
577
|
+
ibGibs: ibGibsToQuery,
|
|
578
|
+
space,
|
|
579
|
+
});
|
|
580
|
+
if (!resLatestAddrsMapInEntireSpace?.data?.latestAddrsMap) { throw new Error(`(UNEXPECTED) getLatestAddrs result latestAddrsMap falsy (E: 088caa1fc95fd3b079108ab63ef33422)`); }
|
|
581
|
+
queriedLatestAddrsMap = resLatestAddrsMapInEntireSpace?.data?.latestAddrsMap;
|
|
582
|
+
if (Object.keys(queriedLatestAddrsMap).length !== countOfTimelinesNotYetGotten) {
|
|
583
|
+
// this happens when the space does not have the address, sometimes because of
|
|
584
|
+
// not pushing the most recent changes to the sync space...hmmm
|
|
585
|
+
throw new Error(`(UNEXPECTED) latestAddrsMap is not the same size as the incoming map (E: 666af512bbd44534983bb28ee8d43fed)`);
|
|
586
|
+
}
|
|
587
|
+
if (logalot) { console.log(`${lc} queriedLatestAddrsMap: ${pretty(queriedLatestAddrsMap)} (I: 7b39a5f7ce9e9d9fabae4be98ed44522)`); }
|
|
588
|
+
latestAddrsMap = {
|
|
589
|
+
...queriedLatestAddrsMap,
|
|
590
|
+
...latestAddrsMap
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
if (logalot) { console.log(`${lc} combined latestAddrsMap: ${pretty(latestAddrsMap)} (I: e3aedea63f29c5b06a79632f691aa522)`); }
|
|
594
|
+
|
|
595
|
+
/**
|
|
596
|
+
* these addrs are those whose timelines we did not yet have the latest.
|
|
597
|
+
* this means that we will have to work off of these ibgibs.
|
|
598
|
+
*/
|
|
599
|
+
const newerAddrsFound: IbGibAddr[] = [];
|
|
600
|
+
Object.values(mapTjpAddrToLatestIbGibInTimelineThatWeHaventAlreadyAnalyzed)
|
|
601
|
+
.forEach(latestIbGibAlreadyGotten => {
|
|
602
|
+
const latestAddrAlreadyGotten = getIbGibAddr({ ibGib: latestIbGibAlreadyGotten });
|
|
603
|
+
const tjpAddr = mapLatestAddrAlreadyGottenToTjpAddr[latestAddrAlreadyGotten];
|
|
604
|
+
const latestAddrInSpace = latestAddrsMap[latestAddrAlreadyGotten];
|
|
605
|
+
if (!latestAddrInSpace) { throw new Error(`(UNEXPECTED) latestAddrInSpace not found in latestAddrsMap (E: 095d2b3f88e3e8a2c3e7d3de4c6d5622)`); }
|
|
606
|
+
if (latestAddrInSpace === latestAddrAlreadyGotten) {
|
|
607
|
+
// we've already got the latest for this timeline. This
|
|
608
|
+
// means that we must have already at least queued all
|
|
609
|
+
// timelines possible, so nothing else to do.
|
|
610
|
+
if (logalot) { console.log(`${lc} analyzed ${tjpAddr}(I: afb7960900f04b8a87538f4c7bd903b7)`); }
|
|
611
|
+
tjpAddrsAlreadyAnalyzed!.push(tjpAddr);
|
|
612
|
+
} else {
|
|
613
|
+
// there is a newer "latest" in this timeline that we
|
|
614
|
+
// haven't gotten yet, so add that addr to the
|
|
615
|
+
newerAddrsFound.push(latestAddrInSpace);
|
|
616
|
+
}
|
|
617
|
+
});
|
|
618
|
+
|
|
619
|
+
let rel8dAddrsNotYetGotten: IbGibAddr[] = [];
|
|
620
|
+
for (let i = 0; i < (ibGibs ?? []).length; i++) {
|
|
621
|
+
const ibGib = ibGibs![i];
|
|
622
|
+
const rel8ns = ibGib.rel8ns ?? {};
|
|
623
|
+
const rel8nNames = Object.keys(rel8ns)
|
|
624
|
+
.filter(x => !(skipRel8nNames ?? []).includes(x))
|
|
625
|
+
.filter(x => onlyRel8nNames ? onlyRel8nNames.includes(x) : true);
|
|
626
|
+
rel8nNames.forEach(rel8nName => {
|
|
627
|
+
const rel8dAddrs = rel8ns[rel8nName] ?? [];
|
|
628
|
+
rel8dAddrs.forEach(rel8dAddr => {
|
|
629
|
+
// only add todo if we don't already have the ibgib
|
|
630
|
+
|
|
631
|
+
if (!rel8dAddrsNotYetGotten.includes(rel8dAddr) &&
|
|
632
|
+
!ibGibs!.some(x => getIbGibAddr({ ibGib: x }) === rel8dAddr)
|
|
633
|
+
) {
|
|
634
|
+
rel8dAddrsNotYetGotten.push(rel8dAddr);
|
|
635
|
+
}
|
|
636
|
+
});
|
|
637
|
+
});
|
|
638
|
+
}
|
|
639
|
+
ibGibAddrs = unique([...(ibGibAddrs ?? []), ...rel8dAddrsNotYetGotten]);
|
|
640
|
+
|
|
641
|
+
if (newerAddrsFound.length === 0) {
|
|
642
|
+
// there were no newer addrs found, necessitating that we have
|
|
643
|
+
// no additional ibgibs that we don't know about.
|
|
644
|
+
|
|
645
|
+
return await getGraphProjection({
|
|
646
|
+
ibGibs, ibGibAddrs,
|
|
647
|
+
gotten, tjpAddrsAlreadyAnalyzed,
|
|
648
|
+
// gotten, /* tjpAddrsAlreadyAnalyzed not used */
|
|
649
|
+
skipAddrs, skipRel8nNames, onlyRel8nNames,
|
|
650
|
+
maxRetries, msBetweenRetries,
|
|
651
|
+
space,
|
|
652
|
+
timeLogName,
|
|
653
|
+
live: true,
|
|
654
|
+
});
|
|
655
|
+
} else {
|
|
656
|
+
// there are still newer ibgibs that must be included in the analysis, without yet
|
|
657
|
+
// going into the direct rel8ns of
|
|
658
|
+
// need to call recursively this _Live function, passing in
|
|
659
|
+
// the already computated latest map in mapTjpAddrToLatestAddrsInSpace
|
|
660
|
+
// I need to also adjust preceding code to use this map.
|
|
661
|
+
// leaving off here
|
|
662
|
+
// getDependencyGraph_Live({...})
|
|
663
|
+
Object.keys(queriedLatestAddrsMap).forEach(latestAddrNotGotten => {
|
|
664
|
+
const tjpAddr = mapLatestAddrAlreadyGottenToTjpAddr[latestAddrNotGotten];
|
|
665
|
+
mapTjpAddrToLatestAddrsInSpace![tjpAddr] = latestAddrNotGotten;
|
|
666
|
+
if (queriedLatestAddrsMap[latestAddrNotGotten]) { ibGibAddrs!.push(); }
|
|
667
|
+
});
|
|
668
|
+
ibGibAddrs = unique(ibGibAddrs);
|
|
669
|
+
// ibGibAddrs = unique([...ibGibAddrs, ...rel8dAddrsNotYetGotten]);
|
|
670
|
+
|
|
671
|
+
return await getGraphProjection({
|
|
672
|
+
ibGibs, ibGibAddrs,
|
|
673
|
+
gotten, tjpAddrsAlreadyAnalyzed,
|
|
674
|
+
skipAddrs, skipRel8nNames, onlyRel8nNames,
|
|
675
|
+
maxRetries, msBetweenRetries,
|
|
676
|
+
space,
|
|
677
|
+
timeLogName,
|
|
678
|
+
live: true,
|
|
679
|
+
mapTjpAddrToLatestAddrsInSpace,
|
|
680
|
+
});
|
|
681
|
+
}
|
|
682
|
+
} else {
|
|
683
|
+
// we have no more timelines that we haven't already gotten, so we
|
|
684
|
+
// can pass off to the non-live version
|
|
685
|
+
if (!ibGibs) { ibGibs = []; }
|
|
686
|
+
Object.values(gotten ?? {}).forEach(x => {
|
|
687
|
+
const addr = getIbGibAddr({ ibGib: x });
|
|
688
|
+
if (!ibGibs!.some(y => getIbGibAddr({ ibGib: x }) === addr)) {
|
|
689
|
+
ibGibs!.push(x);
|
|
690
|
+
}
|
|
691
|
+
});
|
|
692
|
+
return await getGraphProjection({ /* <<<< returns early */
|
|
693
|
+
ibGibs, ibGibAddrs,
|
|
694
|
+
gotten, /* tjpAddrsAlreadyAnalyzed not used */
|
|
695
|
+
skipAddrs, skipRel8nNames, onlyRel8nNames,
|
|
696
|
+
maxRetries, msBetweenRetries,
|
|
697
|
+
space,
|
|
698
|
+
timeLogName,
|
|
699
|
+
live: false,
|
|
700
|
+
});
|
|
701
|
+
}
|
|
702
|
+
} catch (error) {
|
|
703
|
+
const emsg = `${lc} ${error.message}`;
|
|
704
|
+
console.error(emsg);
|
|
705
|
+
if (timeLogName) { console.timeLog(timeLogName, `${lc} error: ${emsg}`); }
|
|
706
|
+
throw error;
|
|
707
|
+
} finally {
|
|
708
|
+
if (timeLogName) { console.timeLog(timeLogName, `${lc} complete.`) }
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
/**
|
|
713
|
+
* NOT EXPORTED
|
|
714
|
+
*
|
|
715
|
+
* @see {@link getGraphProjection}
|
|
716
|
+
* @see {@link getDependencyGraph}
|
|
717
|
+
*/
|
|
718
|
+
async function getGraphProjection_NonLive({
|
|
719
|
+
ibGibs, ibGibAddrs,
|
|
720
|
+
gotten, /* tjpAddrsAlreadyAnalyzed not used */
|
|
721
|
+
skipAddrs, skipRel8nNames, onlyRel8nNames,
|
|
722
|
+
maxRetries, msBetweenRetries,
|
|
723
|
+
space,
|
|
724
|
+
timeLogName,
|
|
725
|
+
}: GetGraphProjectionOptions): Promise<GetGraphResult> {
|
|
726
|
+
const lc = `[${getGraphProjection_NonLive.name}]`;
|
|
727
|
+
try {
|
|
728
|
+
// next, compile what could be a rather large list of rel8d ibgibAddrs
|
|
729
|
+
// which must necessarily be in the past of the futuremost incoming
|
|
730
|
+
// ibGib/ibGibAddr/s as rel8ns only work backwards (whereas tjp's can
|
|
731
|
+
// refer to future timelines, the DAG substrate only looks backwards)
|
|
732
|
+
const addrsWeDontHaveAlready_Rel8dAddrs: IbGibAddr[] = [];
|
|
733
|
+
ibGibs ??= [];
|
|
734
|
+
gotten ??= {};
|
|
735
|
+
skipAddrs ??= [];
|
|
736
|
+
skipRel8nNames ??= [];
|
|
737
|
+
|
|
738
|
+
// so, we will iterate through all of our given and loaded ibGibs (not
|
|
739
|
+
// the ones in gotten map though), look through all of their rel8ns, and
|
|
740
|
+
// add any that haven't already been gotten
|
|
741
|
+
if (timeLogName) { console.timeLog(timeLogName, `${lc} analyzing next step starting...`); }
|
|
742
|
+
for (let i = 0; i < ibGibs.length; i++) {
|
|
743
|
+
const ibGib = ibGibs[i];
|
|
744
|
+
const ibGibAddr = getIbGibAddr({ ibGib });
|
|
745
|
+
|
|
746
|
+
// do i need this?
|
|
747
|
+
const { gib } = getIbAndGib({ ibGib });
|
|
748
|
+
if (gib === GIB) { throw new Error(`cannot get dependency graph of primitive.`); }
|
|
749
|
+
|
|
750
|
+
// ?
|
|
751
|
+
// I believe I have this so we don't try to do this ibgib again on recursive call.
|
|
752
|
+
// but should I be adding it at this point? hmm...
|
|
753
|
+
if (!Object.keys(gotten).includes(ibGibAddr)) { gotten[ibGibAddr] = ibGib; }
|
|
754
|
+
|
|
755
|
+
// iterate through rel8ns and compile list of ibgib addrs not yet gotten
|
|
756
|
+
/** map of addr to validation errors array */
|
|
757
|
+
const invalidAddrs: { [addr: string]: string[] } = {};
|
|
758
|
+
const rel8ns = ibGib.rel8ns || {};
|
|
759
|
+
let rel8nNames = (Object.keys(rel8ns) || []).filter(x => !skipRel8nNames!.includes(x));
|
|
760
|
+
if (onlyRel8nNames) {
|
|
761
|
+
rel8nNames = rel8nNames.filter(x => onlyRel8nNames.includes(x));
|
|
762
|
+
}
|
|
763
|
+
const gottenKeys = Object.keys(gotten);
|
|
764
|
+
for (let i = 0; i < rel8nNames.length; i++) {
|
|
765
|
+
const rel8nName = rel8nNames[i];
|
|
766
|
+
const rel8dAddrs = rel8ns[rel8nName] ?? [];
|
|
767
|
+
const falsyAddrs = rel8dAddrs.filter(addr =>
|
|
768
|
+
addr === '' ||
|
|
769
|
+
addr === undefined ||
|
|
770
|
+
addr === null ||
|
|
771
|
+
!addr.includes(IBGIB_DELIMITER)
|
|
772
|
+
);
|
|
773
|
+
if (falsyAddrs.length > 0) { console.warn(`${lc} (UNEXPECTED) has falsyAddrs: ${falsyAddrs} (W: da9505cb0a4db68a4aff7f279ad2d322)`); }
|
|
774
|
+
const rel8dAddrsNotGottenYetThisRel8n =
|
|
775
|
+
rel8dAddrs
|
|
776
|
+
.filter(addr => !!addr)
|
|
777
|
+
.filter(addr => !gottenKeys.includes(addr))
|
|
778
|
+
.filter(addr => !skipAddrs!.includes(addr))
|
|
779
|
+
.filter(addr => getIbAndGib({ ibGibAddr: addr }).gib !== GIB)
|
|
780
|
+
.filter(addr => !addrsWeDontHaveAlready_Rel8dAddrs.includes(addr));
|
|
781
|
+
rel8dAddrsNotGottenYetThisRel8n.forEach(rel8dAddr => {
|
|
782
|
+
const validationErrors = validateIbGibAddr({ addr: rel8dAddr });
|
|
783
|
+
if ((validationErrors || []).length === 0) {
|
|
784
|
+
// valid addr. add it if we haven't gotten/queued it yet
|
|
785
|
+
addrsWeDontHaveAlready_Rel8dAddrs.push(rel8dAddr);
|
|
786
|
+
} else {
|
|
787
|
+
// invalid address
|
|
788
|
+
invalidAddrs[rel8dAddr] = validationErrors!;
|
|
789
|
+
}
|
|
790
|
+
});
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
if (Object.keys(invalidAddrs).length > 0) {
|
|
794
|
+
throw new Error(`invalid addresses found in dependency graph. Errors (clipped to 1kB): ${JSON.stringify(invalidAddrs).substring(0, 1024)}`);
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
if (timeLogName) { console.timeLog(timeLogName, `${lc} analyzing next step complete.`); }
|
|
798
|
+
|
|
799
|
+
if (addrsWeDontHaveAlready_Rel8dAddrs.length > 0) {
|
|
800
|
+
if (timeLogName) { console.timeLog(timeLogName, `${lc} get addrsWeDontHaveAlready_Rel8dAddrs starting...`); }
|
|
801
|
+
// execute the get on those addrs
|
|
802
|
+
if (!space) { throw new Error(`(UNEXPECTED) space falsy? (E: 0ce327cf5d521bd798340333460f3423)`); }
|
|
803
|
+
const resGet = await getFromSpace({ addrs: addrsWeDontHaveAlready_Rel8dAddrs, space });
|
|
804
|
+
if (timeLogName) { console.timeLog(timeLogName, `${lc} get addrsWeDontHaveAlready_Rel8dAddrs complete.`); }
|
|
805
|
+
if (resGet.success) {
|
|
806
|
+
if (resGet.ibGibs?.length === addrsWeDontHaveAlready_Rel8dAddrs.length) {
|
|
807
|
+
if (logalot) { console.log(`${lc} got ALL of them (happy path)`); }
|
|
808
|
+
resGet.ibGibs.forEach(x => gotten![getIbGibAddr({ ibGib: x })] = x);
|
|
809
|
+
// return a recursive call for the newly-gotten ibgibs'
|
|
810
|
+
// dependencies, passing in the now-larger accumulating
|
|
811
|
+
// `gotten` map of ibgibs already processed.
|
|
812
|
+
if (timeLogName) { console.timeLog(timeLogName, `${lc} call getGraphProjection recursively starting...`); }
|
|
813
|
+
const result = await getGraphProjection({
|
|
814
|
+
ibGibs: resGet.ibGibs,
|
|
815
|
+
live: false,
|
|
816
|
+
gotten, /* tjpAddrsAlreadyAnalyzed not used */
|
|
817
|
+
skipAddrs, skipRel8nNames, onlyRel8nNames,
|
|
818
|
+
maxRetries, msBetweenRetries,
|
|
819
|
+
space,
|
|
820
|
+
});
|
|
821
|
+
if (timeLogName) { console.timeLog(timeLogName, `${lc} call getGraphProjection recursively complete.`); }
|
|
822
|
+
return result; // <<<< returns early
|
|
823
|
+
} else if ((resGet.ibGibs?.length ?? 0) > 0 && resGet.ibGibs!.length < addrsWeDontHaveAlready_Rel8dAddrs.length) {
|
|
824
|
+
if (logalot) { console.warn(`${lc} got SOME of them (happy-ish path?). not sure what to do here... (W: e3458f61a1ae4979af9e6b18ac935c14)`); }
|
|
825
|
+
throw new Error(`trouble getting dependency ibgibs (E: 8156bf65fd084ae4a4e8a0669db28b07)`);
|
|
826
|
+
} else if ((resGet.ibGibs?.length ?? 0 > 0) && resGet.ibGibs!.length > addrsWeDontHaveAlready_Rel8dAddrs.length) {
|
|
827
|
+
// got more than our original list? not a good space behavior...
|
|
828
|
+
throw new Error(`(UNEXPECTED) got more ibGibs than addrs that we asked for. space not working properly. (E: 352219b3d18543bcbda957f2d60b78f3)`);
|
|
829
|
+
} else {
|
|
830
|
+
// didn't get any...hmm...
|
|
831
|
+
throw new Error(`couldn't get dependency ibgibs from space. (E: 225f26b7d7f84911bb033753a062209b)`);
|
|
832
|
+
}
|
|
833
|
+
} else {
|
|
834
|
+
// resGet.success falsy indicates an error in the space. If it wasn't found
|
|
835
|
+
// then resGet.success would (should) still be truthy.
|
|
836
|
+
throw new Error(`failure getting addrs in space ${space?.data?.name || '[no name?]'} (id: ${space?.data?.uuid || '[no uuid?]'}). (E: 60404e6e389249d9bbecf0039cd51878) addrs:\n${addrsWeDontHaveAlready_Rel8dAddrs.join('\n')} `);
|
|
837
|
+
}
|
|
838
|
+
} else {
|
|
839
|
+
// no other rel8d addrs to get, so our job is done and the `gotten`
|
|
840
|
+
// map of dependency ibgibs is complete (no need for another
|
|
841
|
+
// recursive call).
|
|
842
|
+
return gotten;
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
} catch (error) {
|
|
846
|
+
const emsg = `${lc} ${error.message}`;
|
|
847
|
+
console.error(emsg);
|
|
848
|
+
if (timeLogName) { console.timeLog(timeLogName, `${lc} error: ${emsg}`); }
|
|
849
|
+
throw error;
|
|
850
|
+
} finally {
|
|
851
|
+
if (timeLogName) { console.timeLog(timeLogName, `${lc} complete.`) }
|
|
852
|
+
}
|
|
853
|
+
}
|