@ibgib/ts-gib 0.4.9 → 0.5.1

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 (71) hide show
  1. package/.vscode/settings.json +3 -1
  2. package/CHANGELOG.md +20 -0
  3. package/README.md +30 -5
  4. package/dist/V1/constants.d.mts +30 -1
  5. package/dist/V1/constants.d.mts.map +1 -1
  6. package/dist/V1/constants.mjs +30 -1
  7. package/dist/V1/constants.mjs.map +1 -1
  8. package/dist/V1/factory.d.mts +17 -2
  9. package/dist/V1/factory.d.mts.map +1 -1
  10. package/dist/V1/factory.mjs +15 -0
  11. package/dist/V1/factory.mjs.map +1 -1
  12. package/dist/V1/sha256v1.d.mts.map +1 -1
  13. package/dist/V1/sha256v1.mjs +1 -1
  14. package/dist/V1/sha256v1.mjs.map +1 -1
  15. package/dist/V1/transforms/fork.d.mts.map +1 -1
  16. package/dist/V1/transforms/fork.mjs +2 -1
  17. package/dist/V1/transforms/fork.mjs.map +1 -1
  18. package/dist/V1/transforms/index.d.mts +1 -1
  19. package/dist/V1/transforms/index.d.mts.map +1 -1
  20. package/dist/V1/transforms/index.mjs +1 -1
  21. package/dist/V1/transforms/index.mjs.map +1 -1
  22. package/dist/V1/transforms/mut8.d.mts.map +1 -1
  23. package/dist/V1/transforms/mut8.mjs +2 -1
  24. package/dist/V1/transforms/mut8.mjs.map +1 -1
  25. package/dist/V1/transforms/rel8.d.mts.map +1 -1
  26. package/dist/V1/transforms/rel8.mjs +2 -1
  27. package/dist/V1/transforms/rel8.mjs.map +1 -1
  28. package/dist/V1/transforms/transform-helper.d.mts.map +1 -1
  29. package/dist/V1/transforms/transform-helper.mjs +2 -1
  30. package/dist/V1/transforms/transform-helper.mjs.map +1 -1
  31. package/dist/V1/v1-helper.d.mts +38 -0
  32. package/dist/V1/v1-helper.d.mts.map +1 -0
  33. package/dist/V1/v1-helper.mjs +87 -0
  34. package/dist/V1/v1-helper.mjs.map +1 -0
  35. package/dist/V1/validate-helper.d.mts +83 -0
  36. package/dist/V1/validate-helper.d.mts.map +1 -0
  37. package/dist/V1/validate-helper.mjs +227 -0
  38. package/dist/V1/validate-helper.mjs.map +1 -0
  39. package/dist/helper.d.mts +0 -54
  40. package/dist/helper.d.mts.map +1 -1
  41. package/dist/helper.mjs +0 -114
  42. package/dist/helper.mjs.map +1 -1
  43. package/dist/types.d.mts +39 -8
  44. package/dist/types.d.mts.map +1 -1
  45. package/dist/types.mjs +31 -0
  46. package/dist/types.mjs.map +1 -1
  47. package/jasmine-browser.json +2 -2
  48. package/package.json +5 -1
  49. package/src/V1/constants.mts +31 -3
  50. package/src/V1/factory.mts +18 -2
  51. package/src/V1/factory.spec.mts +2 -1
  52. package/src/V1/sha256v1.mts +5 -5
  53. package/src/V1/transforms/fork.mts +2 -1
  54. package/src/V1/transforms/fork.spec.mts +2 -1
  55. package/src/V1/transforms/index.mts +1 -1
  56. package/src/V1/transforms/mut8.mts +2 -1
  57. package/src/V1/transforms/mut8.spec.mts +4 -3
  58. package/src/V1/transforms/rel8.mts +2 -1
  59. package/src/V1/transforms/rel8.spec.mts +2 -1
  60. package/src/V1/transforms/transform-helper.mts +3 -2
  61. package/src/V1/transforms/transform-helper.spec.mts +6 -5
  62. package/src/V1/v1-helper.mts +90 -0
  63. package/src/V1/validate-helper.mts +286 -0
  64. package/src/helper.mts +0 -116
  65. package/src/helper.spec.mts +47 -115
  66. package/src/types.mts +40 -9
  67. package/dist/index.cjs +0 -4
  68. package/dist/index.cjs.map +0 -1
  69. package/dist/index.d.cts +0 -4
  70. package/dist/index.d.cts.map +0 -1
  71. package/src/index.cts +0 -3
