@ibgib/ts-gib 0.5.26 → 0.5.27
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 +79 -2
- package/dist/V1/factory.d.mts.map +1 -1
- package/dist/V1/factory.mjs +146 -2
- 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 +182 -3
- package/src/V1/factory.respec.mts +100 -0
- 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
|
*
|
|
@@ -34,5 +34,82 @@ export declare class Factory_V1 {
|
|
|
34
34
|
noTimestamp?: boolean;
|
|
35
35
|
nCounter?: boolean;
|
|
36
36
|
}): Promise<TransformResult<IbGib_V1>>;
|
|
37
|
+
/**
|
|
38
|
+
* Generate an ibgib datum that has no dna and no timeline.
|
|
39
|
+
* It's a one-off ibgib.
|
|
40
|
+
*
|
|
41
|
+
* This is similar to {@link Factory_V1.constant}, but this is not
|
|
42
|
+
* necessarily deterministic. It can have a timestamp and/or uuid, though it
|
|
43
|
+
* does not have dna, nCounter, or a tjp.
|
|
44
|
+
*
|
|
45
|
+
* ## validation
|
|
46
|
+
*
|
|
47
|
+
* * validates the given `ib` against `ibRegExpPattern` or default regexp.
|
|
48
|
+
* * validates that rel8ns doesn't include default forbidden rel8n names or
|
|
49
|
+
* atow `'tjp'`.
|
|
50
|
+
*
|
|
51
|
+
* ## intent
|
|
52
|
+
*
|
|
53
|
+
* Stones are useful for one-off ibgibs that are not part of a timeline, but
|
|
54
|
+
* which still should have a timestamp and/or uuid.
|
|
55
|
+
*
|
|
56
|
+
* @see {@link Factory_V1.constant}
|
|
57
|
+
*/
|
|
58
|
+
static stone<TData extends IbGibData_V1 = any, TRel8ns extends IbGibRel8ns_V1 = IbGibRel8ns_V1>({ parentPrimitiveIb, ib, ibRegExpPattern, data, rel8ns, noTimestamp, uuid, }: {
|
|
59
|
+
parentPrimitiveIb: Ib;
|
|
60
|
+
ib: Ib;
|
|
61
|
+
/**
|
|
62
|
+
* for checking the stone's generated ib
|
|
63
|
+
*/
|
|
64
|
+
ibRegExpPattern?: string;
|
|
65
|
+
data?: TData;
|
|
66
|
+
rel8ns?: TRel8ns;
|
|
67
|
+
noTimestamp?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* If true, will generate a uuid for the stone. If falsy, will not.
|
|
70
|
+
*/
|
|
71
|
+
uuid?: boolean;
|
|
72
|
+
}): Promise<IbGib_V1<TData, TRel8ns>>;
|
|
73
|
+
/**
|
|
74
|
+
* Generate a deterministic ibgib datum that has no dna and no timeline.
|
|
75
|
+
* It's a one-off ibgib.
|
|
76
|
+
*
|
|
77
|
+
* Because this is supposed to create and re-create deterministically the equivalent
|
|
78
|
+
* of a non-primitive ibgib "constant", this function creates a single ibgib with...
|
|
79
|
+
* * one ancestor
|
|
80
|
+
* * no past, dna, or tjp rel8ns
|
|
81
|
+
* * no tjp timestamp or uuid
|
|
82
|
+
* * no nCounter
|
|
83
|
+
*
|
|
84
|
+
* This is similar to {@link Factory_V1.stone}, but with guaranteed no
|
|
85
|
+
* timestamp or uuid (unless incoming {@link data} contains a uuid).
|
|
86
|
+
*
|
|
87
|
+
* @see {@link Factory_V1.stone}
|
|
88
|
+
*
|
|
89
|
+
* ## intent
|
|
90
|
+
*
|
|
91
|
+
* I want to be able to create deterministic ibGibs that I can reference at
|
|
92
|
+
* runtime, similar to an ibgib primitive (e.g. "root^gib"), but with the
|
|
93
|
+
* integrity of the `gib` hash. This way, I can reference a deterministic ibgib
|
|
94
|
+
* from code at compile time, and at runtime this will have a corresponding
|
|
95
|
+
* ibgib datum with gib-hashed integrity.
|
|
96
|
+
*
|
|
97
|
+
* ## example
|
|
98
|
+
*
|
|
99
|
+
* I want to create a "hard-coded" schema ibgib that I rel8 to some protocol
|
|
100
|
+
* ibgib. So I'll create the data here, which lives in source control in a text file,
|
|
101
|
+
* and then I'll render that as an ibgib that verifies integrity. If I as a coder change
|
|
102
|
+
* it at all, then the `gib` of course will be different.
|
|
103
|
+
*/
|
|
104
|
+
static constant<TData extends IbGibData_V1 = any, TRel8ns extends IbGibRel8ns_V1 = IbGibRel8ns_V1>({ parentPrimitiveIb, ib, ibRegExpPattern, data, rel8ns, }: {
|
|
105
|
+
parentPrimitiveIb: Ib;
|
|
106
|
+
ib: Ib;
|
|
107
|
+
/**
|
|
108
|
+
* for checking the constant's generated ib
|
|
109
|
+
*/
|
|
110
|
+
ibRegExpPattern?: string;
|
|
111
|
+
data?: TData;
|
|
112
|
+
rel8ns?: TRel8ns;
|
|
113
|
+
}): Promise<IbGib_V1<TData, TRel8ns>>;
|
|
37
114
|
}
|
|
38
115
|
//# 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;AAKrE,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,GACX,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,WAAW,CAAC,EAAE,OAA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
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';
|
|
5
8
|
export class Factory_V1 {
|
|
6
9
|
static root() {
|
|
7
10
|
return Factory_V1.primitive({ ib: IB });
|
|
@@ -28,7 +31,7 @@ export class Factory_V1 {
|
|
|
28
31
|
* @returns The entire transform result object that includes the newly produced ibGib as well as any derivative/intermediate ibgibs.
|
|
29
32
|
*/
|
|
30
33
|
static async firstGen({ ib = IB, parentIbGib = Factory_V1.root(), data, rel8ns, dna, tjp, linkedRel8ns, noTimestamp, nCounter, }) {
|
|
31
|
-
const lc = `[firstGen]`;
|
|
34
|
+
const lc = `[${Factory_V1.name}][${Factory_V1.firstGen.name}]`;
|
|
32
35
|
/** * Multiple transform steps will create multiple results. */
|
|
33
36
|
const interimResults = [];
|
|
34
37
|
let src = parentIbGib || ROOT;
|
|
@@ -89,5 +92,146 @@ export class Factory_V1 {
|
|
|
89
92
|
throw new Error(`${lc} hmm, I'm not sure...`);
|
|
90
93
|
}
|
|
91
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* Generate an ibgib datum that has no dna and no timeline.
|
|
97
|
+
* It's a one-off ibgib.
|
|
98
|
+
*
|
|
99
|
+
* This is similar to {@link Factory_V1.constant}, but this is not
|
|
100
|
+
* necessarily deterministic. It can have a timestamp and/or uuid, though it
|
|
101
|
+
* does not have dna, nCounter, or a tjp.
|
|
102
|
+
*
|
|
103
|
+
* ## validation
|
|
104
|
+
*
|
|
105
|
+
* * validates the given `ib` against `ibRegExpPattern` or default regexp.
|
|
106
|
+
* * validates that rel8ns doesn't include default forbidden rel8n names or
|
|
107
|
+
* atow `'tjp'`.
|
|
108
|
+
*
|
|
109
|
+
* ## intent
|
|
110
|
+
*
|
|
111
|
+
* Stones are useful for one-off ibgibs that are not part of a timeline, but
|
|
112
|
+
* which still should have a timestamp and/or uuid.
|
|
113
|
+
*
|
|
114
|
+
* @see {@link Factory_V1.constant}
|
|
115
|
+
*/
|
|
116
|
+
static async stone({ parentPrimitiveIb, ib, ibRegExpPattern, data, rel8ns, noTimestamp, uuid, }) {
|
|
117
|
+
const lc = `[${Factory_V1.name}][${Factory_V1.stone.name}]`;
|
|
118
|
+
try {
|
|
119
|
+
// validation
|
|
120
|
+
// parentPrimitiveIb
|
|
121
|
+
if (!parentPrimitiveIb) {
|
|
122
|
+
throw new Error(`parentPrimitiveIb required. (E: genuuid)`);
|
|
123
|
+
}
|
|
124
|
+
if (validateIb({ ib: parentPrimitiveIb }) !== null) {
|
|
125
|
+
throw new Error(`Invalid parentPrimitiveIb: ${parentPrimitiveIb}. (E: genuuid)`);
|
|
126
|
+
}
|
|
127
|
+
// ib
|
|
128
|
+
if (!ib) {
|
|
129
|
+
throw new Error(`ib required. (E: genuuid)`);
|
|
130
|
+
}
|
|
131
|
+
const regExp = ibRegExpPattern ? new RegExp(ibRegExpPattern) : IB_REGEXP_DEFAULT;
|
|
132
|
+
if (!ib.match(regExp)) {
|
|
133
|
+
throw new Error(`invalid ib. does not match regexp (${regExp}) (E: genuuid)`);
|
|
134
|
+
}
|
|
135
|
+
// rel8ns
|
|
136
|
+
const incomingRel8nNames = Object.keys(rel8ns ?? {});
|
|
137
|
+
const forbiddenRel8nNames = [...FORBIDDEN_ADD_RENAME_REMOVE_REL8N_NAMES, 'tjp'];
|
|
138
|
+
const rel8nsIsInvalid = incomingRel8nNames.some(x => {
|
|
139
|
+
// we don't want constants trying to look like they have/are descendants/tjps/etc.
|
|
140
|
+
return forbiddenRel8nNames.includes(x);
|
|
141
|
+
});
|
|
142
|
+
if (rel8nsIsInvalid) {
|
|
143
|
+
throw new Error(`Invalid rel8ns. forbiddenRel8nNames: ${forbiddenRel8nNames}. rel8ns keys: ${Object.keys(rel8ns ?? {})}. (E: genuuid)`);
|
|
144
|
+
}
|
|
145
|
+
// create the stone by using the firstGen factory. Then we'll pare
|
|
146
|
+
// off what we don't need.
|
|
147
|
+
const resFirstGen = await Factory_V1.firstGen({
|
|
148
|
+
ib,
|
|
149
|
+
parentIbGib: Factory_V1.primitive({ ib: parentPrimitiveIb }),
|
|
150
|
+
data,
|
|
151
|
+
rel8ns,
|
|
152
|
+
dna: false,
|
|
153
|
+
noTimestamp,
|
|
154
|
+
nCounter: false,
|
|
155
|
+
});
|
|
156
|
+
const stoneIbGib = resFirstGen.newIbGib;
|
|
157
|
+
if (uuid) {
|
|
158
|
+
if (!stoneIbGib.data) {
|
|
159
|
+
stoneIbGib.data = {};
|
|
160
|
+
}
|
|
161
|
+
stoneIbGib.data.uuid = await getUUID();
|
|
162
|
+
}
|
|
163
|
+
// remove any extraneous stuff
|
|
164
|
+
if (stoneIbGib.rel8ns?.past) {
|
|
165
|
+
delete stoneIbGib.rel8ns.past;
|
|
166
|
+
}
|
|
167
|
+
if (stoneIbGib.rel8ns?.tjp) {
|
|
168
|
+
delete stoneIbGib.rel8ns.tjp;
|
|
169
|
+
}
|
|
170
|
+
// recalculate the gib hash
|
|
171
|
+
stoneIbGib.gib = await getGib({
|
|
172
|
+
ibGib: {
|
|
173
|
+
ib: stoneIbGib.ib,
|
|
174
|
+
data: stoneIbGib.data,
|
|
175
|
+
rel8ns: stoneIbGib.rel8ns,
|
|
176
|
+
},
|
|
177
|
+
hasTjp: false,
|
|
178
|
+
});
|
|
179
|
+
return stoneIbGib;
|
|
180
|
+
}
|
|
181
|
+
catch (error) {
|
|
182
|
+
console.error(`${lc} ${error.message}`);
|
|
183
|
+
throw error;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Generate a deterministic ibgib datum that has no dna and no timeline.
|
|
188
|
+
* It's a one-off ibgib.
|
|
189
|
+
*
|
|
190
|
+
* Because this is supposed to create and re-create deterministically the equivalent
|
|
191
|
+
* of a non-primitive ibgib "constant", this function creates a single ibgib with...
|
|
192
|
+
* * one ancestor
|
|
193
|
+
* * no past, dna, or tjp rel8ns
|
|
194
|
+
* * no tjp timestamp or uuid
|
|
195
|
+
* * no nCounter
|
|
196
|
+
*
|
|
197
|
+
* This is similar to {@link Factory_V1.stone}, but with guaranteed no
|
|
198
|
+
* timestamp or uuid (unless incoming {@link data} contains a uuid).
|
|
199
|
+
*
|
|
200
|
+
* @see {@link Factory_V1.stone}
|
|
201
|
+
*
|
|
202
|
+
* ## intent
|
|
203
|
+
*
|
|
204
|
+
* I want to be able to create deterministic ibGibs that I can reference at
|
|
205
|
+
* runtime, similar to an ibgib primitive (e.g. "root^gib"), but with the
|
|
206
|
+
* integrity of the `gib` hash. This way, I can reference a deterministic ibgib
|
|
207
|
+
* from code at compile time, and at runtime this will have a corresponding
|
|
208
|
+
* ibgib datum with gib-hashed integrity.
|
|
209
|
+
*
|
|
210
|
+
* ## example
|
|
211
|
+
*
|
|
212
|
+
* I want to create a "hard-coded" schema ibgib that I rel8 to some protocol
|
|
213
|
+
* ibgib. So I'll create the data here, which lives in source control in a text file,
|
|
214
|
+
* and then I'll render that as an ibgib that verifies integrity. If I as a coder change
|
|
215
|
+
* it at all, then the `gib` of course will be different.
|
|
216
|
+
*/
|
|
217
|
+
static async constant({ parentPrimitiveIb, ib, ibRegExpPattern, data, rel8ns, }) {
|
|
218
|
+
const lc = `[${Factory_V1.name}][${Factory_V1.constant.name}]`;
|
|
219
|
+
try {
|
|
220
|
+
const constantIbGib = await Factory_V1.stone({
|
|
221
|
+
parentPrimitiveIb,
|
|
222
|
+
ib,
|
|
223
|
+
ibRegExpPattern,
|
|
224
|
+
data,
|
|
225
|
+
rel8ns,
|
|
226
|
+
noTimestamp: true,
|
|
227
|
+
uuid: false,
|
|
228
|
+
});
|
|
229
|
+
return constantIbGib;
|
|
230
|
+
}
|
|
231
|
+
catch (error) {
|
|
232
|
+
console.error(`${lc} ${error.message}`);
|
|
233
|
+
throw error;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
92
236
|
}
|
|
93
237
|
//# sourceMappingURL=factory.mjs.map
|
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,OAAO,EAAE,MAAM,iDAAiD,CAAC;AAE1E,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,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,EA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AC;YACb,OAAO,CAAC,KAAK,CAAC,GAAG,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":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,KAAK,SAAS,MAAM,MAAM,CAAC;AAElC,OAAO,EAAE,MAAM,EAAE,MAAM,iDAAiD,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kDAAkD,CAAC;AAEtF,mBAAmB;AACnB;;GAEG;AACH,MAAM,OAAO,GAAG,KAAK,CAAC;AAEtB,qDAAqD;AACrD,MAAM,gCAAgC,GAAG,QAAQ,CAAC;AAElD,iDAAiD;AACjD,MAAM,mBAAmB,GAAG,iBAAiB,CAAC;AAC9C,4DAA4D;AAC5D,sDAAsD;AAEtD;;;;;;;;;GASG;AACH,MAAM,qBAAqB,GAAG,IAAI,CAAC;AACnC;;;;;;;;GAQG;AACH,MAAM,2BAA2B,GAAa,CAAC,
|
|
1
|
+
{"version":3,"file":"respec-gib.node.mjs","sourceRoot":"","sources":["../src/respec-gib.node.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,KAAK,SAAS,MAAM,MAAM,CAAC;AAElC,OAAO,EAAE,MAAM,EAAE,MAAM,iDAAiD,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kDAAkD,CAAC;AAEtF,mBAAmB;AACnB;;GAEG;AACH,MAAM,OAAO,GAAG,KAAK,CAAC;AAEtB,qDAAqD;AACrD,MAAM,gCAAgC,GAAG,QAAQ,CAAC;AAElD,iDAAiD;AACjD,MAAM,mBAAmB,GAAG,iBAAiB,CAAC;AAC9C,4D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,CAAC,GAAG,MAAM,GAAG,CAAC,EAAE,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.27",
|
|
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,13 @@
|
|
|
1
|
+
import { 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';
|
|
7
11
|
|
|
8
12
|
export class Factory_V1 {
|
|
9
13
|
static root() {
|
|
@@ -62,7 +66,7 @@ export class Factory_V1 {
|
|
|
62
66
|
noTimestamp?: boolean,
|
|
63
67
|
nCounter?: boolean,
|
|
64
68
|
}): Promise<TransformResult<IbGib_V1>> {
|
|
65
|
-
const lc = `[firstGen]`;
|
|
69
|
+
const lc = `[${Factory_V1.name}][${Factory_V1.firstGen.name}]`;
|
|
66
70
|
/** * Multiple transform steps will create multiple results. */
|
|
67
71
|
const interimResults: TransformResult<IbGib_V1>[] = [];
|
|
68
72
|
let src: IbGib_V1 = parentIbGib || ROOT;
|
|
@@ -123,4 +127,179 @@ export class Factory_V1 {
|
|
|
123
127
|
throw new Error(`${lc} hmm, I'm not sure...`);
|
|
124
128
|
}
|
|
125
129
|
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Generate an ibgib datum that has no dna and no timeline.
|
|
133
|
+
* It's a one-off ibgib.
|
|
134
|
+
*
|
|
135
|
+
* This is similar to {@link Factory_V1.constant}, but this is not
|
|
136
|
+
* necessarily deterministic. It can have a timestamp and/or uuid, though it
|
|
137
|
+
* does not have dna, nCounter, or a tjp.
|
|
138
|
+
*
|
|
139
|
+
* ## validation
|
|
140
|
+
*
|
|
141
|
+
* * validates the given `ib` against `ibRegExpPattern` or default regexp.
|
|
142
|
+
* * validates that rel8ns doesn't include default forbidden rel8n names or
|
|
143
|
+
* atow `'tjp'`.
|
|
144
|
+
*
|
|
145
|
+
* ## intent
|
|
146
|
+
*
|
|
147
|
+
* Stones are useful for one-off ibgibs that are not part of a timeline, but
|
|
148
|
+
* which still should have a timestamp and/or uuid.
|
|
149
|
+
*
|
|
150
|
+
* @see {@link Factory_V1.constant}
|
|
151
|
+
*/
|
|
152
|
+
static async stone<
|
|
153
|
+
TData extends IbGibData_V1 = any,
|
|
154
|
+
TRel8ns extends IbGibRel8ns_V1 = IbGibRel8ns_V1
|
|
155
|
+
>({
|
|
156
|
+
parentPrimitiveIb,
|
|
157
|
+
ib,
|
|
158
|
+
ibRegExpPattern,
|
|
159
|
+
data,
|
|
160
|
+
rel8ns,
|
|
161
|
+
noTimestamp,
|
|
162
|
+
uuid,
|
|
163
|
+
}: {
|
|
164
|
+
parentPrimitiveIb: Ib,
|
|
165
|
+
ib: Ib,
|
|
166
|
+
/**
|
|
167
|
+
* for checking the stone's generated ib
|
|
168
|
+
*/
|
|
169
|
+
ibRegExpPattern?: string,
|
|
170
|
+
data?: TData,
|
|
171
|
+
rel8ns?: TRel8ns,
|
|
172
|
+
noTimestamp?: boolean,
|
|
173
|
+
/**
|
|
174
|
+
* If true, will generate a uuid for the stone. If falsy, will not.
|
|
175
|
+
*/
|
|
176
|
+
uuid?: boolean,
|
|
177
|
+
}): Promise<IbGib_V1<TData, TRel8ns>> {
|
|
178
|
+
const lc = `[${Factory_V1.name}][${Factory_V1.stone.name}]`;
|
|
179
|
+
try {
|
|
180
|
+
// validation
|
|
181
|
+
// parentPrimitiveIb
|
|
182
|
+
if (!parentPrimitiveIb) { throw new Error(`parentPrimitiveIb required. (E: genuuid)`); }
|
|
183
|
+
if (validateIb({ ib: parentPrimitiveIb }) !== null) { throw new Error(`Invalid parentPrimitiveIb: ${parentPrimitiveIb}. (E: genuuid)`); }
|
|
184
|
+
|
|
185
|
+
// ib
|
|
186
|
+
if (!ib) { throw new Error(`ib required. (E: genuuid)`); }
|
|
187
|
+
const regExp = ibRegExpPattern ? new RegExp(ibRegExpPattern) : IB_REGEXP_DEFAULT;
|
|
188
|
+
if (!ib.match(regExp)) { throw new Error(`invalid ib. does not match regexp (${regExp}) (E: genuuid)`); }
|
|
189
|
+
|
|
190
|
+
// rel8ns
|
|
191
|
+
const incomingRel8nNames = Object.keys(rel8ns ?? {});
|
|
192
|
+
const forbiddenRel8nNames = [...FORBIDDEN_ADD_RENAME_REMOVE_REL8N_NAMES, 'tjp'];
|
|
193
|
+
const rel8nsIsInvalid = incomingRel8nNames.some(x => {
|
|
194
|
+
// we don't want constants trying to look like they have/are descendants/tjps/etc.
|
|
195
|
+
return forbiddenRel8nNames.includes(x);
|
|
196
|
+
});
|
|
197
|
+
if (rel8nsIsInvalid) { throw new Error(`Invalid rel8ns. forbiddenRel8nNames: ${forbiddenRel8nNames}. rel8ns keys: ${Object.keys(rel8ns ?? {})}. (E: genuuid)`); }
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
// create the stone by using the firstGen factory. Then we'll pare
|
|
201
|
+
// off what we don't need.
|
|
202
|
+
const resFirstGen = await Factory_V1.firstGen({
|
|
203
|
+
ib,
|
|
204
|
+
parentIbGib: Factory_V1.primitive({ ib: parentPrimitiveIb }),
|
|
205
|
+
data,
|
|
206
|
+
rel8ns,
|
|
207
|
+
dna: false,
|
|
208
|
+
noTimestamp,
|
|
209
|
+
nCounter: false,
|
|
210
|
+
});
|
|
211
|
+
const stoneIbGib = resFirstGen.newIbGib as IbGib_V1<TData, TRel8ns>;
|
|
212
|
+
if (uuid) {
|
|
213
|
+
if (!stoneIbGib.data) { stoneIbGib.data = {} as TData; }
|
|
214
|
+
stoneIbGib.data.uuid = await getUUID();
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// remove any extraneous stuff
|
|
218
|
+
if (stoneIbGib.rel8ns?.past) { delete stoneIbGib.rel8ns.past; }
|
|
219
|
+
if (stoneIbGib.rel8ns?.tjp) { delete stoneIbGib.rel8ns.tjp; }
|
|
220
|
+
|
|
221
|
+
// recalculate the gib hash
|
|
222
|
+
stoneIbGib.gib = await getGib({
|
|
223
|
+
ibGib: {
|
|
224
|
+
ib: stoneIbGib.ib,
|
|
225
|
+
data: stoneIbGib.data,
|
|
226
|
+
rel8ns: stoneIbGib.rel8ns,
|
|
227
|
+
},
|
|
228
|
+
hasTjp: false,
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
return stoneIbGib;
|
|
232
|
+
} catch (error) {
|
|
233
|
+
console.error(`${lc} ${error.message}`);
|
|
234
|
+
throw error;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Generate a deterministic ibgib datum that has no dna and no timeline.
|
|
240
|
+
* It's a one-off ibgib.
|
|
241
|
+
*
|
|
242
|
+
* Because this is supposed to create and re-create deterministically the equivalent
|
|
243
|
+
* of a non-primitive ibgib "constant", this function creates a single ibgib with...
|
|
244
|
+
* * one ancestor
|
|
245
|
+
* * no past, dna, or tjp rel8ns
|
|
246
|
+
* * no tjp timestamp or uuid
|
|
247
|
+
* * no nCounter
|
|
248
|
+
*
|
|
249
|
+
* This is similar to {@link Factory_V1.stone}, but with guaranteed no
|
|
250
|
+
* timestamp or uuid (unless incoming {@link data} contains a uuid).
|
|
251
|
+
*
|
|
252
|
+
* @see {@link Factory_V1.stone}
|
|
253
|
+
*
|
|
254
|
+
* ## intent
|
|
255
|
+
*
|
|
256
|
+
* I want to be able to create deterministic ibGibs that I can reference at
|
|
257
|
+
* runtime, similar to an ibgib primitive (e.g. "root^gib"), but with the
|
|
258
|
+
* integrity of the `gib` hash. This way, I can reference a deterministic ibgib
|
|
259
|
+
* from code at compile time, and at runtime this will have a corresponding
|
|
260
|
+
* ibgib datum with gib-hashed integrity.
|
|
261
|
+
*
|
|
262
|
+
* ## example
|
|
263
|
+
*
|
|
264
|
+
* I want to create a "hard-coded" schema ibgib that I rel8 to some protocol
|
|
265
|
+
* ibgib. So I'll create the data here, which lives in source control in a text file,
|
|
266
|
+
* and then I'll render that as an ibgib that verifies integrity. If I as a coder change
|
|
267
|
+
* it at all, then the `gib` of course will be different.
|
|
268
|
+
*/
|
|
269
|
+
static async constant<
|
|
270
|
+
TData extends IbGibData_V1 = any,
|
|
271
|
+
TRel8ns extends IbGibRel8ns_V1 = IbGibRel8ns_V1
|
|
272
|
+
>({
|
|
273
|
+
parentPrimitiveIb,
|
|
274
|
+
ib,
|
|
275
|
+
ibRegExpPattern,
|
|
276
|
+
data,
|
|
277
|
+
rel8ns,
|
|
278
|
+
}: {
|
|
279
|
+
parentPrimitiveIb: Ib,
|
|
280
|
+
ib: Ib,
|
|
281
|
+
/**
|
|
282
|
+
* for checking the constant's generated ib
|
|
283
|
+
*/
|
|
284
|
+
ibRegExpPattern?: string,
|
|
285
|
+
data?: TData,
|
|
286
|
+
rel8ns?: TRel8ns,
|
|
287
|
+
}): Promise<IbGib_V1<TData, TRel8ns>> {
|
|
288
|
+
const lc = `[${Factory_V1.name}][${Factory_V1.constant.name}]`;
|
|
289
|
+
try {
|
|
290
|
+
const constantIbGib = await Factory_V1.stone({
|
|
291
|
+
parentPrimitiveIb,
|
|
292
|
+
ib,
|
|
293
|
+
ibRegExpPattern,
|
|
294
|
+
data,
|
|
295
|
+
rel8ns,
|
|
296
|
+
noTimestamp: true,
|
|
297
|
+
uuid: false,
|
|
298
|
+
});
|
|
299
|
+
return constantIbGib;
|
|
300
|
+
} catch (error) {
|
|
301
|
+
console.error(`${lc} ${error.message}`);
|
|
302
|
+
throw error;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
126
305
|
}
|
|
@@ -95,6 +95,106 @@ await respecfully(sir, `when using factory`, async () => {
|
|
|
95
95
|
|
|
96
96
|
});
|
|
97
97
|
|
|
98
|
+
await respecfully(sir, `stone`, async () => {
|
|
99
|
+
await ifWe(sir, `should throw if no parentPrimitiveIb`, async () => {
|
|
100
|
+
let errorMsg;
|
|
101
|
+
try {
|
|
102
|
+
// @ts-ignore
|
|
103
|
+
await factory.stone({ ib: 'ib' });
|
|
104
|
+
} catch (error: any) {
|
|
105
|
+
errorMsg = error.message;
|
|
106
|
+
}
|
|
107
|
+
iReckon(sir, errorMsg).asTo('errorMsg').isGonnaBeTruthy();
|
|
108
|
+
});
|
|
109
|
+
await ifWe(sir, `should throw if invalid parentPrimitiveIb`, async () => {
|
|
110
|
+
let errorMsg;
|
|
111
|
+
try {
|
|
112
|
+
// @ts-ignore
|
|
113
|
+
await factory.stone({ ib: 'ib', parentPrimitiveIb: 'ib^gib' });
|
|
114
|
+
} catch (error: any) {
|
|
115
|
+
errorMsg = error.message;
|
|
116
|
+
}
|
|
117
|
+
iReckon(sir, errorMsg).asTo('errorMsg').isGonnaBeTruthy();
|
|
118
|
+
});
|
|
119
|
+
await ifWe(sir, `should throw if no ib`, async () => {
|
|
120
|
+
let errorMsg;
|
|
121
|
+
try {
|
|
122
|
+
// @ts-ignore
|
|
123
|
+
await factory.stone({ parentPrimitiveIb: 'primitive' });
|
|
124
|
+
} catch (error: any) {
|
|
125
|
+
errorMsg = error.message;
|
|
126
|
+
}
|
|
127
|
+
iReckon(sir, errorMsg).asTo('errorMsg').isGonnaBeTruthy();
|
|
128
|
+
});
|
|
129
|
+
await ifWe(sir, `should throw if invalid ib (default regex)`, async () => {
|
|
130
|
+
let errorMsg;
|
|
131
|
+
try {
|
|
132
|
+
// containing a caret is invalid (it's a delimiter)
|
|
133
|
+
await factory.stone({ ib: 'ib^with^caret', parentPrimitiveIb: 'primitive' });
|
|
134
|
+
} catch (error: any) {
|
|
135
|
+
errorMsg = error.message;
|
|
136
|
+
}
|
|
137
|
+
iReckon(sir, errorMsg).asTo('errorMsg').isGonnaBeTruthy();
|
|
138
|
+
});
|
|
139
|
+
await ifWe(sir, `should throw if forbidden rel8ns`, async () => {
|
|
140
|
+
let errorMsg;
|
|
141
|
+
try {
|
|
142
|
+
// 'ancestor' is forbidden as input rel8n for stone (it's auto-generated)
|
|
143
|
+
await factory.stone({
|
|
144
|
+
ib: 'ib',
|
|
145
|
+
parentPrimitiveIb: 'primitive',
|
|
146
|
+
rel8ns: { 'ancestor': ['ancestor^gib'] }
|
|
147
|
+
});
|
|
148
|
+
} catch (error: any) {
|
|
149
|
+
errorMsg = error.message;
|
|
150
|
+
}
|
|
151
|
+
iReckon(sir, errorMsg).asTo('errorMsg').isGonnaBeTruthy();
|
|
152
|
+
});
|
|
153
|
+
await ifWe(sir, `should create a stone with correct structure`, async () => {
|
|
154
|
+
const stone = await factory.stone({
|
|
155
|
+
ib: 'stone_ib',
|
|
156
|
+
parentPrimitiveIb: 'primitive',
|
|
157
|
+
data: DATA_SIMPLE_XY
|
|
158
|
+
});
|
|
159
|
+
iReckon(sir, stone).isGonnaBeTruthy();
|
|
160
|
+
iReckon(sir, stone.ib).isGonnaBe('stone_ib');
|
|
161
|
+
iReckon(sir, stone.data).isGonnaBeTruthy();
|
|
162
|
+
iReckon(sir, stone.data!.x).isGonnaBe(DATA_SIMPLE_XY.x);
|
|
163
|
+
iReckon(sir, stone.data!.y).isGonnaBe(DATA_SIMPLE_XY.y);
|
|
164
|
+
iReckon(sir, stone.rel8ns).isGonnaBeTruthy();
|
|
165
|
+
iReckon(sir, stone.rel8ns!.past).isGonnaBeUndefined();
|
|
166
|
+
iReckon(sir, stone.rel8ns!.tjp).isGonnaBeUndefined();
|
|
167
|
+
iReckon(sir, stone.gib).isGonnaBeTruthy();
|
|
168
|
+
// uuid should be falsy by default
|
|
169
|
+
iReckon(sir, (stone.data as any).uuid).isGonnaBeFalsy();
|
|
170
|
+
});
|
|
171
|
+
await ifWe(sir, `should generate uuid if requested`, async () => {
|
|
172
|
+
const stone = await factory.stone({
|
|
173
|
+
ib: 'stone_ib_uuid',
|
|
174
|
+
parentPrimitiveIb: 'primitive',
|
|
175
|
+
uuid: true
|
|
176
|
+
});
|
|
177
|
+
iReckon(sir, (stone.data as any).uuid).isGonnaBeTruthy();
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
await respecfully(sir, `constant`, async () => {
|
|
182
|
+
await ifWe(sir, `should create a constant with correct structure`, async () => {
|
|
183
|
+
const constant = await factory.constant({
|
|
184
|
+
ib: 'constant_ib',
|
|
185
|
+
parentPrimitiveIb: 'primitive',
|
|
186
|
+
data: DATA_SIMPLE_XY
|
|
187
|
+
});
|
|
188
|
+
iReckon(sir, constant).isGonnaBeTruthy();
|
|
189
|
+
iReckon(sir, constant.ib).isGonnaBe('constant_ib');
|
|
190
|
+
iReckon(sir, constant.data).isGonnaBe(DATA_SIMPLE_XY);
|
|
191
|
+
iReckon(sir, (constant.data as any).uuid).isGonnaBeFalsy();
|
|
192
|
+
iReckon(sir, (constant.data as any).timestamp).isGonnaBeFalsy();
|
|
193
|
+
iReckon(sir, constant.rel8ns!.tjp).isGonnaBeUndefined();
|
|
194
|
+
iReckon(sir, constant.rel8ns!.dna).isGonnaBeUndefined();
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
|
|
98
198
|
await respecfully(sir, 'hmm how to do this?', async () => {
|
|
99
199
|
var allIbGibs: IbGib_V1[];
|
|
100
200
|
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
|
|