@ibgib/core-gib 0.0.8 → 0.0.11

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.
Files changed (154) hide show
  1. package/README.md +5 -10
  2. package/dist/assumptions.respec.d.mts +2 -0
  3. package/dist/assumptions.respec.d.mts.map +1 -0
  4. package/dist/assumptions.respec.mjs +41 -0
  5. package/dist/assumptions.respec.mjs.map +1 -0
  6. package/dist/core-constants.d.mts +0 -2
  7. package/dist/core-constants.d.mts.map +1 -1
  8. package/dist/core-constants.mjs +0 -2
  9. package/dist/core-constants.mjs.map +1 -1
  10. package/dist/core-helper.respec.d.mts +2 -0
  11. package/dist/core-helper.respec.d.mts.map +1 -0
  12. package/dist/core-helper.respec.mjs +53 -0
  13. package/dist/core-helper.respec.mjs.map +1 -0
  14. package/dist/core-types.d.mts +22 -0
  15. package/dist/core-types.d.mts.map +1 -1
  16. package/dist/respec-gib.node.d.mts +2 -0
  17. package/dist/respec-gib.node.d.mts.map +1 -0
  18. package/dist/respec-gib.node.mjs +211 -0
  19. package/dist/respec-gib.node.mjs.map +1 -0
  20. package/dist/spec-helper.node.respec.d.mts +12 -0
  21. package/dist/spec-helper.node.respec.d.mts.map +1 -0
  22. package/dist/spec-helper.node.respec.mjs +43 -0
  23. package/dist/spec-helper.node.respec.mjs.map +1 -0
  24. package/dist/witness/app/app-base-v1.d.mts +2 -2
  25. package/dist/witness/app/app-base-v1.d.mts.map +1 -1
  26. package/dist/witness/app/app-base-v1.mjs +23 -141
  27. package/dist/witness/app/app-base-v1.mjs.map +1 -1
  28. package/dist/witness/app/app-constants.d.mts +2 -0
  29. package/dist/witness/app/app-constants.d.mts.map +1 -1
  30. package/dist/witness/app/app-constants.mjs +2 -0
  31. package/dist/witness/app/app-constants.mjs.map +1 -1
  32. package/dist/witness/app/app-helper.d.mts.map +1 -1
  33. package/dist/witness/app/app-helper.mjs +2 -1
  34. package/dist/witness/app/app-helper.mjs.map +1 -1
  35. package/dist/witness/app/app-types.d.mts +2 -1
  36. package/dist/witness/app/app-types.d.mts.map +1 -1
  37. package/dist/witness/robbot/robbot-base-v1.d.mts +12 -164
  38. package/dist/witness/robbot/robbot-base-v1.d.mts.map +1 -1
  39. package/dist/witness/robbot/robbot-base-v1.mjs +41 -657
  40. package/dist/witness/robbot/robbot-base-v1.mjs.map +1 -1
  41. package/dist/witness/robbot/robbot-helper.mjs +3 -3
  42. package/dist/witness/robbot/robbot-helper.mjs.map +1 -1
  43. package/dist/witness/robbot/robbot-helper.respec.d.mts +2 -0
  44. package/dist/witness/robbot/robbot-helper.respec.d.mts.map +1 -0
  45. package/dist/witness/robbot/robbot-helper.respec.mjs +106 -0
  46. package/dist/witness/robbot/robbot-helper.respec.mjs.map +1 -0
  47. package/dist/witness/robbot/robbot-types.d.mts +6 -3
  48. package/dist/witness/robbot/robbot-types.d.mts.map +1 -1
  49. package/dist/witness/robbot/robbot-types.mjs +1 -0
  50. package/dist/witness/robbot/robbot-types.mjs.map +1 -1
  51. package/dist/witness/space/filesystem-space/filesystem-space-v1.d.mts +1 -1
  52. package/dist/witness/space/filesystem-space/filesystem-space-v1.d.mts.map +1 -1
  53. package/dist/witness/space/filesystem-space/filesystem-space-v1.respec.d.mts +2 -0
  54. package/dist/witness/space/filesystem-space/filesystem-space-v1.respec.d.mts.map +1 -0
  55. package/dist/witness/space/filesystem-space/filesystem-space-v1.respec.mjs +107 -0
  56. package/dist/witness/space/filesystem-space/filesystem-space-v1.respec.mjs.map +1 -0
  57. package/dist/witness/space/filesystem-space/node-filesystem-space-v1.d.mts.map +1 -1
  58. package/dist/witness/space/filesystem-space/node-filesystem-space-v1.mjs +1 -1
  59. package/dist/witness/space/filesystem-space/node-filesystem-space-v1.mjs.map +1 -1
  60. package/dist/witness/space/filesystem-space/node-filesystem-space-v1.node.respec.d.mts +2 -0
  61. package/dist/witness/space/filesystem-space/node-filesystem-space-v1.node.respec.d.mts.map +1 -0
  62. package/dist/witness/space/filesystem-space/node-filesystem-space-v1.node.respec.mjs +129 -0
  63. package/dist/witness/space/filesystem-space/node-filesystem-space-v1.node.respec.mjs.map +1 -0
  64. package/dist/witness/space/inner-space/inner-space-v1.respec.d.mts +2 -0
  65. package/dist/witness/space/inner-space/inner-space-v1.respec.d.mts.map +1 -0
  66. package/dist/witness/space/inner-space/inner-space-v1.respec.mjs +56 -0
  67. package/dist/witness/space/inner-space/inner-space-v1.respec.mjs.map +1 -0
  68. package/dist/witness/space/metaspace/metaspace-base.d.mts +795 -0
  69. package/dist/witness/space/metaspace/metaspace-base.d.mts.map +1 -0
  70. package/dist/witness/space/metaspace/metaspace-base.mjs +3251 -0
  71. package/dist/witness/space/metaspace/metaspace-base.mjs.map +1 -0
  72. package/dist/witness/space/metaspace/metaspace-innerspace/metaspace-innerspace-helper.d.mts +4 -0
  73. package/dist/witness/space/metaspace/metaspace-innerspace/metaspace-innerspace-helper.d.mts.map +1 -0
  74. package/dist/witness/space/metaspace/metaspace-innerspace/metaspace-innerspace-helper.mjs +117 -0
  75. package/dist/witness/space/metaspace/metaspace-innerspace/metaspace-innerspace-helper.mjs.map +1 -0
  76. package/dist/witness/space/metaspace/metaspace-innerspace/metaspace-innerspace.d.mts +34 -0
  77. package/dist/witness/space/metaspace/metaspace-innerspace/metaspace-innerspace.d.mts.map +1 -0
  78. package/dist/witness/space/metaspace/metaspace-innerspace/metaspace-innerspace.mjs +76 -0
  79. package/dist/witness/space/metaspace/metaspace-innerspace/metaspace-innerspace.mjs.map +1 -0
  80. package/dist/witness/space/metaspace/metaspace-types.d.mts +580 -0
  81. package/dist/witness/space/metaspace/metaspace-types.d.mts.map +1 -0
  82. package/dist/witness/space/metaspace/metaspace-types.mjs +6 -0
  83. package/dist/witness/space/metaspace/metaspace-types.mjs.map +1 -0
  84. package/dist/witness/space/space-helper.d.mts.map +1 -1
  85. package/dist/witness/space/space-helper.mjs +2 -1
  86. package/dist/witness/space/space-helper.mjs.map +1 -1
  87. package/dist/witness/space/{space-spec-helper.d.mts → space-respec-helper.d.mts} +15 -5
  88. package/dist/witness/space/space-respec-helper.d.mts.map +1 -0
  89. package/dist/witness/space/space-respec-helper.mjs +186 -0
  90. package/dist/witness/space/space-respec-helper.mjs.map +1 -0
  91. package/dist/witness/space/space-types.d.mts +2 -1
  92. package/dist/witness/space/space-types.d.mts.map +1 -1
  93. package/dist/witness/space/space-types.mjs.map +1 -1
  94. package/dist/witness/witness-base-v1.d.mts.map +1 -1
  95. package/dist/witness/witness-base-v1.mjs +7 -7
  96. package/dist/witness/witness-base-v1.mjs.map +1 -1
  97. package/dist/witness/witness-cmd/witness-cmd-types.d.mts +31 -0
  98. package/dist/witness/witness-cmd/witness-cmd-types.d.mts.map +1 -0
  99. package/dist/witness/witness-cmd/witness-cmd-types.mjs +2 -0
  100. package/dist/witness/witness-cmd/witness-cmd-types.mjs.map +1 -0
  101. package/dist/witness/witness-helper.d.mts +8 -0
  102. package/dist/witness/witness-helper.d.mts.map +1 -1
  103. package/dist/witness/witness-helper.mjs +30 -0
  104. package/dist/witness/witness-helper.mjs.map +1 -1
  105. package/dist/witness/witness-types.d.mts +26 -36
  106. package/dist/witness/witness-types.d.mts.map +1 -1
  107. package/dist/witness/witness-with-context/witness-with-context-base-v1.d.mts +235 -0
  108. package/dist/witness/witness-with-context/witness-with-context-base-v1.d.mts.map +1 -0
  109. package/dist/witness/witness-with-context/witness-with-context-base-v1.mjs +742 -0
  110. package/dist/witness/witness-with-context/witness-with-context-base-v1.mjs.map +1 -0
  111. package/dist/witness/witness-with-context/witness-with-context-types.d.mts +17 -0
  112. package/dist/witness/witness-with-context/witness-with-context-types.d.mts.map +1 -0
  113. package/dist/witness/witness-with-context/witness-with-context-types.mjs +2 -0
  114. package/dist/witness/witness-with-context/witness-with-context-types.mjs.map +1 -0
  115. package/package.json +12 -15
  116. package/src/{assumptions.spec.mts → assumptions.respec.mts} +11 -5
  117. package/src/core-constants.mts +0 -2
  118. package/src/core-helper.respec.mts +71 -0
  119. package/src/core-types.mts +20 -0
  120. package/src/respec-gib.node.mts +199 -0
  121. package/src/witness/app/app-base-v1.mts +19 -212
  122. package/src/witness/app/app-constants.mts +3 -0
  123. package/src/witness/app/app-helper.mts +2 -1
  124. package/src/witness/app/app-types.mts +1 -1
  125. package/src/witness/robbot/robbot-base-v1.mts +39 -690
  126. package/src/witness/robbot/robbot-helper.mts +1 -1
  127. package/src/witness/robbot/{robbot-helper.spec.mts → robbot-helper.respec.mts} +39 -33
  128. package/src/witness/robbot/robbot-types.mts +5 -3
  129. package/src/witness/space/filesystem-space/filesystem-space-v1.mts +1 -1
  130. package/src/witness/space/filesystem-space/{filesystem-space-v1.spec.mts → filesystem-space-v1.respec.mts} +17 -8
  131. package/src/witness/space/filesystem-space/node-filesystem-space-v1.mts +3 -11
  132. package/src/witness/space/filesystem-space/{node-filesystem-space-v1.node.spec.mts → node-filesystem-space-v1.node.respec.mts} +18 -14
  133. package/src/witness/space/inner-space/{inner-space-v1.spec.mts → inner-space-v1.respec.mts} +17 -8
  134. package/src/witness/space/metaspace/metaspace-base.mts +3702 -0
  135. package/src/witness/space/metaspace/metaspace-innerspace/metaspace-innerspace-helper.mts +116 -0
  136. package/src/witness/space/metaspace/metaspace-innerspace/metaspace-innerspace.mts +88 -0
  137. package/src/witness/space/metaspace/metaspace-types.mts +614 -0
  138. package/src/witness/space/space-helper.mts +2 -1
  139. package/src/witness/space/{space-spec-helper.mts → space-respec-helper.mts} +76 -57
  140. package/src/witness/space/space-types.mts +2 -1
  141. package/src/witness/witness-base-v1.mts +8 -6
  142. package/src/witness/witness-cmd/witness-cmd-types.mts +38 -0
  143. package/src/witness/witness-helper.mts +31 -0
  144. package/src/witness/witness-types.mts +31 -41
  145. package/src/witness/witness-with-context/witness-with-context-base-v1.mts +809 -0
  146. package/src/witness/witness-with-context/witness-with-context-types.mts +24 -0
  147. package/tsconfig.json +1 -0
  148. package/dist/witness/space/space-spec-helper.d.mts.map +0 -1
  149. package/dist/witness/space/space-spec-helper.mjs +0 -179
  150. package/dist/witness/space/space-spec-helper.mjs.map +0 -1
  151. package/jasmine-browser.json +0 -18
  152. package/jasmine.json +0 -6
  153. package/src/core-helper.spec.mts +0 -64
  154. /package/src/{spec-helper.node.spec.mts → spec-helper.node.respec.mts} +0 -0