package/dist/types.d.mts CHANGED
@@ -1,17 +1,43 @@
1
1
  /**
2
- * The core of the simplicity of the ibGib protocol is that
3
- * fundamentally you are taking two ibGibs and producing a third.
2
+ * @module types
4
3
  *
5
- * There are three primary functions: mut8, rel8, fork
4
+ * These are the core types at the lowest level of the ibGib protocol.
6
5
  *
7
- * These are actually different aspects of the single function of
8
- * relationship and time, either extending or creating a timeline.
6
+ * The core of the simplicity of the ibGib protocol is that fundamentally you
7
+ * are encompassing the idea of an ibgib (similar to a base class "object" or
8
+ * "thing") that has intrinsic data and relationships to extrinsic ibgib. Each
9
+ * ibgib is content addressed with a unique addressing style called its ib^gib
10
+ * address. This allows us semantics for abstracting the "content addressing"
11
+ * per use case, with various schemas allowed, but in general the `ib` is
12
+ * per-use-case metadata and the `gib` is the more conventional hash of the
13
+ * ibgib record to allow for the cryptographic guarantees one would expect. Each
14
+ * discrete frame in time of the ibgib is its own ibgib, and a timeline stream
15
+ * of that ibgib is created via the "past" relationship (`rel8n`).
9
16
  *
10
- * Mut8 is intrinsic, rel8 is extrinsic, fork is a new timeline.
11
- * Mut8 changes a timeline, rel8 changes a timeline's link(s),
12
- * fork creates a new timeline.
17
+ * New ibgib records are created via "transforms", of which atow there are three
18
+ * kinds: `mut8`, `rel8`, `fork`
19
+ *
20
+ * These are actually different aspects of the single function of relationship
21
+ * and time, either extending or creating a timeline.
22
+ *
23
+ * Mut8 is intrinsic, rel8 is extrinsic, fork makes a new timeline. Mut8
24
+ * changes a timeline, rel8 changes a timeline's link(s), fork creates a new
25
+ * timeline.
26
+ *
27
+ * ## notes
28
+ *
29
+ * I have attempted to make these version independent, though we will not know
30
+ * how successful that is until we do a V2.
31
+ */
32
+ /**
33
+ * Type alias of string (or empty string) that is meant to convey that it
34
+ * is used as the ib in an ib^gib address or an `IbGib` class.
13
35
  */
14
36
  export declare type Ib = '' | string;
37
+ /**
38
+ * Type alias of string (or empty string) that is meant to convey that it
39
+ * is used as the gib in an ib^gib address or an `IbGib` class.
40
+ */
15
41
  export declare type Gib = '' | 'gib' | string;
16
42
  /**
17
43
  * Convenient for when destructuring an IbGibAddr
@@ -27,6 +53,11 @@ export interface IbAndGib {
27
53
  * that's to decide for future.
28
54
  */
29
55
  export declare type IbGibAddr = string;
