@ibgib/node-gib 0.0.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.
- package/.ibgibignore +30 -0
- package/CHANGELOG.md +18 -0
- package/README.md +16 -0
- package/dist/assumptions.respec.d.mts +2 -0
- package/dist/assumptions.respec.d.mts.map +1 -0
- package/dist/assumptions.respec.mjs +41 -0
- package/dist/assumptions.respec.mjs.map +1 -0
- package/dist/common/prompt-functions.d.mts +89 -0
- package/dist/common/prompt-functions.d.mts.map +1 -0
- package/dist/common/prompt-functions.mjs +418 -0
- package/dist/common/prompt-functions.mjs.map +1 -0
- package/dist/constants.d.mts +3 -0
- package/dist/constants.d.mts.map +1 -0
- package/dist/constants.mjs +3 -0
- package/dist/constants.mjs.map +1 -0
- package/dist/foo.d.mts +2 -0
- package/dist/foo.d.mts.map +1 -0
- package/dist/foo.mjs +19 -0
- package/dist/foo.mjs.map +1 -0
- package/dist/helpers.d.mts +2 -0
- package/dist/helpers.d.mts.map +1 -0
- package/dist/helpers.mjs +3 -0
- package/dist/helpers.mjs.map +1 -0
- package/dist/respec-gib.node.d.mts +2 -0
- package/dist/respec-gib.node.d.mts.map +1 -0
- package/dist/respec-gib.node.mjs +213 -0
- package/dist/respec-gib.node.mjs.map +1 -0
- package/dist/spec-helper.node.respec.d.mts +13 -0
- package/dist/spec-helper.node.respec.d.mts.map +1 -0
- package/dist/spec-helper.node.respec.mjs +50 -0
- package/dist/spec-helper.node.respec.mjs.map +1 -0
- package/dist/types.d.mts +2 -0
- package/dist/types.d.mts.map +1 -0
- package/dist/types.mjs +2 -0
- package/dist/types.mjs.map +1 -0
- package/dist/witness/space/metaspace/metaspace-nodespace/metaspace-nodespace-helper.d.mts +35 -0
- package/dist/witness/space/metaspace/metaspace-nodespace/metaspace-nodespace-helper.d.mts.map +1 -0
- package/dist/witness/space/metaspace/metaspace-nodespace/metaspace-nodespace-helper.mjs +267 -0
- package/dist/witness/space/metaspace/metaspace-nodespace/metaspace-nodespace-helper.mjs.map +1 -0
- package/dist/witness/space/metaspace/metaspace-nodespace/metaspace-nodespace.d.mts +98 -0
- package/dist/witness/space/metaspace/metaspace-nodespace/metaspace-nodespace.d.mts.map +1 -0
- package/dist/witness/space/metaspace/metaspace-nodespace/metaspace-nodespace.mjs +160 -0
- package/dist/witness/space/metaspace/metaspace-nodespace/metaspace-nodespace.mjs.map +1 -0
- package/dist/witness/space/node-filesystem-space/node-filesystem-space-helper.d.mts +42 -0
- package/dist/witness/space/node-filesystem-space/node-filesystem-space-helper.d.mts.map +1 -0
- package/dist/witness/space/node-filesystem-space/node-filesystem-space-helper.mjs +312 -0
- package/dist/witness/space/node-filesystem-space/node-filesystem-space-helper.mjs.map +1 -0
- package/dist/witness/space/node-filesystem-space/node-filesystem-space-types.d.mts +84 -0
- package/dist/witness/space/node-filesystem-space/node-filesystem-space-types.d.mts.map +1 -0
- package/dist/witness/space/node-filesystem-space/node-filesystem-space-types.mjs +65 -0
- package/dist/witness/space/node-filesystem-space/node-filesystem-space-types.mjs.map +1 -0
- package/dist/witness/space/node-filesystem-space/node-filesystem-space-v1.d.mts +77 -0
- package/dist/witness/space/node-filesystem-space/node-filesystem-space-v1.d.mts.map +1 -0
- package/dist/witness/space/node-filesystem-space/node-filesystem-space-v1.mjs +672 -0
- package/dist/witness/space/node-filesystem-space/node-filesystem-space-v1.mjs.map +1 -0
- package/dist/witness/space/node-filesystem-space/node-indexed-filesystem-space/node-indexed-filesystem-space-constants.d.mts +5 -0
- package/dist/witness/space/node-filesystem-space/node-indexed-filesystem-space/node-indexed-filesystem-space-constants.d.mts.map +1 -0
- package/dist/witness/space/node-filesystem-space/node-indexed-filesystem-space/node-indexed-filesystem-space-constants.mjs +5 -0
- package/dist/witness/space/node-filesystem-space/node-indexed-filesystem-space/node-indexed-filesystem-space-constants.mjs.map +1 -0
- package/dist/witness/space/node-filesystem-space/node-indexed-filesystem-space/node-indexed-filesystem-space-types.d.mts +30 -0
- package/dist/witness/space/node-filesystem-space/node-indexed-filesystem-space/node-indexed-filesystem-space-types.d.mts.map +1 -0
- package/dist/witness/space/node-filesystem-space/node-indexed-filesystem-space/node-indexed-filesystem-space-types.mjs +38 -0
- package/dist/witness/space/node-filesystem-space/node-indexed-filesystem-space/node-indexed-filesystem-space-types.mjs.map +1 -0
- package/dist/witness/space/node-filesystem-space/node-indexed-filesystem-space/node-indexed-filesystem-space-v1.d.mts +64 -0
- package/dist/witness/space/node-filesystem-space/node-indexed-filesystem-space/node-indexed-filesystem-space-v1.d.mts.map +1 -0
- package/dist/witness/space/node-filesystem-space/node-indexed-filesystem-space/node-indexed-filesystem-space-v1.mjs +353 -0
- package/dist/witness/space/node-filesystem-space/node-indexed-filesystem-space/node-indexed-filesystem-space-v1.mjs.map +1 -0
- package/dist/witness/space/node-filesystem-space/node-indexed-filesystem-space/respec/testSpace_createAndInit.node-indexed-filesystem-space-v1.respec.d.mts +2 -0
- package/dist/witness/space/node-filesystem-space/node-indexed-filesystem-space/respec/testSpace_createAndInit.node-indexed-filesystem-space-v1.respec.d.mts.map +1 -0
- package/dist/witness/space/node-filesystem-space/node-indexed-filesystem-space/respec/testSpace_createAndInit.node-indexed-filesystem-space-v1.respec.mjs +52 -0
- package/dist/witness/space/node-filesystem-space/node-indexed-filesystem-space/respec/testSpace_createAndInit.node-indexed-filesystem-space-v1.respec.mjs.map +1 -0
- package/dist/witness/space/node-filesystem-space/node-indexed-filesystem-space/respec/testSpace_persistTransformResult.node-indexed-filesystem-space-v1.respec.d.mts +2 -0
- package/dist/witness/space/node-filesystem-space/node-indexed-filesystem-space/respec/testSpace_persistTransformResult.node-indexed-filesystem-space-v1.respec.d.mts.map +1 -0
- package/dist/witness/space/node-filesystem-space/node-indexed-filesystem-space/respec/testSpace_persistTransformResult.node-indexed-filesystem-space-v1.respec.mjs +53 -0
- package/dist/witness/space/node-filesystem-space/node-indexed-filesystem-space/respec/testSpace_persistTransformResult.node-indexed-filesystem-space-v1.respec.mjs.map +1 -0
- package/dist/witness/space/node-filesystem-space/node-indexed-filesystem-space/respec/testSpace_putGetDelete.node-indexed-filesystem-space-v1.respec.d.mts +2 -0
- package/dist/witness/space/node-filesystem-space/node-indexed-filesystem-space/respec/testSpace_putGetDelete.node-indexed-filesystem-space-v1.respec.d.mts.map +1 -0
- package/dist/witness/space/node-filesystem-space/node-indexed-filesystem-space/respec/testSpace_putGetDelete.node-indexed-filesystem-space-v1.respec.mjs +59 -0
- package/dist/witness/space/node-filesystem-space/node-indexed-filesystem-space/respec/testSpace_putGetDelete.node-indexed-filesystem-space-v1.respec.mjs.map +1 -0
- package/dist/witness/space/node-filesystem-space/node-indexed-filesystem-space/respec/testSpace_registerNewIbGib_GetLatest.node-indexed-filesystem-space-v1.respec.d.mts +2 -0
- package/dist/witness/space/node-filesystem-space/node-indexed-filesystem-space/respec/testSpace_registerNewIbGib_GetLatest.node-indexed-filesystem-space-v1.respec.d.mts.map +1 -0
- package/dist/witness/space/node-filesystem-space/node-indexed-filesystem-space/respec/testSpace_registerNewIbGib_GetLatest.node-indexed-filesystem-space-v1.respec.mjs +55 -0
- package/dist/witness/space/node-filesystem-space/node-indexed-filesystem-space/respec/testSpace_registerNewIbGib_GetLatest.node-indexed-filesystem-space-v1.respec.mjs.map +1 -0
- package/dist/witness/space/node-filesystem-space/respec/testSpace_createAndInit.node-filesystem-space-v1.respec.d.mts +2 -0
- package/dist/witness/space/node-filesystem-space/respec/testSpace_createAndInit.node-filesystem-space-v1.respec.d.mts.map +1 -0
- package/dist/witness/space/node-filesystem-space/respec/testSpace_createAndInit.node-filesystem-space-v1.respec.mjs +67 -0
- package/dist/witness/space/node-filesystem-space/respec/testSpace_createAndInit.node-filesystem-space-v1.respec.mjs.map +1 -0
- package/dist/witness/space/node-filesystem-space/respec/testSpace_persistTransformResult.node-filesystem-space-v1.respec.d.mts +2 -0
- package/dist/witness/space/node-filesystem-space/respec/testSpace_persistTransformResult.node-filesystem-space-v1.respec.d.mts.map +1 -0
- package/dist/witness/space/node-filesystem-space/respec/testSpace_persistTransformResult.node-filesystem-space-v1.respec.mjs +67 -0
- package/dist/witness/space/node-filesystem-space/respec/testSpace_persistTransformResult.node-filesystem-space-v1.respec.mjs.map +1 -0
- package/dist/witness/space/node-filesystem-space/respec/testSpace_putGetDelete.node-filesystem-space-v1.respec.d.mts +2 -0
- package/dist/witness/space/node-filesystem-space/respec/testSpace_putGetDelete.node-filesystem-space-v1.respec.d.mts.map +1 -0
- package/dist/witness/space/node-filesystem-space/respec/testSpace_putGetDelete.node-filesystem-space-v1.respec.mjs +68 -0
- package/dist/witness/space/node-filesystem-space/respec/testSpace_putGetDelete.node-filesystem-space-v1.respec.mjs.map +1 -0
- package/dist/witness/space/node-filesystem-space/respec/testSpace_registerNewIbGib_GetLatest.node-filesystem-space-v1.respec.d.mts +2 -0
- package/dist/witness/space/node-filesystem-space/respec/testSpace_registerNewIbGib_GetLatest.node-filesystem-space-v1.respec.d.mts.map +1 -0
- package/dist/witness/space/node-filesystem-space/respec/testSpace_registerNewIbGib_GetLatest.node-filesystem-space-v1.respec.mjs +69 -0
- package/dist/witness/space/node-filesystem-space/respec/testSpace_registerNewIbGib_GetLatest.node-filesystem-space-v1.respec.mjs.map +1 -0
- package/generate-version-file.js +29 -0
- package/package.json +41 -0
- package/src/assumptions.respec.mts +51 -0
- package/src/common/prompt-functions.mts +429 -0
- package/src/constants.mts +2 -0
- package/src/foo.mts +13 -0
- package/src/helpers.mts +5 -0
- package/src/respec-gib.node.mts +201 -0
- package/src/spec-helper.node.respec.mts +50 -0
- package/src/types.mts +0 -0
- package/src/witness/space/metaspace/metaspace-nodespace/metaspace-nodespace-helper.mts +290 -0
- package/src/witness/space/metaspace/metaspace-nodespace/metaspace-nodespace.mts +166 -0
- package/src/witness/space/node-filesystem-space/node-filesystem-space-helper.mts +298 -0
- package/src/witness/space/node-filesystem-space/node-filesystem-space-types.mts +150 -0
- package/src/witness/space/node-filesystem-space/node-filesystem-space-v1.mts +672 -0
- package/src/witness/space/node-filesystem-space/node-indexed-filesystem-space/node-indexed-filesystem-space-constants.mts +6 -0
- package/src/witness/space/node-filesystem-space/node-indexed-filesystem-space/node-indexed-filesystem-space-types.mts +68 -0
- package/src/witness/space/node-filesystem-space/node-indexed-filesystem-space/node-indexed-filesystem-space-v1.mts +403 -0
- package/src/witness/space/node-filesystem-space/node-indexed-filesystem-space/respec/testSpace_createAndInit.node-indexed-filesystem-space-v1.respec.mts +68 -0
- package/src/witness/space/node-filesystem-space/node-indexed-filesystem-space/respec/testSpace_persistTransformResult.node-indexed-filesystem-space-v1.respec.mts +70 -0
- package/src/witness/space/node-filesystem-space/node-indexed-filesystem-space/respec/testSpace_putGetDelete.node-indexed-filesystem-space-v1.respec.mts +72 -0
- package/src/witness/space/node-filesystem-space/node-indexed-filesystem-space/respec/testSpace_registerNewIbGib_GetLatest.node-indexed-filesystem-space-v1.respec.mts +72 -0
- package/src/witness/space/node-filesystem-space/respec/testSpace_createAndInit.node-filesystem-space-v1.respec.mts +87 -0
- package/src/witness/space/node-filesystem-space/respec/testSpace_persistTransformResult.node-filesystem-space-v1.respec.mts +88 -0
- package/src/witness/space/node-filesystem-space/respec/testSpace_putGetDelete.node-filesystem-space-v1.respec.mts +88 -0
- package/src/witness/space/node-filesystem-space/respec/testSpace_registerNewIbGib_GetLatest.node-filesystem-space-v1.respec.mts +90 -0
- package/tsconfig.json +17 -0
- package/tsconfig.test.json +10 -0
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import { extractErrorMsg, getTimestamp, getUUID, pretty } from "@ibgib/helper-gib/dist/helpers/utils-helper.mjs";
|
|
2
|
+
import { getGib, isPrimitive } from "@ibgib/ts-gib/dist/V1/transforms/transform-helper.mjs";
|
|
3
|
+
import { GIB } from "@ibgib/ts-gib/dist/V1/constants.mjs";
|
|
4
|
+
import { getIbAndGib } from "@ibgib/ts-gib/dist/helper.mjs";
|
|
5
|
+
import { fnObs } from "@ibgib/core-gib/dist/common/pubsub/observer/observer-helper.mjs";
|
|
6
|
+
import { isSpaceIb, spaceNameIsValid } from "@ibgib/core-gib/dist/witness/space/space-helper.mjs";
|
|
7
|
+
import { IBGIB_BASE_DIR, IBGIB_BASE_SUBPATH, IBGIB_BIN_SUBPATH, IBGIB_DNA_SUBPATH, IBGIB_ENCODING, IBGIB_IBGIBS_SUBPATH, IBGIB_META_SUBPATH } from "@ibgib/core-gib/dist/witness/space/filesystem-space/filesystem-constants.mjs";
|
|
8
|
+
import { DEFAULT_LOCAL_SPACE_DESCRIPTION, DEFAULT_LOCAL_SPACE_POLLING_INTERVAL_MS, PERSIST_OPTS_AND_RESULTS_IBGIBS_DEFAULT } from "@ibgib/core-gib/dist/witness/space/space-constants.mjs";
|
|
9
|
+
import { GLOBAL_LOG_A_LOT } from "../../../../constants.mjs";
|
|
10
|
+
import { getFnPrompt } from "../../../../common/prompt-functions.mjs";
|
|
11
|
+
import { NodeFilesystemSpace_V1 } from "../../node-filesystem-space/node-filesystem-space-v1.mjs";
|
|
12
|
+
/**
|
|
13
|
+
* used in verbose logging (across all ibgib libs atow)
|
|
14
|
+
*/
|
|
15
|
+
const logalot = GLOBAL_LOG_A_LOT;
|
|
16
|
+
export const fnCreateNewLocalSpace = async ({ allowCancel, spaceName, logalot, }) => {
|
|
17
|
+
const lc = `[fnCreateNewLocalSpace]`;
|
|
18
|
+
try {
|
|
19
|
+
if (logalot) {
|
|
20
|
+
console.log(`${lc} starting... (I: 15bcc16f4f3f9e40e743931a3965ff22)`);
|
|
21
|
+
}
|
|
22
|
+
if (spaceName && !spaceNameIsValid(spaceName)) {
|
|
23
|
+
throw new Error(`spaceName (${spaceName}) is invalid. (E: 820b291cccf9f405f9e0cce87143e323)`);
|
|
24
|
+
// throw because this is used in RCLI and automated testing...
|
|
25
|
+
}
|
|
26
|
+
if (!spaceName) {
|
|
27
|
+
const promptName = async () => {
|
|
28
|
+
const fnPrompt = getFnPrompt();
|
|
29
|
+
const resName = await fnPrompt({
|
|
30
|
+
title: 'greetings program', msg: `all of your data is stored locally on your device's "local space".
|
|
31
|
+
|
|
32
|
+
so name your space with alphanumerics & underscores, like 'phone_alice' or 'web_bob_foo', or leave blank and get a random name.
|
|
33
|
+
|
|
34
|
+
Enter space name:
|
|
35
|
+
`
|
|
36
|
+
});
|
|
37
|
+
if (resName === '' && !allowCancel) {
|
|
38
|
+
spaceName = 'space_' + (await getUUID()).slice(0, 10);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
if (resName && spaceNameIsValid(resName)) {
|
|
42
|
+
spaceName = resName;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
// ...prompt for name
|
|
47
|
+
await promptName();
|
|
48
|
+
if (!spaceName) {
|
|
49
|
+
return undefined; /* <<<< returns early */
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
// ...create in memory with defaults
|
|
53
|
+
const newLocalSpace = new NodeFilesystemSpace_V1(/*initialData*/ {
|
|
54
|
+
version: '1',
|
|
55
|
+
uuid: await getUUID(),
|
|
56
|
+
isTjp: true,
|
|
57
|
+
timestamp: getTimestamp(),
|
|
58
|
+
name: spaceName,
|
|
59
|
+
baseDir: IBGIB_BASE_DIR,
|
|
60
|
+
spaceSubPath: spaceName,
|
|
61
|
+
baseSubPath: IBGIB_BASE_SUBPATH,
|
|
62
|
+
binSubPath: IBGIB_BIN_SUBPATH,
|
|
63
|
+
dnaSubPath: IBGIB_DNA_SUBPATH,
|
|
64
|
+
ibgibsSubPath: IBGIB_IBGIBS_SUBPATH,
|
|
65
|
+
metaSubPath: IBGIB_META_SUBPATH,
|
|
66
|
+
encoding: IBGIB_ENCODING,
|
|
67
|
+
persistOptsAndResultIbGibs: PERSIST_OPTS_AND_RESULTS_IBGIBS_DEFAULT,
|
|
68
|
+
validateIbGibAddrsMatchIbGibs: true,
|
|
69
|
+
trace: false,
|
|
70
|
+
description: DEFAULT_LOCAL_SPACE_DESCRIPTION,
|
|
71
|
+
allowPrimitiveArgs: false,
|
|
72
|
+
catchAllErrors: true,
|
|
73
|
+
longPollingIntervalMs: DEFAULT_LOCAL_SPACE_POLLING_INTERVAL_MS,
|
|
74
|
+
}, /*initialRel8ns*/ undefined);
|
|
75
|
+
if (logalot) {
|
|
76
|
+
console.log(`${lc} localSpace.ib: ${newLocalSpace.ib}`);
|
|
77
|
+
}
|
|
78
|
+
if (logalot) {
|
|
79
|
+
console.log(`${lc} localSpace.gib: ${newLocalSpace.gib} (before sha256v1)`);
|
|
80
|
+
}
|
|
81
|
+
if (logalot) {
|
|
82
|
+
console.log(`${lc} localSpace.data: ${pretty(newLocalSpace.data || 'falsy')}`);
|
|
83
|
+
}
|
|
84
|
+
if (logalot) {
|
|
85
|
+
console.log(`${lc} localSpace.rel8ns: ${pretty(newLocalSpace.rel8ns || 'falsy')}`);
|
|
86
|
+
}
|
|
87
|
+
// trying out with tjp, can't remember why didn't have it except for
|
|
88
|
+
// backwards compatability which i'm no longer shooting for (will be
|
|
89
|
+
// able to project old spaces to new ones i believe)
|
|
90
|
+
// newLocalSpace.gib = await getGib({ ibGib: newLocalSpace, hasTjp: false });
|
|
91
|
+
newLocalSpace.gib = await getGib({ ibGib: newLocalSpace, hasTjp: true });
|
|
92
|
+
if (newLocalSpace.gib === GIB) {
|
|
93
|
+
throw new Error(`localSpace.gib not updated correctly.`);
|
|
94
|
+
}
|
|
95
|
+
if (logalot) {
|
|
96
|
+
console.log(`${lc} localSpace.gib: ${newLocalSpace.gib} (after sha256v1)`);
|
|
97
|
+
}
|
|
98
|
+
return newLocalSpace;
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
102
|
+
throw error;
|
|
103
|
+
}
|
|
104
|
+
finally {
|
|
105
|
+
if (logalot) {
|
|
106
|
+
console.log(`${lc} complete.`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
export const fnDtoToSpace_nodeFilesystem = (spaceDto) => {
|
|
111
|
+
return Promise.resolve(NodeFilesystemSpace_V1.createFromDto(spaceDto));
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* wrapper around metaspace.syncIbGibs
|
|
115
|
+
* @param param0
|
|
116
|
+
* @returns
|
|
117
|
+
*/
|
|
118
|
+
export async function doSync_awaitAllSagas({ addr, metaspace, localSpace, syncSpaces, sagaReporter, verbose, }) {
|
|
119
|
+
const lc = `[${doSync_awaitAllSagas.name}]`;
|
|
120
|
+
try {
|
|
121
|
+
if (logalot || verbose) {
|
|
122
|
+
console.log(`${lc} starting... (I: 6110576156c3f9a946626ff299870324)`);
|
|
123
|
+
}
|
|
124
|
+
const { ib, gib } = getIbAndGib({ ibGibAddr: addr });
|
|
125
|
+
if (isPrimitive({ gib })) {
|
|
126
|
+
throw new Error(`can't sync primitive ibgib (${addr}) (E: 7f87261b5378e38d0f237afa35f52d24)`);
|
|
127
|
+
}
|
|
128
|
+
if (isSpaceIb({ ib })) {
|
|
129
|
+
throw new Error(`can't sync entire space ibgib (${addr}) (E: 00f8d70c4b6c7f8c3c8b26cf097ba724)`);
|
|
130
|
+
}
|
|
131
|
+
if (syncSpaces.length === 0) {
|
|
132
|
+
throw new Error(`syncSpaces required (E: 6015c1c2920fa5301defb91933998d24)`);
|
|
133
|
+
}
|
|
134
|
+
if (syncSpaces.some(x => !x.witness)) {
|
|
135
|
+
throw new Error(`(UNEXPECTED) syncSpaces.some(x => !x.witness)? sync spaces should all be witnesses (and have a witness function). these are not supposed to be just dtos (with ib, gib, data, rel8ns props). (E: 2a670f794b065576ee6df6cf22ffb324)`);
|
|
136
|
+
}
|
|
137
|
+
if (verbose) {
|
|
138
|
+
await sagaReporter('getDependencyGraph starting... (I: d20cf9d59432492ebafdc206e1ecb5dc)', null);
|
|
139
|
+
}
|
|
140
|
+
const dependencyGraph = await metaspace.getDependencyGraph({
|
|
141
|
+
space: localSpace,
|
|
142
|
+
ibGibAddr: addr,
|
|
143
|
+
live: true,
|
|
144
|
+
msBetweenRetries: 1_000,
|
|
145
|
+
});
|
|
146
|
+
if (verbose) {
|
|
147
|
+
await sagaReporter('getDependencyGraph complete. (I: a816ca4d1612409a914661bfe97bb4d1)', null);
|
|
148
|
+
await sagaReporter('syncIbGibs spinning off... (I: 83c8502f93ee46b7ae103d8ff5fa9b42)', null);
|
|
149
|
+
}
|
|
150
|
+
const sagas = await metaspace.syncIbGibs({
|
|
151
|
+
dependencyGraphIbGibs: Object.values(dependencyGraph),
|
|
152
|
+
syncSpaceIbGibs: syncSpaces,
|
|
153
|
+
localSpace,
|
|
154
|
+
}) ?? [];
|
|
155
|
+
if (sagas.length === 0) {
|
|
156
|
+
throw new Error(`(UNEXPECTED) metaspace.syncIbGibs returned undefined (no sagas)? (E: 14989ed4c654eb9419a1faaf35a3e224)`);
|
|
157
|
+
}
|
|
158
|
+
if (verbose) {
|
|
159
|
+
await sagaReporter('syncIbGibs spin off complete. these are not yet done, it/they are just spun off and going. (I: b99dd5938064415d87a5420dc37dc1b1)', sagas.at(0) ?? null);
|
|
160
|
+
}
|
|
161
|
+
let sagaCount = sagas.length;
|
|
162
|
+
let sagaErrorCounter = 0;
|
|
163
|
+
/**
|
|
164
|
+
* using this during debugging...
|
|
165
|
+
*/
|
|
166
|
+
const sagaErrorMsgs = [];
|
|
167
|
+
let sagaCompleteOrErrorCounter = 0;
|
|
168
|
+
let allSagasCompletePromise = new Promise((resolve, reject) => {
|
|
169
|
+
const interval = setInterval(async () => {
|
|
170
|
+
if (sagaCompleteOrErrorCounter === sagaCount) {
|
|
171
|
+
if (sagaErrorCounter > 0) {
|
|
172
|
+
reject(`saga had errors: ${sagaErrorMsgs.join('|')} (E: 15d75f475612492e8d5d0bcf947fc72b)`);
|
|
173
|
+
}
|
|
174
|
+
clearInterval(interval);
|
|
175
|
+
resolve();
|
|
176
|
+
}
|
|
177
|
+
}, 500);
|
|
178
|
+
});
|
|
179
|
+
const fnIncCompleteOrError = async (saga) => {
|
|
180
|
+
const lcInner = `${lc}[fnIncCompleteOrError]`;
|
|
181
|
+
if (logalot || verbose) {
|
|
182
|
+
console.log(`${lcInner} starting... (I: 782b3304e67d4ebdb0acce8147a9cd9f)`);
|
|
183
|
+
}
|
|
184
|
+
try {
|
|
185
|
+
sagaCompleteOrErrorCounter++;
|
|
186
|
+
let updateText;
|
|
187
|
+
if (sagaCompleteOrErrorCounter < sagaCount) {
|
|
188
|
+
updateText = `saga (${saga.sagaId}) complete or errored. ONLY SOME (${sagaCompleteOrErrorCounter}/${sagaCount}) have completed or errored. still more to go...`;
|
|
189
|
+
}
|
|
190
|
+
else if (sagaCompleteOrErrorCounter === sagaCount) {
|
|
191
|
+
updateText = `saga (${saga.sagaId}) complete or errored. ALL ${sagaCount} sync sagas COMPLETE OR ERRORED.`;
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
debugger; // unexpected error state. sagaCompleteOrErrorCounter > sagaCount
|
|
195
|
+
updateText = `uhh, there is an error here. we have incremented sagaCompleteOrErrorCounter (${sagaCompleteOrErrorCounter}) to be greater than sagaCount (${sagaCount}) (E: 4d8373ee93f2466ab9e5c382ae9a3218)`;
|
|
196
|
+
}
|
|
197
|
+
if (logalot || verbose) {
|
|
198
|
+
console.log(`${lc} ${updateText} (I: 976c3deaf7f1a592680f3364a0793524)`);
|
|
199
|
+
await sagaReporter(`${lcInner} ${updateText}`, saga);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
catch (error) {
|
|
203
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
204
|
+
throw error;
|
|
205
|
+
}
|
|
206
|
+
finally {
|
|
207
|
+
if (logalot || verbose) {
|
|
208
|
+
console.log(`${lc}[fnIncCompleteOrError] complete. (I: 3eb96688a5880fe039445fc3d2374b24)`);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
for (let i = 0; i < sagas.length; i++) {
|
|
213
|
+
const saga = sagas[i];
|
|
214
|
+
let subscription = await saga.syncStatus$.subscribe(fnObs({
|
|
215
|
+
next: async (status) => {
|
|
216
|
+
// debugger; // syncStatus$ fnobs next
|
|
217
|
+
if (logalot || verbose) {
|
|
218
|
+
console.log(`${lc} console.dir(status)... (I: 87589e683c7be2067d3596a509deaf24)`);
|
|
219
|
+
console.dir(status);
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
let statusCode = status.data?.statusCode;
|
|
223
|
+
if (statusCode === "already_synced") {
|
|
224
|
+
process.stdout.write('.');
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
console.log(statusCode);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
},
|
|
231
|
+
complete: async () => {
|
|
232
|
+
// debugger; // syncStatus$ fnobs complete before fnIncCompleteOrError
|
|
233
|
+
if (logalot || verbose) {
|
|
234
|
+
console.log(`${lc}[saga complete] triggered for saga (${saga.spaceId}, ${saga.multiSpaceOpId}). (I: 237a2d0db5944359b90335c83c9df60f)`);
|
|
235
|
+
}
|
|
236
|
+
await fnIncCompleteOrError(saga);
|
|
237
|
+
await subscription.unsubscribe();
|
|
238
|
+
},
|
|
239
|
+
error: async (err) => {
|
|
240
|
+
// debugger; // syncStatus$ fnobs error before fnIncCompleteOrError
|
|
241
|
+
const errorMsg = extractErrorMsg(err);
|
|
242
|
+
sagaErrorMsgs.push(errorMsg);
|
|
243
|
+
if (errorMsg.includes('EAI_AGAIN')) {
|
|
244
|
+
console.error(`this error may be because of no internet connection. ${errorMsg}`);
|
|
245
|
+
}
|
|
246
|
+
console.error(`${lc}[error] err: ${errorMsg} (E: fb1b0af934354cc6b41cfe455d1ba12d)`);
|
|
247
|
+
sagaErrorCounter++;
|
|
248
|
+
await fnIncCompleteOrError(saga);
|
|
249
|
+
await subscription.unsubscribe();
|
|
250
|
+
// sagaCompleteOrErrorCounter++;
|
|
251
|
+
}
|
|
252
|
+
}));
|
|
253
|
+
}
|
|
254
|
+
await allSagasCompletePromise;
|
|
255
|
+
return sagas;
|
|
256
|
+
}
|
|
257
|
+
catch (error) {
|
|
258
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
259
|
+
throw error;
|
|
260
|
+
}
|
|
261
|
+
finally {
|
|
262
|
+
if (logalot || verbose) {
|
|
263
|
+
console.log(`${lc} complete.`);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
//# sourceMappingURL=metaspace-nodespace-helper.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metaspace-nodespace-helper.mjs","sourceRoot":"","sources":["../../../../../src/witness/space/metaspace/metaspace-nodespace/metaspace-nodespace-helper.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,iDAAiD,CAAC;AACjH,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,uDAAuD,CAAC;AAC5F,OAAO,EAAE,GAAG,EAAE,MAAM,qCAAqC,CAAC;AAG1D,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAG5D,OAAO,EAAE,KAAK,EAAE,MAAM,iEAAiE,CAAC;AAMxF,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,qDAAqD,CAAC;AAClG,OAAO,EACH,cAAc,EAAE,kBAAkB,EAAE,iBAAiB,EACrD,iBAAiB,EAAE,cAAc,EAAE,oBAAoB,EAAE,kBAAkB,EAC9E,MAAM,8EAA8E,CAAC;AACtF,OAAO,EACH,+BAA+B,EAAE,uCAAuC,EACxE,uCAAuC,EAC1C,MAAM,wDAAwD,CAAC;AAEhE,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAC;AACtE,OAAO,EAAE,sBAAsB,EAAE,MAAM,0DAA0D,CAAC;AAGlG;;GAEG;AACH,MAAM,OAAO,GAAG,gBAAgB,CAAC;AAEjC,MAAM,CAAC,MAAM,qBAAqB,GAA8B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BACpC,CAAC;aACJ,CAAC,CAAC,CAAC;QACR,CAAC;QACD,MAAM,uBAAuB,CAAC;QAC9B,OAAO,KAAK,CAAC;IACjB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACjD,MAAM,KAAK,CAAC;IAChB,CAAC;YAAS,CAAC;QACP,IAAI,OAAO,IAAI,OAAO,EAAE,CAAC;YAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;QAAC,CAAC;IAC/D,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module node-metaspace driven by a node+fs storage substrate
|
|
3
|
+
*
|
|
4
|
+
* a metaspace is a space of spaces. it adds/removes spaces and does
|
|
5
|
+
* inter-spatial composition related things. it's similar to what people think
|
|
6
|
+
* of in terms of a node in a p2p network.
|
|
7
|
+
*/
|
|
8
|
+
import { IbGibSpaceAny } from '@ibgib/core-gib/dist/witness/space/space-base-v1.mjs';
|
|
9
|
+
import { IbGibCacheService } from '@ibgib/core-gib/dist/common/cache/cache-types.mjs';
|
|
10
|
+
import { MetaspaceBase } from '@ibgib/core-gib/dist/witness/space/metaspace/metaspace-base.mjs';
|
|
11
|
+
import { MetaspaceFactory } from '@ibgib/core-gib/dist/witness/space/metaspace/metaspace-types.mjs';
|
|
12
|
+
/**
|
|
13
|
+
* All-purpose mega service (todo: which we'll need to break up!) to interact
|
|
14
|
+
* with ibgibs at the app/device level.
|
|
15
|
+
*
|
|
16
|
+
* This works with the local app user space.
|
|
17
|
+
*
|
|
18
|
+
* ## regarding special ibgibs
|
|
19
|
+
*
|
|
20
|
+
* Special ibgibs' behaviors are what hold in other apps configuration data.
|
|
21
|
+
* Of course the difference is that most special ibgibs can leverage the "on-chain"
|
|
22
|
+
* functionality of "regular" ibgibs.
|
|
23
|
+
*
|
|
24
|
+
* There are a couple meta ibgibs (which I also call "special"):
|
|
25
|
+
* * roots^gib
|
|
26
|
+
* * tracks other special root^gib ibgibs, which are like local app-level indexes.
|
|
27
|
+
* * tags^gib
|
|
28
|
+
* * tracks other special tag^gib ibgibs, which you can apply to any ibgib
|
|
29
|
+
* * latest^gib
|
|
30
|
+
* * tracks mappings between tjp -> latest ib^gib address
|
|
31
|
+
* * ephemeral (deletes past rel8ns and past ibGib frames)
|
|
32
|
+
* * ...
|
|
33
|
+
*
|
|
34
|
+
* ## regarding latest ibgibs
|
|
35
|
+
*
|
|
36
|
+
* The tjp (temporal junction point) defines atow the beginning of an ibGib
|
|
37
|
+
* timeline. it's like the birthday for an ibGib. (Or you can think if it as
|
|
38
|
+
* the id for the stream of ibgib frames in a given timeline.)
|
|
39
|
+
*
|
|
40
|
+
* The latest ibGib in that timeline is also special, because it's often what
|
|
41
|
+
* you want to work with.
|
|
42
|
+
*
|
|
43
|
+
* So ideally, when an ibgib, A, has a tjp A1, and it is updated to A2, A3, An
|
|
44
|
+
* via `mut8` and/or `rel8` transforms, that ibgib creates a single timeline.
|
|
45
|
+
* This service attempts to track the relationship between that starting tjp
|
|
46
|
+
* address and its corresponding latest frame in that timeline, i.e., A1 -> An.
|
|
47
|
+
*
|
|
48
|
+
* ### mapping persistence implementation details
|
|
49
|
+
*
|
|
50
|
+
* The latest ibGib service is backed by a special ibgib that maintains the
|
|
51
|
+
* mapping index. It does this by rel8-ing that special backing ibgib via the
|
|
52
|
+
* tjp pointer, e.g. [special latest ibgib^XXX000].rel8ns[A^TJP123] ===
|
|
53
|
+
* [A^N12345] . It does this via the ib^gib content address pointer, so this
|
|
54
|
+
* becomes a mapping from A^TJP123 to A^N12345.
|
|
55
|
+
*
|
|
56
|
+
* This backing ibGib is special (even for special ibGibs) in that:
|
|
57
|
+
* * it does not relate itself with the current root of the application
|
|
58
|
+
* * it does not maintain references to its past (i.e. rel8ns['past'] === [])
|
|
59
|
+
* * it DELETES its previous incarnation from the files service
|
|
60
|
+
*
|
|
61
|
+
* In other words, this service is meant to be as ephemeral as possible. I am
|
|
62
|
+
* keeping it as an ibGib and not some other data format (like straight in
|
|
63
|
+
* storage/some other db) because I've found this is often useful and what I end
|
|
64
|
+
* up doing anyway to leverage other ibgib behavior. For example, in the future
|
|
65
|
+
* it may be good to take snapshots, which is a simple copy operation of the
|
|
66
|
+
* file persistence.
|
|
67
|
+
*
|
|
68
|
+
* ### current naive implementation notes
|
|
69
|
+
*
|
|
70
|
+
* questions:
|
|
71
|
+
* * What do we want to do if we can't locate an ibGib record?
|
|
72
|
+
* * How/when do we want to alert the user/our own code that we've found
|
|
73
|
+
* multiple timelines for an ibGib with a tjp (usually a thing we want to
|
|
74
|
+
* avoid)?
|
|
75
|
+
* * Who do we want to notify when new ibGibs arrive?
|
|
76
|
+
* * How often do we want to check external sources for latest?
|
|
77
|
+
* * When do we get to merging ibGib timelines?
|
|
78
|
+
*
|
|
79
|
+
* This is behavior that is somewhat taken care of, e.g. in git, with the HEAD
|
|
80
|
+
* pointer for a repo. But we're talking about here basically as a metarepo or
|
|
81
|
+
* "repo of repos", and unlike git, we don't want our HEAD metadata living "off
|
|
82
|
+
* chain" (outside of the DLT itself that it's modifying). So eventually, what
|
|
83
|
+
* we want is just like what we want with ALL ibGibs: perspective. From "the
|
|
84
|
+
* app"'s perspective, the latest is mapped. But really, apps can't view slices
|
|
85
|
+
* of ibGib graphs in all sorts of interesting ways and still be productive &
|
|
86
|
+
* beneficial to the ecosystem as a whole.
|
|
87
|
+
*/
|
|
88
|
+
export declare class Metaspace_Nodespace extends MetaspaceBase {
|
|
89
|
+
protected cacheSvc: IbGibCacheService | undefined;
|
|
90
|
+
protected lc: string;
|
|
91
|
+
get zeroSpace(): IbGibSpaceAny;
|
|
92
|
+
constructor(cacheSvc: IbGibCacheService | undefined);
|
|
93
|
+
protected initializeMetaspaceFactory({ metaspaceFactory }: {
|
|
94
|
+
metaspaceFactory: MetaspaceFactory;
|
|
95
|
+
}): Promise<void>;
|
|
96
|
+
initializeZeroSpace(): Promise<void>;
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=metaspace-nodespace.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metaspace-nodespace.d.mts","sourceRoot":"","sources":["../../../../../src/witness/space/metaspace/metaspace-nodespace/metaspace-nodespace.mts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,sDAAsD,CAAC;AACrF,OAAO,EAAE,iBAAiB,EAAE,MAAM,mDAAmD,CAAC;AACtF,OAAO,EAAE,aAAa,EAAE,MAAM,iEAAiE,CAAC;AAChG,OAAO,EAAE,gBAAgB,EAAE,MAAM,kEAAkE,CAAC;AAQpG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2EG;AACH,qBAAa,mBAAoB,SAAQ,aAAa;IAiBlD,SAAS,CAAC,QAAQ,EAAE,iBAAiB,GAAG,SAAS;IAdnD,SAAS,CAAC,EAAE,EAAE,MAAM,CAAmC;IAEvD,IAAI,SAAS,IAAI,aAAa,CAO7B;gBAKW,QAAQ,EAAE,iBAAiB,GAAG,SAAS;cAanC,0BAA0B,CAAC,EAAE,gBAAgB,EAAE,EAAE;QAC/D,gBAAgB,EAAE,gBAAgB,CAAC;KACpC,GAAG,OAAO,CAAC,IAAI,CAAC;IAwBX,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;CAa3C"}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module node-metaspace driven by a node+fs storage substrate
|
|
3
|
+
*
|
|
4
|
+
* a metaspace is a space of spaces. it adds/removes spaces and does
|
|
5
|
+
* inter-spatial composition related things. it's similar to what people think
|
|
6
|
+
* of in terms of a node in a p2p network.
|
|
7
|
+
*/
|
|
8
|
+
import { extractErrorMsg } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
9
|
+
import { MetaspaceBase } from '@ibgib/core-gib/dist/witness/space/metaspace/metaspace-base.mjs';
|
|
10
|
+
import { GLOBAL_LOG_A_LOT, GLOBAL_TIMER_NAME } from '../../../../constants.mjs';
|
|
11
|
+
import { fnCreateNewLocalSpace, fnDtoToSpace_nodeFilesystem } from './metaspace-nodespace-helper.mjs';
|
|
12
|
+
import { NodeFilesystemSpace_V1 } from '../../node-filesystem-space/node-filesystem-space-v1.mjs';
|
|
13
|
+
const logalot = GLOBAL_LOG_A_LOT;
|
|
14
|
+
/**
|
|
15
|
+
* All-purpose mega service (todo: which we'll need to break up!) to interact
|
|
16
|
+
* with ibgibs at the app/device level.
|
|
17
|
+
*
|
|
18
|
+
* This works with the local app user space.
|
|
19
|
+
*
|
|
20
|
+
* ## regarding special ibgibs
|
|
21
|
+
*
|
|
22
|
+
* Special ibgibs' behaviors are what hold in other apps configuration data.
|
|
23
|
+
* Of course the difference is that most special ibgibs can leverage the "on-chain"
|
|
24
|
+
* functionality of "regular" ibgibs.
|
|
25
|
+
*
|
|
26
|
+
* There are a couple meta ibgibs (which I also call "special"):
|
|
27
|
+
* * roots^gib
|
|
28
|
+
* * tracks other special root^gib ibgibs, which are like local app-level indexes.
|
|
29
|
+
* * tags^gib
|
|
30
|
+
* * tracks other special tag^gib ibgibs, which you can apply to any ibgib
|
|
31
|
+
* * latest^gib
|
|
32
|
+
* * tracks mappings between tjp -> latest ib^gib address
|
|
33
|
+
* * ephemeral (deletes past rel8ns and past ibGib frames)
|
|
34
|
+
* * ...
|
|
35
|
+
*
|
|
36
|
+
* ## regarding latest ibgibs
|
|
37
|
+
*
|
|
38
|
+
* The tjp (temporal junction point) defines atow the beginning of an ibGib
|
|
39
|
+
* timeline. it's like the birthday for an ibGib. (Or you can think if it as
|
|
40
|
+
* the id for the stream of ibgib frames in a given timeline.)
|
|
41
|
+
*
|
|
42
|
+
* The latest ibGib in that timeline is also special, because it's often what
|
|
43
|
+
* you want to work with.
|
|
44
|
+
*
|
|
45
|
+
* So ideally, when an ibgib, A, has a tjp A1, and it is updated to A2, A3, An
|
|
46
|
+
* via `mut8` and/or `rel8` transforms, that ibgib creates a single timeline.
|
|
47
|
+
* This service attempts to track the relationship between that starting tjp
|
|
48
|
+
* address and its corresponding latest frame in that timeline, i.e., A1 -> An.
|
|
49
|
+
*
|
|
50
|
+
* ### mapping persistence implementation details
|
|
51
|
+
*
|
|
52
|
+
* The latest ibGib service is backed by a special ibgib that maintains the
|
|
53
|
+
* mapping index. It does this by rel8-ing that special backing ibgib via the
|
|
54
|
+
* tjp pointer, e.g. [special latest ibgib^XXX000].rel8ns[A^TJP123] ===
|
|
55
|
+
* [A^N12345] . It does this via the ib^gib content address pointer, so this
|
|
56
|
+
* becomes a mapping from A^TJP123 to A^N12345.
|
|
57
|
+
*
|
|
58
|
+
* This backing ibGib is special (even for special ibGibs) in that:
|
|
59
|
+
* * it does not relate itself with the current root of the application
|
|
60
|
+
* * it does not maintain references to its past (i.e. rel8ns['past'] === [])
|
|
61
|
+
* * it DELETES its previous incarnation from the files service
|
|
62
|
+
*
|
|
63
|
+
* In other words, this service is meant to be as ephemeral as possible. I am
|
|
64
|
+
* keeping it as an ibGib and not some other data format (like straight in
|
|
65
|
+
* storage/some other db) because I've found this is often useful and what I end
|
|
66
|
+
* up doing anyway to leverage other ibgib behavior. For example, in the future
|
|
67
|
+
* it may be good to take snapshots, which is a simple copy operation of the
|
|
68
|
+
* file persistence.
|
|
69
|
+
*
|
|
70
|
+
* ### current naive implementation notes
|
|
71
|
+
*
|
|
72
|
+
* questions:
|
|
73
|
+
* * What do we want to do if we can't locate an ibGib record?
|
|
74
|
+
* * How/when do we want to alert the user/our own code that we've found
|
|
75
|
+
* multiple timelines for an ibGib with a tjp (usually a thing we want to
|
|
76
|
+
* avoid)?
|
|
77
|
+
* * Who do we want to notify when new ibGibs arrive?
|
|
78
|
+
* * How often do we want to check external sources for latest?
|
|
79
|
+
* * When do we get to merging ibGib timelines?
|
|
80
|
+
*
|
|
81
|
+
* This is behavior that is somewhat taken care of, e.g. in git, with the HEAD
|
|
82
|
+
* pointer for a repo. But we're talking about here basically as a metarepo or
|
|
83
|
+
* "repo of repos", and unlike git, we don't want our HEAD metadata living "off
|
|
84
|
+
* chain" (outside of the DLT itself that it's modifying). So eventually, what
|
|
85
|
+
* we want is just like what we want with ALL ibGibs: perspective. From "the
|
|
86
|
+
* app"'s perspective, the latest is mapped. But really, apps can't view slices
|
|
87
|
+
* of ibGib graphs in all sorts of interesting ways and still be productive &
|
|
88
|
+
* beneficial to the ecosystem as a whole.
|
|
89
|
+
*/
|
|
90
|
+
export class Metaspace_Nodespace extends MetaspaceBase {
|
|
91
|
+
cacheSvc;
|
|
92
|
+
// we won't get an object back, only a DTO ibGib essentially
|
|
93
|
+
lc = `[${Metaspace_Nodespace.name}]`;
|
|
94
|
+
get zeroSpace() {
|
|
95
|
+
const lc = `[${this.lc}][get zeroSpace]`;
|
|
96
|
+
if (this.metaspaceFactory.fnZeroSpaceFactory) {
|
|
97
|
+
return this.metaspaceFactory.fnZeroSpaceFactory();
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
throw new Error(`${lc} (UNEXPECTED) this.metaspaceFactory.fnZeroSpaceFactory falsy. not initialized? (E: 9e6c6954dacd868b18c9f34a71e63523)`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
constructor(
|
|
104
|
+
// public modalController: ModalController,
|
|
105
|
+
// public alertController: AlertController,
|
|
106
|
+
cacheSvc) {
|
|
107
|
+
super(cacheSvc);
|
|
108
|
+
this.cacheSvc = cacheSvc;
|
|
109
|
+
const lc = `${this.lc}[ctor]`;
|
|
110
|
+
if (logalot) {
|
|
111
|
+
console.log(`${lc}${GLOBAL_TIMER_NAME}`);
|
|
112
|
+
console.timeLog(GLOBAL_TIMER_NAME);
|
|
113
|
+
console.log(`${lc} created. (I: 5690dc2ebf774df3a442bd463dee7455)`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
async initializeMetaspaceFactory({ metaspaceFactory }) {
|
|
117
|
+
const lc = `[${this.initializeMetaspaceFactory.name}]`;
|
|
118
|
+
try {
|
|
119
|
+
if (logalot) {
|
|
120
|
+
console.log(`${lc} starting... (I: 5a29670439ac47634dcdfe25225c8223)`);
|
|
121
|
+
}
|
|
122
|
+
await super.initializeMetaspaceFactory({ metaspaceFactory });
|
|
123
|
+
metaspaceFactory.fnDefaultLocalSpaceFactory ??= (opts) => fnCreateNewLocalSpace(opts);
|
|
124
|
+
metaspaceFactory.fnDtoToSpace ??= (spaceDto) => fnDtoToSpace_nodeFilesystem(spaceDto);
|
|
125
|
+
this.metaspaceFactory.fnZeroSpaceFactory ??= () => {
|
|
126
|
+
// default to node space
|
|
127
|
+
const zeroSpace = new NodeFilesystemSpace_V1(/*initialData*/ undefined, /*initialRel8ns*/ undefined);
|
|
128
|
+
zeroSpace.gib = 'gib';
|
|
129
|
+
return zeroSpace;
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
133
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
134
|
+
throw error;
|
|
135
|
+
}
|
|
136
|
+
finally {
|
|
137
|
+
if (logalot) {
|
|
138
|
+
console.log(`${lc} complete.`);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
async initializeZeroSpace() {
|
|
143
|
+
const lc = `[${this.initializeZeroSpace.name}]`;
|
|
144
|
+
try {
|
|
145
|
+
if (logalot) {
|
|
146
|
+
console.log(`${lc} starting... (I: a3364e9601c70c8163e67868e5d67723)`);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
catch (error) {
|
|
150
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
151
|
+
throw error;
|
|
152
|
+
}
|
|
153
|
+
finally {
|
|
154
|
+
if (logalot) {
|
|
155
|
+
console.log(`${lc} complete.`);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
//# sourceMappingURL=metaspace-nodespace.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metaspace-nodespace.mjs","sourceRoot":"","sources":["../../../../../src/witness/space/metaspace/metaspace-nodespace/metaspace-nodespace.mts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,iDAAiD,CAAC;AAGlF,OAAO,EAAE,aAAa,EAAE,MAAM,iEAAiE,CAAC;AAGhG,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAChF,OAAO,EAAE,qBAAqB,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AACtG,OAAO,EAAE,sBAAsB,EAAE,MAAM,0DAA0D,CAAC;AAElG,MAAM,OAAO,GAAG,gBAAgB,CAAC;AAEjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2EG;AACH,MAAM,OAAO,mBAAoB,SAAQ,aAAa;IAiBxC;IAfZ,4DAA4D;IAClD,EAAE,GAAW,IAAI,mBAAmB,CAAC,IAAI,GAAG,CAAC;IAEvD,IAAI,SAAS;QACX,MAAM,EAAE,GAAG,IAAI,IAAI,CAAC,EAAE,kBAAkB,CAAC;QACzC,IAAI,IAAI,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,CAAC;YAC7C,OAAO,IAAI,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,CAAC;QACpD,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,GAAG,EAAE,sHAAsH,CAAC,CAAC;QAC/I,CAAC;IACH,CAAC;IAED;IACE,2CAA2C;IAC3C,2CAA2C;IACjC,QAAuC;QAGjD,KAAK,CAAC,QAAQ,CAAC,CAAC;QAHN,aAAQ,GAAR,QAAQ,CAA+B;QAIjD,MAAM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,CAAC;gBAAS,CAAC;YACT,IAAI,OAAO,EAAE,CAAC;gBAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;YAAC,CAAC;QAClD,CAAC;IACH,CAAC;IAED,KAAK,CAAC,mBAAmB;QACvB,MAAM,EAAE,GAAG,IAAI,IAAI,CAAC,mBAAmB,CAAC,IAAI,GAAG,CAAC;QAChD,IAAI,CAAC;YACH,IAAI,OAAO,EAAE,CAAC;gBAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,oDAAoD,CAAC,CAAC;YAAC,CAAC;QAE1F,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YACjD,MAAM,KAAK,CAAC;QACd,CAAC;gBAAS,CAAC;YACT,IAAI,OAAO,EAAE,CAAC;gBAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;YAAC,CAAC;QAClD,CAAC;IACH,CAAC;CAEF"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module node-filesystem-space-helper
|
|
3
|
+
*
|
|
4
|
+
*/
|
|
5
|
+
import { NodeFilesystemSpace_V1 } from './node-filesystem-space-v1.mjs';
|
|
6
|
+
import { FileDataInfo, FileEncoding } from './node-filesystem-space-types.mjs';
|
|
7
|
+
/**
|
|
8
|
+
* tries to read the given path. if fails **FOR ANY REASON**, @returns `null`.
|
|
9
|
+
*
|
|
10
|
+
* does not throw
|
|
11
|
+
*
|
|
12
|
+
* @returns file contents as string or `null`
|
|
13
|
+
*/
|
|
14
|
+
export declare function tryRead({ path, directory, encoding, }: {
|
|
15
|
+
path: string;
|
|
16
|
+
directory: string;
|
|
17
|
+
encoding: string;
|
|
18
|
+
}): Promise<string | Uint8Array | null>;
|
|
19
|
+
export declare function tryRead_bin({ path, directory, encoding, }: {
|
|
20
|
+
path: string;
|
|
21
|
+
directory: string;
|
|
22
|
+
encoding: string;
|
|
23
|
+
}): Promise<FileDataInfo | null>;
|
|
24
|
+
/**
|
|
25
|
+
* basic validation for a node fs space ibgib
|
|
26
|
+
*/
|
|
27
|
+
export declare function validateNodeFilesystemSpace_V1Intrinsically({ space }: {
|
|
28
|
+
space: NodeFilesystemSpace_V1<any, any>;
|
|
29
|
+
}): Promise<string[] | null>;
|
|
30
|
+
/**
|
|
31
|
+
* gets the data and encoding of a given {@link inputPath} if that file exists.
|
|
32
|
+
* if it doesn't exist, this will throw an ENOENT error, but this is not logged
|
|
33
|
+
* as an error.
|
|
34
|
+
*
|
|
35
|
+
* this is because atow (03/2024) this is only used in a tryRead_bin function
|
|
36
|
+
* where the file often does not exist.
|
|
37
|
+
*/
|
|
38
|
+
export declare function getFileDataAndEncoding({ inputPath, encodingsToTry, }: {
|
|
39
|
+
inputPath: string;
|
|
40
|
+
encodingsToTry?: (FileEncoding | undefined)[];
|
|
41
|
+
}): Promise<FileDataInfo>;
|
|
42
|
+
//# sourceMappingURL=node-filesystem-space-helper.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-filesystem-space-helper.d.mts","sourceRoot":"","sources":["../../../../src/witness/space/node-filesystem-space/node-filesystem-space-helper.mts"],"names":[],"mappings":"AAAA;;;GAGG;AAeH,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAkD,YAAY,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAK/H;;;;;;GAMG;AACH,wBAAsB,OAAO,CAAC,EAC1B,IAAI,EACJ,SAAS,EACT,QAAQ,GACX,EAAE;IACC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CACpB,GAAG,OAAO,CAAC,MAAM,GAAG,UAAU,GAAG,IAAI,CAAC,CA2BtC;AAED,wBAAsB,WAAW,CAAC,EAC9B,IAAI,EACJ,SAAS,EACT,QAAQ,GACX,EAAE;IACC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CACpB,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAuC/B;AAED;;GAEG;AACH,wBAAsB,2CAA2C,CAAC,EAAE,KAAK,EAAE,EAAE;IAAE,KAAK,EAAE,sBAAsB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;CAAE,GAAG,OAAO,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAyFlJ;AAED;;;;;;;GAOG;AACH,wBAAsB,sBAAsB,CAAC,EACzC,SAAS,EACT,cAA+C,GAClD,EAAE;IACC,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,CAAC,YAAY,GAAG,SAAS,CAAC,EAAE,CAAC;CACjD,GAAG,OAAO,CAAC,YAAY,CAAC,CAwExB"}
|