@ibgib/core-gib 0.0.65 → 0.0.67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/witness/space/metaspace/metaspace-base.d.mts +9 -59
- package/dist/witness/space/metaspace/metaspace-base.d.mts.map +1 -1
- package/dist/witness/space/metaspace/metaspace-base.mjs +272 -300
- package/dist/witness/space/metaspace/metaspace-base.mjs.map +1 -1
- package/dist/witness/space/metaspace/metaspace-types.d.mts +20 -29
- package/dist/witness/space/metaspace/metaspace-types.d.mts.map +1 -1
- package/dist/witness/space/outer-space/outer-space-helper.d.mts +34 -1
- package/dist/witness/space/outer-space/outer-space-helper.d.mts.map +1 -1
- package/dist/witness/space/outer-space/outer-space-helper.mjs +76 -2
- package/dist/witness/space/outer-space/outer-space-helper.mjs.map +1 -1
- package/dist/witness/space/outer-space/outer-space-types.d.mts +10 -0
- package/dist/witness/space/outer-space/outer-space-types.d.mts.map +1 -1
- package/dist/witness/space/outer-space/outer-space-types.mjs.map +1 -1
- package/dist/witness/space/space-helper.d.mts +0 -3
- package/dist/witness/space/space-helper.d.mts.map +1 -1
- package/dist/witness/space/space-helper.mjs +1 -19
- package/dist/witness/space/space-helper.mjs.map +1 -1
- package/package.json +1 -1
- package/src/witness/space/metaspace/metaspace-base.mts +300 -355
- package/src/witness/space/metaspace/metaspace-types.mts +38 -62
- package/src/witness/space/outer-space/outer-space-helper.mts +89 -5
- package/src/witness/space/outer-space/outer-space-types.mts +10 -0
- package/src/witness/space/space-helper.mts +1 -20
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
GetIbGibOpts, GetIbGibResult,
|
|
15
15
|
PutIbGibOpts, PutIbGibResult
|
|
16
16
|
} from '../../../common/other/other-types.mjs';
|
|
17
|
-
import { SyncSagaInfo, } from '../../../witness/space/outer-space/outer-space-types.mjs';
|
|
17
|
+
import { SyncSagaInfo, SyncSpaceIbGib, } from '../../../witness/space/outer-space/outer-space-types.mjs';
|
|
18
18
|
import { SpaceId } from '../../../witness/space/space-types.mjs';
|
|
19
19
|
import { IbGibSpaceAny } from '../../../witness/space/space-base-v1.mjs';
|
|
20
20
|
import { IbGibTimelineUpdateInfo, SpecialIbGibType } from '../../../common/other/other-types.mjs';
|
|
@@ -37,10 +37,21 @@ export interface CreateLocalSpaceOptions {
|
|
|
37
37
|
logalot?: number | boolean;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
/**
|
|
41
|
+
* factory function that takes a dto ibgib (one without a .witness function for
|
|
42
|
+
* behavior) and creates/loads its corresponding witness.
|
|
43
|
+
*/
|
|
40
44
|
export type DtoToSpaceFunction = (spaceDto: IbGib_V1) => Promise<IbGibSpaceAny>;
|
|
41
45
|
export type ZeroSpaceFactoryFunction = () => IbGibSpaceAny;
|
|
42
46
|
export type LocalSpaceFactoryFunction = (opts: CreateLocalSpaceOptions) => Promise<IbGibSpaceAny | undefined>;
|
|
43
47
|
|
|
48
|
+
/**
|
|
49
|
+
* two levels deep map of space type.subtype -> factory function.
|
|
50
|
+
*
|
|
51
|
+
* @see {@link DtoToSpaceFunction}
|
|
52
|
+
*/
|
|
53
|
+
export type SpaceFactoryFnMap = { [type: string]: { [subtype: string]: DtoToSpaceFunction } }
|
|
54
|
+
|
|
44
55
|
export interface MetaspaceInitializeOptions {
|
|
45
56
|
/**
|
|
46
57
|
* If provided, will initialize using this spaceName if creating a new local
|
|
@@ -544,24 +555,24 @@ export interface MetaspaceService {
|
|
|
544
555
|
dontPrompt?: boolean,
|
|
545
556
|
space: IbGibSpaceAny,
|
|
546
557
|
}): Promise<string>;
|
|
547
|
-
unwrapEncryptedSyncSpace(arg: {
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
}): Promise<IbGibSpaceAny>;
|
|
553
|
-
getSyncSpaces(arg: {
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
}): Promise<
|
|
558
|
+
// unwrapEncryptedSyncSpace(arg: {
|
|
559
|
+
// encryptedSpace: IbGibSpaceAny,
|
|
560
|
+
// fnPromptPassword: (title: string, msg: string) => Promise<string | null>,
|
|
561
|
+
// dontPrompt?: boolean,
|
|
562
|
+
// space?: IbGibSpaceAny,
|
|
563
|
+
// }): Promise<IbGibSpaceAny>;
|
|
564
|
+
// getSyncSpaces(arg: {
|
|
565
|
+
// // unwrapEncrypted: boolean,
|
|
566
|
+
// createIfNone: boolean,
|
|
567
|
+
// /**
|
|
568
|
+
// * If true, don't prompt the user if we don't have it already cached.
|
|
569
|
+
// *
|
|
570
|
+
// * We don't want the user to hit the page and then always have to type in
|
|
571
|
+
// * the password, just because my password code sucks atow.
|
|
572
|
+
// */
|
|
573
|
+
// dontPrompt?: boolean,
|
|
574
|
+
// space?: IbGibSpaceAny,
|
|
575
|
+
// }): Promise<SyncSpaceIbGib[]>;
|
|
565
576
|
getAppRobbotIbGibs(arg: {
|
|
566
577
|
createIfNone: boolean,
|
|
567
578
|
fnPromptRobbot: (space: IbGibSpaceAny, ibGib: RobbotIbGib_V1 | null) => Promise<RobbotPromptResult | undefined>;
|
|
@@ -581,55 +592,20 @@ export interface MetaspaceService {
|
|
|
581
592
|
* ibgibs to be synced.
|
|
582
593
|
*/
|
|
583
594
|
dependencyGraphIbGibs?: IbGib_V1[],
|
|
584
|
-
|
|
595
|
+
/**
|
|
596
|
+
* sync space witnesses that we are going to send a put+sync cmd with
|
|
597
|
+
* the given {@link dependencyGraphIbGibs}.
|
|
598
|
+
*
|
|
599
|
+
* Note these are witnesses ({@link IbGibSpaceAny}) and not just the
|
|
600
|
+
* {@link SyncSpaceIbGib} interface, which is itself only an ibgib shape.
|
|
601
|
+
*/
|
|
602
|
+
syncSpaceIbGibs: IbGibSpaceAny[],
|
|
585
603
|
// /**
|
|
586
604
|
// * If true, will watch ibgibs in dependency graph that have timelines
|
|
587
605
|
// * (tjps) to keep in sync going forward.
|
|
588
606
|
// */
|
|
589
607
|
// watch?: boolean,
|
|
590
|
-
/**
|
|
591
|
-
* if provided, these will determine which outerspace(s) we will sync
|
|
592
|
-
* the {@link dependencyGraphIbGibs} with.
|
|
593
|
-
*/
|
|
594
|
-
outerspaceIds?: SpaceId[],
|
|
595
|
-
/**
|
|
596
|
-
* The meat of the sync process is tracked via a status within the sync
|
|
597
|
-
* spaces themselves. I'm addign this fn to track the pre and post progress
|
|
598
|
-
* stuff, since decrypting takes some time, and building the dependency
|
|
599
|
-
* graphs takes time. Both of these happen before the actual syncing occurs
|
|
600
|
-
* in the spaces.
|
|
601
|
-
*/
|
|
602
|
-
fnPreSyncProgress?: (msg: string) => Promise<void>,
|
|
603
608
|
}): Promise<SyncSagaInfo[] | undefined>;
|
|
604
|
-
// /**
|
|
605
|
-
// * Prompts the user to select a new picture for the given `picIbGib`.
|
|
606
|
-
// *
|
|
607
|
-
// * If the user does select one, this creates the appropriate ibgibs (pic,
|
|
608
|
-
// * binary, dependencies), saves them, registers the new pic (but not the bin)
|
|
609
|
-
// * in the given `space` if specified, else in the current `localUserSpace`.
|
|
610
|
-
// */
|
|
611
|
-
// updatePic(arg: {
|
|
612
|
-
// /**
|
|
613
|
-
// * picIbGib to update with a new image.
|
|
614
|
-
// */
|
|
615
|
-
// picIbGib: PicIbGib_V1,
|
|
616
|
-
// /**
|
|
617
|
-
// * space within which we are working, i.e., where the incoming `picIbGib` is
|
|
618
|
-
// * and where we will save any new ibgibs.
|
|
619
|
-
// */
|
|
620
|
-
// space?: IbGibSpaceAny,
|
|
621
|
-
// }): Promise<void>;
|
|
622
|
-
// updateComment(arg: {
|
|
623
|
-
// /**
|
|
624
|
-
// * commentIbGib to update with a new text
|
|
625
|
-
// */
|
|
626
|
-
// commentIbGib: CommentIbGib_V1,
|
|
627
|
-
// /**
|
|
628
|
-
// * space within which we are working, i.e., where the incoming `commentIbGib` is
|
|
629
|
-
// * and where we will save any new ibgibs.
|
|
630
|
-
// */
|
|
631
|
-
// space?: IbGibSpaceAny,
|
|
632
|
-
// }): Promise<void>;
|
|
633
609
|
|
|
634
610
|
/**
|
|
635
611
|
* creates a new local space with the given `fnLocalSpaceFactory` function
|
|
@@ -14,10 +14,13 @@ import { extractErrorMsg } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs
|
|
|
14
14
|
|
|
15
15
|
import { GLOBAL_LOG_A_LOT } from '../../../core-constants.mjs';
|
|
16
16
|
import { SpaceType, SpaceSubtype, VALID_SPACE_SUBTYPES, VALID_SPACE_TYPES, } from '../space-types.mjs';
|
|
17
|
-
import { StatusCode, StatusIbInfo, } from './outer-space-types.mjs';
|
|
17
|
+
import { StatusCode, StatusIbInfo, SyncSpaceIbGib, } from './outer-space-types.mjs';
|
|
18
18
|
import { OUTER_SPACE_DEFAULT_IB_DELIMITER } from './outer-space-constants.mjs';
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
19
|
+
import { IbGibSpaceAny } from '../space-base-v1.mjs';
|
|
20
|
+
import { getSpecialRel8dIbGibs } from '../space-helper.mjs';
|
|
21
|
+
import { SpecialIbGibType } from '../../../common/other/other-types.mjs';
|
|
22
|
+
import { SYNC_SPACE_REL8N_NAME } from '../space-constants.mjs';
|
|
23
|
+
import { SpaceFactoryFnMap } from '../metaspace/metaspace-types.mjs';
|
|
21
24
|
|
|
22
25
|
|
|
23
26
|
/**
|
|
@@ -49,7 +52,7 @@ export function getStatusIb({
|
|
|
49
52
|
|
|
50
53
|
return `status ${sagaId} ${statusCode} ${spaceType} ${spaceSubtype}`;
|
|
51
54
|
} catch (error) {
|
|
52
|
-
console.error(`${lc} ${error
|
|
55
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
53
56
|
throw error;
|
|
54
57
|
}
|
|
55
58
|
}
|
|
@@ -91,7 +94,88 @@ export function getStatusIbInfo({
|
|
|
91
94
|
|
|
92
95
|
return { statusCode, spaceType, spaceSubtype, sagaId, delimiter };
|
|
93
96
|
} catch (error) {
|
|
94
|
-
console.error(`${lc} ${error
|
|
97
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
98
|
+
throw error;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export async function getSyncSpaces({
|
|
103
|
+
space,
|
|
104
|
+
}: {
|
|
105
|
+
space: IbGibSpaceAny,
|
|
106
|
+
}): Promise<SyncSpaceIbGib[]> {
|
|
107
|
+
const lc = `[${getSyncSpaces.name}]`;
|
|
108
|
+
try {
|
|
109
|
+
if (!space) { throw new Error(`space required. (E: c03f80eca6b045b9a73b0aafa44cdf26)`); }
|
|
110
|
+
let syncSpaces = await getSpecialRel8dIbGibs<SyncSpaceIbGib>({
|
|
111
|
+
type: SpecialIbGibType.outerspaces,
|
|
112
|
+
rel8nName: SYNC_SPACE_REL8N_NAME,
|
|
113
|
+
space,
|
|
114
|
+
});
|
|
115
|
+
return syncSpaces;
|
|
116
|
+
} catch (error) {
|
|
117
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
118
|
+
throw error;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* gets the sync space ibgibs referenced in the given local {@link localSpace}
|
|
124
|
+
* and loads them into their corresponding witness classes.
|
|
125
|
+
*
|
|
126
|
+
* note: atow (03/2024) this throws if a factory function isn't found for ANY of
|
|
127
|
+
* the sync spaces found. later on, when multiple kinds of sync spaces are in
|
|
128
|
+
* existence, this behavior should change because it would be quite possible
|
|
129
|
+
* that we have multiple spaces that may not have a loaded factory function
|
|
130
|
+
* available.
|
|
131
|
+
*
|
|
132
|
+
* @see {@link SpaceFactoryFnMap}
|
|
133
|
+
*
|
|
134
|
+
* @returns sync space witnesses
|
|
135
|
+
*/
|
|
136
|
+
export async function getSyncSpaces_witnesses({
|
|
137
|
+
localSpace,
|
|
138
|
+
spaceFactoryFns,
|
|
139
|
+
}: {
|
|
140
|
+
/**
|
|
141
|
+
* user's local space that contains references to outer space "proxy"
|
|
142
|
+
* ibgibs.
|
|
143
|
+
*/
|
|
144
|
+
localSpace: IbGibSpaceAny,
|
|
145
|
+
/**
|
|
146
|
+
* factory function map (by type/subtype) that generates the space witnesses
|
|
147
|
+
* from the space dtos.
|
|
148
|
+
*
|
|
149
|
+
* @see {@link SpaceFactoryFnMap}
|
|
150
|
+
*/
|
|
151
|
+
spaceFactoryFns: SpaceFactoryFnMap,
|
|
152
|
+
}): Promise<IbGibSpaceAny[]> {
|
|
153
|
+
const lc = `[${getSyncSpaces_witnesses.name}]`;
|
|
154
|
+
try {
|
|
155
|
+
if (!localSpace) { throw new Error(`localSpace required. (E: c03f80eca6b045b9a73b0aafa44cdf26)`); }
|
|
156
|
+
let resSpaceWitnesses: IbGibSpaceAny[] = [];
|
|
157
|
+
|
|
158
|
+
const syncSpaceDtos = await getSyncSpaces({ space: localSpace });
|
|
159
|
+
for (let i = 0; i < syncSpaceDtos.length; i++) {
|
|
160
|
+
const syncSpaceDto = syncSpaceDtos[i];
|
|
161
|
+
if (!syncSpaceDto.data) { throw new Error(`(UNEXPECTED) syncSpaceDto.data falsy? (E: 5404f124b8bb781c0a52b3cc9f8e6524)`); }
|
|
162
|
+
const { type, subtype } = syncSpaceDto.data;
|
|
163
|
+
if (!type) { throw new Error(`(UNEXPECTED) syncSpaceDto.data.type falsy? (E: b3461e0df562d301fc84d68d95f91424)`); }
|
|
164
|
+
if (!subtype) { throw new Error(`(UNEXPECTED) syncSpaceDto.data.subtype falsy? (E: 524c471119564b4b817261f9e1edcafb)`); }
|
|
165
|
+
const fnFactory_typeSubset = spaceFactoryFns[syncSpaceDto.data.type] ?? {};
|
|
166
|
+
const fnFactory = fnFactory_typeSubset[syncSpaceDto.data.subtype];
|
|
167
|
+
if (!fnFactory) { throw new Error(`(UNEXPECTED) no factory function found for type (${type}) and subtype (${subtype})? (E: fd726f9049ade511f679d1de621dec24)`); }
|
|
168
|
+
const spaceWitness = await fnFactory(syncSpaceDto);
|
|
169
|
+
resSpaceWitnesses.push(spaceWitness);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (syncSpaceDtos.length !== resSpaceWitnesses.length) {
|
|
173
|
+
throw new Error(`(UNEXPECTED) syncSpaceDtos.length !== resSpaceWitnesses.length? (E: c85b1c93fce972a57683da727e6dc224)`);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return resSpaceWitnesses;
|
|
177
|
+
} catch (error) {
|
|
178
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
95
179
|
throw error;
|
|
96
180
|
}
|
|
97
181
|
}
|
|
@@ -125,9 +125,16 @@ export interface OuterSpaceData extends IbGibSpaceData {
|
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
export interface OuterSpaceRel8ns extends IbGibSpaceRel8ns {
|
|
128
|
+
/**
|
|
129
|
+
* the ciphertext will contain private data that is typed per use case (per
|
|
130
|
+
* concrete implementation).
|
|
131
|
+
*/
|
|
128
132
|
[CIPHERTEXT_REL8N_NAME]?: IbGibAddr[];
|
|
129
133
|
}
|
|
130
134
|
|
|
135
|
+
/**
|
|
136
|
+
*
|
|
137
|
+
*/
|
|
131
138
|
export interface OuterSpaceIbGib
|
|
132
139
|
extends IbGib_V1<OuterSpaceData, OuterSpaceRel8ns> {
|
|
133
140
|
}
|
|
@@ -567,6 +574,9 @@ export interface SagaInfo<
|
|
|
567
574
|
sagaId: string;
|
|
568
575
|
/**
|
|
569
576
|
* Reference to the space with which we're communicating.
|
|
577
|
+
*
|
|
578
|
+
* Note that this is a witness not just an ibgib data shape. so you will be
|
|
579
|
+
* able to pass in args to witness to this space.
|
|
570
580
|
*/
|
|
571
581
|
outerSpace: IbGibSpaceAny;
|
|
572
582
|
spaceId: string;
|
|
@@ -51,6 +51,7 @@ import { validateBootstrapIbGib } from './bootstrap/bootstrap-helper.mjs';
|
|
|
51
51
|
import { BootstrapData, BootstrapIbGib, BootstrapRel8ns } from './bootstrap/bootstrap-types.mjs';
|
|
52
52
|
import { newUpMetaStone } from '../../common/meta-stone/meta-stone-helper.mjs';
|
|
53
53
|
import { WITNESS_ATOM } from '../witness-constants.mjs';
|
|
54
|
+
import { SyncSpaceIbGib } from './outer-space/outer-space-types.mjs';
|
|
54
55
|
|
|
55
56
|
let logalot = GLOBAL_LOG_A_LOT;
|
|
56
57
|
|
|
@@ -325,26 +326,6 @@ export async function persistTransformResult({
|
|
|
325
326
|
}
|
|
326
327
|
}
|
|
327
328
|
|
|
328
|
-
export async function getSyncSpaces({
|
|
329
|
-
space,
|
|
330
|
-
}: {
|
|
331
|
-
space: IbGibSpaceAny,
|
|
332
|
-
}): Promise<IbGibSpaceAny[]> {
|
|
333
|
-
const lc = `[${getSyncSpaces.name}]`;
|
|
334
|
-
try {
|
|
335
|
-
if (!space) { throw new Error(`space required. (E: c03f80eca6b045b9a73b0aafa44cdf26)`); }
|
|
336
|
-
let syncSpaces = await getSpecialRel8dIbGibs<IbGibSpaceAny>({
|
|
337
|
-
type: "outerspaces",
|
|
338
|
-
rel8nName: SYNC_SPACE_REL8N_NAME,
|
|
339
|
-
space,
|
|
340
|
-
});
|
|
341
|
-
return syncSpaces;
|
|
342
|
-
} catch (error) {
|
|
343
|
-
console.error(`${lc} ${error.message}`);
|
|
344
|
-
throw error;
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
|
|
348
329
|
export async function getSpecialRel8dIbGibs<TIbGib extends IbGib_V1 = IbGib_V1>({
|
|
349
330
|
type,
|
|
350
331
|
rel8nName,
|