56
+ /**
57
+ * Type alias that indicates that this is intended to be a tjp (temporal
58
+ * junction point) address.
59
+ */
60
+ export declare type TjpIbGibAddr = IbGibAddr;
30
61
  export declare type IbGibRel8ns = {
31
62
  /**
32
63
  * The key is the rel8nName.
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../src/types.mts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,OAAO,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC;AACrC,MAAM,CAAC,OAAO,MAAM,GAAG,GAAG,EAAE,GAAG,KAAK,GAAG,MAAM,CAAC;AAC9C;;GAEG;AACH,MAAM,WAAW,QAAQ;IACrB,EAAE,EAAE,EAAE,CAAC;IACP,GAAG,EAAE,GAAG,CAAC;CACZ;AACD;;;;;GAKG;AACH,MAAM,CAAC,OAAO,MAAM,SAAS,GAAG,MAAM,CAAC;AACvC,MAAM,CAAC,OAAO,MAAM,WAAW,GAAG;IAC9B;;;;;;;OAOG;IACH,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,EAAE,GAAG,IAAI,GAAG,SAAS,CAAC;CACjD,CAAC;AACF;;;GAGG;AACH,MAAM,WAAW,KAAK;IAClB,EAAE,EAAE,EAAE,CAAC;IACP,GAAG,CAAC,EAAE,GAAG,CAAC;CACb;AACD;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,sBAAsB,CAAC,KAAK,GAAG,GAAG,EAAE,OAAO,SAAS,WAAW,GAAG,WAAW,CAAE,SAAQ,KAAK;IACzG;;;OAGG;IACH,IAAI,CAAC,EAAE,KAAK,GAAG,SAAS,CAAC;IACzB;;;;;;;;;;OAUG;IACH,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAChC;AACD,MAAM,CAAC,OAAO,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAC7D,MAAM,WAAW,aAAa,CAAC,IAAI,SAAS,KAAK,GAAG,KAAK;IACrD;;OAEG;IACH,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB;;OA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OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACvB;AACD,MAAM,WAAW,kBAAkB,CAAC,IAAI,SAAS,KAAK,GAAG,KAAK,EAAE,QAAQ,GAAG,GAAG,CAAE,SAAQ,aAAa,CAAC,IAAI,CAAC;IACvG,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;;;;;;OAUG;IACH,YAAY,CAAC,EAAE;QACX,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACtB,CAAC;IACF;;;;;;;;;;OAUG;IACH,YAAY,CAAC,EAAE;QACX,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACtB,CAAC;IACF;;OAEG;IACH,gBAAgB,CAAC,EAAE,QAAQ,CAAC;IAC5B;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;AACD,MAAM,WAAW,kBAAkB,CAAC,IAAI,SAAS,KAAK,GAAG,KAAK,CAAE,SAAQ,aAAa,CAAC,IAAI,CAAC;IACvF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;;;;;OASG;IACH,iBAAiB,CAAC,EAAE,WAAW,CAAC;IAChC;;;;;;;OAOG;IACH,oBAAoB,CAAC,EAAE,WAAW,CAAC;CACtC;AACD,MAAM,WAAW,eAAe,CAAC,IAAI,SAAS,KAAK;IAC/C;;OAEG;IACH,QAAQ,EAAE,IAAI,CAAC;IACf;;OAEG;IACH,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC;IACd;;;OAGG;IACH,kBAAkB,CAAC,EAAE,IAAI,EAAE,CAAC;CAC/B"}
package/dist/types.mjs CHANGED
@@ -1,2 +1,33 @@
1
+ /**
2
+ * @module types
3
+ *
4
+ * These are the core types at the lowest level of the ibGib protocol.
5
+ *
6
+ * The core of the simplicity of the ibGib protocol is that fundamentally you
7
+ * are encompassing the idea of an ibgib (similar to a base class "object" or
8
+ * "thing") that has intrinsic data and relationships to extrinsic ibgib. Each
9
+ * ibgib is content addressed with a unique addressing style called its ib^gib
10
+ * address. This allows us semantics for abstracting the "content addressing"
11
+ * per use case, with various schemas allowed, but in general the `ib` is
12
+ * per-use-case metadata and the `gib` is the more conventional hash of the
13
+ * ibgib record to allow for the cryptographic guarantees one would expect. Each
14
+ * discrete frame in time of the ibgib is its own ibgib, and a timeline stream
15
+ * of that ibgib is created via the "past" relationship (`rel8n`).
16
+ *
17
+ * New ibgib records are created via "transforms", of which atow there are three
18
+ * kinds: `mut8`, `rel8`, `fork`
19
+ *
20
+ * These are actually different aspects of the single function of relationship
21
+ * and time, either extending or creating a timeline.
22
+ *
23
+ * Mut8 is intrinsic, rel8 is extrinsic, fork makes a new timeline. Mut8
24
+ * changes a timeline, rel8 changes a timeline's link(s), fork creates a new
25
+ * timeline.
26
+ *
27
+ * ## notes
28
+ *
29
+ * I have attempted to make these version independent, though we will not know
30
+ * how successful that is until we do a V2.
31
+ */
1
32
  export {};
2
33
  //# sourceMappingURL=types.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.mts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.mts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG"}
@@ -13,6 +13,6 @@
13
13
  "random": true
14
14
  },