@@ -0,0 +1,614 @@
1
+ /**
2
+ * Gigantic file with a bunch of shift in it. Needs to be refactored when we
3
+ * have a clearer picture and the prototype is up and limping along...
4
+ */
5
+
6
+ import { Observable, } from 'rxjs';
7
+
8
+
9
+ import { IbGib_V1, } from '@ibgib/ts-gib/dist/V1/index.mjs';
10
+ import { IbGibAddr, TransformResult, } from '@ibgib/ts-gib';
11
+
12
+ import {
13
+ DeleteIbGibOpts, DeleteIbGibResult,
14
+ GetIbGibOpts, GetIbGibResult,
15
+ PutIbGibOpts, PutIbGibResult
16
+ } from '../../../common/other/other-types.mjs';
17
+ import { SyncSagaInfo, } from '../../../witness/space/outer-space/outer-space-types.mjs';
18
+ import { SpaceId } from '../../../witness/space/space-types.mjs';
19
+ import { IbGibSpaceAny } from '../../../witness/space/space-base-v1.mjs';
20
+ import { IbGibTimelineUpdateInfo, SpecialIbGibType } from '../../../common/other/other-types.mjs';
21
+ import { RootData } from '../../../common/root/root-types.mjs';
22
+ import {
23
+ CiphertextData, CiphertextIbGib_V1, CiphertextRel8ns,
24
+ EncryptionData_V1, EncryptionIbGib, EncryptionInfo_EncryptGib,
25
+ SecretData_V1, SecretIbGib_V1, SecretInfo_Password
26
+ } from '../../../common/encrypt/encrypt-types.mjs';
27
+ import { RobbotIbGib_V1 } from '../../../witness/robbot/robbot-types.mjs';
28
+ import { AppIbGib_V1 } from '../../../witness/app/app-types.mjs';
29
+ import { rel8ToSpecialIbGib, } from '../../../witness/space/space-helper.mjs';
30
+ import { GetDependencyGraphOptions } from '../../../common/other/graph-helper.mjs';
31
+
32
+ export interface CreateLocalSpaceOptions {
33
+ allowCancel: boolean;
34
+ spaceName: string | undefined;
35
+ getFnPrompt: () => ((arg: { title: string, msg: string }) => Promise<string>);
36
+ logalot?: number | boolean;
37
+ }
38
+
39
+ export type DtoToSpaceFunction = (spaceDto: IbGib_V1) => Promise<IbGibSpaceAny>;
40
+ export type ZeroSpaceFactoryFunction = () => IbGibSpaceAny;
41
+ export type LocalSpaceFactoryFunction = (opts: CreateLocalSpaceOptions) => Promise<IbGibSpaceAny | undefined>;
42
+
43
+ export interface MetaspaceInitializeOptions {
44
+ /**
45
+ * If provided, will initialize using this spaceName if creating a new local
46
+ * space. if a local space already exists, i.e., if a bootstrap already points
47
+ * to an existing local space, then this is ignored.
48
+ */
49
+ spaceName?: string;
50
+ metaspaceFactory?: MetaspaceFactory;
51
+ getFnAlert: () => ((arg: { title: string, msg: string, }) => Promise<void>);
52
+ getFnPrompt: () => ((arg: { title: string, msg: string }) => Promise<string>);
53
+ getFnPromptPassword: () => ((title: string, msg: string) => Promise<string | null>);
54
+ }
55
+
56
+ /**
57
+ * space-related factory functions
58
+ */
59
+ export interface MetaspaceFactory {
60
+ /**
61
+ * if this is truthy, then this will be used when the service.zerospace
62
+ * getter property is called.
63
+ *
64
+ * # intent
65
+ *
66
+ * I'm adding this for the ability to have an in-memory only zero space and
67
+ * other spaces implementation.
68
+ *
69
+ * @returns factory function for generating zero space
70
+ */
71
+ fnZeroSpaceFactory?: ZeroSpaceFactoryFunction;
72
+ /**
73
+ * If truthy, this will be used when creating local spaces by default.
74
+
75
+ * # intent
76
+ *
77
+ * I'm adding this for the ability to have an in-memory only zero space and
78
+ * other spaces implementation.
79
+ *
80
+ * @returns async factory function for generating local spaces
81
+ */
82
+ fnDefaultLocalSpaceFactory?: LocalSpaceFactoryFunction;
83
+ fnDtoToSpace?: DtoToSpaceFunction;
84
+ }
85
+
86
+ export interface TempCacheEntry {
87
+ /**
88
+ * Password to the user's password.
89
+ */
90
+ tempMetaPassword: string;
91
+ /**
92
+ * Encrypted user password
93
+ */
94
+ encryptedPassword: string;
95
+ /**
96
+ * salt used in cached encryption.
97
+ */
98
+ salt: string;
99
+ }
100
+
101
+ /**
102
+ * Primary "All Powerful" service (too big) that does a lot of work for a local
103
+ * metaspace (like a node).
104
+ *
105
+ * This service provides conveniences for working with one or more local spaces,
106
+ * using one space as a default space.
107
+ *
108
+ * For example, the metaspace maintains data about timelines via the latest^gib.
109
+ * This provides the local source of truth for the "head" of each timeline,
110
+ * similar to an index. This latest^gib ibgib is one example of a "special
111
+ * ibgib". Usually these are indexes to other ibgibs.
112
+ *
113
+ * ## regarding special ibgibs
114
+ *
115
+ * Many special ibgibs are analogs to other apps' configuration data. The
116
+ * difference is that most special ibgibs can leverage the "on-chain"
117
+ * functionality of "regular" ibgibs.
118
+ *
119
+ * Here are a couple of special ibgibs atow:
120
+ * * roots^gib
121
+ * * indexes root^gib ibgibs. Any ibgib in a local space will usually have
122
+ * its temporal junction point (the very first unique ibgib in a timeline,
123
+ * like a birthday) in a root^gib.
124
+ * * latest^gib
125
+ * * tracks mappings between tjp -> latest ib^gib address
126
+ * * ephemeral (deletes past rel8ns and past ibGib frames)
127
+ * * tags^gib
128
+ * * index of tag^gib ibgibs, which function like tags or bookmarks in the
129
+ * MVP.
130
+ * * apps^gib
131
+ * * indexes app ibgibs
132
+ * * these hold data like app config but
133
+ * * also relate to witness ibgibs provide UXs for human users to interact
134
+ * within a context ibgib.
135
+ * * robbots^gib
136
+ * * indexes robbot ibgibs, which can interact within context ibgibs.
137
+ * * secrets^gib
138
+ * * indexes secret^gib that are used with creating private ibgib data.
139
+ * * does not contain actual secrets, but rather provides metadata to prompt
140
+ * the user for some secret, like hints/context to a password.
141
+ * * encryptions^gib
142
+ * * encryption settings
143
+ * * outerspaces^gib
144
+ * * other spaces to connect with, e.g. cloud sync space
145
+ * * autosyncs^gib
146
+ * * metadata of ibgibs that get automatically synced with other space(s)
147
+ *
148
+ * ## regarding latest ibgibs
149
+ *
150
+ * The tjp (temporal junction point) defines atow the beginning of an ibGib
151
+ * timeline. it's like the birthday for an ibGib. (Or you can think if it as
152
+ * the id for the stream of ibgib frames in a given timeline, but the "id" is
153
+ * itself an ib^gib content address that includes the hash.)
154
+ *
155
+ * The latest ibGib in that timeline is also special, because it's often what
156
+ * you want to work with.
157
+ *
158
+ * So ideally, when an ibgib, A, has a tjp A1, and it is updated to A2, A3, An
159
+ * via `mut8` and/or `rel8` transforms, that ibgib creates a single timeline.
160
+ * This service attempts to track the relationship between that starting tjp
161
+ * address and its corresponding latest frame in that timeline, i.e., A1 -> An.
162
+ *
163
+ * ### mapping persistence implementation details
164
+ *
165
+ * The latest ibGib service is backed by a special ibgib that maintains the
166
+ * mapping index. It does this by rel8-ing that special backing ibgib via the
167
+ * tjp pointer, e.g. [special latest ibgib^XXX000].rel8ns[A^TJP123] ===
168
+ * [A^N12345] . It does this via the ib^gib content address pointer, so this
169
+ * becomes a mapping from A^TJP123 to A^N12345.
170
+ *
171
+ * This backing ibGib is special (even for special ibGibs) in that:
172
+ * * it does not relate itself with the current root of the application
173
+ * * it does not maintain references to its past (i.e. rel8ns['past'] === [])
174
+ * * it DELETES its previous incarnation from the files service
175
+ *
176
+ * In other words, this service is meant to be as ephemeral as possible. I am
177
+ * keeping it as an ibGib and not some other data format (like straight in
178
+ * storage/some other db) because I've found this is often useful and what I end
179
+ * up doing anyway to leverage other ibgib behavior. For example, in the future
180
+ * it may be good to take snapshots, which is a simple copy operation of the
181
+ * file persistence.
182
+ *
183
+ * ### current naive implementation notes
184
+ *
185
+ * questions:
186
+ * * What do we want to do if we can't locate an ibGib record?
187
+ * * How/when do we want to alert the user/our own code that we've found
188
+ * multiple timelines for an ibGib with a tjp (usually a thing we want to
189
+ * avoid)?
190
+ * * Who do we want to notify when new ibGibs arrive?
191
+ * * How often do we want to check external sources for latest?
192
+ * * When do we get to merging ibGib timelines?
193
+ *
194
+ * This is behavior that is somewhat taken care of, e.g. in git, with the HEAD
195
+ * pointer for a repo. But we're talking about here basically as a metarepo or
196
+ * "repo of repos", and unlike git, we don't want our HEAD metadata living "off
197
+ * chain" (outside of the DLT itself that it's modifying). So eventually, what
198
+ * we want is just like what we want with ALL ibGibs: perspective. From "the
199
+ * app"'s perspective, the latest is mapped. But really, apps can't view slices
200
+ * of ibGib graphs in all sorts of interesting ways and still be productive &
201
+ * beneficial to the ecosystem as a whole.
202
+ */
203
+ export interface MetaspaceService {
204
+ instanceId: string;
205
+ get initialized(): boolean;
206
+ get initializing(): boolean;
207
+ get initialized$(): Observable<void>;
208
+ get latestObs(): Observable<IbGibTimelineUpdateInfo>;
209
+
210
+ /**
211
+ * gets the current local user space according to this svc.
212
+ */
213
+ getLocalUserSpace(arg: {
214
+ /**
215
+ * If true, then we lock by bootstrap/spaceId before trying to retrieve.
216
+ *
217
+ * @default If undefined, will default to false if platform is 'web', else true
218
+ */
219
+ lock?: boolean,
220
+ /**
221
+ * If provided, will look for the space via this id in the bootstrap ibgib.
222
+ * If not provided, will use the bootstrap ibgib's default spaceId.
223
+ */
224
+ localSpaceId?: SpaceId,
225
+ }): Promise<IbGibSpaceAny | undefined>;
226
+
227
+ /**
228
+ * gets all local user spaces known in bootstrap ibgib, according to
229
+ * spaceIds property
230
+ *
231
+ * (`bootstrapIbGib.data[BOOTSTRAP_DATA_KNOWN_SPACE_IDS_KEY]` atow)
232
+ *
233
+ * ## example bootstrap ibgib atow
234
+ *
235
+ ```json
236
+ {
237
+ "ib":"bootstrap",
238
+ "gib":"gib",
239
+ "data":{
240
+ "defaultSpaceId":"d455d9a72807617634ccbf1e532b71037c45762f824ec85fcd9a4c2275562f33",
241
+ "spaceIds":["d455d9a72807617634ccbf1e532b71037c45762f824ec85fcd9a4c2275562f33"]
242
+ },
243
+ "rel8ns":{
244
+ "d455d9a72807617634ccbf1e532b71037c45762f824ec85fcd9a4c2275562f33":[
245
+ "witness space IonicSpace_V1 oij d455d9a72807617634ccbf1e532b71037c45762f824ec85fcd9a4c2275562f33^B336251655E8C56B38E9E86F20E0E42E6C153785F1A0A798ADE6916E71CF055B"
246
+ ]
247
+ }
248
+ }
249
+ ```
250
+ *
251
+ * so this enumerates `data.spaceIds` and gets the corresponding addrs in the `rel8ns`.
252
+ * it then gets the space ibgibs themselves via the local zero space.
253
+ *
254
+ * @returns array of known local user spaces
255
+ *
256
+ * @throws if no local user spaces found (there should be at least one atow i think)
257
+ */
258
+ getLocalUserSpaces(arg: {
259
+ /**
260
+ * If true, then we lock by bootstrap/spaceId before trying to retrieve.
261
+ *
262
+ * @default false if platform is 'web', else true
263
+ */
264
+ lock?: boolean,
265
+ }): Promise<IbGibSpaceAny[]>;
266
+
267
+ get zeroSpace(): IbGibSpaceAny;
268
+
269
+ get syncing(): boolean;
270
+ initialize(opts: MetaspaceInitializeOptions): Promise<void>;
271
+
272
+ /**
273
+ * Takes the given `key`, which should be unique in the given space (or
274
+ * zerospace), and uses that to get the stored `addr` in that space.
275
+ *
276
+ * # notes
277
+ *
278
+ * configuration is stored in "special" ibgibs, and so we need only to persist
279
+ * the address of that configuration.
280
+ */
281
+ getConfigAddr(arg: {
282
+ key: string,
283
+ space?: IbGibSpaceAny,
284
+ }): Promise<string | undefined>;
285
+ fnUpdateBootstrap: (newSpace: IbGibSpaceAny) => Promise<void>;
286
+ fnBroadcast: (info: IbGibTimelineUpdateInfo) => void;
287
+ /**
288
+ * Takes the given `key`, which should be unique in the given space (or
289
+ * zerospace), and uses that to persist the given `addr` in that space.
290
+ *
291
+ * # notes
292
+ *
293
+ * configuration is stored in "special" ibgibs, and so we need only to persist
294
+ * the address of that configuration.
295
+ */
296
+ setConfigAddr(arg: {
297
+ key: string,
298
+ addr: string,
299
+ space?: IbGibSpaceAny,
300
+ }): Promise<IbGibSpaceAny>;
301
+ /**
302
+ * Gets the current root in the given space, or the default zerospace if not provided.
303
+ */
304
+ getCurrentRoot(arg: { space?: IbGibSpaceAny }): Promise<IbGib_V1<RootData> | undefined>;
305
+ /**
306
+ * Sets the current root in the given space, or the default zerospace if not provided.
307
+ */
308
+ setCurrentRoot(arg: { root: IbGib_V1<RootData>, space?: IbGibSpaceAny }): Promise<void>;
309
+ /**
310
+ * Every tjp should be related to one of the roots in a space.
311
+ *
312
+ * You should NOT relate every ibgib frame of a given ibGib.
313
+ */
314
+ rel8ToCurrentRoot(arg: {
315
+ ibGib: IbGib_V1,
316
+ linked?: boolean,
317
+ rel8nName?: string,
318
+ space?: IbGibSpaceAny,
319
+ }): Promise<void>;
320
+ /**
321
+ * rel8s given ibgibs to special ibgib.
322
+ * @see {@link rel8ToSpecialIbGib}
323
+ * @returns new special ibgib addr
324
+ */
325
+ rel8ToSpecialIbGib(arg: {
326
+ type: SpecialIbGibType,
327
+ rel8nName: string,
328
+ /**
329
+ * multiple ibgibs to rel8
330
+ */
331
+ ibGibsToRel8?: IbGib_V1[],
332
+ /**
333
+ * multiple ibgibs to remove rel8n.
334
+ */
335
+ ibGibsToUnRel8?: IbGib_V1[],
336
+ linked?: boolean,
337
+ /**
338
+ * Clears out the special.rel8ns.past array to an empty array.
339
+ *
340
+ * {@see deletePreviousSpecialIbGib} for driving use case.
341
+ */
342
+ severPast?: boolean,
343
+ /**
344
+ * Deletes the previous special ibGib.
345
+ *
346
+ * ## driving use case
347
+ *
348
+ * the latest ibGib is one that is completely ephemeral. It doesn't get attached
349
+ * to the current root, and it only has the current instance. So we don't want to
350
+ * keep around past incarnations.
351
+ */
352
+ deletePreviousSpecialIbGib?: boolean,
353
+ space?: IbGibSpaceAny,
354
+ }): Promise<IbGibAddr>;
355
+ /**
356
+ * Used for tracking tjpAddr -> latest ibGibAddr.
357
+ *
358
+ * Call this when you create a new ibGib.
359
+ *
360
+ * Need to put this in another service at some point, but crunch crunch
361
+ * like pacman's lunch.
362
+ */
363
+ registerNewIbGib(arg: { ibGib: IbGib_V1, space?: IbGibSpaceAny }): Promise<void>;
364
+ /**
365
+ * Will trigger a latest info event to be fired.
366
+ * @param param0
367
+ */
368
+ pingLatest_Local(arg: {
369
+ ibGib: IbGib_V1<any>,
370
+ tjpIbGib: IbGib_V1<any>,
371
+ space?: IbGibSpaceAny,
372
+ /**
373
+ * If true, then will check the latest ibgib cache first. if found, will
374
+ * just return that.
375
+ */
376
+ useCache: boolean,
377
+ }): Promise<void>;
378
+ /**
379
+ * Convenience function for persisting a transform result, which has
380
+ * a newIbGib and optionally intermediate ibGibs and/or dnas.
381
+ *
382
+ * it persists these ibgibs into the given space, else the current space.
383
+ */
384
+ persistTransformResult(arg: {
385
+ resTransform: TransformResult<IbGib_V1>,
386
+ isMeta?: boolean,
387
+ force?: boolean,
388
+ space?: IbGibSpaceAny,
389
+ }): Promise<void>;
390
+ /**
391
+ * Wrapper for retrieving ibgib from a given space, else the current space.
392
+ */
393
+ get(arg: GetIbGibOpts): Promise<GetIbGibResult>;
394
+ /**
395
+ * Wrapper for saving ibgib in a given space, else the current space.
396
+ */
397
+ put(arg: PutIbGibOpts): Promise<PutIbGibResult>;
398
+ /**
399
+ * Wrapper for removing ibgib from the a given space, else the current space.
400
+ */
401
+ delete(arg: DeleteIbGibOpts): Promise<DeleteIbGibResult>;
402
+ /**
403
+ * Wrapper for `getDependencyGraph` fn in `helper/space.ts`, but using
404
+ * `this.localUserSpace` as default space.
405
+ *
406
+ * (refactoring!)
407
+ *
408
+ * ## note on space
409
+ *
410
+ * pass in `null` for space if you want to
411
+ *
412
+ * ## warning
413
+ *
414
+ * This does not (YET) have a flag that gets the latest ibgibs for the graph.
415
+ * It only climbs the current graph, which may not cover all ibgibs when you
416
+ * deal with ibGibs with tjps (timelines). We're going to eventually
417
+ * combat this with auto-updating our rel8ns, but for now we're just going
418
+ * to earmark this for the future.
419
+ *
420
+ * todo: auto-update or better
421
+ *
422
+ * @returns map of addr => ibGib
423
+ */
424
+ getDependencyGraph(opts: GetDependencyGraphOptions): Promise<{ [addr: string]: IbGib_V1 }>;
425
+ /**
426
+ * Wrapper for getting the latest addr in the given space.
427
+ *
428
+ * ## warnings
429
+ *
430
+ * * This was written early and makes many assumptions.
431
+ * * Meant to work with Ionic space atow.
432
+ *
433
+ * @returns latest addr in a given space (or localUserSpace)
434
+ */
435
+ getLatestAddr(arg: {
436
+ ibGib?: IbGib_V1<any>,
437
+ addr?: IbGibAddr,
438
+ tjpAddr?: IbGibAddr,
439
+ tjp?: IbGib_V1<any>,
440
+ space?: IbGibSpaceAny,
441
+ }): Promise<IbGibAddr | undefined>;
442
+ /**
443
+ * Gets the tjpIbGib for the given `ibGib` in the given `space`.
444
+ * atow, naive must be true.
445
+ *
446
+ *
447
+ *
448
+ * @returns tjpIbGib for the given `ibGib`
449
+ */
450
+ getTjpIbGib(arg: {
451
+ ibGib: IbGib_V1<any>,
452
+ naive?: boolean,
453
+ space?: IbGibSpaceAny,
454
+ }): Promise<IbGib_V1<any> | undefined>;
455
+ /**
456
+ * Gets one of the app's special ibGibs, e.g., TagsIbGib.
457
+ *
458
+ * When initializing tags, this will generate some boilerplate tags.
459
+ * I'm going to be doing roots here also, and who knows what else, but each
460
+ * one will have its own initialize specifics.
461
+ *
462
+ * @param initialize initialize (i.e. create) ONLY IF IbGib not found. Used for initializing app (first run).
463
+ *
464
+ * @see {@link createSpecial}
465
+ * @see {@link createTags}
466
+ */
467
+ getSpecialIbGib(arg: {
468
+ type: SpecialIbGibType,
469
+ initialize?: boolean,
470
+ space?: IbGibSpaceAny,
471
+ lock?: boolean,
472
+ }): Promise<IbGib_V1 | null>;
473
+ getSpecialRel8dIbGibs<TIbGib extends IbGib_V1 = IbGib_V1>(arg: {
474
+ type: SpecialIbGibType,
475
+ rel8nName: string,
476
+ space?: IbGibSpaceAny,
477
+ }): Promise<TIbGib[]>;
478
+ /**
479
+ * Feels klugy.
480
+ */
481
+ getPasswordForSecrets(arg: {
482
+ secretIbGibs: IbGib_V1<SecretData_V1>[],
483
+ fnPromptPassword: (title: string, msg: string) => Promise<string | null>,
484
+ dontPrompt?: boolean,
485
+ checkCacheFirst?: boolean,
486
+ cacheAfter?: boolean,
487
+ }): Promise<string | null>;
488
+ getCiphertextIbGib<TEncryptionIbGib extends IbGib_V1<EncryptionData_V1>, TMetadata = any>(arg: {
489
+ /**
490
+ * Um...data...to...erm...encrypt...(as a string)
491
+ */
492
+ plaintext: string,
493
+ /**
494
+ * Password to perform the encryption.
495
+ */
496
+ password: string,
497
+ /**
498
+ * Information about encryption, i.e. encryption settings.
499
+ */
500
+ encryptionIbGib: TEncryptionIbGib,
501
+ /**
502
+ * Decrypts and checks against original data
503
+ */
504
+ confirm?: boolean,
505
+ /**
506
+ * If true, will persist the ibgib
507
+ */
508
+ persist?: boolean,
509
+ /**
510
+ * If you provide this, the resulting ibgib will have the following format:
511
+ * `${ibRoot} ${publicIbMetadata}`. Otherwise, this will default to:
512
+ * `ciphertext ${publicIbMetadata}`, or just `ciphertext` if
513
+ * `publicIbMetadata` is falsy.
514
+ */
515
+ ibRoot?: string,
516
+ /**
517
+ * If you want to include metadata in the ib itself of the
518
+ * ciphertext ibgib. This will of course make this metadata
519
+ * available without loading the full ibgib, but will increase
520
+ * storage size because every address linking to the ibgib will
521
+ * include this as well.
522
+ */
523
+ publicIbMetadata?: string,
524
+ /**
525
+ * If you want to include public, unencrypted metadata in the ibgib's
526
+ * data body itself.
527
+ */
528
+ publicMetadata?: TMetadata,
529
+ }): Promise<TransformResult<CiphertextIbGib_V1>>;
530
+ /**
531
+ * Brings together a ciphertext and secretIbGibs to decrypt
532
+ * the `ciphertextIbGib.data.ciphertext`
533
+ * @returns plaintext string of `ciphertextIbGib.data.ciphertext`
534
+ */
535
+ getPlaintextString(arg: {
536
+ ciphertextIbGib: CiphertextIbGib_V1,
537
+ secretIbGibs: SecretIbGib_V1[],
538
+ fnPromptPassword: (title: string, msg: string) => Promise<string | null>,
539
+ dontPrompt?: boolean,
540
+ space: IbGibSpaceAny,
541
+ }): Promise<string>;
542
+ unwrapEncryptedSyncSpace(arg: {
543
+ encryptedSpace: IbGibSpaceAny,
544
+ fnPromptPassword: (title: string, msg: string) => Promise<string | null>,
545
+ dontPrompt?: boolean,
546
+ space?: IbGibSpaceAny,
547
+ }): Promise<IbGibSpaceAny>;
548
+ getAppSyncSpaces(arg: {
549
+ unwrapEncrypted: boolean,
550
+ createIfNone: boolean,
551
+ /**
552
+ * If true, don't prompt the user if we don't have it already cached.
553
+ *
554
+ * We don't want the user to hit the page and then always have to type in
555
+ * the password, just because my password code sucks atow.
556
+ */
557
+ dontPrompt?: boolean,
558
+ space?: IbGibSpaceAny,
559
+ }): Promise<IbGibSpaceAny[]>;
560
+ getAppRobbotIbGibs(arg: {
561
+ createIfNone: boolean,
562
+ space?: IbGibSpaceAny,
563
+ }): Promise<RobbotIbGib_V1[]>;
564
+ getAppAppIbGibs(arg: {
565
+ createIfNone: boolean,
566
+ space?: IbGibSpaceAny,
567
+ }): Promise<AppIbGib_V1[]>;
568
+ syncIbGibs(arg: {
569
+ dependencyGraphIbGibs?: IbGib_V1[],
570
+ // confirm?: boolean,
571
+ /**
572
+ * If true, will watch ibgibs in dependency graph that have timelines
573
+ * (tjps).
574
+ */
575
+ watch?: boolean,
576
+ /**
577
+ * The meat of the sync process is tracked via a status within the sync
578
+ * spaces themselves. I'm addign this fn to track the pre and post progress
579
+ * stuff, since decrypting takes some time, and building the dependency
580
+ * graphs takes time. Both of these happen before the actual syncing occurs
581
+ * in the spaces.
582
+ */
583
+ fnPreSyncProgress?: (msg: string) => Promise<void>,
584
+ }): Promise<SyncSagaInfo[] | undefined>;
585
+ // /**
586
+ // * Prompts the user to select a new picture for the given `picIbGib`.
587
+ // *
588
+ // * If the user does select one, this creates the appropriate ibgibs (pic,
589
+ // * binary, dependencies), saves them, registers the new pic (but not the bin)
590
+ // * in the given `space` if specified, else in the current `localUserSpace`.
591
+ // */
592
+ // updatePic(arg: {
593
+ // /**
594
+ // * picIbGib to update with a new image.
595
+ // */
596
+ // picIbGib: PicIbGib_V1,
597
+ // /**
598
+ // * space within which we are working, i.e., where the incoming `picIbGib` is
599
+ // * and where we will save any new ibgibs.
600
+ // */
601
+ // space?: IbGibSpaceAny,
602
+ // }): Promise<void>;
603
+ // updateComment(arg: {
604
+ // /**
605
+ // * commentIbGib to update with a new text
606
+ // */
607
+ // commentIbGib: CommentIbGib_V1,
608
+ // /**
609
+ // * space within which we are working, i.e., where the incoming `commentIbGib` is
610
+ // * and where we will save any new ibgibs.
611
+ // */
612
+ // space?: IbGibSpaceAny,
613
+ // }): Promise<void>;
614
+ }
@@ -7,7 +7,8 @@ import {
7
7
  import { GIB, IbGib_V1, Rel8n, Factory_V1 as factory, IBGIB_DELIMITER, } from '@ibgib/ts-gib/dist/V1/index.mjs';
8
8
  import { getGib, } from '@ibgib/ts-gib/dist/V1/transforms/transform-helper.mjs';
9
9
 
10
- import { APP_REL8N_NAME, GLOBAL_LOG_A_LOT } from '../../core-constants.mjs';
10
+ import { GLOBAL_LOG_A_LOT } from '../../core-constants.mjs';
11
+ import { APP_REL8N_NAME } from '../app/app-constants.mjs';
11
12
  import {
12
13
  GetIbGibOpts, GetIbGibResult,
13
14
  PutIbGibOpts, PutIbGibResult,