@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
@@ -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 { IbGibAddr, getIbGibAddr } from "@ibgib/ts-gib";
2
8
  import { IbGib_V1, } from "@ibgib/ts-gib/dist/V1/types.mjs";
3
9
  import { Factory_V1 as factory } from '@ibgib/ts-gib/dist/V1/factory.mjs';
@@ -7,6 +13,10 @@ import { IbGibSpaceAny } from "./space-base-v1.mjs";
7
13
  import { getGib } from "@ibgib/ts-gib/dist/V1/index.mjs";
8
14
 
9
15
  export interface CommonSpaceSpecOptions {
16
+ /**
17
+ * sir, maam, whatever the title is
18
+ */
19
+ respecfulTitle: string,
10
20
  /** @optional additional description label for testing */
11
21
  desc?: string,
12
22
  /**
@@ -27,7 +37,7 @@ export interface CommonSpaceSpecOptions {
27
37
  /**
28
38
  * if true, will use `fit` to short-circuit testing.
29
39
  */
30
- useFit?: boolean,
40
+ shortcircuitRespec?: boolean,
31
41
  fnBeforeEach?: () => Promise<void>,
32
42
  fnAfterEach?: () => Promise<void>,
33
43
  }
@@ -42,71 +52,76 @@ export interface CommonSpaceSpecOptions {
42
52
  * run tests on an ibgib space that are common to all/most spaces.
43
53
  *
44
54
  * So, we can run these against any space, inner, outer, local ionic/filesystem based, etc.
55
+ *
56
+ * NOTE: Be sure to await these tests.
45
57
  */
46
- export function testSpace_createAndInit({
58
+ export async function testSpace_createAndInit({
59
+ respecfulTitle: sir,
47
60
  desc,
48
61
  fnGetInitialData,
49
62
  fnGetInitialRel8ns,
50
63
  fnGetSpace,
51
- useFit,
64
+ shortcircuitRespec,
52
65
  fnBeforeEach, fnAfterEach,
53
66
  }: CommonSpaceSpecOptions): Promise<void> {
54
67
  const logContext = `[${testSpace_PutGetDelete.name}]${desc ?? ''}`;
55
68
 
56
- return new Promise<void>((resolve) => {
69
+ debugger;
70
+ await respecfully(sir, logContext, async () => {
71
+
57
72
  let initialData: any | undefined;
58
73
  let initialRel8ns: any | undefined;
59
74
  let space: IbGibSpaceAny;
60
75
 
61
- beforeEach(async () => {
76
+ firstOfEach(sir, async () => {
62
77
  if (fnBeforeEach) { await fnBeforeEach(); }
63
78
  initialData = await fnGetInitialData();
64
79
  initialRel8ns = await fnGetInitialRel8ns();
65
80
  });
66
81
 
67
82
  if (fnAfterEach) {
68
- afterEach(async () => {
83
+ lastOfEach(sir, async () => {
69
84
  await fnAfterEach();
70
85
  });
71
86
  }
72
87
 
73
- const fnIt: any = useFit ? fit : it;
88
+ const fnIfWeBlock: any = shortcircuitRespec ? ifWeMight : ifWe;
74
89
 
75
- fnIt(`when created and initialized, space should be initialized`, async () => {
90
+ debugger;
91
+ await fnIfWeBlock(sir, `when created and initialized, space should be initialized`, async () => {
76
92
  space = await fnGetSpace(initialData, initialRel8ns);
77
93
  await space.initialized;
78
94
 
79
- expect(space).withContext('space').toBeTruthy();
80
- expect(space.ib).withContext('ib').toBeTruthy();
81
- expect(space.gib).withContext('gib').toBeTruthy();
95
+ iReckon(sir, space).asTo('space').isGonnaBeTruthy();
96
+ iReckon(sir, space.ib).asTo('ib').isGonnaBeTruthy();
97
+ iReckon(sir, space.gib).asTo('gib').isGonnaBeTruthy();
82
98
  if (initialData) {
83
- expect(space.data).withContext('data, initialData truthy').toBeTruthy();
99
+ iReckon(sir, space.data).asTo('data, initialData truthy').isGonnaBeTruthy();
84
100
  } else {
85
- expect(space.rel8ns).withContext('data, initialData falsy').toBeUndefined();
101
+ iReckon(sir, space.rel8ns).asTo('data, initialData falsy').isGonnaBeUndefined();
86
102
  }
87
103
  if (initialRel8ns) {
88
- expect(space.rel8ns).withContext('rel8ns, initialRel8ns truthy').toBeTruthy();
104
+ iReckon(sir, space.rel8ns).asTo('rel8ns, initialRel8ns truthy').isGonnaBeTruthy();
89
105
  } else {
90
- expect(space.rel8ns).withContext('rel8ns, initialRel8ns falsy').toBeUndefined();
106
+ iReckon(sir, space.rel8ns).asTo('rel8ns, initialRel8ns falsy').isGonnaBeUndefined();
91
107
  }
92
108
  });
93
109
 
94
- fnIt(`space.ib should contain correct info per initialData`, async () => {
110
+ await fnIfWeBlock(sir, `space.ib should contain correct info per initialData`, async () => {
95
111
  space = await fnGetSpace(initialData, initialRel8ns);
96
112
  await space.initialized;
97
113
 
98
- expect(space.ib).toContain(initialData.name);
99
- expect(space.ib).toContain(initialData.uuid);
114
+ iReckon(sir, space.ib).includes(initialData.name);
115
+ iReckon(sir, space.ib).includes(initialData.uuid);
100
116
 
101
117
  let { spaceClassname, spaceId, spaceName, } = parseSpaceIb({ spaceIb: space.ib });
102
- expect(space.data?.classname).withContext('space.data?.classname').toEqual(spaceClassname);
103
- expect(space.data?.name).withContext('space.data?.name, initial').toEqual(initialData.name);
104
- expect(space.data?.name).withContext('space.data?.name, spaceName').toEqual(spaceName);
105
- expect(space.data?.uuid).withContext('space.data?.uuid, initial').toEqual(initialData.uuid);
106
- expect(space.data?.uuid).withContext('space.data?.uuid, spaceId').toEqual(spaceId);
118
+ iReckon(sir, space.data?.classname).asTo('space.data?.classname').isGonnaBe(spaceClassname);
119
+ iReckon(sir, space.data?.name).asTo('space.data?.name, initial').isGonnaBe(initialData.name);
120
+ iReckon(sir, space.data?.name).asTo('space.data?.name, spaceName').isGonnaBe(spaceName);
121
+ iReckon(sir, space.data?.uuid).asTo('space.data?.uuid, initial').isGonnaBe(initialData.uuid);
122
+ iReckon(sir, space.data?.uuid).asTo('space.data?.uuid, spaceId').isGonnaBe(spaceId);
107
123
  });
108
124
 
109
- resolve();
110
125
  });
111
126
  }
112
127
 
@@ -120,24 +135,27 @@ export function testSpace_createAndInit({
120
135
  * run tests on an ibgib space that are common to all/most spaces.
121
136
  *
122
137
  * So, we can run these against any space, inner, outer, local ionic/filesystem based, etc.
138
+ *
139
+ * NOTE: Be sure to await these tests.
123
140
  */
124
- export function testSpace_PutGetDelete({
141
+ export async function testSpace_PutGetDelete({
142
+ respecfulTitle: sir,
125
143
  desc,
126
144
  fnGetInitialData,
127
145
  fnGetInitialRel8ns,
128
146
  fnGetSpace,
129
- useFit,
147
+ shortcircuitRespec,
130
148
  fnBeforeEach, fnAfterEach,
131
149
  }: CommonSpaceSpecOptions): Promise<void> {
132
150
  const logContext = `[${testSpace_PutGetDelete.name}]${desc ?? ''}`;
133
151
 
134
- return new Promise<void>((resolve) => {
152
+ await respecfully(sir, logContext, async () => {
135
153
  let initialData: any | undefined;
136
154
  let initialRel8ns: any | undefined;
137
155
  let space: IbGibSpaceAny;
138
156
 
139
157
 
140
- beforeEach(async () => {
158
+ firstOfEach(sir, async () => {
141
159
  if (fnBeforeEach) { await fnBeforeEach(); }
142
160
  initialData = await fnGetInitialData();
143
161
  initialRel8ns = await fnGetInitialRel8ns();
@@ -146,14 +164,14 @@ export function testSpace_PutGetDelete({
146
164
  });
147
165
 
148
166
  if (fnAfterEach) {
149
- afterEach(async () => {
167
+ lastOfEach(sir, async () => {
150
168
  await fnAfterEach();
151
169
  });
152
170
  }
153
171
 
154
- const fnIt: any = useFit ? fit : it;
172
+ const fnIfWeBlock: any = shortcircuitRespec ? ifWeMight : ifWe;
155
173
 
156
- fnIt(`${logContext}, should put/get/delete`, async () => {
174
+ await fnIfWeBlock(sir, `${logContext}, should put/get/delete`, async () => {
157
175
  let newIbGib: IbGib_V1 = {
158
176
  ib: 'test ib',
159
177
  data: { x: 1 },
@@ -164,28 +182,26 @@ export function testSpace_PutGetDelete({
164
182
 
165
183
  // put
166
184
  let resPut = await putInSpace({ ibGib: newIbGib, space });
167
- expect(resPut).withContext('resPut').toBeTruthy();
168
- expect(resPut.success).toBeTrue();
185
+ iReckon(sir, resPut).asTo('resPut').isGonnaBeTruthy();
186
+ iReckon(sir, resPut.success).isGonnaBeTrue();
169
187
 
170
188
  // get
171
189
  let resGet = await getFromSpace({ addr: newIbGibAddr, space });
172
- expect(resGet).withContext('resGet').toBeTruthy();
173
- expect(resGet.success).withContext('resGet').toBeTrue();
174
- expect(resGet.errorMsg).withContext('resGet').toBeFalsy();
175
- expect(resGet.ibGibs).withContext('resGet').toBeTruthy();
176
- expect(resGet.ibGibs!.length).withContext('resGet').toEqual(1);
177
- expect(resGet.ibGibs![0]).withContext('resGet').toEqual(newIbGib);
190
+ iReckon(sir, resGet).asTo('resGet').isGonnaBeTruthy();
191
+ iReckon(sir, resGet.success).asTo('resGet').isGonnaBeTrue();
192
+ iReckon(sir, resGet.errorMsg).asTo('resGet').isGonnaBeFalsy();
193
+ iReckon(sir, resGet.ibGibs).asTo('resGet').isGonnaBeTruthy();
194
+ iReckon(sir, resGet.ibGibs!.length).asTo('resGet').isGonnaBe(1);
195
+ iReckon(sir, resGet.ibGibs![0]).asTo('resGet').isGonnaBe(newIbGib);
178
196
 
179
197
  // delete
180
198
  await deleteFromSpace({ addr: newIbGibAddr, space });
181
199
  resGet = await getFromSpace({ addr: newIbGibAddr, space });
182
- expect(resGet).withContext('resGet after delete').toBeTruthy();
183
- expect(resGet.success).withContext('resGet after delete').toBeFalse();
184
- expect(resGet.errorMsg).withContext('resGet after delete').toBeTruthy();
185
- expect(resGet.ibGibs).withContext('resGet after delete').toBeUndefined();
200
+ iReckon(sir, resGet).asTo('resGet after delete').isGonnaBeTruthy();
201
+ iReckon(sir, resGet.success).asTo('resGet after delete').isGonnaBeFalse();
202
+ iReckon(sir, resGet.errorMsg).asTo('resGet after delete').isGonnaBeTruthy();
203
+ iReckon(sir, resGet.ibGibs).asTo('resGet after delete').isGonnaBeUndefined();
186
204
  });
187
-
188
- resolve();
189
205
  });
190
206
  }
191
207
 
@@ -197,31 +213,35 @@ export function testSpace_PutGetDelete({
197
213
  * run tests on an ibgib space that are common to all/most spaces.
198
214
  *
199
215
  * So, we can run these against any space, inner, outer, local ionic/filesystem based, etc.
216
+ *
217
+ * NOTE: Be sure to await these tests.
200
218
  */
201
- export function testSpace_persistTransformResult({
219
+ export async function testSpace_persistTransformResult({
220
+ respecfulTitle: sir,
202
221
  desc,
203
222
  fnGetInitialData,
204
223
  fnGetInitialRel8ns,
205
224
  fnGetSpace,
206
- useFit,
225
+ shortcircuitRespec,
207
226
  }: CommonSpaceSpecOptions): Promise<void> {
208
227
  const logContext = `[${testSpace_persistTransformResult.name}]${desc ?? ''}`;
209
228
 
210
- return new Promise<void>((resolve) => {
229
+ await respecfully(sir, logContext, async () => {
230
+
211
231
  let initialData: any | undefined;
212
232
  let initialRel8ns: any | undefined;
213
233
  let space: IbGibSpaceAny;
214
234
 
215
- beforeEach(async () => {
235
+ firstOfEach(sir, async () => {
216
236
  initialData = await fnGetInitialData();
217
237
  initialRel8ns = await fnGetInitialRel8ns();
218
238
  space = await fnGetSpace(initialData, initialRel8ns);
219
239
  await space.initialized;
220
240
  });
221
241
 
222
- const fnIt: any = useFit ? fit : it;
242
+ const fnIfWeBlock: any = shortcircuitRespec ? ifWeMight : ifWe;
223
243
 
224
- fnIt(`${logContext} should persist all ibgibs (new, dna, intermediate)`, async () => {
244
+ await fnIfWeBlock(sir, `${logContext} should persist all ibgibs (new, dna, intermediate)`, async () => {
225
245
  let resNew = await factory.firstGen({
226
246
  ib: 'test ib',
227
247
  parentIbGib: factory.primitive({ ib: 'test ib' }),
@@ -241,13 +261,12 @@ export function testSpace_persistTransformResult({
241
261
 
242
262
  let resGet = await getFromSpace({ addrs: allAddrs, space });
243
263
 
244
- expect(resGet).withContext('resGet').toBeTruthy();
245
- expect(resGet.success).toBeTrue();
246
- expect(resGet.ibGibs).toBeTruthy();
247
- expect(resGet.ibGibs!.length).toEqual(allAddrs.length);
248
- expect(resGet.ibGibs![0]).toEqual(newIbGib);
264
+ iReckon(sir, resGet).asTo('resGet').isGonnaBeTruthy();
265
+ iReckon(sir, resGet.success).isGonnaBeTrue();
266
+ iReckon(sir, resGet.ibGibs).isGonnaBeTruthy();
267
+ iReckon(sir, resGet.ibGibs!.length).isGonnaBe(allAddrs.length);
268
+ iReckon(sir, resGet.ibGibs![0]).isGonnaBe(newIbGib);
249
269
  });
250
270
 
251
- resolve();
252
271
  });
253
272
  }
@@ -2,11 +2,12 @@ import { IbGibRel8ns_V1, IbGib_V1 } from '@ibgib/ts-gib/dist/V1/index.mjs';
2
2
  import { IbGibAddr, IbGib, IbGibRel8ns, TjpIbGibAddr } from '@ibgib/ts-gib';
3
3
 
4
4
  import {
5
- Witness, WitnessCmdData, WitnessCmdIbGib, WitnessCmdRel8ns,
5
+ Witness,
6
6
  WitnessData_V1, WitnessResultData, WitnessResultIbGib, WitnessResultRel8ns,
7
7
  } from '../witness-types.mjs';
8
8
  import { IbGibSpaceAny } from './space-base-v1.mjs';
9
9
  import { ENCRYPTION_REL8N_NAME } from '../../common/encrypt/encrypt-constants.mjs';
10
+ import { WitnessCmdData, WitnessCmdIbGib, WitnessCmdRel8ns, } from '../witness-cmd/witness-cmd-types.mjs';
10
11
 
11
12
  /**
12
13
  * Marker type to show intent that it should be the spaceId, i.e.
@@ -9,6 +9,8 @@ import { validateGib, validateIb, validateIbGibIntrinsically } from '@ibgib/ts-g
9
9
  import { ErrorIbGib_V1 } from '../common/error/error-types.mjs';
10
10
  import { toDto } from '../common/other/ibgib-helper.mjs';
11
11
  import { GLOBAL_LOG_A_LOT } from '../core-constants.mjs';
12
+ import { IbGibLocalSpaceService_AllPowerful } from '../core-types.mjs';
13
+ import { clone, pretty } from '@ibgib/helper-gib';
12
14
 
13
15
  const logalot = GLOBAL_LOG_A_LOT || false;
14
16
 
@@ -165,8 +167,8 @@ export abstract class WitnessBase_V1<
165
167
 
166
168
  // let dtoIbGib: IbGib_V1<TData, TRel8ns> = { ib: (this.ib || '').slice() };
167
169
  // if (this.gib) { dtoIbGib.gib = this.gib.slice(); };
168
- // if (this.data) { dtoIbGib.data = h.clone(this.data); }
169
- // if (this.rel8ns) { dtoIbGib.rel8ns = h.clone(this.rel8ns); }
170
+ // if (this.data) { dtoIbGib.data = clone(this.data); }
171
+ // if (this.rel8ns) { dtoIbGib.rel8ns = clone(this.rel8ns); }
170
172
 
171
173
  // return dtoIbGib;
172
174
  }
@@ -190,14 +192,14 @@ export abstract class WitnessBase_V1<
190
192
  if (!dto.ib) { console.warn(`${lc} dto.ib is falsy.`); }
191
193
  if (!dto.gib) { console.warn(`${lc} dto.gib is falsy.`); }
192
194
 
193
- this.ib = h.clone(dto.ib);
194
- this.gib = h.clone(dto.gib);
195
+ this.ib = clone(dto.ib);
196
+ this.gib = clone(dto.gib);
195
197
  if (dto.data) {
196
- this.data = h.clone(dto.data);
198
+ this.data = clone(dto.data);
197
199
  } else {
198
200
  delete this.data;
199
201
  }
200
- if (dto.rel8ns) { this.rel8ns = h.clone(dto.rel8ns); } else { delete this.rel8ns; }
202
+ if (dto.rel8ns) { this.rel8ns = clone(dto.rel8ns); } else { delete this.rel8ns; }
201
203
 
202
204
  return Promise.resolve();
203
205
  } catch (error) {
@@ -0,0 +1,38 @@
1
+ import { IbGibRel8ns_V1 } from "@ibgib/ts-gib/dist/V1/types.mjs";
2
+ import { WitnessArgData, WitnessArgIbGib } from "../witness-types.mjs";
3
+ import { IbGib } from "@ibgib/ts-gib/dist/types.mjs";
4
+
5
+ /**
6
+ * Base information for cmd with optional modifiers to interact with a witness.
7
+ *
8
+ * Note that it is not necessary for a witness to listen to these types of
9
+ * ibgibs, this is just convenient plumbing for those who wish to listen to
10
+ * command-style ibgibs.
11
+ */
12
+ export interface WitnessCmdData<TCmds, TCmdModifiers> extends WitnessArgData {
13
+ /**
14
+ * The `cmd` property is the name of the command, analogous to a function
15
+ * name.
16
+ */
17
+ cmd: TCmds | string;
18
+ /**
19
+ * Optional modifier flag(s) to the command.
20
+ *
21
+ * ## notes
22
+ *
23
+ * An implementing class can always use/extend these or extend the interface
24
+ * of the options data.
25
+ */
26
+ cmdModifiers?: (TCmdModifiers | string)[];
27
+ }
28
+
29
+ export interface WitnessCmdRel8ns extends IbGibRel8ns_V1 {
30
+ }
31
+
32
+ export interface WitnessCmdIbGib<
33
+ TIbGib extends IbGib,
34
+ TCmds, TCmdModifiers,
35
+ TCmdData extends WitnessCmdData<TCmds, TCmdModifiers>,
36
+ TCmdRel8ns extends WitnessCmdRel8ns,
37
+ > extends WitnessArgIbGib<TIbGib, TCmdData, TCmdRel8ns> {
38
+ }
@@ -7,6 +7,7 @@ import {
7
7
  import { GLOBAL_LOG_A_LOT } from '../core-constants.mjs';
8
8
  import { WITNESS_ARG_METADATA_STRING, WITNESS_RESULT_METADATA_STRING } from './witness-constants.mjs';
9
9
 
10
+ import { WitnessCmdData } from './witness-cmd/witness-cmd-types.mjs';
10
11
 
11
12
  const logalot = GLOBAL_LOG_A_LOT || false;
12
13
 
@@ -254,3 +255,33 @@ export function validateWitnessClassname({
254
255
  if (logalot) { console.log(`${lc} complete.`); }
255
256
  }
256
257
  }
258
+
259
+ /**
260
+ * @throws if `ibGib` falsy.
261
+ *
262
+ * @returns true ibGib indicates a cmd arg ibgib, else false
263
+ */
264
+ export function isCommand({
265
+ ibGib,
266
+ }: {
267
+ ibGib: IbGib_V1,
268
+ }): boolean {
269
+ const lc = `[${isCommand.name}]`;
270
+ try {
271
+ if (logalot) { console.log(`${lc} starting...`); }
272
+
273
+ if (!ibGib) { throw new Error(`ibGib required (E: e11cee2a6c59a5e7a4d39ea55751c423)`); }
274
+
275
+ if (!ibGib.data) {
276
+ return false; /* <<<< returns early */
277
+ }
278
+
279
+ const cmdData = (ibGib.data as WitnessCmdData<any, any>);
280
+ return (cmdData.cmd && typeof (cmdData.cmd) === 'string');
281
+ } catch (error) {
282
+ console.error(`${lc} ${error.message}`);
283
+ throw error;
284
+ } finally {
285
+ if (logalot) { console.log(`${lc} complete.`); }
286
+ }
287
+ }
@@ -19,8 +19,8 @@ import { ErrorIbGib_V1 } from '../common/error/error-types.mjs';
19
19
  export interface Witness<
20
20
  TIbGibIn extends IbGib,
21
21
  TIbGibOut extends IbGib,
22
- TData = any,
23
- TRel8ns extends IbGibRel8ns = IbGibRel8ns,
22
+ TData extends WitnessData_V1 = WitnessData_V1,
23
+ TRel8ns extends WitnessRel8ns_V1 = WitnessRel8ns_V1,
24
24
  >
25
25
  extends IbGibWithDataAndRel8ns<TData, TRel8ns> {
26
26
  witness(arg: TIbGibIn): Promise<TIbGibOut | undefined>;
@@ -132,61 +132,45 @@ export interface Witness_V1<
132
132
  * ibgibs, this is just convenient plumbing for those who wish to listen to
133
133
  * command-style ibgibs.
134
134
  */
135
- export interface WitnessCmdData<TCmds, TCmdModifiers> {
135
+ export interface WitnessArgData {
136
136
  /**
137
137
  * Not really in use atm, but will use in the future.
138
138
  */
139
139
  version?: string;
140
140
  /**
141
- * The `cmd` property is the name of the command, analogous to a function
142
- * name.
143
- */
144
- cmd: TCmds | string;
145
- /**
146
- * Optional modifier flag(s) to the command.
147
- *
148
- * ## notes
149
- *
150
- * An implementing class can always use/extend these or extend the interface
151
- * of the options data.
152
- */
153
- cmdModifiers?: (TCmdModifiers | string)[];
154
- /**
155
- * Addrs of ibgibs to get/delete
141
+ * Addrs of ibgibs that this witness arg is wrapping.
156
142
  */
157
143
  ibGibAddrs?: IbGibAddr[];
158
144
  }
159
145
 
160
- export interface WitnessCmdRel8ns extends IbGibRel8ns_V1 {
146
+ export interface WitnessArgRel8ns extends IbGibRel8ns_V1 {
161
147
  }
162
148
 
163
- export interface WitnessCmdIbGib<
149
+
150
+
151
+ /**
152
+ * Shape of an arg wrapper ibgib with a couple common-use properties in data and
153
+ * the object class itself.
154
+ *
155
+ * This is meant to serve as a base class for others, most notably command arg
156
+ * ibgibs, when using witness ibgibs.
157
+ */
158
+ export interface WitnessArgIbGib<
164
159
  TIbGib extends IbGib,
165
- TCmds, TCmdModifiers,
166
- TCmdData extends WitnessCmdData<TCmds, TCmdModifiers>,
167
- TCmdRel8ns extends WitnessCmdRel8ns,
168
- > extends IbGib_V1<TCmdData, TCmdRel8ns> {
160
+ TArgData extends WitnessArgData,
161
+ TArgRel8ns extends WitnessArgRel8ns,
162
+ > extends IbGib_V1<TArgData, TArgRel8ns> {
169
163
  /**
170
- * When putting ibGibs, we don't want to persist the entire graph in the
171
- * data object. So these ibGibs live on the ibGib arg object itself.
172
- *
173
- * If only ibGibs are passed in, and not their corresponding ibGibAddrs in
174
- * the `TOptsData`, then you can't confirm cryptographically if the ibGibs
175
- * are legit. But if you include their corresponding ibGibAddrs in that
176
- * data, then the space can confirm that the ibGibs have not been altered
177
- * from the expected cryptographic audit trail.
178
- *
179
- * This doesn't mean that the ibGibs are kosher completely, but at least
180
- * there is internal agreement and an audit trail.
164
+ * ibgib(s) that this arg wraps.
181
165
  *
182
- * ## example
183
- *
184
- * For an example, check out sync space saga
166
+ * So when you pass in an arg to a witness, this is used often as the
167
+ * payload. For example, a space witness acts like a repo with puts and
168
+ * gets command args. This will contain the references to the ibgibs being
169
+ * put into the space.
185
170
  */
186
171
  ibGibs?: TIbGib[];
187
172
  }
188
173
 
189
-
190
174
  export interface WitnessResultData {
191
175
  /**
192
176
  * The address of the options ibGib that corresponds this space result.
@@ -242,8 +226,14 @@ export interface WitnessResultIbGib<
242
226
  extends IbGibWithDataAndRel8ns<TResultData, TResultRel8ns> {
243
227
 
244
228
  /**
245
- * When expecting ibGibs back, we don't want to persist the graph. So this property of
246
- * ibGibs lives on the ibGib result object, but not in the `data` property.
229
+ * Reference to list of result ibgibs from witness operation.
230
+ *
231
+ * ## notes
232
+ *
233
+ * * this does not have to be the only property on the concrete result
234
+ * ibgib. From my experience so far, this is convenient for when there is
235
+ * one and only one obvious result from a witness operation, like a get
236
+ * command that returns a list of ibgibs.
247
237
  */
248
238
  ibGibs?: TIbGib[];
249
239
  }