15
15
  "browser": {
16
- "name": "firefox"
16
+ "name": "headlessChrome"
17
17
  }
18
- }
18
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ibgib/ts-gib",
3
- "version": "0.4.9",
3
+ "version": "0.5.1",
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",
@@ -32,6 +32,7 @@
32
32
  "test:browser:serve:nobuild": "npx jasmine-browser-runner serve --config=jasmine-browser.json ",
33
33
  "man:test:browser:serve:nobuild": "use this if you are troubleshooting existing dist output and don't want to overwrite those files. (and you're debugging in the browser)",
34
34
  "pack": "npm pack --pack-destination=\"./published\"",
35
+ "prepare:publish:minor": "npm run clean && npm version minor && npm run build && npm run pack",
35
36
  "prepare:publish": "npm run clean && npm version patch && npm run build && npm run pack",
36
37
  "man:prepare:publish": "use this to patch > build > pack for publishing to npm repo"
37
38
  },
@@ -57,5 +58,8 @@
57
58
  },
58
59
  "publishConfig": {
59
60
  "access": "public"
61
+ },
62
+ "dependencies": {
63
+ "@ibgib/helper-gib": "^0.0.2"
60
64
  }
61
65
  }
@@ -1,8 +1,27 @@
1
1
  import { IbGib_V1 } from './types.mjs';
2
2
 
3
+ /**
4
+ * This is essentially an alias of the string literal `'ib'`
5
+ */
3
6
  export const IB = 'ib';
7
+ /**
8
+ * This is essentially an alias of the string literal `'gib'`
9
+ *
10
+ * When you have a primitive ibgib, this should be the `ibGib.gib` value, as
11
+ * there is no hashing metadata for primitives.
12
+ */
4
13
  export const GIB = 'gib';
14
+ /**
15
+ * This is the root ibgib from which all ibgib are ultimately forked.
16
+ * It has 0 and infinite data, 0 and infinite rel8ns. Its ib and gib
17
+ * are simply 'ib' and 'gib'.
18
+ */
5
19
  export const ROOT: IbGib_V1 = { ib: IB, gib: GIB, }
20
+ /**
21
+ * The default delimiter is the caret (^) symbol. This is derived from
22
+ * taking an ib^gib address and turning it into an ibGib object (note
23
+ * the capitalized "G").
24
+ */
6
25
  export const IBGIB_DELIMITER = '^';
7
26
  /**
8
27
  * Gib is often just a single hash for a single ib^gib record.
@@ -15,9 +34,18 @@ export const IBGIB_DELIMITER = '^';
15
34
  * @example "comment abc^TJPHASH123", "comment abc^TJPHASH123.THISRECORDHASH456"
16
35
  */
17
36
  export const GIB_DELIMITER = '.';
37
+ /**
38
+ * This is the address of the ROOT ibgib with the default delimiter (caret ^).
39
+ */
18
40
  export const ROOT_ADDR = 'ib^gib'; // `${IB}${IBGIB_DELIMITER}${GIB}`;
