@ibgib/core-gib 0.0.7 → 0.0.10
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/README.md +34 -13
- 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/form/form-helper.d.mts.map +1 -1
- package/dist/common/form/form-helper.mjs +0 -2
- package/dist/common/form/form-helper.mjs.map +1 -1
- package/dist/core-constants.d.mts +0 -2
- package/dist/core-constants.d.mts.map +1 -1
- package/dist/core-constants.mjs +0 -2
- package/dist/core-constants.mjs.map +1 -1
- package/dist/core-helper.respec.d.mts +2 -0
- package/dist/core-helper.respec.d.mts.map +1 -0
- package/dist/core-helper.respec.mjs +53 -0
- package/dist/core-helper.respec.mjs.map +1 -0
- package/dist/core-types.d.mts +24 -2
- package/dist/core-types.d.mts.map +1 -1
- 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 +211 -0
- package/dist/respec-gib.node.mjs.map +1 -0
- package/dist/spec-helper.node.respec.d.mts +12 -0
- package/dist/spec-helper.node.respec.d.mts.map +1 -0
- package/dist/spec-helper.node.respec.mjs +43 -0
- package/dist/spec-helper.node.respec.mjs.map +1 -0
- package/dist/witness/app/app-base-v1.d.mts +1 -0
- package/dist/witness/app/app-base-v1.d.mts.map +1 -1
- package/dist/witness/app/app-base-v1.mjs +48 -11
- package/dist/witness/app/app-base-v1.mjs.map +1 -1
- package/dist/witness/app/app-constants.d.mts +2 -0
- package/dist/witness/app/app-constants.d.mts.map +1 -1
- package/dist/witness/app/app-constants.mjs +2 -0
- package/dist/witness/app/app-constants.mjs.map +1 -1
- package/dist/witness/app/app-helper.d.mts.map +1 -1
- package/dist/witness/app/app-helper.mjs +2 -1
- package/dist/witness/app/app-helper.mjs.map +1 -1
- package/dist/witness/robbot/robbot-base-v1.d.mts +4 -5
- package/dist/witness/robbot/robbot-base-v1.d.mts.map +1 -1
- package/dist/witness/robbot/robbot-base-v1.mjs +29 -1
- package/dist/witness/robbot/robbot-base-v1.mjs.map +1 -1
- package/dist/witness/robbot/robbot-helper.respec.d.mts +2 -0
- package/dist/witness/robbot/robbot-helper.respec.d.mts.map +1 -0
- package/dist/witness/robbot/robbot-helper.respec.mjs +106 -0
- package/dist/witness/robbot/robbot-helper.respec.mjs.map +1 -0
- package/dist/witness/space/bootstrap/bootstrap-helper.d.mts +3 -0
- package/dist/witness/space/bootstrap/bootstrap-helper.d.mts.map +1 -0
- package/dist/witness/space/bootstrap/bootstrap-helper.mjs +51 -0
- package/dist/witness/space/bootstrap/bootstrap-helper.mjs.map +1 -0
- package/dist/witness/space/bootstrap/bootstrap-types.d.mts +117 -0
- package/dist/witness/space/bootstrap/bootstrap-types.d.mts.map +1 -0
- package/dist/witness/space/bootstrap/bootstrap-types.mjs +7 -0
- package/dist/witness/space/bootstrap/bootstrap-types.mjs.map +1 -0
- package/dist/witness/space/filesystem-space/filesystem-constants.d.mts +64 -0
- package/dist/witness/space/filesystem-space/filesystem-constants.d.mts.map +1 -0
- package/dist/witness/space/filesystem-space/filesystem-constants.mjs +64 -0
- package/dist/witness/space/filesystem-space/filesystem-constants.mjs.map +1 -0
- package/dist/witness/space/filesystem-space/filesystem-space-v1.d.mts +180 -0
- package/dist/witness/space/filesystem-space/filesystem-space-v1.d.mts.map +1 -0
- package/dist/witness/space/filesystem-space/filesystem-space-v1.mjs +1145 -0
- package/dist/witness/space/filesystem-space/filesystem-space-v1.mjs.map +1 -0
- package/dist/witness/space/filesystem-space/filesystem-space-v1.respec.d.mts +2 -0
- package/dist/witness/space/filesystem-space/filesystem-space-v1.respec.d.mts.map +1 -0
- package/dist/witness/space/filesystem-space/filesystem-space-v1.respec.mjs +107 -0
- package/dist/witness/space/filesystem-space/filesystem-space-v1.respec.mjs.map +1 -0
- package/dist/witness/space/filesystem-space/filesystem-types.d.mts +73 -0
- package/dist/witness/space/filesystem-space/filesystem-types.d.mts.map +1 -0
- package/dist/witness/space/filesystem-space/filesystem-types.mjs +2 -0
- package/dist/witness/space/filesystem-space/filesystem-types.mjs.map +1 -0
- package/dist/witness/space/filesystem-space/node-filesystem-space-v1.d.mts +90 -0
- package/dist/witness/space/filesystem-space/node-filesystem-space-v1.d.mts.map +1 -0
- package/dist/witness/space/filesystem-space/node-filesystem-space-v1.mjs +669 -0
- package/dist/witness/space/filesystem-space/node-filesystem-space-v1.mjs.map +1 -0
- package/dist/witness/space/filesystem-space/node-filesystem-space-v1.node.respec.d.mts +2 -0
- package/dist/witness/space/filesystem-space/node-filesystem-space-v1.node.respec.d.mts.map +1 -0
- package/dist/witness/space/filesystem-space/node-filesystem-space-v1.node.respec.mjs +129 -0
- package/dist/witness/space/filesystem-space/node-filesystem-space-v1.node.respec.mjs.map +1 -0
- package/dist/witness/space/{inner-space-v1.d.mts → inner-space/inner-space-v1.d.mts} +2 -2
- package/dist/witness/space/inner-space/inner-space-v1.d.mts.map +1 -0
- package/dist/witness/space/{inner-space-v1.mjs → inner-space/inner-space-v1.mjs} +3 -3
- package/dist/witness/space/inner-space/inner-space-v1.mjs.map +1 -0
- package/dist/witness/space/inner-space/inner-space-v1.respec.d.mts +2 -0
- package/dist/witness/space/inner-space/inner-space-v1.respec.d.mts.map +1 -0
- package/dist/witness/space/inner-space/inner-space-v1.respec.mjs +56 -0
- package/dist/witness/space/inner-space/inner-space-v1.respec.mjs.map +1 -0
- package/dist/witness/space/space-constants.d.mts +0 -27
- package/dist/witness/space/space-constants.d.mts.map +1 -1
- package/dist/witness/space/space-constants.mjs +0 -27
- package/dist/witness/space/space-constants.mjs.map +1 -1
- package/dist/witness/space/space-helper.d.mts +3 -3
- package/dist/witness/space/space-helper.d.mts.map +1 -1
- package/dist/witness/space/space-helper.mjs +6 -51
- package/dist/witness/space/space-helper.mjs.map +1 -1
- package/dist/witness/space/space-respec-helper.d.mts +71 -0
- package/dist/witness/space/space-respec-helper.d.mts.map +1 -0
- package/dist/witness/space/space-respec-helper.mjs +186 -0
- package/dist/witness/space/space-respec-helper.mjs.map +1 -0
- package/dist/witness/space/space-types.d.mts +0 -98
- package/dist/witness/space/space-types.d.mts.map +1 -1
- package/dist/witness/space/space-types.mjs +0 -1
- package/dist/witness/space/space-types.mjs.map +1 -1
- package/dist/witness/witness-base-v1.d.mts.map +1 -1
- package/dist/witness/witness-base-v1.mjs +7 -7
- package/dist/witness/witness-base-v1.mjs.map +1 -1
- package/dist/witness/witness-helper.d.mts +8 -0
- package/dist/witness/witness-helper.d.mts.map +1 -1
- package/dist/witness/witness-helper.mjs +30 -0
- package/dist/witness/witness-helper.mjs.map +1 -1
- package/package.json +12 -15
- package/src/{assumptions.spec.mts → assumptions.respec.mts} +11 -5
- package/src/common/form/form-helper.mts +3 -4
- package/src/core-constants.mts +0 -2
- package/src/core-helper.respec.mts +71 -0
- package/src/core-types.mts +24 -2
- package/src/respec-gib.node.mts +199 -0
- package/src/spec-helper.node.respec.mts +45 -0
- package/src/witness/app/app-base-v1.mts +38 -23
- package/src/witness/app/app-constants.mts +3 -0
- package/src/witness/app/app-helper.mts +2 -1
- package/src/witness/robbot/robbot-base-v1.mts +9 -6
- package/src/witness/robbot/{robbot-helper.spec.mts → robbot-helper.respec.mts} +39 -33
- package/src/witness/space/bootstrap/bootstrap-helper.mts +50 -0
- package/src/witness/space/bootstrap/bootstrap-types.mts +123 -0
- package/src/witness/space/filesystem-space/filesystem-constants.mts +66 -0
- package/src/witness/space/filesystem-space/filesystem-space-v1.mts +1283 -0
- package/src/witness/space/filesystem-space/filesystem-space-v1.respec.mts +110 -0
- package/src/witness/space/filesystem-space/filesystem-types.mts +75 -0
- package/src/witness/space/filesystem-space/node-filesystem-space-v1.mts +697 -0
- package/src/witness/space/filesystem-space/node-filesystem-space-v1.node.respec.mts +148 -0
- package/src/witness/space/{inner-space-v1.mts → inner-space/inner-space-v1.mts} +5 -6
- package/src/witness/space/{inner-space-v1.spec.mts → inner-space/inner-space-v1.respec.mts} +17 -8
- package/src/witness/space/space-constants.mts +0 -27
- package/src/witness/space/space-helper.mts +17 -54
- package/src/witness/space/{space-spec-helper.spec.mts → space-respec-helper.mts} +97 -57
- package/src/witness/space/space-types.mts +0 -105
- package/src/witness/witness-base-v1.mts +8 -6
- package/src/witness/witness-helper.mts +31 -0
- package/tsconfig.json +4 -2
- package/dist/witness/space/inner-space-v1.d.mts.map +0 -1
- package/dist/witness/space/inner-space-v1.mjs.map +0 -1
- package/jasmine-browser.json +0 -18
- package/jasmine.json +0 -6
- package/src/core-helper.spec.mts +0 -64
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import {
|
|
2
|
+
firstOfEach, firstOfAll, ifWe,
|
|
3
|
+
lastOfEach, lastOfAll,
|
|
4
|
+
ifWeMight, iReckon, respecfully
|
|
5
|
+
} from '@ibgib/helper-gib/dist/respec-gib/respec-gib.mjs';
|
|
6
|
+
const maam = `[${import.meta.url}]`, sir = maam;
|
|
1
7
|
// import { getIbAndGib } from '@ibgib/ts-gib';
|
|
2
8
|
// import { IbGib_V1 } from '@ibgib/ts-gib/dist/V1/index.mjs';
|
|
3
9
|
// import { getGibInfo } from 'ts-gib/dist/V1/transforms/transform-helper';
|
|
@@ -10,9 +16,9 @@
|
|
|
10
16
|
import { IbGib_V1 } from "@ibgib/ts-gib/dist/V1/types.mjs";
|
|
11
17
|
import { getSpaceDelimitedSaferRequestText } from "./robbot-helper.mjs";
|
|
12
18
|
|
|
13
|
-
|
|
19
|
+
await respecfully(sir, 'getRequestTextFromComment', async () => {
|
|
14
20
|
|
|
15
|
-
|
|
21
|
+
await ifWe(sir, 'should get request text with single-char escape', () => {
|
|
16
22
|
['?', '??', '/', '/esc'].forEach(escape => {
|
|
17
23
|
['help', 'hi',].forEach(requestText => {
|
|
18
24
|
const text = escape + requestText;
|
|
@@ -23,7 +29,7 @@ describe('getRequestTextFromComment', () => {
|
|
|
23
29
|
data: { text }
|
|
24
30
|
}
|
|
25
31
|
const resRequestText = getSpaceDelimitedSaferRequestText({ ibGib, requestEscapeString: escape });
|
|
26
|
-
|
|
32
|
+
iReckon(sir, resRequestText).isGonnaBe(requestText);
|
|
27
33
|
});
|
|
28
34
|
});
|
|
29
35
|
});
|
|
@@ -31,7 +37,7 @@ describe('getRequestTextFromComment', () => {
|
|
|
31
37
|
|
|
32
38
|
|
|
33
39
|
|
|
34
|
-
//
|
|
40
|
+
// await respecfully(sir, 'RobbotSessionIb', () => {
|
|
35
41
|
|
|
36
42
|
// // one big test because jasmine unfortunately makes you declare variables
|
|
37
43
|
// // multiple times to get async working, which doesn't scale, so it's a bad
|
|
@@ -58,12 +64,12 @@ describe('getRequestTextFromComment', () => {
|
|
|
58
64
|
// contextTjpGib: commentGibInfo.tjpGib,
|
|
59
65
|
// sessionId,
|
|
60
66
|
// });
|
|
61
|
-
// expect(ib).
|
|
62
|
-
// expect(ib.startsWith(ROBBOT_SESSION_ATOM)).
|
|
63
|
-
// expect(ib.match(timestampInTicks)).
|
|
64
|
-
// expect(ib.match(sessionId)).
|
|
65
|
-
// expect(ib.match(robbot.data.name)).
|
|
66
|
-
// expect(ib.match(robbot.data.uuid)).
|
|
67
|
+
// expect(ib).isGonnaBeTruthy();
|
|
68
|
+
// expect(ib.startsWith(ROBBOT_SESSION_ATOM)).isGonnaBe(true, `doesnt start with robbot session atom. (${ib})`);
|
|
69
|
+
// expect(ib.match(timestampInTicks)).isGonnaBeTruthy(`timestampInTicks not included. (${ib}\n${timestampInTicks})`);
|
|
70
|
+
// expect(ib.match(sessionId)).isGonnaBeTruthy(`sessionId.\nib: ${ib}\nsessionId: ${sessionId}`);
|
|
71
|
+
// expect(ib.match(robbot.data.name)).isGonnaBeTruthy('robbot name');
|
|
72
|
+
// expect(ib.match(robbot.data.uuid)).isGonnaBeTruthy('robbot uuid');
|
|
67
73
|
|
|
68
74
|
// let { timestamp, robbotName,
|
|
69
75
|
// robbotClassname, robbotId, robbotTjpGib,
|
|
@@ -71,14 +77,14 @@ describe('getRequestTextFromComment', () => {
|
|
|
71
77
|
// addlMetadata: addlMetadata_Out
|
|
72
78
|
// } = parseRobbotSessionIb({ ib });
|
|
73
79
|
|
|
74
|
-
// expect(timestamp).
|
|
75
|
-
// expect(robbotName).
|
|
76
|
-
// expect(robbotClassname).
|
|
77
|
-
// expect(robbotId).
|
|
78
|
-
// expect(robbotTjpGib).
|
|
79
|
-
// expect(sessionId_Out).
|
|
80
|
-
// expect(contextTjpGib).
|
|
81
|
-
// expect(addlMetadata_Out).
|
|
80
|
+
// expect(timestamp).isGonnaBe(timestampInTicks, 'timestampInTicks');
|
|
81
|
+
// expect(robbotName).isGonnaBe(robbot.data.name, 'robbot name');
|
|
82
|
+
// expect(robbotClassname).isGonnaBe(robbot.data.classname, 'robbot classname');
|
|
83
|
+
// expect(robbotId).isGonnaBe(robbot.data.uuid, 'robbot uuid');
|
|
84
|
+
// expect(robbotTjpGib).isGonnaBe(getGibInfo({ gib: robbot.gib }).tjpGib, 'robbot tjpgib');
|
|
85
|
+
// expect(sessionId_Out).isGonnaBe(sessionId, 'sessionId');
|
|
86
|
+
// expect(contextTjpGib).isGonnaBe(getGibInfo({ gib: commentIbGib.gib }).tjpGib, 'contextTjpGib');
|
|
87
|
+
// expect(addlMetadata_Out).isGonnaBe(undefined, 'addlMetadata');
|
|
82
88
|
|
|
83
89
|
// // #endregion get/parse normal, no metadata
|
|
84
90
|
|
|
@@ -92,13 +98,13 @@ describe('getRequestTextFromComment', () => {
|
|
|
92
98
|
// addlMetadata,
|
|
93
99
|
// });
|
|
94
100
|
|
|
95
|
-
// expect(ib).
|
|
96
|
-
// expect(ib.startsWith(ROBBOT_SESSION_ATOM)).
|
|
97
|
-
// expect(ib.match(timestampInTicks)).
|
|
98
|
-
// expect(ib.match(sessionId)).
|
|
99
|
-
// expect(ib.match(robbot.data.name)).
|
|
100
|
-
// expect(ib.match(robbot.data.uuid)).
|
|
101
|
-
// expect(ib.match(addlMetadata)).
|
|
101
|
+
// expect(ib).isGonnaBeTruthy();
|
|
102
|
+
// expect(ib.startsWith(ROBBOT_SESSION_ATOM)).isGonnaBe(true, `2 doesnt start with robbot session atom. (${ib})`);
|
|
103
|
+
// expect(ib.match(timestampInTicks)).isGonnaBeTruthy(`2 timestampInTicks not included. (${ib}\n${timestampInTicks})`);
|
|
104
|
+
// expect(ib.match(sessionId)).isGonnaBeTruthy(`2 sessionId.\nib: ${ib}\nsessionId: ${sessionId}`);
|
|
105
|
+
// expect(ib.match(robbot.data.name)).isGonnaBeTruthy('2 robbot name');
|
|
106
|
+
// expect(ib.match(robbot.data.uuid)).isGonnaBeTruthy('2 robbot uuid');
|
|
107
|
+
// expect(ib.match(addlMetadata)).isGonnaBeTruthy('addlMetadata');
|
|
102
108
|
|
|
103
109
|
// // thanks https://flaviocopes.com/javascript-destructure-object-to-existing-variable/
|
|
104
110
|
// ({
|
|
@@ -107,14 +113,14 @@ describe('getRequestTextFromComment', () => {
|
|
|
107
113
|
// sessionId: sessionId_Out, contextTjpGib, addlMetadata: addlMetadata_Out
|
|
108
114
|
// } = parseRobbotSessionIb({ ib }));
|
|
109
115
|
|
|
110
|
-
// expect(timestamp).
|
|
111
|
-
// expect(robbotName).
|
|
112
|
-
// expect(robbotClassname).
|
|
113
|
-
// expect(robbotId).
|
|
114
|
-
// expect(robbotTjpGib).
|
|
115
|
-
// expect(sessionId_Out).
|
|
116
|
-
// expect(contextTjpGib).
|
|
117
|
-
// expect(addlMetadata_Out).
|
|
116
|
+
// expect(timestamp).isGonnaBe(timestampInTicks, '2 timestampInTicks');
|
|
117
|
+
// expect(robbotName).isGonnaBe(robbot.data.name, '2 robbot name');
|
|
118
|
+
// expect(robbotClassname).isGonnaBe(robbot.data.classname, '2 robbot classname');
|
|
119
|
+
// expect(robbotId).isGonnaBe(robbot.data.uuid, '2 robbot uuid');
|
|
120
|
+
// expect(robbotTjpGib).isGonnaBe(getGibInfo({ gib: robbot.gib }).tjpGib, '2 robbot tjpgib');
|
|
121
|
+
// expect(sessionId_Out).isGonnaBe(sessionId, '2 sessionId');
|
|
122
|
+
// expect(contextTjpGib).isGonnaBe(getGibInfo({ gib: commentIbGib.gib }).tjpGib, '2 contextTjpGib');
|
|
123
|
+
// expect(addlMetadata_Out).isGonnaBe(addlMetadata, 'addlMetadata');
|
|
118
124
|
|
|
119
125
|
// // #endregion with addl metadata
|
|
120
126
|
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { getIbGibAddr } from "@ibgib/ts-gib";
|
|
2
|
+
import { IbGib_V1 } from "@ibgib/ts-gib/dist/V1/index.mjs";
|
|
3
|
+
import { BOOTSTRAP_DATA_DEFAULT_SPACE_ID_KEY, BOOTSTRAP_IBGIB_ADDR } from "./bootstrap-constants.mjs";
|
|
4
|
+
import { validateIbGibIntrinsically } from "@ibgib/ts-gib/dist/V1/validate-helper.mjs";
|
|
5
|
+
import { BootstrapData, BootstrapRel8ns } from "./bootstrap-types.mjs";
|
|
6
|
+
|
|
7
|
+
export async function validateBootstrapIbGib(bootstrapSpace: IbGib_V1): Promise<boolean> {
|
|
8
|
+
const lc = `[${validateBootstrapIbGib.name}]`;
|
|
9
|
+
const errors: string[] = [];
|
|
10
|
+
try {
|
|
11
|
+
const addr = getIbGibAddr({ ibGib: bootstrapSpace });
|
|
12
|
+
if (addr !== BOOTSTRAP_IBGIB_ADDR) {
|
|
13
|
+
errors.push(`invalid bootstrapSpace addr. Should equal "${BOOTSTRAP_IBGIB_ADDR}" (E: ecfdbed719284db7a1aa3f867f706fe9)`);
|
|
14
|
+
}
|
|
15
|
+
let intrinsicErrors = await validateIbGibIntrinsically({ ibGib: bootstrapSpace });
|
|
16
|
+
if (intrinsicErrors?.length ?? -1 > 0) { intrinsicErrors!.forEach(e => errors.push(e)); }
|
|
17
|
+
|
|
18
|
+
const data = (bootstrapSpace.data as BootstrapData);
|
|
19
|
+
const rel8ns = (bootstrapSpace.rel8ns as BootstrapRel8ns);
|
|
20
|
+
|
|
21
|
+
if (Object.keys(data || {}).length === 0) {
|
|
22
|
+
errors.push(`invalid bootstrapSpace data. data required (E: 5a9bd15dd0644f9b93cafbbba660cfdf)`);
|
|
23
|
+
}
|
|
24
|
+
if ((data.spaceIds ?? []).length === 0) {
|
|
25
|
+
errors.push(`invalid bootstrapSpace, data.spaceIds required. (E: 6b91ddc12cfd41e59ded7d7502c1909f)`);
|
|
26
|
+
}
|
|
27
|
+
if (Object.keys(bootstrapSpace.rel8ns || {}).length === 0) {
|
|
28
|
+
errors.push(`invalid bootstrapSpace rel8ns (empty). Should have at least one rel8n, with rel8nName corresponding to the spaceId (E: b188ce4ae25e49f794f35e141bc2ecde)`);
|
|
29
|
+
}
|
|
30
|
+
data.spaceIds.forEach((spaceId: string) => {
|
|
31
|
+
if ((rel8ns[spaceId] ?? []).length === 0) {
|
|
32
|
+
errors.push(`invalid bootstrap. Each spaceId listed in data should have a corresponding address in rel8ns. spaceId (${spaceId}) missing. (E: 62dd0d76e29a415a98b4b27deb8db17e)`);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
if (!data[BOOTSTRAP_DATA_DEFAULT_SPACE_ID_KEY]) {
|
|
36
|
+
errors.push(`invalid bootstrap. data.${BOOTSTRAP_DATA_DEFAULT_SPACE_ID_KEY} required. (E: f763af2e275f445cbf1db5801bacafad)`);
|
|
37
|
+
} else if ((rel8ns[data[BOOTSTRAP_DATA_DEFAULT_SPACE_ID_KEY]] ?? []).length === 0) {
|
|
38
|
+
errors.push(`invalid bootstrap. data.${BOOTSTRAP_DATA_DEFAULT_SPACE_ID_KEY} (${data[BOOTSTRAP_DATA_DEFAULT_SPACE_ID_KEY]}) not found in rel8ns. (E: 44d0799d232f4a51a0b0019ebebe019f)`);
|
|
39
|
+
}
|
|
40
|
+
if (errors.length === 0) {
|
|
41
|
+
return true;
|
|
42
|
+
} else {
|
|
43
|
+
console.error(`${lc} errors: ${errors.join('|')}`);
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
} catch (error) {
|
|
47
|
+
console.error(`${lc} ${error.message}`);
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module bootstrap
|
|
3
|
+
*
|
|
4
|
+
* @see {@link BootstrapIbGib}
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { IbGibRel8ns_V1, IbGib_V1 } from "@ibgib/ts-gib/dist/V1/index.mjs";
|
|
8
|
+
|
|
9
|
+
import { SpaceId } from "../space-types.mjs";
|
|
10
|
+
import { BOOTSTRAP_DATA_DEFAULT_SPACE_ID_KEY, BOOTSTRAP_DATA_KNOWN_SPACE_IDS_KEY } from "./bootstrap-constants.mjs";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Data of a {@link BootstrapIbGib}
|
|
14
|
+
*/
|
|
15
|
+
export interface BootstrapData {
|
|
16
|
+
/**
|
|
17
|
+
* this id will be the default space of the bootstrap (meta space).
|
|
18
|
+
*
|
|
19
|
+
* The `bootstrapIbGib.rel8ns` will contain links to the space addresses,
|
|
20
|
+
* with `rel8nName === spaceId`.
|
|
21
|
+
*
|
|
22
|
+
* So to get the default space, you need the default space address. To get
|
|
23
|
+
* that address, you first read this data value, then index into
|
|
24
|
+
* `bootstrap.rel8ns[spaceId]`.
|
|
25
|
+
*/
|
|
26
|
+
[BOOTSTRAP_DATA_DEFAULT_SPACE_ID_KEY]: SpaceId;
|
|
27
|
+
/**
|
|
28
|
+
* List of known spaces in this bootstrap. These should be rel8n names in
|
|
29
|
+
* the bootstrap's `rel8ns` map.
|
|
30
|
+
*/
|
|
31
|
+
[BOOTSTRAP_DATA_KNOWN_SPACE_IDS_KEY]: SpaceId[];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Rel8ns of a {@link BootstrapIbGib}
|
|
36
|
+
*
|
|
37
|
+
* atow, these will have rel8nNames of [spaceId] that point to the corresponding
|
|
38
|
+
* latest spaceAddr, such that the length is always === 1.
|
|
39
|
+
*/
|
|
40
|
+
export interface BootstrapRel8ns extends IbGibRel8ns_V1 {
|
|
41
|
+
// [BOOTSTRAP_REL8N_NAME_SPACE]: IbGibAddr[];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* # tl;dr
|
|
46
|
+
*
|
|
47
|
+
* a bootstrap ibgib...
|
|
48
|
+
*
|
|
49
|
+
* * is a meta space without hash.
|
|
50
|
+
* * contain info for a "default" local space
|
|
51
|
+
* * default local space defines what space is used when not specified in space functions
|
|
52
|
+
* * contains a list of known spaces available to some entity (app/robbot/etc via ibgibs svc)
|
|
53
|
+
*
|
|
54
|
+
* # bootstrapping "applications"
|
|
55
|
+
*
|
|
56
|
+
* When the application first starts, it looks to bootstrap itself. So it will
|
|
57
|
+
* look for an ibgib with this "primitive" address, i.e. where the gib is the
|
|
58
|
+
* string literal 'gib'. It looks for this address inside what is called the
|
|
59
|
+
* "zero space". This is a default space with default parameters that always
|
|
60
|
+
* points to the same location, relative to the context (app in our current case,
|
|
61
|
+
* but in the future the context could be e.g. an IoT device or AI microservice).
|
|
62
|
+
*
|
|
63
|
+
* So the context execution starts, creating a default zero space ibgib in
|
|
64
|
+
* memory, which itself has a default location/parameters that the space looks
|
|
65
|
+
* in in storage. Here it looks for the bootstrap ibgib with a known address
|
|
66
|
+
* "bootstrap^gib" (atow). Inside that bootstrap ibgib, there should be at least
|
|
67
|
+
* one local space referenced, or a new one must be created and then stored here
|
|
68
|
+
* for future app/context startups.
|
|
69
|
+
*
|
|
70
|
+
* Spaces are rel8d by their `spaceId`'s in `ibgib.rel8ns`, and the `ibgib.data`
|
|
71
|
+
* key (`ibgib.data.defaultSpaceId` atow) contains the default `spaceId`. If
|
|
72
|
+
* there are multiple local spaces that the bootstrap ibgib knows about, there
|
|
73
|
+
* will be only one "default" set.
|
|
74
|
+
*
|
|
75
|
+
* ## first run
|
|
76
|
+
*
|
|
77
|
+
* @see {@link IbgibsService.createNewLocalSpaceAndBootstrapGib}
|
|
78
|
+
* @see {@link getLocalSpace} in `helper/space.ts`
|
|
79
|
+
*
|
|
80
|
+
* A new local space will be created, whose parameters (including its `uuid`
|
|
81
|
+
* which is its `spaceId`) contribute to its reiffied gib hash. A new bootstrap
|
|
82
|
+
* ibgib is created, and in its `bootstrapIbGib.data.defaultSpaceId` we set the
|
|
83
|
+
* newly created local space's id. We then rel8 the space to the bootstrap also
|
|
84
|
+
* via this spaceId as the rel8nName.
|
|
85
|
+
*
|
|
86
|
+
* Note that when the local space is updated, its most recent address must
|
|
87
|
+
* replace the address that the bootstrap ibgib is pointing to.
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
*
|
|
91
|
+
* Here is a copy of a bootstrap^gib.json file on March 30, 2022:
|
|
92
|
+
* ```
|
|
93
|
+
* {
|
|
94
|
+
* "ib":"bootstrap",
|
|
95
|
+
* "gib":"gib",
|
|
96
|
+
* "data":{
|
|
97
|
+
* "defaultSpaceId":"72af3bba9c6da224829de86982346e283469823e49862398a56510c238bad869",
|
|
98
|
+
* "spaceIds":["72af3bba9c6da224829de86982346e283469823e49862398a56510c238bad869"]
|
|
99
|
+
* },
|
|
100
|
+
* "rel8ns":{
|
|
101
|
+
* "72af3bba9c6da224829de86982346e283469823e49862398a56510c238bad869": [
|
|
102
|
+
* "witness space IonicSpace_V1 test_space_name 72af3bba9c6da224829de86982346e283469823e49862398a56510c238bad869^62879B18C2726D27262626552672868923477EE09171626A386C1982F392AC26"
|
|
103
|
+
* ]
|
|
104
|
+
* }
|
|
105
|
+
* }
|
|
106
|
+
* ```
|
|
107
|
+
*
|
|
108
|
+
* ## notes
|
|
109
|
+
*
|
|
110
|
+
* Usually primitives are not stored/persisted. This is because the `gib`
|
|
111
|
+
* indicates that there is no hash corroboration ("guarantee") to the internal
|
|
112
|
+
* data or rel8ns. However, a newly started app has to start somewhere. This
|
|
113
|
+
* offers an alternative to using app storage and streamlines the app overall,
|
|
114
|
+
* since instead of working with two stores (in Ionic: `Storage` and
|
|
115
|
+
* `FileSystem`) we will just be working with one (`FileSystem`).
|
|
116
|
+
*
|
|
117
|
+
* In the future, we'll want to do a workflow here where the user
|
|
118
|
+
* can start from an existing space, but for now it's just located
|
|
119
|
+
* here.
|
|
120
|
+
*/
|
|
121
|
+
export interface BootstrapIbGib
|
|
122
|
+
extends IbGib_V1<BootstrapData, BootstrapRel8ns> {
|
|
123
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { IBGIB_SPACE_NAME_DEFAULT } from "../space-constants.mjs";
|
|
2
|
+
import { Directory, Encoding } from "./filesystem-types.mjs";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* atow this is '.' (cwd)
|
|
6
|
+
*
|
|
7
|
+
* In original ionic space, this would be "DOCUMENTS" or similar.
|
|
8
|
+
*/
|
|
9
|
+
export const IBGIB_BASE_DIR: Directory = '.';
|
|
10
|
+
/**
|
|
11
|
+
* atow this is 'utf8'
|
|
12
|
+
*
|
|
13
|
+
* this stems from original ionic space default encoding.
|
|
14
|
+
*/
|
|
15
|
+
export const IBGIB_ENCODING: Encoding = 'utf8';
|
|
16
|
+
/**
|
|
17
|
+
* Base directory for all data of the app.
|
|
18
|
+
*/
|
|
19
|
+
export const IBGIB_BASE_SUBPATH = 'ibgib';
|
|
20
|
+
/**
|
|
21
|
+
* Default space that is also used for bootstrapping.
|
|
22
|
+
*
|
|
23
|
+
* The user should provide his/her own space name that will contain their data.
|
|
24
|
+
* If a custom user space name is not provided, one should be auto-generated.
|
|
25
|
+
*
|
|
26
|
+
* ## notes
|
|
27
|
+
*
|
|
28
|
+
* * the leading 000's help to put the space earlier in alphabetized listing if viewing through an OS file viewer
|
|
29
|
+
*/
|
|
30
|
+
export const IBGIB_SPACE_SUBPATH_DEFAULT = `000_${IBGIB_SPACE_NAME_DEFAULT}`;
|
|
31
|
+
/**
|
|
32
|
+
* Subpath for "normal" ibgibs (non-meta, non-dna, non-binary, etc.).
|
|
33
|
+
*/
|
|
34
|
+
export const IBGIB_IBGIBS_SUBPATH = 'ibgibs';
|
|
35
|
+
/**
|
|
36
|
+
* should contain special-use ibgibs to the application.
|
|
37
|
+
*
|
|
38
|
+
* Use case:
|
|
39
|
+
* Because some special ibgibs will be changed frequently,
|
|
40
|
+
* e.g. settings, a separate folder will be useful.
|
|
41
|
+
*/
|
|
42
|
+
export const IBGIB_META_SUBPATH = 'meta';
|
|
43
|
+
/**
|
|
44
|
+
* Path for storing the dna for ibgibs.
|
|
45
|
+
*
|
|
46
|
+
* bins will be stored without hyphens in the format:
|
|
47
|
+
* [hash].[ext]
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* 641575866a7c42bda89f58de5cd1c3aa.jpg
|
|
51
|
+
*/
|
|
52
|
+
export const IBGIB_BIN_SUBPATH = 'bin';
|
|
53
|
+
/**
|
|
54
|
+
* Path for storing the dna for ibgibs.
|
|
55
|
+
*
|
|
56
|
+
* ## notes
|
|
57
|
+
*
|
|
58
|
+
* eventually, these should most likely be stored in "colder"
|
|
59
|
+
* storage, like compressed, low-priority.
|
|
60
|
+
*/
|
|
61
|
+
export const IBGIB_DNA_SUBPATH = 'dna';
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Yep, this one starts with default instead of ending with it.
|
|
65
|
+
*/
|
|
66
|
+
export const DEFAULT_FILESYSTEM_SPACE_DESCRIPTION = `This is a filesystem space. The ibgib data contains settings for the space itself, and the witness ibgib object interfaces with a back end that is hierarchical like a filesystem. Descend from this class if you're working with a similar space.`;
|