@ibgib/core-gib 0.0.75 → 0.0.77

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.
@@ -105,13 +105,13 @@ export class WitnessWithContextBase_V1 extends WitnessBase_V1 {
105
105
  if (logalot) {
106
106
  console.log(`${lc} starting... (I: 94755c3131f4dfa12d20fa38e2926522)`);
107
107
  }
108
- if (this.ibgibsSvc) {
108
+ if (this.metaspace) {
109
109
  // check for newer version of self locally before executing
110
110
  const thisAddr = getIbGibAddr({ ibGib: this });
111
- const latestAddr = await this.ibgibsSvc.getLatestAddr({ ibGib: this });
111
+ const latestAddr = await this.metaspace.getLatestAddr({ ibGib: this });
112
112
  if (latestAddr && latestAddr !== thisAddr) {
113
113
  // this has a newer ibgib in its timeline
114
- let resGet = await this.ibgibsSvc.get({ addr: latestAddr });
114
+ let resGet = await this.metaspace.get({ addr: latestAddr });
115
115
  if (!resGet || !resGet?.success || (resGet?.ibGibs ?? []).length === 0) {
116
116
  throw new Error(`could not get newer ibgib in timeline (E: 15fa346c8ac17edb96e4b0870104c122)`);
117
117
  }
@@ -123,7 +123,7 @@ export class WitnessWithContextBase_V1 extends WitnessBase_V1 {
123
123
  }
124
124
  }
125
125
  else {
126
- console.warn(`${lc} this.ibgibsSvc undefined (W: 44cc5bf1b14b4695b8de4c589787be06)`);
126
+ console.warn(`${lc} this.metaspace undefined (W: 44cc5bf1b14b4695b8de4c589787be06)`);
127
127
  }
128
128
  }
129
129
  catch (error) {
@@ -145,16 +145,16 @@ export class WitnessWithContextBase_V1 extends WitnessBase_V1 {
145
145
  *
146
146
  * @see {@link ibGibs}
147
147
  * @see {@link rel8nName}
148
- * @see {@link ibgibsSvc}
148
+ * @see {@link metaspace}
149
149
  * @see {@link space}
150
150
  *
151
151
  * ## notes
152
152
  *
153
- * * If there is no given `space`, then we will use the `ibgibsSvc` to get
153
+ * * If there is no given `space`, then we will use the `metaspace` to get
154
154
  * the local user space. If none, then we skip persistence.
155
- * * If there is no `ibgibsSvc`, we won't register the new ibgibs locally.
155
+ * * If there is no `metaspace`, we won't register the new ibgibs locally.
156
156
  */
157
- async rel8To({ ibGibs, rel8nName, linked, ibgibsSvc,
157
+ async rel8To({ ibGibs, rel8nName, linked, metaspace,
158
158
  // space,
159
159
  }) {
160
160
  const lc = `${this.lc}[${this.rel8To.name}]`;
@@ -174,21 +174,21 @@ export class WitnessWithContextBase_V1 extends WitnessBase_V1 {
174
174
  if (thisValidationErrors?.length > 0) {
175
175
  throw new Error(`this is an invalid ibGib. thisValidationErrors: ${thisValidationErrors.join('|')} (E: 8f08716866cd13bf254222ee9e6a6722)`);
176
176
  }
177
- ibgibsSvc = ibgibsSvc ?? this.ibgibsSvc;
178
- if (!ibgibsSvc) {
179
- // if (this.ibgibsSvc) {
180
- // if (logalot) { console.log(`${lc} ibgibsSvc arg falsy, but we have a reference on this object, which we will use. (I: ee0d39a47ee8aee8ffd797721fea4322)`); }
181
- // ibgibsSvc = this.ibgibsSvc;
177
+ metaspace = metaspace ?? this.metaspace;
178
+ if (!metaspace) {
179
+ // if (this.metaspace) {
180
+ // if (logalot) { console.log(`${lc} metaspace arg falsy, but we have a reference on this object, which we will use. (I: ee0d39a47ee8aee8ffd797721fea4322)`); }
181
+ // metaspace = this.metaspace;
182
182
  // }
183
- throw new Error(`either ibgibsSvc or this.ibgibsSvc required (E: b5f9453ddb394a2b76dec74c7304df22)`);
183
+ throw new Error(`either metaspace or this.metaspace required (E: b5f9453ddb394a2b76dec74c7304df22)`);
184
184
  }
185
185
  // if (!space) {
186
- // if (ibgibsSvc) {
187
- // if (logalot) { console.log(`${lc} space arg falsy, but ibgibsSvc truthy, so we'll use ibgibsSvc's local user space for persistence. (I: 37a4b4c1406556cb23831671755b0d22)`); }
188
- // space = await ibgibsSvc.getLocalUserSpace({ lock: true });
186
+ // if (metaspace) {
187
+ // if (logalot) { console.log(`${lc} space arg falsy, but metaspace truthy, so we'll use metaspace's local user space for persistence. (I: 37a4b4c1406556cb23831671755b0d22)`); }
188
+ // space = await metaspace.getLocalUserSpace({ lock: true });
189
189
  // }
190
190
  // }
191
- // if (!space) { throw new Error(`(UNEXPECTED) space required and ibgibsSvc couldn't get it? (E: a3b9f9b72f6f6f18883199a19d38c622)`); }
191
+ // if (!space) { throw new Error(`(UNEXPECTED) space required and metaspace couldn't get it? (E: a3b9f9b72f6f6f18883199a19d38c622)`); }
192
192
  // #endregion initialize, validate args and this
193
193
  // we want to rel8 only to the ibGibs whose timelines we're not
194
194
  // already related to. So we look to see if we already have the tjpGib
@@ -222,7 +222,7 @@ export class WitnessWithContextBase_V1 extends WitnessBase_V1 {
222
222
  }
223
223
  // if space is given, perform the persistence
224
224
  // if (space) {
225
- await ibgibsSvc.persistTransformResult({ resTransform: resNewThis });
225
+ await metaspace.persistTransformResult({ resTransform: resNewThis });
226
226
  // } else {
227
227
  // if (logalot) { console.log(`${lc} space falsy, skipping persistence (I: 90aa3553e92ad1d02bce61f83648ea22)`); }
228
228
  // }
@@ -230,7 +230,7 @@ export class WitnessWithContextBase_V1 extends WitnessBase_V1 {
230
230
  // override `loadIbGibDto` to update secondary/derivative properties
231
231
  await this.loadIbGibDto(newThisIbGib);
232
232
  // (in the future, need to revisit the ibgibs service to the idea of locality/ies).
233
- await ibgibsSvc.registerNewIbGib({ ibGib: newThisIbGib });
233
+ await metaspace.registerNewIbGib({ ibGib: newThisIbGib });
234
234
  }
235
235
  catch (error) {
236
236
  console.error(`${lc} ${extractErrorMsg(error)}`);
@@ -253,10 +253,10 @@ export class WitnessWithContextBase_V1 extends WitnessBase_V1 {
253
253
  if (!contextIbGib) {
254
254
  throw new Error(`contextIbGib required (E: 85f27c7cbf713704c21084c141cd8822)`);
255
255
  }
256
- if (!this.ibgibsSvc) {
257
- throw new Error(`this.ibgibsSvc required (E: 6a38c4274bdefc8d44cafd2d6faaa222)`);
256
+ if (!this.metaspace) {
257
+ throw new Error(`this.metaspace required (E: 6a38c4274bdefc8d44cafd2d6faaa222)`);
258
258
  }
259
- // space = space ?? await this.ibgibsSvc.getLocalUserSpace({ lock: true });
259
+ // space = space ?? await this.metaspace.getLocalUserSpace({ lock: true });
260
260
  // if (!space) { throw new Error(`space required (E: 267ad87c148942cda641349df0bbbd22)`); }
261
261
  if ((rel8nNames ?? []).length === 0) {
262
262
  if (!this.data?.defaultRel8nName) {
@@ -276,10 +276,10 @@ export class WitnessWithContextBase_V1 extends WitnessBase_V1 {
276
276
  nCounter: true
277
277
  });
278
278
  // ...persist it...
279
- await this.ibgibsSvc.persistTransformResult({ resTransform: resRel8ToContext });
279
+ await this.metaspace.persistTransformResult({ resTransform: resRel8ToContext });
280
280
  // ...register the context.
281
281
  const { newIbGib: newContext } = resRel8ToContext;
282
- await this.ibgibsSvc.registerNewIbGib({ ibGib: newContext });
282
+ await this.metaspace.registerNewIbGib({ ibGib: newContext });
283
283
  }
284
284
  catch (error) {
285
285
  console.error(`${lc} ${extractErrorMsg(error)}`);
@@ -292,21 +292,21 @@ export class WitnessWithContextBase_V1 extends WitnessBase_V1 {
292
292
  if (logalot) {
293
293
  console.log(`${lc} starting... (I: c3a005f7d323468a5b4e1b2710901d22)`);
294
294
  }
295
- if (!this.ibgibsSvc) {
296
- throw new Error(`this.ibgibsSvc required (E: 5dbb1a7f0ff5469b8ce3cb1be175e521)`);
295
+ if (!this.metaspace) {
296
+ throw new Error(`this.metaspace required (E: 5dbb1a7f0ff5469b8ce3cb1be175e521)`);
297
297
  }
298
- // space = space ?? await this.ibgibsSvc.getLocalUserSpace({ lock: true });
299
- // if (!space) { throw new Error(`(UNEXPECTED) space required and wasn't able to get it from ibgibsSvc? (E: 7159f9893a66c28a7e09b61384545622)`); }
300
- let space = await this.ibgibsSvc.getLocalUserSpace({ lock: true });
298
+ // space = space ?? await this.metaspace.getLocalUserSpace({ lock: true });
299
+ // if (!space) { throw new Error(`(UNEXPECTED) space required and wasn't able to get it from metaspace? (E: 7159f9893a66c28a7e09b61384545622)`); }
300
+ let space = await this.metaspace.getLocalUserSpace({ lock: true });
301
301
  /** tag this comment with metadata to show it came from this witness */
302
302
  let resComment = await createCommentIbGib({ text, addlMetadataText: this.getAddlMetadata(), saveInSpace: true, space });
303
303
  // get again to be sure it's the latest space.
304
- space = await this.ibgibsSvc.getLocalUserSpace({ lock: true });
304
+ space = await this.metaspace.getLocalUserSpace({ lock: true });
305
305
  const commentIbGib = resComment.newIbGib;
306
306
  if (!commentIbGib) {
307
307
  throw new Error(`(UNEXPECTED) failed to create comment? (E: 6d668f4e55198e654324622eabaac922)`);
308
308
  }
309
- await this.ibgibsSvc.registerNewIbGib({ ibGib: commentIbGib });
309
+ await this.metaspace.registerNewIbGib({ ibGib: commentIbGib });
310
310
  await this.rel8ToContextIbGib({ ibGibToRel8: commentIbGib, contextIbGib, rel8nNames: ['comment'] });
311
311
  await this.rel8To({
312
312
  ibGibs: [commentIbGib],
@@ -393,8 +393,8 @@ export class WitnessWithContextBase_V1 extends WitnessBase_V1 {
393
393
  if (!arg && !addr) {
394
394
  throw new Error(`either arg or addr required. (E: 3f647b65742242fd9ba878521acf7c22)`);
395
395
  }
396
- if (!this.ibgibsSvc) {
397
- throw new Error(`(UNEXPECTED) this.ibgibsSvc required (E: f0046290b0d66d28c4bbbf83d9d9f523)`);
396
+ if (!this.metaspace) {
397
+ throw new Error(`(UNEXPECTED) this.metaspace required (E: f0046290b0d66d28c4bbbf83d9d9f523)`);
398
398
  }
399
399
  if (arg) {
400
400
  if ((arg.ibGibs ?? []).length === 0) {
@@ -407,16 +407,16 @@ export class WitnessWithContextBase_V1 extends WitnessBase_V1 {
407
407
  }
408
408
  else {
409
409
  // addr provided
410
- const resGet = await this.ibgibsSvc.get({ addr });
410
+ const resGet = await this.metaspace.get({ addr });
411
411
  if (!resGet.success || resGet.ibGibs?.length !== 1) {
412
412
  throw new Error(`could not get context addr (${addr}) (E: 834492313512a45b23a7bebacdc48122)`);
413
413
  }
414
414
  contextIbGib = resGet.ibGibs[0];
415
415
  }
416
416
  if (latest) {
417
- const resLatestAddr = await this.ibgibsSvc.getLatestAddr({ ibGib: contextIbGib });
417
+ const resLatestAddr = await this.metaspace.getLatestAddr({ ibGib: contextIbGib });
418
418
  if (resLatestAddr !== getIbGibAddr({ ibGib: contextIbGib })) {
419
- const resGet = await this.ibgibsSvc.get({ addr: resLatestAddr });
419
+ const resGet = await this.metaspace.get({ addr: resLatestAddr });
420
420
  if (resGet.success && resGet.ibGibs?.length === 1) {
421
421
  contextIbGib = resGet.ibGibs[0];
422
422
  }
@@ -441,7 +441,7 @@ export class WitnessWithContextBase_V1 extends WitnessBase_V1 {
441
441
  * The context is the ibgib where we are interacting with the user(s).
442
442
  *
443
443
  * When we initialize, we are setting state on this witness as well as
444
- * subscribing to the context ibgib's updates in `this.ibgibsSvc`.
444
+ * subscribing to the context ibgib's updates in `this.metaspace`.
445
445
  *
446
446
  * if we already have a context, then this will check the new incoming
447
447
  * context against it. If it's the same timeline, then this won't do
@@ -453,8 +453,8 @@ export class WitnessWithContextBase_V1 extends WitnessBase_V1 {
453
453
  if (logalot) {
454
454
  console.log(`${lc} starting... (I: d93429c85b0a494388f66fba3eece922)`);
455
455
  }
456
- if (!this.ibgibsSvc) {
457
- throw new Error(`this.ibgibsSvc (metaspace) required. set this before using this witness. (E: 67db388a0223bf813b40accd9941ad23)`);
456
+ if (!this.metaspace) {
457
+ throw new Error(`this.metaspace (metaspace) required. set this before using this witness. (E: 67db388a0223bf813b40accd9941ad23)`);
458
458
  }
459
459
  if (arg && contextIbGib) {
460
460
  console.warn(`${lc} both arg and contextIbGib provided. using raw contextIbGib (W: d6d723ad7fb942079833c40647aecd22)`);
@@ -493,14 +493,14 @@ export class WitnessWithContextBase_V1 extends WitnessBase_V1 {
493
493
  updatePriorChildren();
494
494
  // subscribe to context ibgib updates
495
495
  const contextTjpAddr = getTjpAddr({ ibGib: this._currentWorkingContextIbGib });
496
- if (!this.ibgibsSvc) {
497
- throw new Error(`(UNEXPECTED) this.ibgibsSvc falsy...not initialized? (E: 6e38bfdc5c2eb5fef884f0183889e823)`);
496
+ if (!this.metaspace) {
497
+ throw new Error(`(UNEXPECTED) this.metaspace falsy...not initialized? (E: 6e38bfdc5c2eb5fef884f0183889e823)`);
498
498
  }
499
- if (!this.ibgibsSvc.latestObs) {
500
- throw new Error(`(UNEXPECTED) this.ibgibsSvc.latestObs falsy? (E: 831936570c14ed526f9c9ab511929923)`);
499
+ if (!this.metaspace.latestObs) {
500
+ throw new Error(`(UNEXPECTED) this.metaspace.latestObs falsy? (E: 831936570c14ed526f9c9ab511929923)`);
501
501
  }
502
502
  this._contextChangesSubscription =
503
- await this.ibgibsSvc.latestObs
503
+ await this.metaspace.latestObs
504
504
  // .pipe(
505
505
  // filter(x => x.tjpAddr === contextTjpAddr)
506
506
  // ).subscribe(async (update: any) => {
@@ -543,7 +543,7 @@ export class WitnessWithContextBase_V1 extends WitnessBase_V1 {
543
543
  },
544
544
  error: async (err) => {
545
545
  const lcErr = `${lc}[latestObs.error]`;
546
- console.error(`${lcErr} this.ibgibsSvc.latestObs error: ${extractObsErrMsg({ err })}. (E: 99df4c42195d46d0a9dbfb06ac45ae00)`);
546
+ console.error(`${lcErr} this.metaspace.latestObs error: ${extractObsErrMsg({ err })}. (E: 99df4c42195d46d0a9dbfb06ac45ae00)`);
547
547
  },
548
548
  }));
549
549
  // rel8 to the context (conversation)
@@ -558,7 +558,7 @@ export class WitnessWithContextBase_V1 extends WitnessBase_V1 {
558
558
  // if needed)
559
559
  // let gibInfo = getGibInfo({ gib: this._currentWorkingContextIbGib.gib });
560
560
  // if (gibInfo.tjpGib) {
561
- // this.ibgibsSvc.latestObs
561
+ // this.metaspace.latestObs
562
562
  // .subscribe(update => {
563
563
  // if (!update.tjpAddr) { return; /* <<<< returns early */ }
564
564
  // if (getIbAndGib({ ibGibAddr: update.tjpAddr }).gib !== gibInfo.tjpGib) { return; /* <<<< returns early */ }
@@ -724,10 +724,10 @@ export class WitnessWithContextBase_V1 extends WitnessBase_V1 {
724
724
  return []; /* <<<< returns early */
725
725
  }
726
726
  // get the latest addrs for those children
727
- if (!this.ibgibsSvc) {
728
- throw new Error(`this.ibgibsSvc falsy. not initialized? (E: 1cc26ca7de7fadcdbaecbd6613350e23)`);
727
+ if (!this.metaspace) {
728
+ throw new Error(`this.metaspace falsy. not initialized? (E: 1cc26ca7de7fadcdbaecbd6613350e23)`);
729
729
  }
730
- const space = await this.ibgibsSvc.getLocalUserSpace({});
730
+ const space = await this.metaspace.getLocalUserSpace({});
731
731
  if (!space) {
732
732
  throw new Error(`couldn't get local user space? (E: f118f75e5852fc22bba3a6495beec723)`);
733
733
  }
@@ -741,7 +741,7 @@ export class WitnessWithContextBase_V1 extends WitnessBase_V1 {
741
741
  // some of the addrs were not found in the space
742
742
  throw new Error(`some addrs were not found in the space. (E: 2216d8e5ad7fb600ceb025ed7c90f323)`);
743
743
  }
744
- const resGet = await this.ibgibsSvc.get({ addrs: latestAddrs });
744
+ const resGet = await this.metaspace.get({ addrs: latestAddrs });
745
745
  if (!resGet.success || resGet.ibGibs?.length !== newChildrenAddrs.length) {
746
746
  throw new Error(`failed to get newChildren with addrs: ${newChildrenAddrs.join('|')}. Error: ${resGet.errorMsg ?? 'unknown error 5737bd0996d5445b8bd80975bedc0d57'} (E: 05722e11350ec6ffffdb5c7d0caa2922)`);
747
747
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ibgib/core-gib",
3
- "version": "0.0.75",
3
+ "version": "0.0.77",
4
4
  "description": "ibgib core functionality, including base architecture for witnesses, spaces, apps, robbots, etc., as well as shared utility functions. Node v19+ needed for heavily-used isomorphic webcrypto hashing consumed in both node and browsers.",
5
5
  "repository": {
6
6
  "url": "https://gitlab.com/ibgib/core-gib",
@@ -64,7 +64,7 @@ export abstract class ObservableBase_V1<
64
64
  * Reference to the local ibgibs service, which is one way at getting at the
65
65
  * local user space.
66
66
  */
67
- public ibgibsSvc: MetaspaceService | undefined;
67
+ public metaspace: MetaspaceService | undefined;
68
68
 
69
69
  protected _subscribers: { [subscriptionId: string]: [SubscriptionWitness, ObserverWitness<TIbGibIn_ie_Payload> | WitnessAny] } = {};
70
70
 
@@ -89,7 +89,7 @@ export class Subject_V1<
89
89
  * Reference to the local ibgibs service, which is one way at getting at the
90
90
  * local user space.
91
91
  */
92
- public ibgibsSvc: MetaspaceService | undefined;
92
+ public metaspace: MetaspaceService | undefined;
93
93
 
94
94
  constructor(initialData?: SubjectData_V1, initialRel8ns?: SubjectRel8ns_V1) {
95
95
  super(initialData, initialRel8ns);
@@ -82,7 +82,7 @@ export class Subscription_V1
82
82
  * Reference to the local ibgibs service, which is one way at getting at the
83
83
  * local user space.
84
84
  */
85
- public ibgibsSvc: MetaspaceService | undefined;
85
+ public metaspace: MetaspaceService | undefined;
86
86
 
87
87
  /**
88
88
  * this is UNDEFINED if we have not yet subscribed.
@@ -61,7 +61,7 @@ export abstract class AppBase_V1<
61
61
  * Reference to the local ibgibs service, which is one way at getting at the
62
62
  * local user space.
63
63
  */
64
- ibgibsSvc: MetaspaceService | undefined;
64
+ metaspace: MetaspaceService | undefined;
65
65
 
66
66
  constructor(initialData?: TData, initialRel8ns?: TRel8ns) {
67
67
  super(initialData, initialRel8ns);
@@ -69,7 +69,7 @@ export abstract class KeystoneBase_V1<
69
69
  * Reference to the local ibgibs service, which is one way at getting at the
70
70
  * local user space.
71
71
  */
72
- ibgibsSvc: MetaspaceService | undefined;
72
+ metaspace: MetaspaceService | undefined;
73
73
 
74
74
  constructor(initialData?: TData, initialRel8ns?: TRel8ns) {
75
75
  super(initialData, initialRel8ns);
@@ -685,8 +685,8 @@ export abstract class RobbotBase_V1<
685
685
 
686
686
  await this.loadNewerSelfIfAvailable();
687
687
 
688
- if (!this.ibgibsSvc) { throw new Error(`this.ibgibsSvc falsy (E: fd2f9e4384a725122f4de2eb76696923)`); }
689
- const space = await this.ibgibsSvc.getLocalUserSpace({ lock: true });
688
+ if (!this.metaspace) { throw new Error(`this.metaspace falsy (E: fd2f9e4384a725122f4de2eb76696923)`); }
689
+ const space = await this.metaspace.getLocalUserSpace({ lock: true });
690
690
 
691
691
  const rel8dIbGibs: { [rel8nName: string]: IbGib_V1[] } = {};
692
692
 
@@ -459,8 +459,11 @@ export abstract class MetaspaceBase implements MetaspaceService {
459
459
  protected cacheSvc: IbGibCacheService | undefined,
460
460
  ) {
461
461
  const lc = `${this.lc}[ctor]`;
462
- if (logalot) { console.log(`${lc}${GLOBAL_TIMER_NAME}`); console.timeLog(GLOBAL_TIMER_NAME); }
463
- console.log(`${lc} created.`);
462
+ if (logalot) {
463
+ console.log(`${lc}${GLOBAL_TIMER_NAME}`);
464
+ console.timeLog(GLOBAL_TIMER_NAME);
465
+ console.log(`${lc} created. (I: 5fe7af9fccc2488282eecc8255729cec)`);
466
+ }
464
467
  }
465
468
 
466
469
  protected async initializeMetaspaceFactory({ metaspaceFactory }: { metaspaceFactory: MetaspaceFactory }): Promise<void> {
@@ -1490,7 +1490,9 @@ export async function createSpecialIbGib({
1490
1490
  nCounter: true,
1491
1491
  });
1492
1492
  await persistTransformResult({ resTransform: resNewSpecial, space });
1493
- if (type !== 'roots' && !skipRel8ToRoot) {
1493
+ // we don't relate the special roots index to itself and we don't relate
1494
+ // the latest index as it is a super (woohoo!) special ephemeral ibgib.
1495
+ if (type !== 'roots' && type !== 'latest' && !skipRel8ToRoot) {
1494
1496
  await rel8ToCurrentRoot({
1495
1497
  ibGib: resNewSpecial.newIbGib,
1496
1498
  linked: true,
@@ -102,7 +102,7 @@ export abstract class WitnessWithContextBase_V1<
102
102
  *
103
103
  * todo: refactor this to `metaspace` after we have completed majority of refactor/breakout from mvp
104
104
  */
105
- public ibgibsSvc: MetaspaceService | undefined;
105
+ public metaspace: MetaspaceService | undefined;
106
106
 
107
107
  protected _contextChangesSubscription: SubscriptionWitness | undefined;
108
108
  protected _currentWorkingContextIbGib: IbGib_V1 | undefined;
@@ -142,13 +142,13 @@ export abstract class WitnessWithContextBase_V1<
142
142
  const lc = `${this.lc}[${this.loadNewerSelfIfAvailable.name}]`;
143
143
  try {
144
144
  if (logalot) { console.log(`${lc} starting... (I: 94755c3131f4dfa12d20fa38e2926522)`); }
145
- if (this.ibgibsSvc) {
145
+ if (this.metaspace) {
146
146
  // check for newer version of self locally before executing
147
147
  const thisAddr = getIbGibAddr({ ibGib: this });
148
- const latestAddr = await this.ibgibsSvc.getLatestAddr({ ibGib: this });
148
+ const latestAddr = await this.metaspace.getLatestAddr({ ibGib: this });
149
149
  if (latestAddr && latestAddr !== thisAddr) {
150
150
  // this has a newer ibgib in its timeline
151
- let resGet = await this.ibgibsSvc.get({ addr: latestAddr });
151
+ let resGet = await this.metaspace.get({ addr: latestAddr });
152
152
  if (!resGet || !resGet?.success || (resGet?.ibGibs ?? []).length === 0) {
153
153
  throw new Error(`could not get newer ibgib in timeline (E: 15fa346c8ac17edb96e4b0870104c122)`);
154
154
  }
@@ -157,7 +157,7 @@ export abstract class WitnessWithContextBase_V1<
157
157
  if (validationErrors?.length > 0) { throw new Error(`validationErrors when loading newer version: ${pretty(validationErrors)} (E: 0d9f0684a1ff6af44e20a57130e3ac22)`); }
158
158
  }
159
159
  } else {
160
- console.warn(`${lc} this.ibgibsSvc undefined (W: 44cc5bf1b14b4695b8de4c589787be06)`);
160
+ console.warn(`${lc} this.metaspace undefined (W: 44cc5bf1b14b4695b8de4c589787be06)`);
161
161
  }
162
162
  } catch (error) {
163
163
  console.error(`${lc} ${extractErrorMsg(error)}`);
@@ -176,20 +176,20 @@ export abstract class WitnessWithContextBase_V1<
176
176
  *
177
177
  * @see {@link ibGibs}
178
178
  * @see {@link rel8nName}
179
- * @see {@link ibgibsSvc}
179
+ * @see {@link metaspace}
180
180
  * @see {@link space}
181
181
  *
182
182
  * ## notes
183
183
  *
184
- * * If there is no given `space`, then we will use the `ibgibsSvc` to get
184
+ * * If there is no given `space`, then we will use the `metaspace` to get
185
185
  * the local user space. If none, then we skip persistence.
186
- * * If there is no `ibgibsSvc`, we won't register the new ibgibs locally.
186
+ * * If there is no `metaspace`, we won't register the new ibgibs locally.
187
187
  */
188
188
  protected async rel8To({
189
189
  ibGibs,
190
190
  rel8nName,
191
191
  linked,
192
- ibgibsSvc,
192
+ metaspace,
193
193
  // space,
194
194
  }: {
195
195
  /**
@@ -211,7 +211,7 @@ export abstract class WitnessWithContextBase_V1<
211
211
  /**
212
212
  * If provided, will register the newly created ibgib.
213
213
  */
214
- ibgibsSvc?: MetaspaceService,
214
+ metaspace?: MetaspaceService,
215
215
  // /**
216
216
  // * If given (which atow is most likely the case), then the {@link TransformResult} will
217
217
  // * be persisted in this `space`.
@@ -232,24 +232,24 @@ export abstract class WitnessWithContextBase_V1<
232
232
  const thisValidationErrors = await this.validateThis();
233
233
  if (thisValidationErrors?.length > 0) { throw new Error(`this is an invalid ibGib. thisValidationErrors: ${thisValidationErrors.join('|')} (E: 8f08716866cd13bf254222ee9e6a6722)`); }
234
234
 
235
- ibgibsSvc = ibgibsSvc ?? this.ibgibsSvc;
235
+ metaspace = metaspace ?? this.metaspace;
236
236
 
237
- if (!ibgibsSvc) {
238
- // if (this.ibgibsSvc) {
239
- // if (logalot) { console.log(`${lc} ibgibsSvc arg falsy, but we have a reference on this object, which we will use. (I: ee0d39a47ee8aee8ffd797721fea4322)`); }
240
- // ibgibsSvc = this.ibgibsSvc;
237
+ if (!metaspace) {
238
+ // if (this.metaspace) {
239
+ // if (logalot) { console.log(`${lc} metaspace arg falsy, but we have a reference on this object, which we will use. (I: ee0d39a47ee8aee8ffd797721fea4322)`); }
240
+ // metaspace = this.metaspace;
241
241
  // }
242
- throw new Error(`either ibgibsSvc or this.ibgibsSvc required (E: b5f9453ddb394a2b76dec74c7304df22)`);
242
+ throw new Error(`either metaspace or this.metaspace required (E: b5f9453ddb394a2b76dec74c7304df22)`);
243
243
  }
244
244
 
245
245
  // if (!space) {
246
- // if (ibgibsSvc) {
247
- // if (logalot) { console.log(`${lc} space arg falsy, but ibgibsSvc truthy, so we'll use ibgibsSvc's local user space for persistence. (I: 37a4b4c1406556cb23831671755b0d22)`); }
248
- // space = await ibgibsSvc.getLocalUserSpace({ lock: true });
246
+ // if (metaspace) {
247
+ // if (logalot) { console.log(`${lc} space arg falsy, but metaspace truthy, so we'll use metaspace's local user space for persistence. (I: 37a4b4c1406556cb23831671755b0d22)`); }
248
+ // space = await metaspace.getLocalUserSpace({ lock: true });
249
249
  // }
250
250
  // }
251
251
 
252
- // if (!space) { throw new Error(`(UNEXPECTED) space required and ibgibsSvc couldn't get it? (E: a3b9f9b72f6f6f18883199a19d38c622)`); }
252
+ // if (!space) { throw new Error(`(UNEXPECTED) space required and metaspace couldn't get it? (E: a3b9f9b72f6f6f18883199a19d38c622)`); }
253
253
 
254
254
  // #endregion initialize, validate args and this
255
255
 
@@ -285,7 +285,7 @@ export abstract class WitnessWithContextBase_V1<
285
285
 
286
286
  // if space is given, perform the persistence
287
287
  // if (space) {
288
- await ibgibsSvc.persistTransformResult({ resTransform: resNewThis });
288
+ await metaspace.persistTransformResult({ resTransform: resNewThis });
289
289
  // } else {
290
290
  // if (logalot) { console.log(`${lc} space falsy, skipping persistence (I: 90aa3553e92ad1d02bce61f83648ea22)`); }
291
291
  // }
@@ -295,7 +295,7 @@ export abstract class WitnessWithContextBase_V1<
295
295
  await this.loadIbGibDto(newThisIbGib);
296
296
 
297
297
  // (in the future, need to revisit the ibgibs service to the idea of locality/ies).
298
- await ibgibsSvc.registerNewIbGib({ ibGib: newThisIbGib });
298
+ await metaspace.registerNewIbGib({ ibGib: newThisIbGib });
299
299
  } catch (error) {
300
300
  console.error(`${lc} ${extractErrorMsg(error)}`);
301
301
  throw error;
@@ -321,9 +321,9 @@ export abstract class WitnessWithContextBase_V1<
321
321
  try {
322
322
  if (!ibGibToRel8 && !ibGibAddrToRel8) { throw new Error(`ibGibToRel8 or ibGibAddrToRel8 required (E: 3ee14659fd22355a5ba0e537a477be22)`); }
323
323
  if (!contextIbGib) { throw new Error(`contextIbGib required (E: 85f27c7cbf713704c21084c141cd8822)`); }
324
- if (!this.ibgibsSvc) { throw new Error(`this.ibgibsSvc required (E: 6a38c4274bdefc8d44cafd2d6faaa222)`); }
324
+ if (!this.metaspace) { throw new Error(`this.metaspace required (E: 6a38c4274bdefc8d44cafd2d6faaa222)`); }
325
325
 
326
- // space = space ?? await this.ibgibsSvc.getLocalUserSpace({ lock: true });
326
+ // space = space ?? await this.metaspace.getLocalUserSpace({ lock: true });
327
327
  // if (!space) { throw new Error(`space required (E: 267ad87c148942cda641349df0bbbd22)`); }
328
328
 
329
329
  if ((rel8nNames ?? []).length === 0) {
@@ -346,11 +346,11 @@ export abstract class WitnessWithContextBase_V1<
346
346
  });
347
347
 
348
348
  // ...persist it...
349
- await this.ibgibsSvc.persistTransformResult({ resTransform: resRel8ToContext });
349
+ await this.metaspace.persistTransformResult({ resTransform: resRel8ToContext });
350
350
 
351
351
  // ...register the context.
352
352
  const { newIbGib: newContext } = resRel8ToContext;
353
- await this.ibgibsSvc.registerNewIbGib({ ibGib: newContext });
353
+ await this.metaspace.registerNewIbGib({ ibGib: newContext });
354
354
  } catch (error) {
355
355
  console.error(`${lc} ${extractErrorMsg(error)}`);
356
356
  throw error;
@@ -365,27 +365,27 @@ export abstract class WitnessWithContextBase_V1<
365
365
  text: string,
366
366
  contextIbGib: IbGib_V1,
367
367
  rel8nName: string,
368
- ibgibsSvc?: MetaspaceService,
368
+ metaspace?: MetaspaceService,
369
369
  }): Promise<void> {
370
370
  const lc = `${this.lc}[${this.createCommentAndRel8ToContextIbGib.name}]`;
371
371
  try {
372
372
  if (logalot) { console.log(`${lc} starting... (I: c3a005f7d323468a5b4e1b2710901d22)`); }
373
373
 
374
- if (!this.ibgibsSvc) { throw new Error(`this.ibgibsSvc required (E: 5dbb1a7f0ff5469b8ce3cb1be175e521)`); }
374
+ if (!this.metaspace) { throw new Error(`this.metaspace required (E: 5dbb1a7f0ff5469b8ce3cb1be175e521)`); }
375
375
 
376
- // space = space ?? await this.ibgibsSvc.getLocalUserSpace({ lock: true });
377
- // if (!space) { throw new Error(`(UNEXPECTED) space required and wasn't able to get it from ibgibsSvc? (E: 7159f9893a66c28a7e09b61384545622)`); }
378
- let space = await this.ibgibsSvc.getLocalUserSpace({ lock: true });
376
+ // space = space ?? await this.metaspace.getLocalUserSpace({ lock: true });
377
+ // if (!space) { throw new Error(`(UNEXPECTED) space required and wasn't able to get it from metaspace? (E: 7159f9893a66c28a7e09b61384545622)`); }
378
+ let space = await this.metaspace.getLocalUserSpace({ lock: true });
379
379
 
380
380
  /** tag this comment with metadata to show it came from this witness */
381
381
  let resComment = await createCommentIbGib({ text, addlMetadataText: this.getAddlMetadata(), saveInSpace: true, space });
382
382
 
383
383
  // get again to be sure it's the latest space.
384
- space = await this.ibgibsSvc.getLocalUserSpace({ lock: true });
384
+ space = await this.metaspace.getLocalUserSpace({ lock: true });
385
385
 
386
386
  const commentIbGib = resComment.newIbGib as CommentIbGib_V1;
387
387
  if (!commentIbGib) { throw new Error(`(UNEXPECTED) failed to create comment? (E: 6d668f4e55198e654324622eabaac922)`); }
388
- await this.ibgibsSvc.registerNewIbGib({ ibGib: commentIbGib });
388
+ await this.metaspace.registerNewIbGib({ ibGib: commentIbGib });
389
389
 
390
390
  await this.rel8ToContextIbGib({ ibGibToRel8: commentIbGib, contextIbGib, rel8nNames: ['comment'] });
391
391
  await this.rel8To({
@@ -477,22 +477,22 @@ export abstract class WitnessWithContextBase_V1<
477
477
  if (logalot) { console.log(`${lc} starting... (I: c13f7cb92133984048f606075efb8a22)`); }
478
478
  let contextIbGib: IbGib_V1;
479
479
  if (!arg && !addr) { throw new Error(`either arg or addr required. (E: 3f647b65742242fd9ba878521acf7c22)`); }
480
- if (!this.ibgibsSvc) { throw new Error(`(UNEXPECTED) this.ibgibsSvc required (E: f0046290b0d66d28c4bbbf83d9d9f523)`); }
480
+ if (!this.metaspace) { throw new Error(`(UNEXPECTED) this.metaspace required (E: f0046290b0d66d28c4bbbf83d9d9f523)`); }
481
481
  if (arg) {
482
482
  if ((arg.ibGibs ?? []).length === 0) { throw new Error(`(UNEXPECTED) invalid arg? no context ibgib on arg (E: 89997eb4bdeb3885bee9de5d33ee0f22)`); }
483
483
  if ((arg.ibGibs ?? []).length !== 1) { throw new Error(`(UNEXPECTED) invalid arg? only expected one ibgib on arg.ibGibs (E: 1a1498af668740fe9439f4953a74ea8a)`); }
484
484
  contextIbGib = arg.ibGibs![0];
485
485
  } else {
486
486
  // addr provided
487
- const resGet = await this.ibgibsSvc.get({ addr });
487
+ const resGet = await this.metaspace.get({ addr });
488
488
  if (!resGet.success || resGet.ibGibs?.length !== 1) { throw new Error(`could not get context addr (${addr}) (E: 834492313512a45b23a7bebacdc48122)`); }
489
489
  contextIbGib = resGet.ibGibs[0];
490
490
  }
491
491
 
492
492
  if (latest) {
493
- const resLatestAddr = await this.ibgibsSvc.getLatestAddr({ ibGib: contextIbGib });
493
+ const resLatestAddr = await this.metaspace.getLatestAddr({ ibGib: contextIbGib });
494
494
  if (resLatestAddr !== getIbGibAddr({ ibGib: contextIbGib })) {
495
- const resGet = await this.ibgibsSvc.get({ addr: resLatestAddr });
495
+ const resGet = await this.metaspace.get({ addr: resLatestAddr });
496
496
  if (resGet.success && resGet.ibGibs?.length === 1) {
497
497
  contextIbGib = resGet.ibGibs[0];
498
498
  } else {
@@ -513,7 +513,7 @@ export abstract class WitnessWithContextBase_V1<
513
513
  * The context is the ibgib where we are interacting with the user(s).
514
514
  *
515
515
  * When we initialize, we are setting state on this witness as well as
516
- * subscribing to the context ibgib's updates in `this.ibgibsSvc`.
516
+ * subscribing to the context ibgib's updates in `this.metaspace`.
517
517
  *
518
518
  * if we already have a context, then this will check the new incoming
519
519
  * context against it. If it's the same timeline, then this won't do
@@ -553,7 +553,7 @@ export abstract class WitnessWithContextBase_V1<
553
553
  const lc = `${this.lc}[${this.initializeContext.name}]`;
554
554
  try {
555
555
  if (logalot) { console.log(`${lc} starting... (I: d93429c85b0a494388f66fba3eece922)`); }
556
- if (!this.ibgibsSvc) { throw new Error(`this.ibgibsSvc (metaspace) required. set this before using this witness. (E: 67db388a0223bf813b40accd9941ad23)`); }
556
+ if (!this.metaspace) { throw new Error(`this.metaspace (metaspace) required. set this before using this witness. (E: 67db388a0223bf813b40accd9941ad23)`); }
557
557
  if (arg && contextIbGib) {
558
558
  console.warn(`${lc} both arg and contextIbGib provided. using raw contextIbGib (W: d6d723ad7fb942079833c40647aecd22)`);
559
559
  }
@@ -593,10 +593,10 @@ export abstract class WitnessWithContextBase_V1<
593
593
 
594
594
  // subscribe to context ibgib updates
595
595
  const contextTjpAddr = getTjpAddr({ ibGib: this._currentWorkingContextIbGib });
596
- if (!this.ibgibsSvc) { throw new Error(`(UNEXPECTED) this.ibgibsSvc falsy...not initialized? (E: 6e38bfdc5c2eb5fef884f0183889e823)`); }
597
- if (!this.ibgibsSvc.latestObs) { throw new Error(`(UNEXPECTED) this.ibgibsSvc.latestObs falsy? (E: 831936570c14ed526f9c9ab511929923)`); }
596
+ if (!this.metaspace) { throw new Error(`(UNEXPECTED) this.metaspace falsy...not initialized? (E: 6e38bfdc5c2eb5fef884f0183889e823)`); }
597
+ if (!this.metaspace.latestObs) { throw new Error(`(UNEXPECTED) this.metaspace.latestObs falsy? (E: 831936570c14ed526f9c9ab511929923)`); }
598
598
  this._contextChangesSubscription =
599
- await this.ibgibsSvc.latestObs
599
+ await this.metaspace.latestObs
600
600
  // .pipe(
601
601
  // filter(x => x.tjpAddr === contextTjpAddr)
602
602
  // ).subscribe(async (update: any) => {
@@ -631,7 +631,7 @@ export abstract class WitnessWithContextBase_V1<
631
631
  },
632
632
  error: async (err) => {
633
633
  const lcErr = `${lc}[latestObs.error]`;
634
- console.error(`${lcErr} this.ibgibsSvc.latestObs error: ${extractObsErrMsg({ err })}. (E: 99df4c42195d46d0a9dbfb06ac45ae00)`)
634
+ console.error(`${lcErr} this.metaspace.latestObs error: ${extractObsErrMsg({ err })}. (E: 99df4c42195d46d0a9dbfb06ac45ae00)`)
635
635
  },
636
636
  }));
637
637
 
@@ -649,7 +649,7 @@ export abstract class WitnessWithContextBase_V1<
649
649
  // if needed)
650
650
  // let gibInfo = getGibInfo({ gib: this._currentWorkingContextIbGib.gib });
651
651
  // if (gibInfo.tjpGib) {
652
- // this.ibgibsSvc.latestObs
652
+ // this.metaspace.latestObs
653
653
  // .subscribe(update => {
654
654
  // if (!update.tjpAddr) { return; /* <<<< returns early */ }
655
655
  // if (getIbAndGib({ ibGibAddr: update.tjpAddr }).gib !== gibInfo.tjpGib) { return; /* <<<< returns early */ }
@@ -809,8 +809,8 @@ export abstract class WitnessWithContextBase_V1<
809
809
  }
810
810
 
811
811
  // get the latest addrs for those children
812
- if (!this.ibgibsSvc) { throw new Error(`this.ibgibsSvc falsy. not initialized? (E: 1cc26ca7de7fadcdbaecbd6613350e23)`); }
813
- const space = await this.ibgibsSvc.getLocalUserSpace({});
812
+ if (!this.metaspace) { throw new Error(`this.metaspace falsy. not initialized? (E: 1cc26ca7de7fadcdbaecbd6613350e23)`); }
813
+ const space = await this.metaspace.getLocalUserSpace({});
814
814
  if (!space) { throw new Error(`couldn't get local user space? (E: f118f75e5852fc22bba3a6495beec723)`); }
815
815
  const resLatestAddrs = await getLatestAddrs({ addrs: newChildrenAddrs, space, });
816
816
  const latestAddrs = Object.values(resLatestAddrs?.data?.latestAddrsMap ?? {});
@@ -821,7 +821,7 @@ export abstract class WitnessWithContextBase_V1<
821
821
  // some of the addrs were not found in the space
822
822
  throw new Error(`some addrs were not found in the space. (E: 2216d8e5ad7fb600ceb025ed7c90f323)`);
823
823
  }
824
- const resGet = await this.ibgibsSvc.get({ addrs: latestAddrs as IbGibAddr[] });
824
+ const resGet = await this.metaspace.get({ addrs: latestAddrs as IbGibAddr[] });
825
825
  if (!resGet.success || resGet.ibGibs?.length !== newChildrenAddrs.length) {
826
826
  throw new Error(`failed to get newChildren with addrs: ${newChildrenAddrs.join('|')}. Error: ${resGet.errorMsg ?? 'unknown error 5737bd0996d5445b8bd80975bedc0d57'} (E: 05722e11350ec6ffffdb5c7d0caa2922)`);
827
827
  }