19
-
20
41
  /**
21
- * Some rel8ns should not be able to be renamed or removed.
42
+ * Some rel8ns should not be able to be renamed or removed, as these have
43
+ * "special" semantic meaning in the low-level graphing protocol.
44
+ *
45
+ * ## notes
46
+ *
47
+ * * Of course, this can be forged or tinkered with, and that ultimately is what
48
+ * consensus would be utilized for.
49
+ * * protocols built on top of this may also have reserved rel8n/data key names
22
50
  */
23
- export const FORBIDDEN_ADD_RENAME_REMOVE_REL8N_NAMES = ['past', 'ancestor', 'dna', 'tjp'];
51
+ export const FORBIDDEN_ADD_RENAME_REMOVE_REL8N_NAMES = ['past', 'ancestor', 'dna', 'tjp'];
@@ -9,6 +9,12 @@ export class Factory_V1 {
9
9
  static root() {
10
10
  return Factory_V1.primitive({ ib: IB });
11
11
  }
12
+
13
+ /**
14
+ * Returns an ibGib primitive with the given `ib`, e.g. "{ib: '7', gib: 'gib'}".
15
+ *
16
+ * @returns a single primitive ibGib
17
+ */
12
18
  static primitive({
13
19
  ib
14
20
  }: {
@@ -17,14 +23,24 @@ export class Factory_V1 {
17
23
  return { ib, gib: GIB };
18
24
  }
19
25
 
26
+ /**
27
+ * generates multiple primitive ibgibs from the given `ibs` array.
28
+ * @returns array of generated ibgibs.
29
+ */
20
30
  static primitives({
21
31
  ibs
22
32
  }: {
23
33
  ibs: Ib[]
24
- }) {
34
+ }): IbGib_V1[] {
25
35
  return ibs.map(ib => Factory_V1.primitive({ ib }));
26
36
  }
27
37
 
38
+ /**
39
+ * Takes the incoming `parentIbGib` and forks it. Then applies the
40
+ * `data` and/or `rel8ns` if any, depending on the other config params.
41
+ *
42
+ * @returns The entire transform result object that includes the newly produced ibGib as well as any derivative/intermediate ibgibs.
43
+ */
28
44
  static async firstGen<TData = any>({
29
45
  ib = IB,
30
46
  parentIbGib = Factory_V1.root(),
@@ -45,7 +61,7 @@ export class Factory_V1 {
45
61
  linkedRel8ns?: string[],
46
62
  noTimestamp?: boolean,
47
63
  nCounter?: boolean,
48
- }) {
64
+ }): Promise<TransformResult<IbGib_V1>> {
49
65
  const lc = `[firstGen]`;
50
66
  /** * Multiple transform steps will create multiple results. */
51
67
  const interimResults: TransformResult<IbGib_V1>[] = [];
@@ -2,7 +2,8 @@
2
2
  import { IbGib_V1, IbGibRel8ns_V1, Rel8n } from './types.mjs';
3
3
  import { fork } from './transforms/fork.mjs';
4
4
  import { TransformOpts_Fork, IbGibAddr, Ib, TransformResult, IbGibRel8ns } from '../types.mjs';
5
- import { pretty, clone, delay, getIbGibAddr } from '../helper.mjs';
5
+ import { getIbGibAddr, getIbAndGib } from '../helper.mjs';
6
+ import { pretty, clone, delay, } from '@ibgib/helper-gib';
6
7
  import { ROOT, ROOT_ADDR } from './constants.mjs';
7
8
  import { Factory_V1 as factory } from './factory.mjs';
8
9
  import { mut8 } from './transforms/mut8.mjs';
@@ -1,9 +1,9 @@
1
- let crypto: any = globalThis.crypto;
2
- let { subtle } = crypto;
3
-
1
+ import { extractErrorMsg } from "@ibgib/helper-gib";
4
2
  import { IbGib_V1, IbGibData_V1, IbGibRel8ns_V1 } from "./types.mjs";
5
3
  import { Ib } from "../types.mjs";
6
- import { extractErrorMsg } from "../helper.mjs";
4
+
5
+ let crypto: any = globalThis.crypto;
6
+ let { subtle } = crypto;
7
7
 
8
8
  /**
9
9
  * Performs the gib hash like V1
@@ -82,4 +82,4 @@ export async function hashToHexCopy(
82
82
  console.error(extractErrorMsg(e.message));
83
83
  return undefined;
84
84
  }
85
- };
85
+ };
@@ -1,4 +1,5 @@
1
- import { getIbGibAddr, clone, getUUID, getTimestamp } from '../../helper.mjs';
1
+ import { getIbGibAddr } from '../../helper.mjs';
2
+ import { clone, getUUID, getTimestamp } from '@ibgib/helper-gib';
2
3
  import { sha256v1 } from '../sha256v1.mjs';
3
4
  import { IbGib_V1, IbGibData_V1, IbGibRel8ns_V1, Rel8n } from '../types.mjs';
4
5
  import { TransformOpts_Fork, TransformResult } from '../../types.mjs';
@@ -19,7 +19,8 @@
19
19
  import { IbGib_V1, IbGibRel8ns_V1, Rel8n } from '../types.mjs';
20
20
  import { fork } from './fork.mjs';
21
21
  import { TransformOpts_Fork, IbGibAddr, Ib, TransformResult } from '../../types.mjs';
22
- import { pretty, clone, delay, getIbGibAddr } from '../../helper.mjs';
22
+ import { getIbGibAddr } from '../../helper.mjs';
23
+ import { pretty, clone, delay, } from '@ibgib/helper-gib';
23
24
  import { ROOT, ROOT_ADDR } from '../constants.mjs';
24
25
  import { mut8 } from './mut8.mjs';
25
26
  import { getGib } from './transform-helper.mjs';
@@ -1,4 +1,4 @@
1
1
  export * from './fork.mjs';
2
2
  export * from './mut8.mjs';
3
3
  export * from './rel8.mjs';
4
- export { isPrimitive, isDna } from './transform-helper.mjs';
4
+ export * from './transform-helper.mjs';
@@ -1,4 +1,5 @@
1
- import { getIbGibAddr, clone, getTimestamp } from '../../helper.mjs';
1
+ import { getIbGibAddr } from '../../helper.mjs';
2
+ import { clone, getTimestamp, } from '@ibgib/helper-gib';
2
3
  import { IbGib_V1, IbGibData_V1, IbGibRel8ns_V1, Rel8n } from '../types.mjs';
3
4
  import { TransformOpts_Mut8, TransformResult } from '../../types.mjs';
4
5
  import { IBGIB_DELIMITER, } from '../constants.mjs';
@@ -7,11 +7,12 @@
7
7
  * going.
8
8
  */
9
9
 
10
- import { IbGib_V1, IbGibRel8ns_V1, Rel8n } from '../types.mjs';
10
+ import { IbGib_V1, IbGibRel8ns_V1 } from '../types.mjs';
11
11
  import { TransformOpts_Mut8, IbGibAddr } from '../../types.mjs';
12
- import { pretty, clone, delay, getIbGibAddr, getIbAndGib, } from '../../helper.mjs';
12
+ import { getIbGibAddr, getIbAndGib, } from '../../helper.mjs';
13
+ import { clone, delay, } from '@ibgib/helper-gib';
13
14
  import { sha256v1, } from '../sha256v1.mjs';
14
- import { ROOT, ROOT_ADDR, GIB_DELIMITER } from '../constants.mjs';
15
+ import { ROOT } from '../constants.mjs';
15
16
  import { fork } from './fork.mjs';
16
17
  import { mut8 } from './mut8.mjs';
17
18
  import { Factory_V1 as factory } from '../factory.mjs';
@@ -1,4 +1,5 @@
1
- import { getIbGibAddr, clone, getTimestamp } from '../../helper.mjs';
1
+ import { getIbGibAddr, getIbAndGib } from '../../helper.mjs';
2
+ import { pretty, clone, delay, getTimestamp, } from '@ibgib/helper-gib';
2
3
  import { sha256v1 } from '../sha256v1.mjs';
3
4
  import { IbGib_V1, IbGibData_V1, IbGibRel8ns_V1, Rel8n } from '../types.mjs';
4
5
  import { TransformOpts_Rel8, TransformResult, IbGibAddr } from '../../types.mjs';
@@ -9,7 +9,8 @@
9
9
 
10
10
  import { IbGib_V1, IbGibRel8ns_V1, Rel8n } from '../types.mjs';
11
11
  import { TransformOpts_Rel8, IbGibAddr, IbGibRel8ns } from '../../types.mjs';
12
- import { pretty, clone, delay, getIbGibAddr, getIbAndGib } from '../../helper.mjs';
12
+ import { getIbGibAddr, getIbAndGib } from '../../helper.mjs';
13
+ import { pretty, clone, delay, } from '@ibgib/helper-gib';
13
14
  import { ROOT, ROOT_ADDR } from '../constants.mjs';
14
15
  import { fork } from './fork.mjs';
15
16
  // import { mut8 } from './mut8.mjs';
@@ -1,5 +1,6 @@
1
- import { TransformOpts, IbGib, Gib, Ib, IbGibAddr, } from "../../types.mjs";
2
- import { clone, getIbGibAddr, getIbAndGib, HashAlgorithm, extractErrorMsg, } from "../../helper.mjs";
1
+ import { clone, extractErrorMsg, } from "@ibgib/helper-gib";
2
+ import { TransformOpts, IbGib, Gib, IbGibAddr, } from "../../types.mjs";
3
+ import { getIbGibAddr, getIbAndGib, } from "../../helper.mjs";
3
4
  import { sha256v1, } from "../sha256v1.mjs";
4
5
  import { GibInfo, IbGib_V1, } from "../types.mjs";
5
6
  import { IBGIB_DELIMITER, GIB, GIB_DELIMITER } from "../constants.mjs";
@@ -3,13 +3,14 @@
3
3
  */
4
4
 
5
5
 
6
- import { IbGib_V1, IbGibRel8ns_V1, Rel8n } from '../types.mjs';
7
- import { TransformOpts_Rel8, IbGibAddr, IbGibRel8ns } from '../../types.mjs';
8
- import { pretty, clone, delay, getIbGibAddr } from '../../helper.mjs';
9
- import { ROOT, ROOT_ADDR } from '../constants.mjs';
6
+ // import { IbGib_V1, IbGibRel8ns_V1, Rel8n } from '../types.mjs';
7
+ // import { TransformOpts_Rel8, IbGibAddr, IbGibRel8ns } from '../../types.mjs';
8
+ // import { getIbGibAddr, getIbAndGib } from '../../helper.mjs';
9
+ // import { pretty, clone, delay, } from '@ibgib/helper-gib';
10
+ // import { ROOT, ROOT_ADDR } from '../constants.mjs';
10
11
  import { fork } from './fork.mjs';
11
12
  // import { mut8 } from './mut8.mjs';
12
- import { rel8 } from './rel8.mjs';
13
+ // import { rel8 } from './rel8.mjs';
13
14
  import { Factory_V1 as factory } from '../factory.mjs';
14
15
  import { isDna } from './transform-helper.mjs';
15
16
 
@@ -0,0 +1,90 @@
1
+ import { getIbGibAddr, getIbAndGib } from '../helper.mjs';
2
+ import { pretty, clone, delay, } from '@ibgib/helper-gib';
3
+ import * as cTsGib from './constants.mjs';
4
+ import { getGibInfo } from './transforms/transform-helper.mjs';
5
+ import { IbGibRel8ns_V1, IbGib_V1 } from "./types.mjs";
6
+
7
+ /**
8
+ * Helper function that checks the given `ibGib` to see if it
9
+ * either has a tjp or is a tjp itself.
10
+ *
11
+ * ## notes
12
+ *
13
+ * Only unique ibGibs are meant to have tjps, or rather, if an
14
+ * ibGib timeline is expected to be unique over "time", then the
15
+ * tjp is an extremely convenient mechanism that provides a
16
+ * "name" for that timeline.
17
+ *
18
+ * Otherwise, if they are not unique, then successive "different"
19
+ * timelines cannot be easily referenced by their first unique
20
+ * frame in time, making it much harder to pub/sub updates among
21
+ * other things. (If there are no unique frames, then they are
22
+ * the same ibGib.)
23
+ *
24
+ * ## tjp = temporal junction point
25
+ *
26
+ * I've written elsewhere on this as well. Refer to B2tF2.
27
+ *
28
+ * @returns true if the ibGib has/is a tjp, else false
29
+ */
30
+ export function hasTjp({ ibGib }: { ibGib: IbGib_V1 }): boolean {
31
+ const lc = `[${hasTjp.name}]`;
32
+
33
+ if (!ibGib) {
34
+ console.warn(`${lc} ibGib falsy. (W: 884178562f5b4f15933ac4d98db74cc6)`);
35
+ return false;
36
+ }
37
+
38
+ if (ibGib.data?.isTjp || ibGib.rel8ns?.tjp?.length! > 0) {
39
+ return true;
40
+ }
41
+
42
+ // dna transforms do not have tjp
43
+ const dnaPrimitives = ['fork^gib', 'mut8^gib', 'rel8^gib'];
44
+ if ((ibGib.rel8ns?.ancestor ?? []).some(x => dnaPrimitives.includes(x))) {
45
+ return false;
46
+ }
47
+
48
+ if (!ibGib.gib) {
49
+ console.warn(`${lc} ibGib.gib falsy. (W: 6400d780822b44d992846f1196509be3)`);
50
+ return false;
51
+ }
52
+ if (ibGib.gib.includes(cTsGib.GIB_DELIMITER)) {
53
+ return true;
54
+ }
55
+
56
+ if (ibGib.gib === cTsGib.GIB) {
57
+ // primitive
58
+ return false;
59
+ }
60
+
61
+ // use more expensive getGibInfo call.
62
+ // could possibly just return false at this point, but since gib info
63
+ // would change if we change our standards for gib, this is nicer.
64
+ const gibInfo = getGibInfo({ ibGibAddr: getIbGibAddr({ ibGib }) });
65
+ return gibInfo.tjpGib ? true : false;
66
+ }
67
+
68
+ /**
69
+ * If you have an ibgib object, it may also contain other properties/functions.
70
+ *
71
+ * This helper function takes the incoming object and returns a copy
72
+ * @param param0
73
+ * @returns
74
+ */
75
+ export function toDto<TData, TRel8ns extends IbGibRel8ns_V1 = IbGibRel8ns_V1>({
76
+ ibGib,
77
+ }: {
78
+ ibGib: IbGib_V1,
79
+ }): IbGib_V1<TData, TRel8ns> {
80
+ const lc = `[${toDto.name}]`;
81
+ if (!ibGib.ib) { console.warn(`${lc} ibGib.ib is falsy. (W: e60e41c2a1fc48268379d88ce13cb77b)`); }
82
+ if (!ibGib.gib) { console.warn(`${lc} ibGib.gib is falsy. (W: fb3889cbf0684ae4ac51e48f28570377)`); }
83
+
84
+ let dtoIbGib: IbGib_V1<TData, TRel8ns> = { ib: (ibGib.ib || '').slice() };
85
+ if (ibGib.gib) { dtoIbGib.gib = ibGib.gib.slice(); };
86
+ if (ibGib.data) { dtoIbGib.data = clone(ibGib.data); }
87
+ if (ibGib.rel8ns) { dtoIbGib.rel8ns = clone(ibGib.rel8ns); }
88
+
89
+ return dtoIbGib;
90
+ }