@ibgib/ts-gib 0.5.26 → 0.5.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/dist/V1/constants.d.mts +12 -0
- package/dist/V1/constants.d.mts.map +1 -1
- package/dist/V1/constants.mjs +12 -0
- package/dist/V1/constants.mjs.map +1 -1
- package/dist/V1/factory.d.mts +105 -3
- package/dist/V1/factory.d.mts.map +1 -1
- package/dist/V1/factory.mjs +238 -49
- package/dist/V1/factory.mjs.map +1 -1
- package/dist/respec-gib.node.mjs +1 -1
- package/dist/respec-gib.node.mjs.map +1 -1
- package/package.json +1 -1
- package/src/V1/constants.mts +14 -0
- package/src/V1/factory.mts +297 -50
- package/src/V1/factory.respec.mts +144 -1
- package/src/respec-gib.node.mts +1 -1
package/CHANGELOG.md
CHANGED
package/dist/V1/constants.d.mts
CHANGED
|
@@ -48,4 +48,16 @@ export declare const ROOT_ADDR = "ib^gib";
|
|
|
48
48
|
* * protocols built on top of this may also have reserved rel8n/data key names
|
|
49
49
|
*/
|
|
50
50
|
export declare const FORBIDDEN_ADD_RENAME_REMOVE_REL8N_NAMES: string[];
|
|
51
|
+
export declare const IB_MAX_LENGTH_DEFAULT = 155;
|
|
52
|
+
/**
|
|
53
|
+
* Defaults to word characters, space, tab, hyphen, and other
|
|
54
|
+
* non-slash (path navigating) chars.
|
|
55
|
+
*
|
|
56
|
+
* Does not allow new lines or other whitespace, only tabs and spaces.
|
|
57
|
+
*
|
|
58
|
+
* ## atow
|
|
59
|
+
*
|
|
60
|
+
* `^[\\w\\t\\-|=+.&%\$#@!~\` \\[\\]\\(\\)\\{\\}]{1,${IB_MAX_LENGTH_DEFAULT}}$`
|
|
61
|
+
*/
|
|
62
|
+
export declare const IB_REGEXP_DEFAULT: RegExp;
|
|
51
63
|
//# sourceMappingURL=constants.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.mts","sourceRoot":"","sources":["../../src/V1/constants.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC;;GAEG;AACH,eAAO,MAAM,EAAE,OAAO,CAAC;AACvB;;;;;GAKG;AACH,eAAO,MAAM,GAAG,QAAQ,CAAC;AACzB;;;;GAIG;AACH,eAAO,MAAM,IAAI,EAAE,QAAgC,CAAA;AACnD;;;;GAIG;AACH,eAAO,MAAM,eAAe,MAAM,CAAC;AACnC;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,MAAM,CAAC;AACjC;;GAEG;AACH,eAAO,MAAM,SAAS,WAAW,CAAC;AAClC;;;;;;;;;GASG;AACH,eAAO,MAAM,uCAAuC,UAAqC,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.d.mts","sourceRoot":"","sources":["../../src/V1/constants.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC;;GAEG;AACH,eAAO,MAAM,EAAE,OAAO,CAAC;AACvB;;;;;GAKG;AACH,eAAO,MAAM,GAAG,QAAQ,CAAC;AACzB;;;;GAIG;AACH,eAAO,MAAM,IAAI,EAAE,QAAgC,CAAA;AACnD;;;;GAIG;AACH,eAAO,MAAM,eAAe,MAAM,CAAC;AACnC;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,MAAM,CAAC;AACjC;;GAEG;AACH,eAAO,MAAM,SAAS,WAAW,CAAC;AAClC;;;;;;;;;GASG;AACH,eAAO,MAAM,uCAAuC,UAAqC,CAAC;AAE1F,eAAO,MAAM,qBAAqB,MAAM,CAAC;AAEzC;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,QAA2F,CAAC"}
|
package/dist/V1/constants.mjs
CHANGED
|
@@ -47,4 +47,16 @@ export const ROOT_ADDR = 'ib^gib'; // `${IB}${IBGIB_DELIMITER}${GIB}`;
|
|
|
47
47
|
* * protocols built on top of this may also have reserved rel8n/data key names
|
|
48
48
|
*/
|
|
49
49
|
export const FORBIDDEN_ADD_RENAME_REMOVE_REL8N_NAMES = ['past', 'ancestor', 'dna', 'tjp'];
|
|
50
|
+
export const IB_MAX_LENGTH_DEFAULT = 155;
|
|
51
|
+
/**
|
|
52
|
+
* Defaults to word characters, space, tab, hyphen, and other
|
|
53
|
+
* non-slash (path navigating) chars.
|
|
54
|
+
*
|
|
55
|
+
* Does not allow new lines or other whitespace, only tabs and spaces.
|
|
56
|
+
*
|
|
57
|
+
* ## atow
|
|
58
|
+
*
|
|
59
|
+
* `^[\\w\\t\\-|=+.&%\$#@!~\` \\[\\]\\(\\)\\{\\}]{1,${IB_MAX_LENGTH_DEFAULT}}$`
|
|
60
|
+
*/
|
|
61
|
+
export const IB_REGEXP_DEFAULT = new RegExp(`^[\\w\\t\\-|=+.&%\$#@!~\` \\[\\]\\(\\)\\{\\}]{1,${IB_MAX_LENGTH_DEFAULT}}$`);
|
|
50
62
|
//# sourceMappingURL=constants.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.mjs","sourceRoot":"","sources":["../../src/V1/constants.mts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC;AACvB;;;;;GAKG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,KAAK,CAAC;AACzB;;;;GAIG;AACH,MAAM,CAAC,MAAM,IAAI,GAAa,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,GAAG,CAAA;AACnD;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,CAAC;AACnC;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,CAAC;AACjC;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,QAAQ,CAAC,CAAC,mCAAmC;AACtE;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,uCAAuC,GAAG,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.mjs","sourceRoot":"","sources":["../../src/V1/constants.mts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC;AACvB;;;;;GAKG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,KAAK,CAAC;AACzB;;;;GAIG;AACH,MAAM,CAAC,MAAM,IAAI,GAAa,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,GAAG,CAAA;AACnD;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,CAAC;AACnC;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,CAAC;AACjC;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,QAAQ,CAAC,CAAC,mCAAmC;AACtE;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,uCAAuC,GAAG,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;AAE1F,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAEzC;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,MAAM,CAAC,mDAAmD,qBAAqB,IAAI,CAAC,CAAC"}
|
package/dist/V1/factory.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Ib, IbGib, IbGibRel8ns, TransformResult, TemporalJunctionPointOptions } from '../types.mjs';
|
|
2
|
-
import { IbGib_V1 } from './types.mjs';
|
|
2
|
+
import { IbGib_V1, IbGibData_V1, IbGibRel8ns_V1 } from './types.mjs';
|
|
3
3
|
export declare class Factory_V1 {
|
|
4
|
-
static root(): IbGib_V1<
|
|
4
|
+
static root(): IbGib_V1<IbGibData_V1, IbGibRel8ns_V1>;
|
|
5
5
|
/**
|
|
6
6
|
* Returns an ibGib primitive with the given `ib`, e.g. "{ib: '7', gib: 'gib'}".
|
|
7
7
|
*
|
|
@@ -23,7 +23,7 @@ export declare class Factory_V1 {
|
|
|
23
23
|
*
|
|
24
24
|
* @returns The entire transform result object that includes the newly produced ibGib as well as any derivative/intermediate ibgibs.
|
|
25
25
|
*/
|
|
26
|
-
static firstGen<TData = any>({ ib, parentIbGib, data, rel8ns, dna, tjp, linkedRel8ns, noTimestamp, nCounter, }: {
|
|
26
|
+
static firstGen<TData = any>({ ib, parentIbGib, data, rel8ns, dna, tjp, linkedRel8ns, noTimestamp, nCounter, squash, }: {
|
|
27
27
|
ib: Ib;
|
|
28
28
|
parentIbGib: IbGib;
|
|
29
29
|
data?: TData;
|
|
@@ -31,8 +31,110 @@ export declare class Factory_V1 {
|
|
|
31
31
|
dna?: boolean;
|
|
32
32
|
tjp?: TemporalJunctionPointOptions;
|
|
33
33
|
linkedRel8ns?: string[];
|
|
34
|
+
/**
|
|
35
|
+
* If true, no timestamp will be
|
|
36
|
+
*/
|
|
34
37
|
noTimestamp?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* if true, data.n will be set to 0 on the first frame, and 1 on the
|
|
40
|
+
* second.
|
|
41
|
+
*/
|
|
35
42
|
nCounter?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* ONLY USED IF {@link dna} IS FALSY.
|
|
45
|
+
*
|
|
46
|
+
* If {@link dna} is falsy and this is true, then the resulting 1st gen
|
|
47
|
+
* ibgib will be squashed into a single frame, even if both mut8 and
|
|
48
|
+
* rel8 transforms are executed.
|
|
49
|
+
*
|
|
50
|
+
* ## intent / driving use case
|
|
51
|
+
*
|
|
52
|
+
* We are working on the new, production-quality v1 sync saga and we
|
|
53
|
+
* want the saga ibgib to be one frame per participant (Alice, Bob).
|
|
54
|
+
* So Alice creates one frame, then Bob evolves 1 frame, etc. No dna
|
|
55
|
+
* is required, because this is not meant to be merged at a later time.
|
|
56
|
+
*
|
|
57
|
+
* So the use case is when you don't need dna and you want a single
|
|
58
|
+
* frame.
|
|
59
|
+
*/
|
|
60
|
+
squash?: boolean;
|
|
36
61
|
}): Promise<TransformResult<IbGib_V1>>;
|
|
62
|
+
/**
|
|
63
|
+
* Generate an ibgib datum that has no dna and no timeline.
|
|
64
|
+
* It's a one-off ibgib.
|
|
65
|
+
*
|
|
66
|
+
* This is similar to {@link Factory_V1.constant}, but this is not
|
|
67
|
+
* necessarily deterministic. It can have a timestamp and/or uuid, though it
|
|
68
|
+
* does not have dna, nCounter, or a tjp.
|
|
69
|
+
*
|
|
70
|
+
* ## validation
|
|
71
|
+
*
|
|
72
|
+
* * validates the given `ib` against `ibRegExpPattern` or default regexp.
|
|
73
|
+
* * validates that rel8ns doesn't include default forbidden rel8n names or
|
|
74
|
+
* atow `'tjp'`.
|
|
75
|
+
*
|
|
76
|
+
* ## intent
|
|
77
|
+
*
|
|
78
|
+
* Stones are useful for one-off ibgibs that are not part of a timeline, but
|
|
79
|
+
* which still should have a timestamp and/or uuid.
|
|
80
|
+
*
|
|
81
|
+
* @see {@link Factory_V1.constant}
|
|
82
|
+
*/
|
|
83
|
+
static stone<TData extends IbGibData_V1 = any, TRel8ns extends IbGibRel8ns_V1 = IbGibRel8ns_V1>({ parentPrimitiveIb, ib, ibRegExpPattern, data, rel8ns, noTimestamp, uuid, }: {
|
|
84
|
+
parentPrimitiveIb: Ib;
|
|
85
|
+
ib: Ib;
|
|
86
|
+
/**
|
|
87
|
+
* for checking the stone's generated ib
|
|
88
|
+
*/
|
|
89
|
+
ibRegExpPattern?: string;
|
|
90
|
+
data?: TData;
|
|
91
|
+
rel8ns?: TRel8ns;
|
|
92
|
+
noTimestamp?: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* If true, will generate a uuid for the stone. If falsy, will not.
|
|
95
|
+
*/
|
|
96
|
+
uuid?: boolean;
|
|
97
|
+
}): Promise<IbGib_V1<TData, TRel8ns>>;
|
|
98
|
+
/**
|
|
99
|
+
* Generate a deterministic ibgib datum that has no dna and no timeline.
|
|
100
|
+
* It's a one-off ibgib.
|
|
101
|
+
*
|
|
102
|
+
* Because this is supposed to create and re-create deterministically the equivalent
|
|
103
|
+
* of a non-primitive ibgib "constant", this function creates a single ibgib with...
|
|
104
|
+
* * one ancestor
|
|
105
|
+
* * no past, dna, or tjp rel8ns
|
|
106
|
+
* * no tjp timestamp or uuid
|
|
107
|
+
* * no nCounter
|
|
108
|
+
*
|
|
109
|
+
* This is similar to {@link Factory_V1.stone}, but with guaranteed no
|
|
110
|
+
* timestamp or uuid (unless incoming {@link data} contains a uuid).
|
|
111
|
+
*
|
|
112
|
+
* @see {@link Factory_V1.stone}
|
|
113
|
+
*
|
|
114
|
+
* ## intent
|
|
115
|
+
*
|
|
116
|
+
* I want to be able to create deterministic ibGibs that I can reference at
|
|
117
|
+
* runtime, similar to an ibgib primitive (e.g. "root^gib"), but with the
|
|
118
|
+
* integrity of the `gib` hash. This way, I can reference a deterministic ibgib
|
|
119
|
+
* from code at compile time, and at runtime this will have a corresponding
|
|
120
|
+
* ibgib datum with gib-hashed integrity.
|
|
121
|
+
*
|
|
122
|
+
* ## example
|
|
123
|
+
*
|
|
124
|
+
* I want to create a "hard-coded" schema ibgib that I rel8 to some protocol
|
|
125
|
+
* ibgib. So I'll create the data here, which lives in source control in a text file,
|
|
126
|
+
* and then I'll render that as an ibgib that verifies integrity. If I as a coder change
|
|
127
|
+
* it at all, then the `gib` of course will be different.
|
|
128
|
+
*/
|
|
129
|
+
static constant<TData extends IbGibData_V1 = any, TRel8ns extends IbGibRel8ns_V1 = IbGibRel8ns_V1>({ parentPrimitiveIb, ib, ibRegExpPattern, data, rel8ns, }: {
|
|
130
|
+
parentPrimitiveIb: Ib;
|
|
131
|
+
ib: Ib;
|
|
132
|
+
/**
|
|
133
|
+
* for checking the constant's generated ib
|
|
134
|
+
*/
|
|
135
|
+
ibRegExpPattern?: string;
|
|
136
|
+
data?: TData;
|
|
137
|
+
rel8ns?: TRel8ns;
|
|
138
|
+
}): Promise<IbGib_V1<TData, TRel8ns>>;
|
|
37
139
|
}
|
|
38
140
|
//# sourceMappingURL=factory.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.mts","sourceRoot":"","sources":["../../src/V1/factory.mts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"factory.d.mts","sourceRoot":"","sources":["../../src/V1/factory.mts"],"names":[],"mappings":"AAKA,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAC;AACrG,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAOrE,qBAAa,UAAU;IACnB,MAAM,CAAC,IAAI;IAIX;;;;OAIG;IACH,MAAM,CAAC,SAAS,CAAC,EACb,EAAE,EACL,EAAE;QACC,EAAE,EAAE,EAAE,CAAA;KACT,GAAG,QAAQ;IAIZ;;;OAGG;IACH,MAAM,CAAC,UAAU,CAAC,EACd,GAAG,EACN,EAAE;QACC,GAAG,EAAE,EAAE,EAAE,CAAA;KACZ,GAAG,QAAQ,EAAE;IAId;;;;;OAKG;WACU,QAAQ,CAAC,KAAK,GAAG,GAAG,EAAE,EAC/B,EAAO,EACP,WAA+B,EAC/B,IAAI,EACJ,MAAM,EACN,GAAG,EACH,GAAG,EACH,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,MAAM,GACT,EAAE;QACC,EAAE,EAAE,EAAE,CAAC;QACP,WAAW,EAAE,KAAK,CAAC;QACnB,IAAI,CAAC,EAAE,KAAK,CAAC;QACb,MAAM,CAAC,EAAE,WAAW,CAAC;QACrB,GAAG,CAAC,EAAE,OAAO,CAAC;QACd,GAAG,CAAC,EAAE,4BAA4B,CAAC;QACnC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;QACxB;;WAEG;QACH,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB;;;WAGG;QACH,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB;;;;;;;;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utils-helper.mjs';
|
|
1
2
|
import { fork } from './transforms/fork.mjs';
|
|
2
3
|
import { mut8 } from './transforms/mut8.mjs';
|
|
3
4
|
import { rel8 } from './transforms/rel8.mjs';
|
|
4
|
-
import { IB, GIB, ROOT } from './constants.mjs';
|
|
5
|
+
import { IB, GIB, ROOT, IB_REGEXP_DEFAULT, FORBIDDEN_ADD_RENAME_REMOVE_REL8N_NAMES } from './constants.mjs';
|
|
6
|
+
import { validateIb } from './validate-helper.mjs';
|
|
7
|
+
import { getGib } from './transforms/transform-helper.mjs';
|
|
8
|
+
const logalot = false;
|
|
5
9
|
export class Factory_V1 {
|
|
6
10
|
static root() {
|
|
7
11
|
return Factory_V1.primitive({ ib: IB });
|
|
@@ -27,66 +31,251 @@ export class Factory_V1 {
|
|
|
27
31
|
*
|
|
28
32
|
* @returns The entire transform result object that includes the newly produced ibGib as well as any derivative/intermediate ibgibs.
|
|
29
33
|
*/
|
|
30
|
-
static async firstGen({ ib = IB, parentIbGib = Factory_V1.root(), data, rel8ns, dna, tjp, linkedRel8ns, noTimestamp, nCounter, }) {
|
|
31
|
-
const lc = `[firstGen]`;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
});
|
|
44
|
-
interimResults.push(resFork);
|
|
45
|
-
src = resFork.newIbGib;
|
|
46
|
-
if (data) {
|
|
47
|
-
let resMut8 = await mut8({
|
|
34
|
+
static async firstGen({ ib = IB, parentIbGib = Factory_V1.root(), data, rel8ns, dna, tjp, linkedRel8ns, noTimestamp, nCounter, squash, }) {
|
|
35
|
+
const lc = `[${Factory_V1.name}][${Factory_V1.firstGen.name}]`;
|
|
36
|
+
try {
|
|
37
|
+
if (logalot) {
|
|
38
|
+
console.log(`${lc} starting... (I: b7152fbd94382516d9f7c591bcf4c326)`);
|
|
39
|
+
}
|
|
40
|
+
if (dna && squash) {
|
|
41
|
+
throw new Error(`both dna and squash cannot be true. Squash requires that no dna exist. (E: abfc58b4a4c8654924aa5428d0831826)`);
|
|
42
|
+
}
|
|
43
|
+
/** * Multiple transform steps will create multiple results. */
|
|
44
|
+
const interimResults = [];
|
|
45
|
+
let src = parentIbGib || ROOT;
|
|
46
|
+
let resFork = await fork({
|
|
48
47
|
src,
|
|
49
|
-
|
|
48
|
+
destIb: ib,
|
|
49
|
+
tjp,
|
|
50
50
|
dna,
|
|
51
51
|
linkedRel8ns,
|
|
52
52
|
noTimestamp,
|
|
53
53
|
nCounter,
|
|
54
54
|
});
|
|
55
|
-
interimResults.push(
|
|
56
|
-
src =
|
|
55
|
+
interimResults.push(resFork);
|
|
56
|
+
src = resFork.newIbGib;
|
|
57
|
+
if (data) {
|
|
58
|
+
let resMut8 = await mut8({
|
|
59
|
+
src,
|
|
60
|
+
dataToAddOrPatch: data,
|
|
61
|
+
dna,
|
|
62
|
+
linkedRel8ns,
|
|
63
|
+
noTimestamp,
|
|
64
|
+
nCounter,
|
|
65
|
+
});
|
|
66
|
+
interimResults.push(resMut8);
|
|
67
|
+
src = resMut8.newIbGib;
|
|
68
|
+
}
|
|
69
|
+
;
|
|
70
|
+
if (rel8ns) {
|
|
71
|
+
let resRel8 = await rel8({
|
|
72
|
+
src,
|
|
73
|
+
rel8nsToAddByAddr: rel8ns,
|
|
74
|
+
dna,
|
|
75
|
+
linkedRel8ns,
|
|
76
|
+
noTimestamp,
|
|
77
|
+
nCounter,
|
|
78
|
+
});
|
|
79
|
+
interimResults.push(resRel8);
|
|
80
|
+
// src = resRel8.newIbGib; // not needed because not used (this is the last step)
|
|
81
|
+
}
|
|
82
|
+
if (interimResults.length > 1) {
|
|
83
|
+
const newIbGib = interimResults.slice(interimResults.length - 1)[0].newIbGib;
|
|
84
|
+
const resultWithIntermediates = {
|
|
85
|
+
newIbGib,
|
|
86
|
+
/**
|
|
87
|
+
* all the interResults except the last one go in the intermediate ibGibs
|
|
88
|
+
*/
|
|
89
|
+
intermediateIbGibs: interimResults.slice(0, interimResults.length - 1).map(x => x.newIbGib),
|
|
90
|
+
};
|
|
91
|
+
if (dna) {
|
|
92
|
+
if (squash) {
|
|
93
|
+
(`${lc} (E: 62c595422e21ad8ce8eae658976fd826)`);
|
|
94
|
+
}
|
|
95
|
+
// combine all of the interim dnas
|
|
96
|
+
let dnas = [];
|
|
97
|
+
interimResults.forEach(res => { dnas = dnas.concat(res.dnas); });
|
|
98
|
+
resultWithIntermediates.dnas = dnas;
|
|
99
|
+
return resultWithIntermediates;
|
|
100
|
+
}
|
|
101
|
+
else if (squash) {
|
|
102
|
+
// manually remove past and change the tjp, if it exists
|
|
103
|
+
if (!newIbGib.rel8ns) {
|
|
104
|
+
throw new Error(`(UNEXPECTED) newIbGib.rel8ns is falsy? (E: 6b09e8057fc5b00c6cfd13be60e97f26)`);
|
|
105
|
+
}
|
|
106
|
+
delete newIbGib.rel8ns.past;
|
|
107
|
+
if (newIbGib.rel8ns.tjp) {
|
|
108
|
+
delete newIbGib.rel8ns.tjp;
|
|
109
|
+
newIbGib.data ??= {};
|
|
110
|
+
newIbGib.data.isTjp = true;
|
|
111
|
+
}
|
|
112
|
+
// recalculate the gib
|
|
113
|
+
newIbGib.gib = await getGib({ ibGib: newIbGib });
|
|
114
|
+
const resultSquashed = { newIbGib };
|
|
115
|
+
return resultSquashed;
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
// no dna and no squash
|
|
119
|
+
return resultWithIntermediates;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
else if (interimResults.length === 1) {
|
|
123
|
+
// for some reason the caller just used this as a fork.
|
|
124
|
+
return interimResults[0];
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
throw new Error(`(UNEXPECTED) interimResults.length is not 1 and not greater than 1? 0? But we had to fork? (E: a256c88c56916a46a888796f76ef4826)`);
|
|
128
|
+
}
|
|
57
129
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
130
|
+
catch (error) {
|
|
131
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
132
|
+
throw error;
|
|
133
|
+
}
|
|
134
|
+
finally {
|
|
135
|
+
if (logalot) {
|
|
136
|
+
console.log(`${lc} complete.`);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Generate an ibgib datum that has no dna and no timeline.
|
|
142
|
+
* It's a one-off ibgib.
|
|
143
|
+
*
|
|
144
|
+
* This is similar to {@link Factory_V1.constant}, but this is not
|
|
145
|
+
* necessarily deterministic. It can have a timestamp and/or uuid, though it
|
|
146
|
+
* does not have dna, nCounter, or a tjp.
|
|
147
|
+
*
|
|
148
|
+
* ## validation
|
|
149
|
+
*
|
|
150
|
+
* * validates the given `ib` against `ibRegExpPattern` or default regexp.
|
|
151
|
+
* * validates that rel8ns doesn't include default forbidden rel8n names or
|
|
152
|
+
* atow `'tjp'`.
|
|
153
|
+
*
|
|
154
|
+
* ## intent
|
|
155
|
+
*
|
|
156
|
+
* Stones are useful for one-off ibgibs that are not part of a timeline, but
|
|
157
|
+
* which still should have a timestamp and/or uuid.
|
|
158
|
+
*
|
|
159
|
+
* @see {@link Factory_V1.constant}
|
|
160
|
+
*/
|
|
161
|
+
static async stone({ parentPrimitiveIb, ib, ibRegExpPattern, data, rel8ns, noTimestamp, uuid, }) {
|
|
162
|
+
const lc = `[${Factory_V1.name}][${Factory_V1.stone.name}]`;
|
|
163
|
+
try {
|
|
164
|
+
// validation
|
|
165
|
+
// parentPrimitiveIb
|
|
166
|
+
if (!parentPrimitiveIb) {
|
|
167
|
+
throw new Error(`parentPrimitiveIb required. (E: genuuid)`);
|
|
168
|
+
}
|
|
169
|
+
if (validateIb({ ib: parentPrimitiveIb }) !== null) {
|
|
170
|
+
throw new Error(`Invalid parentPrimitiveIb: ${parentPrimitiveIb}. (E: genuuid)`);
|
|
171
|
+
}
|
|
172
|
+
// ib
|
|
173
|
+
if (!ib) {
|
|
174
|
+
throw new Error(`ib required. (E: genuuid)`);
|
|
175
|
+
}
|
|
176
|
+
const regExp = ibRegExpPattern ? new RegExp(ibRegExpPattern) : IB_REGEXP_DEFAULT;
|
|
177
|
+
if (!ib.match(regExp)) {
|
|
178
|
+
throw new Error(`invalid ib. does not match regexp (${regExp}) (E: genuuid)`);
|
|
179
|
+
}
|
|
180
|
+
// rel8ns
|
|
181
|
+
const incomingRel8nNames = Object.keys(rel8ns ?? {});
|
|
182
|
+
const forbiddenRel8nNames = [...FORBIDDEN_ADD_RENAME_REMOVE_REL8N_NAMES, 'tjp'];
|
|
183
|
+
const rel8nsIsInvalid = incomingRel8nNames.some(x => {
|
|
184
|
+
// we don't want constants trying to look like they have/are descendants/tjps/etc.
|
|
185
|
+
return forbiddenRel8nNames.includes(x);
|
|
186
|
+
});
|
|
187
|
+
if (rel8nsIsInvalid) {
|
|
188
|
+
throw new Error(`Invalid rel8ns. forbiddenRel8nNames: ${forbiddenRel8nNames}. rel8ns keys: ${Object.keys(rel8ns ?? {})}. (E: genuuid)`);
|
|
189
|
+
}
|
|
190
|
+
// create the stone by using the firstGen factory. Then we'll pare
|
|
191
|
+
// off what we don't need.
|
|
192
|
+
const resFirstGen = await Factory_V1.firstGen({
|
|
193
|
+
ib,
|
|
194
|
+
parentIbGib: Factory_V1.primitive({ ib: parentPrimitiveIb }),
|
|
195
|
+
data,
|
|
196
|
+
rel8ns,
|
|
197
|
+
dna: false,
|
|
65
198
|
noTimestamp,
|
|
66
|
-
nCounter,
|
|
199
|
+
nCounter: false,
|
|
200
|
+
});
|
|
201
|
+
const stoneIbGib = resFirstGen.newIbGib;
|
|
202
|
+
if (uuid) {
|
|
203
|
+
if (!stoneIbGib.data) {
|
|
204
|
+
stoneIbGib.data = {};
|
|
205
|
+
}
|
|
206
|
+
stoneIbGib.data.uuid = await getUUID();
|
|
207
|
+
}
|
|
208
|
+
// remove any extraneous stuff
|
|
209
|
+
if (stoneIbGib.rel8ns?.past) {
|
|
210
|
+
delete stoneIbGib.rel8ns.past;
|
|
211
|
+
}
|
|
212
|
+
if (stoneIbGib.rel8ns?.tjp) {
|
|
213
|
+
delete stoneIbGib.rel8ns.tjp;
|
|
214
|
+
}
|
|
215
|
+
// recalculate the gib hash
|
|
216
|
+
stoneIbGib.gib = await getGib({
|
|
217
|
+
ibGib: {
|
|
218
|
+
ib: stoneIbGib.ib,
|
|
219
|
+
data: stoneIbGib.data,
|
|
220
|
+
rel8ns: stoneIbGib.rel8ns,
|
|
221
|
+
},
|
|
222
|
+
hasTjp: false,
|
|
67
223
|
});
|
|
68
|
-
|
|
69
|
-
// src = resRel8.newIbGib; // not needed because not used (this is the last step)
|
|
224
|
+
return stoneIbGib;
|
|
70
225
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
newIbGib,
|
|
75
|
-
intermediateIbGibs: interimResults.slice(0, interimResults.length - 1).map(x => x.newIbGib),
|
|
76
|
-
};
|
|
77
|
-
if (dna) {
|
|
78
|
-
let dnas = [];
|
|
79
|
-
interimResults.forEach(res => { dnas = dnas.concat(res.dnas); });
|
|
80
|
-
result.dnas = dnas;
|
|
81
|
-
}
|
|
82
|
-
return result;
|
|
226
|
+
catch (error) {
|
|
227
|
+
console.error(`${lc} ${error.message}`);
|
|
228
|
+
throw error;
|
|
83
229
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Generate a deterministic ibgib datum that has no dna and no timeline.
|
|
233
|
+
* It's a one-off ibgib.
|
|
234
|
+
*
|
|
235
|
+
* Because this is supposed to create and re-create deterministically the equivalent
|
|
236
|
+
* of a non-primitive ibgib "constant", this function creates a single ibgib with...
|
|
237
|
+
* * one ancestor
|
|
238
|
+
* * no past, dna, or tjp rel8ns
|
|
239
|
+
* * no tjp timestamp or uuid
|
|
240
|
+
* * no nCounter
|
|
241
|
+
*
|
|
242
|
+
* This is similar to {@link Factory_V1.stone}, but with guaranteed no
|
|
243
|
+
* timestamp or uuid (unless incoming {@link data} contains a uuid).
|
|
244
|
+
*
|
|
245
|
+
* @see {@link Factory_V1.stone}
|
|
246
|
+
*
|
|
247
|
+
* ## intent
|
|
248
|
+
*
|
|
249
|
+
* I want to be able to create deterministic ibGibs that I can reference at
|
|
250
|
+
* runtime, similar to an ibgib primitive (e.g. "root^gib"), but with the
|
|
251
|
+
* integrity of the `gib` hash. This way, I can reference a deterministic ibgib
|
|
252
|
+
* from code at compile time, and at runtime this will have a corresponding
|
|
253
|
+
* ibgib datum with gib-hashed integrity.
|
|
254
|
+
*
|
|
255
|
+
* ## example
|
|
256
|
+
*
|
|
257
|
+
* I want to create a "hard-coded" schema ibgib that I rel8 to some protocol
|
|
258
|
+
* ibgib. So I'll create the data here, which lives in source control in a text file,
|
|
259
|
+
* and then I'll render that as an ibgib that verifies integrity. If I as a coder change
|
|
260
|
+
* it at all, then the `gib` of course will be different.
|
|
261
|
+
*/
|
|
262
|
+
static async constant({ parentPrimitiveIb, ib, ibRegExpPattern, data, rel8ns, }) {
|
|
263
|
+
const lc = `[${Factory_V1.name}][${Factory_V1.constant.name}]`;
|
|
264
|
+
try {
|
|
265
|
+
const constantIbGib = await Factory_V1.stone({
|
|
266
|
+
parentPrimitiveIb,
|
|
267
|
+
ib,
|
|
268
|
+
ibRegExpPattern,
|
|
269
|
+
data,
|
|
270
|
+
rel8ns,
|
|
271
|
+
noTimestamp: true,
|
|
272
|
+
uuid: false,
|
|
273
|
+
});
|
|
274
|
+
return constantIbGib;
|
|
87
275
|
}
|
|
88
|
-
|
|
89
|
-
|
|
276
|
+
catch (error) {
|
|
277
|
+
console.error(`${lc} ${error.message}`);
|
|
278
|
+
throw error;
|
|
90
279
|
}
|
|
91
280
|
}
|
|
92
281
|
}
|
package/dist/V1/factory.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.mjs","sourceRoot":"","sources":["../../src/V1/factory.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAG7C,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"factory.mjs","sourceRoot":"","sources":["../../src/V1/factory.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,iDAAiD,CAAC;AAE3F,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAG7C,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,iBAAiB,EAAE,uCAAuC,EAAE,MAAM,iBAAiB,CAAC;AAC5G,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAE3D,MAAM,OAAO,GAAG,KAAK,CAAC;AAEtB,MAAM,OAAO,UAAU;IACnB,MAAM,CAAC,IAAI;QACP,OAAO,UAAU,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;IAC5C,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,SAAS,CAAC,EACb,EAAE,EAGL;QACG,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,UAAU,CAAC,EACd,GAAG,EAGN;QACG,OAAO,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC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G,EAAE,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YACxC,MAAM,KAAK,CAAC;QAChB,CAAC;IACL,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,MAAM,CAAC,KAAK,CAAC,QAAQ,CAGnB,EACE,iBAAiB,EACjB,EAAE,EACF,eAAe,EACf,IAAI,EACJ,MAAM,GAUT;QACG,MAAM,EAAE,GAAG,IAAI,UAAU,CAAC,IAAI,KAAK,UAAU,CAAC,QAAQ,CAAC,IAAI,GAAG,CAAC;QAC/D,IAAI,CAAC;YACD,MAAM,aAAa,GAAG,MAAM,UAAU,CAAC,KAAK,CAAC;gBACzC,iBAAiB;gBACjB,EAAE;gBACF,eAAe;gBACf,IAAI;gBACJ,MAAM;gBACN,WAAW,EAAE,IAAI;gBACjB,IAAI,EAAE,KAAK;aACd,CAAC,CAAC;YACH,OAAO,aAAa,CAAC;QACzB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YACxC,MAAM,KAAK,CAAC;QAChB,CAAC;IACL,CAAC;CACJ"}
|
package/dist/respec-gib.node.mjs
CHANGED
|
@@ -35,7 +35,7 @@ const LOOK_FOR_EXTRA_RESPEC = true;
|
|
|
35
35
|
* do have these will execute fully, but the output will only include these
|
|
36
36
|
* particular blocks.
|
|
37
37
|
*/
|
|
38
|
-
const EXTRA_RESPEC_FUNCTION_NAMES = ['respecfullyDear', 'ifWeMight'];
|
|
38
|
+
const EXTRA_RESPEC_FUNCTION_NAMES = ['await respecfullyDear', 'ifWeMight'];
|
|
39
39
|
// #endregion settings
|
|
40
40
|
// #region 1. get respec paths
|
|
41
41
|
const basePath = process.cwd();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"respec-gib.node.mjs","sourceRoot":"","sources":["../src/respec-gib.node.mts"],"names":[],"mappings":"AA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E,CAAC;oBAAC,OAAO,IAAI,CAAC;gBAAC,CAAC;YACrD,CAAC,CAAC,CAAC;YACP,IAAI,oBAAoB,EAAE,CAAC;gBACvB,OAAO,IAAI,CAAC;YAChB,CAAC;QACL,CAAC;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QACxC,MAAM,KAAK,CAAC;IAChB,CAAC;YAAS,CAAC;QACP,IAAI,OAAO,EAAE,CAAC;YAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;QAAC,CAAC;IACpD,CAAC;AACL,CAAC;AAED,8BAA8B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ibgib/ts-gib",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.28",
|
|
4
4
|
"description": "ibgib library with low-level graphing-related substrate functionality, e.g. creating raw ibgibs and transformations. node19+ needed for heavily-used webcrypto hashing isomorphically consumed in node and browsers (apps).",
|
|
5
5
|
"repository": {
|
|
6
6
|
"url": "https://gitlab.com/ibgib/ts-gib",
|
package/src/V1/constants.mts
CHANGED
|
@@ -49,3 +49,17 @@ export const ROOT_ADDR = 'ib^gib'; // `${IB}${IBGIB_DELIMITER}${GIB}`;
|
|
|
49
49
|
* * protocols built on top of this may also have reserved rel8n/data key names
|
|
50
50
|
*/
|
|
51
51
|
export const FORBIDDEN_ADD_RENAME_REMOVE_REL8N_NAMES = ['past', 'ancestor', 'dna', 'tjp'];
|
|
52
|
+
|
|
53
|
+
export const IB_MAX_LENGTH_DEFAULT = 155;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Defaults to word characters, space, tab, hyphen, and other
|
|
57
|
+
* non-slash (path navigating) chars.
|
|
58
|
+
*
|
|
59
|
+
* Does not allow new lines or other whitespace, only tabs and spaces.
|
|
60
|
+
*
|
|
61
|
+
* ## atow
|
|
62
|
+
*
|
|
63
|
+
* `^[\\w\\t\\-|=+.&%\$#@!~\` \\[\\]\\(\\)\\{\\}]{1,${IB_MAX_LENGTH_DEFAULT}}$`
|
|
64
|
+
*/
|
|
65
|
+
export const IB_REGEXP_DEFAULT = new RegExp(`^[\\w\\t\\-|=+.&%\$#@!~\` \\[\\]\\(\\)\\{\\}]{1,${IB_MAX_LENGTH_DEFAULT}}$`);
|
package/src/V1/factory.mts
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
|
+
import { extractErrorMsg, getUUID } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
2
|
+
|
|
1
3
|
import { fork } from './transforms/fork.mjs';
|
|
2
4
|
import { mut8 } from './transforms/mut8.mjs';
|
|
3
5
|
import { rel8 } from './transforms/rel8.mjs';
|
|
4
6
|
import { Ib, IbGib, IbGibRel8ns, TransformResult, TemporalJunctionPointOptions } from '../types.mjs';
|
|
5
|
-
import { IbGib_V1 } from './types.mjs';
|
|
6
|
-
import { IB, GIB, ROOT } from './constants.mjs';
|
|
7
|
+
import { IbGib_V1, IbGibData_V1, IbGibRel8ns_V1 } from './types.mjs';
|
|
8
|
+
import { IB, GIB, ROOT, IB_REGEXP_DEFAULT, FORBIDDEN_ADD_RENAME_REMOVE_REL8N_NAMES } from './constants.mjs';
|
|
9
|
+
import { validateIb } from './validate-helper.mjs';
|
|
10
|
+
import { getGib } from './transforms/transform-helper.mjs';
|
|
11
|
+
|
|
12
|
+
const logalot = false;
|
|
7
13
|
|
|
8
14
|
export class Factory_V1 {
|
|
9
15
|
static root() {
|
|
@@ -51,6 +57,7 @@ export class Factory_V1 {
|
|
|
51
57
|
linkedRel8ns,
|
|
52
58
|
noTimestamp,
|
|
53
59
|
nCounter,
|
|
60
|
+
squash,
|
|
54
61
|
}: {
|
|
55
62
|
ib: Ib,
|
|
56
63
|
parentIbGib: IbGib,
|
|
@@ -59,68 +66,308 @@ export class Factory_V1 {
|
|
|
59
66
|
dna?: boolean,
|
|
60
67
|
tjp?: TemporalJunctionPointOptions;
|
|
61
68
|
linkedRel8ns?: string[],
|
|
69
|
+
/**
|
|
70
|
+
* If true, no timestamp will be
|
|
71
|
+
*/
|
|
62
72
|
noTimestamp?: boolean,
|
|
73
|
+
/**
|
|
74
|
+
* if true, data.n will be set to 0 on the first frame, and 1 on the
|
|
75
|
+
* second.
|
|
76
|
+
*/
|
|
63
77
|
nCounter?: boolean,
|
|
78
|
+
/**
|
|
79
|
+
* ONLY USED IF {@link dna} IS FALSY.
|
|
80
|
+
*
|
|
81
|
+
* If {@link dna} is falsy and this is true, then the resulting 1st gen
|
|
82
|
+
* ibgib will be squashed into a single frame, even if both mut8 and
|
|
83
|
+
* rel8 transforms are executed.
|
|
84
|
+
*
|
|
85
|
+
* ## intent / driving use case
|
|
86
|
+
*
|
|
87
|
+
* We are working on the new, production-quality v1 sync saga and we
|
|
88
|
+
* want the saga ibgib to be one frame per participant (Alice, Bob).
|
|
89
|
+
* So Alice creates one frame, then Bob evolves 1 frame, etc. No dna
|
|
90
|
+
* is required, because this is not meant to be merged at a later time.
|
|
91
|
+
*
|
|
92
|
+
* So the use case is when you don't need dna and you want a single
|
|
93
|
+
* frame.
|
|
94
|
+
*/
|
|
95
|
+
squash?: boolean,
|
|
64
96
|
}): Promise<TransformResult<IbGib_V1>> {
|
|
65
|
-
const lc = `[firstGen]`;
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
noTimestamp,
|
|
76
|
-
nCounter,
|
|
77
|
-
});
|
|
78
|
-
interimResults.push(resFork);
|
|
79
|
-
src = resFork.newIbGib;
|
|
80
|
-
|
|
81
|
-
if (data) {
|
|
82
|
-
let resMut8 = await mut8({
|
|
97
|
+
const lc = `[${Factory_V1.name}][${Factory_V1.firstGen.name}]`;
|
|
98
|
+
try {
|
|
99
|
+
if (logalot) { console.log(`${lc} starting... (I: b7152fbd94382516d9f7c591bcf4c326)`); }
|
|
100
|
+
|
|
101
|
+
if (dna && squash) { throw new Error(`both dna and squash cannot be true. Squash requires that no dna exist. (E: abfc58b4a4c8654924aa5428d0831826)`); }
|
|
102
|
+
|
|
103
|
+
/** * Multiple transform steps will create multiple results. */
|
|
104
|
+
const interimResults: TransformResult<IbGib_V1>[] = [];
|
|
105
|
+
let src: IbGib_V1 = parentIbGib || ROOT;
|
|
106
|
+
let resFork = await fork({
|
|
83
107
|
src,
|
|
84
|
-
|
|
108
|
+
destIb: ib,
|
|
109
|
+
tjp,
|
|
85
110
|
dna,
|
|
86
111
|
linkedRel8ns,
|
|
87
112
|
noTimestamp,
|
|
88
113
|
nCounter,
|
|
89
114
|
});
|
|
90
|
-
interimResults.push(
|
|
91
|
-
src =
|
|
92
|
-
};
|
|
115
|
+
interimResults.push(resFork);
|
|
116
|
+
src = resFork.newIbGib;
|
|
93
117
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
118
|
+
if (data) {
|
|
119
|
+
let resMut8 = await mut8({
|
|
120
|
+
src,
|
|
121
|
+
dataToAddOrPatch: data,
|
|
122
|
+
dna,
|
|
123
|
+
linkedRel8ns,
|
|
124
|
+
noTimestamp,
|
|
125
|
+
nCounter,
|
|
126
|
+
});
|
|
127
|
+
interimResults.push(resMut8);
|
|
128
|
+
src = resMut8.newIbGib;
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
if (rel8ns) {
|
|
132
|
+
let resRel8 = await rel8({
|
|
133
|
+
src,
|
|
134
|
+
rel8nsToAddByAddr: rel8ns,
|
|
135
|
+
dna,
|
|
136
|
+
linkedRel8ns,
|
|
137
|
+
noTimestamp,
|
|
138
|
+
nCounter,
|
|
139
|
+
});
|
|
140
|
+
interimResults.push(resRel8);
|
|
141
|
+
// src = resRel8.newIbGib; // not needed because not used (this is the last step)
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (interimResults.length > 1) {
|
|
145
|
+
const newIbGib = interimResults.slice(interimResults.length - 1)[0].newIbGib;
|
|
146
|
+
const resultWithIntermediates = {
|
|
147
|
+
newIbGib,
|
|
148
|
+
/**
|
|
149
|
+
* all the interResults except the last one go in the intermediate ibGibs
|
|
150
|
+
*/
|
|
151
|
+
intermediateIbGibs: interimResults.slice(0, interimResults.length - 1).map(x => x.newIbGib),
|
|
152
|
+
} as TransformResult<IbGib_V1>;
|
|
153
|
+
|
|
154
|
+
if (dna) {
|
|
155
|
+
if (squash) { (`${lc} (E: 62c595422e21ad8ce8eae658976fd826)`) }
|
|
156
|
+
|
|
157
|
+
// combine all of the interim dnas
|
|
158
|
+
let dnas: IbGib_V1[] = [];
|
|
159
|
+
interimResults.forEach(res => { dnas = dnas.concat(res.dnas!); });
|
|
160
|
+
resultWithIntermediates.dnas = dnas;
|
|
161
|
+
|
|
162
|
+
return resultWithIntermediates;
|
|
163
|
+
} else if (squash) {
|
|
164
|
+
// manually remove past and change the tjp, if it exists
|
|
165
|
+
if (!newIbGib.rel8ns) { throw new Error(`(UNEXPECTED) newIbGib.rel8ns is falsy? (E: 6b09e8057fc5b00c6cfd13be60e97f26)`); }
|
|
166
|
+
|
|
167
|
+
delete newIbGib.rel8ns.past;
|
|
168
|
+
|
|
169
|
+
if (newIbGib.rel8ns.tjp) {
|
|
170
|
+
delete newIbGib.rel8ns.tjp;
|
|
171
|
+
newIbGib.data ??= {};
|
|
172
|
+
newIbGib.data.isTjp = true;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// recalculate the gib
|
|
176
|
+
newIbGib.gib = await getGib({ ibGib: newIbGib });
|
|
177
|
+
|
|
178
|
+
const resultSquashed: TransformResult<IbGib_V1> = { newIbGib };
|
|
179
|
+
|
|
180
|
+
return resultSquashed;
|
|
181
|
+
} else {
|
|
182
|
+
// no dna and no squash
|
|
183
|
+
return resultWithIntermediates;
|
|
184
|
+
}
|
|
185
|
+
} else if (interimResults.length === 1) {
|
|
186
|
+
// for some reason the caller just used this as a fork.
|
|
187
|
+
return interimResults[0];
|
|
188
|
+
} else {
|
|
189
|
+
throw new Error(`(UNEXPECTED) interimResults.length is not 1 and not greater than 1? 0? But we had to fork? (E: a256c88c56916a46a888796f76ef4826)`);
|
|
190
|
+
}
|
|
191
|
+
} catch (error) {
|
|
192
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
193
|
+
throw error;
|
|
194
|
+
} finally {
|
|
195
|
+
if (logalot) { console.log(`${lc} complete.`); }
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Generate an ibgib datum that has no dna and no timeline.
|
|
201
|
+
* It's a one-off ibgib.
|
|
202
|
+
*
|
|
203
|
+
* This is similar to {@link Factory_V1.constant}, but this is not
|
|
204
|
+
* necessarily deterministic. It can have a timestamp and/or uuid, though it
|
|
205
|
+
* does not have dna, nCounter, or a tjp.
|
|
206
|
+
*
|
|
207
|
+
* ## validation
|
|
208
|
+
*
|
|
209
|
+
* * validates the given `ib` against `ibRegExpPattern` or default regexp.
|
|
210
|
+
* * validates that rel8ns doesn't include default forbidden rel8n names or
|
|
211
|
+
* atow `'tjp'`.
|
|
212
|
+
*
|
|
213
|
+
* ## intent
|
|
214
|
+
*
|
|
215
|
+
* Stones are useful for one-off ibgibs that are not part of a timeline, but
|
|
216
|
+
* which still should have a timestamp and/or uuid.
|
|
217
|
+
*
|
|
218
|
+
* @see {@link Factory_V1.constant}
|
|
219
|
+
*/
|
|
220
|
+
static async stone<
|
|
221
|
+
TData extends IbGibData_V1 = any,
|
|
222
|
+
TRel8ns extends IbGibRel8ns_V1 = IbGibRel8ns_V1
|
|
223
|
+
>({
|
|
224
|
+
parentPrimitiveIb,
|
|
225
|
+
ib,
|
|
226
|
+
ibRegExpPattern,
|
|
227
|
+
data,
|
|
228
|
+
rel8ns,
|
|
229
|
+
noTimestamp,
|
|
230
|
+
uuid,
|
|
231
|
+
}: {
|
|
232
|
+
parentPrimitiveIb: Ib,
|
|
233
|
+
ib: Ib,
|
|
234
|
+
/**
|
|
235
|
+
* for checking the stone's generated ib
|
|
236
|
+
*/
|
|
237
|
+
ibRegExpPattern?: string,
|
|
238
|
+
data?: TData,
|
|
239
|
+
rel8ns?: TRel8ns,
|
|
240
|
+
noTimestamp?: boolean,
|
|
241
|
+
/**
|
|
242
|
+
* If true, will generate a uuid for the stone. If falsy, will not.
|
|
243
|
+
*/
|
|
244
|
+
uuid?: boolean,
|
|
245
|
+
}): Promise<IbGib_V1<TData, TRel8ns>> {
|
|
246
|
+
const lc = `[${Factory_V1.name}][${Factory_V1.stone.name}]`;
|
|
247
|
+
try {
|
|
248
|
+
// validation
|
|
249
|
+
// parentPrimitiveIb
|
|
250
|
+
if (!parentPrimitiveIb) { throw new Error(`parentPrimitiveIb required. (E: genuuid)`); }
|
|
251
|
+
if (validateIb({ ib: parentPrimitiveIb }) !== null) { throw new Error(`Invalid parentPrimitiveIb: ${parentPrimitiveIb}. (E: genuuid)`); }
|
|
252
|
+
|
|
253
|
+
// ib
|
|
254
|
+
if (!ib) { throw new Error(`ib required. (E: genuuid)`); }
|
|
255
|
+
const regExp = ibRegExpPattern ? new RegExp(ibRegExpPattern) : IB_REGEXP_DEFAULT;
|
|
256
|
+
if (!ib.match(regExp)) { throw new Error(`invalid ib. does not match regexp (${regExp}) (E: genuuid)`); }
|
|
257
|
+
|
|
258
|
+
// rel8ns
|
|
259
|
+
const incomingRel8nNames = Object.keys(rel8ns ?? {});
|
|
260
|
+
const forbiddenRel8nNames = [...FORBIDDEN_ADD_RENAME_REMOVE_REL8N_NAMES, 'tjp'];
|
|
261
|
+
const rel8nsIsInvalid = incomingRel8nNames.some(x => {
|
|
262
|
+
// we don't want constants trying to look like they have/are descendants/tjps/etc.
|
|
263
|
+
return forbiddenRel8nNames.includes(x);
|
|
264
|
+
});
|
|
265
|
+
if (rel8nsIsInvalid) { throw new Error(`Invalid rel8ns. forbiddenRel8nNames: ${forbiddenRel8nNames}. rel8ns keys: ${Object.keys(rel8ns ?? {})}. (E: genuuid)`); }
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
// create the stone by using the firstGen factory. Then we'll pare
|
|
269
|
+
// off what we don't need.
|
|
270
|
+
const resFirstGen = await Factory_V1.firstGen({
|
|
271
|
+
ib,
|
|
272
|
+
parentIbGib: Factory_V1.primitive({ ib: parentPrimitiveIb }),
|
|
273
|
+
data,
|
|
274
|
+
rel8ns,
|
|
275
|
+
dna: false,
|
|
100
276
|
noTimestamp,
|
|
101
|
-
nCounter,
|
|
277
|
+
nCounter: false,
|
|
278
|
+
});
|
|
279
|
+
const stoneIbGib = resFirstGen.newIbGib as IbGib_V1<TData, TRel8ns>;
|
|
280
|
+
if (uuid) {
|
|
281
|
+
if (!stoneIbGib.data) { stoneIbGib.data = {} as TData; }
|
|
282
|
+
stoneIbGib.data.uuid = await getUUID();
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// remove any extraneous stuff
|
|
286
|
+
if (stoneIbGib.rel8ns?.past) { delete stoneIbGib.rel8ns.past; }
|
|
287
|
+
if (stoneIbGib.rel8ns?.tjp) { delete stoneIbGib.rel8ns.tjp; }
|
|
288
|
+
|
|
289
|
+
// recalculate the gib hash
|
|
290
|
+
stoneIbGib.gib = await getGib({
|
|
291
|
+
ibGib: {
|
|
292
|
+
ib: stoneIbGib.ib,
|
|
293
|
+
data: stoneIbGib.data,
|
|
294
|
+
rel8ns: stoneIbGib.rel8ns,
|
|
295
|
+
},
|
|
296
|
+
hasTjp: false,
|
|
102
297
|
});
|
|
103
|
-
|
|
104
|
-
|
|
298
|
+
|
|
299
|
+
return stoneIbGib;
|
|
300
|
+
} catch (error) {
|
|
301
|
+
console.error(`${lc} ${error.message}`);
|
|
302
|
+
throw error;
|
|
105
303
|
}
|
|
304
|
+
}
|
|
106
305
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
306
|
+
/**
|
|
307
|
+
* Generate a deterministic ibgib datum that has no dna and no timeline.
|
|
308
|
+
* It's a one-off ibgib.
|
|
309
|
+
*
|
|
310
|
+
* Because this is supposed to create and re-create deterministically the equivalent
|
|
311
|
+
* of a non-primitive ibgib "constant", this function creates a single ibgib with...
|
|
312
|
+
* * one ancestor
|
|
313
|
+
* * no past, dna, or tjp rel8ns
|
|
314
|
+
* * no tjp timestamp or uuid
|
|
315
|
+
* * no nCounter
|
|
316
|
+
*
|
|
317
|
+
* This is similar to {@link Factory_V1.stone}, but with guaranteed no
|
|
318
|
+
* timestamp or uuid (unless incoming {@link data} contains a uuid).
|
|
319
|
+
*
|
|
320
|
+
* @see {@link Factory_V1.stone}
|
|
321
|
+
*
|
|
322
|
+
* ## intent
|
|
323
|
+
*
|
|
324
|
+
* I want to be able to create deterministic ibGibs that I can reference at
|
|
325
|
+
* runtime, similar to an ibgib primitive (e.g. "root^gib"), but with the
|
|
326
|
+
* integrity of the `gib` hash. This way, I can reference a deterministic ibgib
|
|
327
|
+
* from code at compile time, and at runtime this will have a corresponding
|
|
328
|
+
* ibgib datum with gib-hashed integrity.
|
|
329
|
+
*
|
|
330
|
+
* ## example
|
|
331
|
+
*
|
|
332
|
+
* I want to create a "hard-coded" schema ibgib that I rel8 to some protocol
|
|
333
|
+
* ibgib. So I'll create the data here, which lives in source control in a text file,
|
|
334
|
+
* and then I'll render that as an ibgib that verifies integrity. If I as a coder change
|
|
335
|
+
* it at all, then the `gib` of course will be different.
|
|
336
|
+
*/
|
|
337
|
+
static async constant<
|
|
338
|
+
TData extends IbGibData_V1 = any,
|
|
339
|
+
TRel8ns extends IbGibRel8ns_V1 = IbGibRel8ns_V1
|
|
340
|
+
>({
|
|
341
|
+
parentPrimitiveIb,
|
|
342
|
+
ib,
|
|
343
|
+
ibRegExpPattern,
|
|
344
|
+
data,
|
|
345
|
+
rel8ns,
|
|
346
|
+
}: {
|
|
347
|
+
parentPrimitiveIb: Ib,
|
|
348
|
+
ib: Ib,
|
|
349
|
+
/**
|
|
350
|
+
* for checking the constant's generated ib
|
|
351
|
+
*/
|
|
352
|
+
ibRegExpPattern?: string,
|
|
353
|
+
data?: TData,
|
|
354
|
+
rel8ns?: TRel8ns,
|
|
355
|
+
}): Promise<IbGib_V1<TData, TRel8ns>> {
|
|
356
|
+
const lc = `[${Factory_V1.name}][${Factory_V1.constant.name}]`;
|
|
357
|
+
try {
|
|
358
|
+
const constantIbGib = await Factory_V1.stone({
|
|
359
|
+
parentPrimitiveIb,
|
|
360
|
+
ib,
|
|
361
|
+
ibRegExpPattern,
|
|
362
|
+
data,
|
|
363
|
+
rel8ns,
|
|
364
|
+
noTimestamp: true,
|
|
365
|
+
uuid: false,
|
|
366
|
+
});
|
|
367
|
+
return constantIbGib;
|
|
368
|
+
} catch (error) {
|
|
369
|
+
console.error(`${lc} ${error.message}`);
|
|
370
|
+
throw error;
|
|
124
371
|
}
|
|
125
372
|
}
|
|
126
373
|
}
|
|
@@ -5,7 +5,7 @@ import { ROOT, } from './constants.mjs';
|
|
|
5
5
|
import { Factory_V1 as factory } from './factory.mjs';
|
|
6
6
|
import { sha256v1 } from './sha256v1.mjs';
|
|
7
7
|
import { getGib, getGibInfo } from './transforms/transform-helper.mjs';
|
|
8
|
-
import { firstOfAll, ifWe, iReckon, respecfully } from '@ibgib/helper-gib/dist/respec-gib/respec-gib.mjs';
|
|
8
|
+
import { firstOfAll, ifWe, ifWeMight, iReckon, respecfully } from '@ibgib/helper-gib/dist/respec-gib/respec-gib.mjs';
|
|
9
9
|
const maam = `[${import.meta.url}]`, sir = maam;
|
|
10
10
|
|
|
11
11
|
const PRIMITIVE_IBS: string[] = [
|
|
@@ -91,10 +91,153 @@ await respecfully(sir, `when using factory`, async () => {
|
|
|
91
91
|
iReckon(sir, intermediateIbGibs![1].ib).isGonnaBe(testIb);
|
|
92
92
|
});
|
|
93
93
|
|
|
94
|
+
await respecfully(sir, `squash param`, async () => {
|
|
95
|
+
await ifWe(sir, `should throw if both dna and squash are true`, async () => {
|
|
96
|
+
let errorMsg;
|
|
97
|
+
try {
|
|
98
|
+
await factory.firstGen({
|
|
99
|
+
ib: 'squash_dna_fail',
|
|
100
|
+
parentIbGib: ROOT,
|
|
101
|
+
dna: true,
|
|
102
|
+
squash: true,
|
|
103
|
+
});
|
|
104
|
+
} catch (e: any) { errorMsg = e.message; }
|
|
105
|
+
iReckon(sir, errorMsg).asTo('errorMsg').isGonnaBeTruthy();
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
await ifWe(sir, `should squash simple fork+mut8 into single frame`, async () => {
|
|
109
|
+
const { newIbGib, intermediateIbGibs } = await factory.firstGen({
|
|
110
|
+
ib: 'squash_it',
|
|
111
|
+
parentIbGib: ROOT,
|
|
112
|
+
data: DATA_SIMPLE_XY,
|
|
113
|
+
squash: true,
|
|
114
|
+
noTimestamp: true,
|
|
115
|
+
});
|
|
116
|
+
iReckon(sir, newIbGib).isGonnaBeTruthy();
|
|
117
|
+
iReckon(sir, newIbGib.data).isGonnaBe(DATA_SIMPLE_XY);
|
|
118
|
+
// should nuke past
|
|
119
|
+
iReckon(sir, newIbGib.rel8ns!.past).isGonnaBeUndefined();
|
|
120
|
+
// should not return intermediates
|
|
121
|
+
iReckon(sir, intermediateIbGibs).isGonnaBeUndefined();
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
await ifWe(sir, `should handle tjp (remove rel8n, add data.isTjp)`, async () => {
|
|
125
|
+
const { newIbGib } = await factory.firstGen({
|
|
126
|
+
ib: 'squash_tjp',
|
|
127
|
+
parentIbGib: ROOT,
|
|
128
|
+
data: DATA_SIMPLE_XY,
|
|
129
|
+
squash: true,
|
|
130
|
+
tjp: { timestamp: true }
|
|
131
|
+
});
|
|
132
|
+
iReckon(sir, newIbGib.rel8ns!.tjp).isGonnaBeUndefined();
|
|
133
|
+
iReckon(sir, newIbGib.data!.isTjp).isGonnaBeTruthy();
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
|
|
94
137
|
|
|
95
138
|
|
|
96
139
|
});
|
|
97
140
|
|
|
141
|
+
await respecfully(sir, `stone`, async () => {
|
|
142
|
+
await ifWe(sir, `should throw if no parentPrimitiveIb`, async () => {
|
|
143
|
+
let errorMsg;
|
|
144
|
+
try {
|
|
145
|
+
// @ts-ignore
|
|
146
|
+
await factory.stone({ ib: 'ib' });
|
|
147
|
+
} catch (error: any) {
|
|
148
|
+
errorMsg = error.message;
|
|
149
|
+
}
|
|
150
|
+
iReckon(sir, errorMsg).asTo('errorMsg').isGonnaBeTruthy();
|
|
151
|
+
});
|
|
152
|
+
await ifWe(sir, `should throw if invalid parentPrimitiveIb`, async () => {
|
|
153
|
+
let errorMsg;
|
|
154
|
+
try {
|
|
155
|
+
// @ts-ignore
|
|
156
|
+
await factory.stone({ ib: 'ib', parentPrimitiveIb: 'ib^gib' });
|
|
157
|
+
} catch (error: any) {
|
|
158
|
+
errorMsg = error.message;
|
|
159
|
+
}
|
|
160
|
+
iReckon(sir, errorMsg).asTo('errorMsg').isGonnaBeTruthy();
|
|
161
|
+
});
|
|
162
|
+
await ifWe(sir, `should throw if no ib`, async () => {
|
|
163
|
+
let errorMsg;
|
|
164
|
+
try {
|
|
165
|
+
// @ts-ignore
|
|
166
|
+
await factory.stone({ parentPrimitiveIb: 'primitive' });
|
|
167
|
+
} catch (error: any) {
|
|
168
|
+
errorMsg = error.message;
|
|
169
|
+
}
|
|
170
|
+
iReckon(sir, errorMsg).asTo('errorMsg').isGonnaBeTruthy();
|
|
171
|
+
});
|
|
172
|
+
await ifWe(sir, `should throw if invalid ib (default regex)`, async () => {
|
|
173
|
+
let errorMsg;
|
|
174
|
+
try {
|
|
175
|
+
// containing a caret is invalid (it's a delimiter)
|
|
176
|
+
await factory.stone({ ib: 'ib^with^caret', parentPrimitiveIb: 'primitive' });
|
|
177
|
+
} catch (error: any) {
|
|
178
|
+
errorMsg = error.message;
|
|
179
|
+
}
|
|
180
|
+
iReckon(sir, errorMsg).asTo('errorMsg').isGonnaBeTruthy();
|
|
181
|
+
});
|
|
182
|
+
await ifWe(sir, `should throw if forbidden rel8ns`, async () => {
|
|
183
|
+
let errorMsg;
|
|
184
|
+
try {
|
|
185
|
+
// 'ancestor' is forbidden as input rel8n for stone (it's auto-generated)
|
|
186
|
+
await factory.stone({
|
|
187
|
+
ib: 'ib',
|
|
188
|
+
parentPrimitiveIb: 'primitive',
|
|
189
|
+
rel8ns: { 'ancestor': ['ancestor^gib'] }
|
|
190
|
+
});
|
|
191
|
+
} catch (error: any) {
|
|
192
|
+
errorMsg = error.message;
|
|
193
|
+
}
|
|
194
|
+
iReckon(sir, errorMsg).asTo('errorMsg').isGonnaBeTruthy();
|
|
195
|
+
});
|
|
196
|
+
await ifWe(sir, `should create a stone with correct structure`, async () => {
|
|
197
|
+
const stone = await factory.stone({
|
|
198
|
+
ib: 'stone_ib',
|
|
199
|
+
parentPrimitiveIb: 'primitive',
|
|
200
|
+
data: DATA_SIMPLE_XY
|
|
201
|
+
});
|
|
202
|
+
iReckon(sir, stone).isGonnaBeTruthy();
|
|
203
|
+
iReckon(sir, stone.ib).isGonnaBe('stone_ib');
|
|
204
|
+
iReckon(sir, stone.data).isGonnaBeTruthy();
|
|
205
|
+
iReckon(sir, stone.data!.x).isGonnaBe(DATA_SIMPLE_XY.x);
|
|
206
|
+
iReckon(sir, stone.data!.y).isGonnaBe(DATA_SIMPLE_XY.y);
|
|
207
|
+
iReckon(sir, stone.rel8ns).isGonnaBeTruthy();
|
|
208
|
+
iReckon(sir, stone.rel8ns!.past).isGonnaBeUndefined();
|
|
209
|
+
iReckon(sir, stone.rel8ns!.tjp).isGonnaBeUndefined();
|
|
210
|
+
iReckon(sir, stone.gib).isGonnaBeTruthy();
|
|
211
|
+
// uuid should be falsy by default
|
|
212
|
+
iReckon(sir, (stone.data as any).uuid).isGonnaBeFalsy();
|
|
213
|
+
});
|
|
214
|
+
await ifWe(sir, `should generate uuid if requested`, async () => {
|
|
215
|
+
const stone = await factory.stone({
|
|
216
|
+
ib: 'stone_ib_uuid',
|
|
217
|
+
parentPrimitiveIb: 'primitive',
|
|
218
|
+
uuid: true
|
|
219
|
+
});
|
|
220
|
+
iReckon(sir, (stone.data as any).uuid).isGonnaBeTruthy();
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
await respecfully(sir, `constant`, async () => {
|
|
225
|
+
await ifWe(sir, `should create a constant with correct structure`, async () => {
|
|
226
|
+
const constant = await factory.constant({
|
|
227
|
+
ib: 'constant_ib',
|
|
228
|
+
parentPrimitiveIb: 'primitive',
|
|
229
|
+
data: DATA_SIMPLE_XY
|
|
230
|
+
});
|
|
231
|
+
iReckon(sir, constant).isGonnaBeTruthy();
|
|
232
|
+
iReckon(sir, constant.ib).isGonnaBe('constant_ib');
|
|
233
|
+
iReckon(sir, constant.data).isGonnaBe(DATA_SIMPLE_XY);
|
|
234
|
+
iReckon(sir, (constant.data as any).uuid).isGonnaBeFalsy();
|
|
235
|
+
iReckon(sir, (constant.data as any).timestamp).isGonnaBeFalsy();
|
|
236
|
+
iReckon(sir, constant.rel8ns!.tjp).isGonnaBeUndefined();
|
|
237
|
+
iReckon(sir, constant.rel8ns!.dna).isGonnaBeUndefined();
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
|
|
98
241
|
await respecfully(sir, 'hmm how to do this?', async () => {
|
|
99
242
|
var allIbGibs: IbGib_V1[];
|
|
100
243
|
firstOfAll(sir, async () => {
|
package/src/respec-gib.node.mts
CHANGED
|
@@ -40,7 +40,7 @@ const LOOK_FOR_EXTRA_RESPEC = true;
|
|
|
40
40
|
* do have these will execute fully, but the output will only include these
|
|
41
41
|
* particular blocks.
|
|
42
42
|
*/
|
|
43
|
-
const EXTRA_RESPEC_FUNCTION_NAMES: string[] = ['respecfullyDear', 'ifWeMight'];
|
|
43
|
+
const EXTRA_RESPEC_FUNCTION_NAMES: string[] = ['await respecfullyDear', 'ifWeMight'];
|
|
44
44
|
|
|
45
45
|
// #endregion settings
|
|
46
46
|
|