@ibgib/core-gib 0.0.59 → 0.0.61

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 (30) hide show
  1. package/dist/witness/space/outer-space/outer-space-helper.d.mts.map +1 -1
  2. package/dist/witness/space/outer-space/outer-space-helper.mjs +4 -3
  3. package/dist/witness/space/outer-space/outer-space-helper.mjs.map +1 -1
  4. package/dist/witness/space/outer-space/outer-space-types.d.mts +5 -28
  5. package/dist/witness/space/outer-space/outer-space-types.d.mts.map +1 -1
  6. package/dist/witness/space/outer-space/outer-space-types.mjs +0 -16
  7. package/dist/witness/space/outer-space/outer-space-types.mjs.map +1 -1
  8. package/dist/witness/space/space-constants.d.mts +4 -0
  9. package/dist/witness/space/space-constants.d.mts.map +1 -1
  10. package/dist/witness/space/space-constants.mjs +4 -0
  11. package/dist/witness/space/space-constants.mjs.map +1 -1
  12. package/dist/witness/space/space-helper.d.mts +27 -19
  13. package/dist/witness/space/space-helper.d.mts.map +1 -1
  14. package/dist/witness/space/space-helper.mjs +96 -62
  15. package/dist/witness/space/space-helper.mjs.map +1 -1
  16. package/dist/witness/space/space-types.d.mts +102 -0
  17. package/dist/witness/space/space-types.d.mts.map +1 -1
  18. package/dist/witness/space/space-types.mjs +78 -0
  19. package/dist/witness/space/space-types.mjs.map +1 -1
  20. package/dist/witness/witness-constants.d.mts +1 -0
  21. package/dist/witness/witness-constants.d.mts.map +1 -1
  22. package/dist/witness/witness-constants.mjs +1 -0
  23. package/dist/witness/witness-constants.mjs.map +1 -1
  24. package/package.json +1 -1
  25. package/src/witness/space/outer-space/outer-space-helper.mts +6 -9
  26. package/src/witness/space/outer-space/outer-space-types.mts +6 -29
  27. package/src/witness/space/space-constants.mts +5 -0
  28. package/src/witness/space/space-helper.mts +108 -66
  29. package/src/witness/space/space-types.mts +97 -0
  30. package/src/witness/witness-constants.mts +1 -0
@@ -1,4 +1,82 @@
1
1
  import { ENCRYPTION_REL8N_NAME } from '../../common/encrypt/encrypt-constants.mjs';
2
+ export const SpaceLocation = {
3
+ /**
4
+ * space is a local space, with lower latency and direct usage with
5
+ * metaspace. To be used as the primary local user space.
6
+ *
7
+ * no real proxy is involved, rather, we should be speaking "directly" with
8
+ * the local location.
9
+ */
10
+ local: 'local',
11
+ /**
12
+ * space is an outerspace, with higher latency, probably some kind of proxy
13
+ * client access. More intended to be used with syncing...
14
+ */
15
+ outerspace: 'outerspace',
16
+ /**
17
+ * in-memory-only space.
18
+ *
19
+ * Note: I haven't really incorporated this, but I have sketched an
20
+ * in-memory innerspace and in the future, I think this will be heavily
21
+ * utilized.
22
+ */
23
+ innerspace: 'innerspace',
24
+ };
25
+ export const VALID_SPACE_LOCATIONS = Object.values(SpaceLocation).concat();
26
+ export const SpaceType = {
27
+ /**
28
+ * user space that usually (always?) acts locally as the main type of
29
+ * storage for a user.
30
+ *
31
+ * This means that the user is actively working in this space, and it isn't
32
+ * a derivative space. perhaps "source" would be better?
33
+ */
34
+ user: 'user',
35
+ /**
36
+ * this is a derivative user space that is used to synchronize ibgib
37
+ * timelines among two or more other spaces.
38
+ */
39
+ sync: 'sync',
40
+ };
41
+ /**
42
+ * Object.values(SpaceType).concat()
43
+ *
44
+ * for now, you can add valid space types here in initialization code to
45
+ * manually extend this.
46
+ */
47
+ export const VALID_SPACE_TYPES = Object.values(SpaceType).concat();
48
+ /**
49
+ * specific/concrete subtype implementations
50
+ */
51
+ export const UserSpaceSubtype = {
52
+ /**
53
+ * local user space is driven by a node filesystem concrete implementation.
54
+ *
55
+ * Note: This is actually implemented elsewhere, but I am deferring the
56
+ * additional architectural requirements for putting the node filesystem and
57
+ * extending this to include it. so I'm just putting this here. But in the
58
+ * future, this should be moved to a node-specific library and brought in if
59
+ * the app requires it.
60
+ */
61
+ node_filesystem: 'node-filesystem',
62
+ };
63
+ export const SyncSpaceSubtype = {
64
+ aws_dynamodb: 'aws-dynamodb',
65
+ };
66
+ /**
67
+ * specific, concrete implementation of space
68
+ */
69
+ export const SpaceSubtype = {
70
+ ...UserSpaceSubtype,
71
+ ...SyncSpaceSubtype,
72
+ };
73
+ /**
74
+ * Object.values(SpaceSubtype).concat()
75
+ *
76
+ * for now, you can add valid subtypes here in initialization code to manually
77
+ * extend this.
78
+ */
79
+ export const VALID_SPACE_SUBTYPES = Object.values(SpaceSubtype).concat();
2
80
  /** Cmds for interacting with ibgib spaces. */
3
81
  export const IbGibSpaceOptionsCmd = {
4
82
  /** Retrieve ibGib(s) out of the space (does not remove them). */
@@ -1 +1 @@
1
- {"version":3,"file":"space-types.mjs","sourceRoot":"","sources":["../../../src/witness/space/space-types.mts"],"names":[],"mappings":"AAQA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4CAA4C,CAAC;AA6GnF,+CAA+C;AAC/C,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAChC,iEAAiE;IACjE,GAAG,EAAE,KAA6B;IAClC,iDAAiD;IACjD,GAAG,EAAE,KAA6B;IAClC,mCAAmC;IACnC,MAAM,EAAE,QAAgC;CAC3C,CAAA;AAOD;;GAEG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG;IACxC;;;;OAIG;IACH,GAAG,EAAE,KAAqC;IAC1C;;OAEG;IACH,KAAK,EAAE,OAAuC;IAC9C;;;;;;;;;;;OAWG;IACH,MAAM,EAAE,QAAwC;IAChD;;OAEG;IACH,KAAK,EAAE,OAAuC;IAC9C;;OAEG;IACH,OAAO,EAAE,SAAyC;IAClD;;OAEG;IACH,IAAI,EAAE,MAAsC;CAC/C,CAAA"}
1
+ {"version":3,"file":"space-types.mjs","sourceRoot":"","sources":["../../../src/witness/space/space-types.mts"],"names":[],"mappings":"AAQA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4CAA4C,CAAC;AAUnF,MAAM,CAAC,MAAM,aAAa,GAAG;IACzB;;;;;;OAMG;IACH,KAAK,EAAE,OAAwB;IAC/B;;;OAGG;IACH,UAAU,EAAE,YAA6B;IACzC;;;;;;OAMG;IACH,UAAU,EAAE,YAA6B;CAC5C,CAAA;AACD,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,MAAM,EAAE,CAAC;AAG3E,MAAM,CAAC,MAAM,SAAS,GAAG;IACrB;;;;;;OAMG;IACH,IAAI,EAAE,MAAmB;IACzB;;;OAGG;IACH,IAAI,EAAE,MAAmB;CAC5B,CAAA;AACD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,MAAM,EAAE,CAAC;AAGnE;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC5B;;;;;;;;OAQG;IACH,eAAe,EAAE,iBAAqC;CACzD,CAAA;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC5B,YAAY,EAAE,cAAkC;CACnD,CAAA;AAGD;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IACxB,GAAG,gBAAgB;IACnB,GAAG,gBAAgB;CACtB,CAAA;AACD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,MAAM,EAAE,CAAC;AAgHzE,+CAA+C;AAC/C,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAChC,iEAAiE;IACjE,GAAG,EAAE,KAA6B;IAClC,iDAAiD;IACjD,GAAG,EAAE,KAA6B;IAClC,mCAAmC;IACnC,MAAM,EAAE,QAAgC;CAC3C,CAAA;AAOD;;GAEG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG;IACxC;;;;OAIG;IACH,GAAG,EAAE,KAAqC;IAC1C;;OAEG;IACH,KAAK,EAAE,OAAuC;IAC9C;;;;;;;;;;;OAWG;IACH,MAAM,EAAE,QAAwC;IAChD;;OAEG;IACH,KAAK,EAAE,OAAuC;IAC9C;;OAEG;IACH,OAAO,EAAE,SAAyC;IAClD;;OAEG;IACH,IAAI,EAAE,MAAsC;CAC/C,CAAA"}
@@ -1,3 +1,4 @@
1
+ export declare const WITNESS_ATOM = "witness";
1
2
  export declare const WITNESS_ARG_METADATA_STRING = "witness_arg";
2
3
  export declare const WITNESS_RESULT_METADATA_STRING = "witness_result";
3
4
  export declare const WITNESS_CONTEXT_REL8N_NAME = "context";
@@ -1 +1 @@
1
- {"version":3,"file":"witness-constants.d.mts","sourceRoot":"","sources":["../../src/witness/witness-constants.mts"],"names":[],"mappings":"AAAA,eAAO,MAAM,2BAA2B,gBAAgB,CAAC;AACzD,eAAO,MAAM,8BAA8B,mBAAmB,CAAC;AAE/D,eAAO,MAAM,0BAA0B,YAAY,CAAC"}
1
+ {"version":3,"file":"witness-constants.d.mts","sourceRoot":"","sources":["../../src/witness/witness-constants.mts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,YAAY,CAAC;AACtC,eAAO,MAAM,2BAA2B,gBAAgB,CAAC;AACzD,eAAO,MAAM,8BAA8B,mBAAmB,CAAC;AAE/D,eAAO,MAAM,0BAA0B,YAAY,CAAC"}
@@ -1,3 +1,4 @@
1
+ export const WITNESS_ATOM = 'witness';
1
2
  export const WITNESS_ARG_METADATA_STRING = 'witness_arg';
2
3
  export const WITNESS_RESULT_METADATA_STRING = 'witness_result';
3
4
  export const WITNESS_CONTEXT_REL8N_NAME = 'context';
@@ -1 +1 @@
1
- {"version":3,"file":"witness-constants.mjs","sourceRoot":"","sources":["../../src/witness/witness-constants.mts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,2BAA2B,GAAG,aAAa,CAAC;AACzD,MAAM,CAAC,MAAM,8BAA8B,GAAG,gBAAgB,CAAC;AAE/D,MAAM,CAAC,MAAM,0BAA0B,GAAG,SAAS,CAAC"}
1
+ {"version":3,"file":"witness-constants.mjs","sourceRoot":"","sources":["../../src/witness/witness-constants.mts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,YAAY,GAAG,SAAS,CAAC;AACtC,MAAM,CAAC,MAAM,2BAA2B,GAAG,aAAa,CAAC;AACzD,MAAM,CAAC,MAAM,8BAA8B,GAAG,gBAAgB,CAAC;AAE/D,MAAM,CAAC,MAAM,0BAA0B,GAAG,SAAS,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ibgib/core-gib",
3
- "version": "0.0.59",
3
+ "version": "0.0.61",
4
4
  "description": "ibgib core functionality, including base architecture for witnesses, spaces, apps, robbots, etc., as well as shared utility functions. Node v19+ needed for heavily-used isomorphic webcrypto hashing consumed in both node and browsers.",
5
5
  "repository": {
6
6
  "url": "https://gitlab.com/ibgib/core-gib",
@@ -11,11 +11,8 @@
11
11
 
12
12
  import { Ib, } from '@ibgib/ts-gib/dist/types.mjs';
13
13
 
14
- import {
15
- OuterSpaceSubtype, OuterSpaceType,
16
- StatusCode, StatusIbInfo,
17
- VALID_OUTER_SPACE_SUBTYPES, VALID_OUTER_SPACE_TYPES,
18
- } from './outer-space-types.mjs';
14
+ import { SpaceType, SpaceSubtype, VALID_SPACE_SUBTYPES, VALID_SPACE_TYPES, } from '../space-types.mjs';
15
+ import { StatusCode, StatusIbInfo, } from './outer-space-types.mjs';
19
16
  import { OUTER_SPACE_DEFAULT_IB_DELIMITER } from './outer-space-constants.mjs';
20
17
 
21
18
 
@@ -75,13 +72,13 @@ export function getStatusIbInfo({
75
72
  const statusCode = pieces[2] as StatusCode; // tenatively cast as StatusCode
76
73
  if (!Object.values(StatusCode).includes(statusCode)) { throw new Error(`invalid/unknown status code (${statusCode}) (E: 7580860df7b344b3992148552e80a85e)`); }
77
74
 
78
- const spaceType = pieces[3] as OuterSpaceType;
75
+ const spaceType = pieces[3] as SpaceType;
79
76
  if (spaceType === null || spaceType === undefined) { throw new Error(`spaceType is null/undefined. (E: 12473d35e77b451bb59bb05c03cb8b64)`); }
80
- if (!VALID_OUTER_SPACE_TYPES.includes(spaceType)) { throw new Error(`invalid/unknown spaceType (${spaceType}) (E: d3ba9add427f49dda34f265f3225d9db)`); }
77
+ if (!VALID_SPACE_TYPES.includes(spaceType)) { throw new Error(`invalid/unknown spaceType (${spaceType}) (E: d3ba9add427f49dda34f265f3225d9db)`); }
81
78
 
82
- const spaceSubtype = pieces[4] as OuterSpaceSubtype;
79
+ const spaceSubtype = pieces[4] as SpaceSubtype;
83
80
  if (spaceSubtype === null || spaceSubtype === undefined) { throw new Error(`spaceSubtype is null/undefined. (E: 6da7ae919d0b4a22b4ee685520b6c946)`); }
84
- if (!VALID_OUTER_SPACE_SUBTYPES.includes(spaceSubtype)) { throw new Error(`invalid/unknown spaceSubtype (${spaceSubtype}) (E: 703ed1aee44447a294b3e1cf0984baba)`); }
81
+ if (!VALID_SPACE_SUBTYPES.includes(spaceSubtype)) { throw new Error(`invalid/unknown spaceSubtype (${spaceSubtype}) (E: 703ed1aee44447a294b3e1cf0984baba)`); }
85
82
 
86
83
  return { statusCode, spaceType, spaceSubtype, sagaId, delimiter };
87
84
  } catch (error) {
@@ -16,7 +16,7 @@ import {
16
16
  IbGibSpaceData, IbGibSpaceRel8ns,
17
17
  IbGibSpaceOptionsData, IbGibSpaceOptionsRel8ns, IbGibSpaceOptionsIbGib,
18
18
  IbGibSpaceOptionsCmdModifier,
19
- IbGibSpaceResultData, IbGibSpaceResultRel8ns, IbGibSpaceResultIbGib,
19
+ IbGibSpaceResultData, IbGibSpaceResultRel8ns, IbGibSpaceResultIbGib, SyncSpaceSubtype, SpaceType, SpaceSubtype,
20
20
  } from '../space-types.mjs';
21
21
  import { IbGibSpaceAny } from '../space-base-v1.mjs';
22
22
  import { CIPHERTEXT_REL8N_NAME } from '../../../common/encrypt/encrypt-constants.mjs';
@@ -124,33 +124,7 @@ export const StatusCode = {
124
124
  completed: 'completed' as StatusCode,
125
125
  }
126
126
 
127
- export type OuterSpaceType = "sync";
128
- export const OuterSpaceType = {
129
- sync: 'sync' as OuterSpaceType,
130
- }
131
- export const VALID_OUTER_SPACE_TYPES = Object.values(OuterSpaceType).concat();
132
-
133
- export type SyncSpaceSubtype =
134
- 'aws-dynamodb' |
135
- 'local-machine-node';
136
- export const SyncSpaceSubtype = {
137
- aws_dynamodb: 'aws-dynamodb' as SyncSpaceSubtype,
138
- /**
139
- * not implemented yet
140
- */
141
- local_machine_node: 'local-machine-node' as SyncSpaceSubtype,
142
- }
143
-
144
- export type OuterSpaceSubtype = 'tbd' | SyncSpaceSubtype;
145
- export const OuterSpaceSubtype = {
146
- tbd: 'tbd' as OuterSpaceSubtype,
147
- ...SyncSpaceSubtype,
148
- }
149
- export const VALID_OUTER_SPACE_SUBTYPES = Object.values(OuterSpaceSubtype).concat();
150
-
151
127
  export interface OuterSpaceData extends IbGibSpaceData {
152
- type: OuterSpaceType;
153
- subtype: OuterSpaceSubtype;
154
128
  }
155
129
 
156
130
  export interface OuterSpaceRel8ns extends IbGibSpaceRel8ns {
@@ -171,6 +145,9 @@ export interface SyncSpaceData extends OuterSpaceData {
171
145
  }
172
146
  export interface SyncSpaceRel8ns extends OuterSpaceRel8ns {
173
147
  }
148
+ export interface SyncSpaceIbGib
149
+ extends IbGib_V1<SyncSpaceData, SyncSpaceRel8ns> {
150
+ }
174
151
 
175
152
  /**
176
153
  * this is the info about the **space**, as in the space participates in the
@@ -664,8 +641,8 @@ export interface StatusIbInfo {
664
641
  *
665
642
  */
666
643
  statusCode: StatusCode,
667
- spaceType: OuterSpaceType,
668
- spaceSubtype: OuterSpaceSubtype,
644
+ spaceType: SpaceType,
645
+ spaceSubtype: SpaceSubtype,
669
646
  sagaId: string,
670
647
  delimiter?: string,
671
648
  }
@@ -118,6 +118,11 @@ export const DEFAULT_SPACE_REL8N_NAME = 'x';
118
118
  export const DEFAULT_LOCAL_SPACE_POLLING_INTERVAL_MS = 30_000;
119
119
  export const DEFAULT_LOCAL_SPACE_POLLING_DELAY_FIRST_RUN_MS = 10_000;
120
120
 
121
+ /**
122
+ * it's a space
123
+ */
124
+ export const SPACE_ATOM = 'space';
125
+
121
126
  /**
122
127
  * {@link DEFAULT_LOCAL_SPACE_POLLING_INTERVAL_MS} but for outer spaces, so
123
128
  * longer interval atow.
@@ -14,22 +14,18 @@ import { getGib, getGibInfo, } from '@ibgib/ts-gib/dist/V1/transforms/transform-
14
14
  import { GLOBAL_LOG_A_LOT } from '../../core-constants.mjs';
15
15
  import { APP_REL8N_NAME } from '../app/app-constants.mjs';
16
16
  import {
17
- GetIbGibOpts, GetIbGibResult,
18
- PutIbGibOpts, PutIbGibResult,
19
- DeleteIbGibOpts, DeleteIbGibResult, SpecialIbGibType,
20
- IbGibTimelineUpdateInfo,
17
+ GetIbGibOpts, GetIbGibResult, PutIbGibOpts, PutIbGibResult, DeleteIbGibOpts,
18
+ DeleteIbGibResult, SpecialIbGibType, IbGibTimelineUpdateInfo,
21
19
  } from '../../common/other/other-types.mjs';
22
20
  import {
23
- getRootIb,
24
- getSpecialConfigKey, getSpecialIbGibAddr, getSpecialIbGibIb, getSpecialTypeFromIb,
25
- getTjpAddr, isSpecial, isTjp_Naive, tagTextToIb
21
+ getRootIb, getSpecialConfigKey, getSpecialIbGibIb,
22
+ getSpecialTypeFromIb, getTjpAddr, isSpecial, isTjp_Naive, tagTextToIb
26
23
  } from '../../common/other/ibgib-helper.mjs';
27
24
  import { TagData_V1, TagIbGib_V1 } from '../../common/tag/tag-types.mjs';
28
25
  import { BOOTSTRAP_DATA_DEFAULT_SPACE_ID_KEY, BOOTSTRAP_DATA_KNOWN_SPACE_IDS_KEY, BOOTSTRAP_IBGIB_ADDR } from './bootstrap/bootstrap-constants.mjs';
29
26
  import {
30
- SpaceLockScope, IbGibSpaceLockIbGib, SpaceId,
31
- IbGibSpaceLockOptions, TxId,
32
- IbGibSpaceResultIbGib, IbGibSpaceResultData, IbGibSpaceResultRel8ns
27
+ SpaceLockScope, IbGibSpaceLockIbGib, SpaceId, IbGibSpaceLockOptions, TxId,
28
+ IbGibSpaceResultIbGib, IbGibSpaceResultData, IbGibSpaceResultRel8ns, SpaceType, SpaceSubtype, VALID_SPACE_TYPES, VALID_SPACE_SUBTYPES, IbGibSpaceData
33
29
  } from './space-types.mjs';
34
30
  import { getAppIb, } from '../app/app-helper.mjs';
35
31
  import { AppData_V1, AppIbGib_V1 } from '../app/app-types.mjs';
@@ -40,19 +36,21 @@ import { IbGibSpaceAny } from './space-base-v1.mjs';
40
36
  import { RootData } from '../../common/root/root-types.mjs';
41
37
  import { IbGibCacheService } from '../../common/cache/cache-types.mjs';
42
38
  import {
43
- DEFAULT_MAX_DELAY_MS_RETRY_LOCK_ACQUIRE, DEFAULT_MAX_DELAY_RETRY_LOCK_ACQUIRE_ATTEMPTS,
44
- DEFAULT_SECONDS_VALID_LOCAL, DEFAULT_TX_ID_LENGTH, IBGIB_SPACE_NAME_DEFAULT,
39
+ DEFAULT_MAX_DELAY_MS_RETRY_LOCK_ACQUIRE,
40
+ DEFAULT_MAX_DELAY_RETRY_LOCK_ACQUIRE_ATTEMPTS, DEFAULT_SECONDS_VALID_LOCAL,
41
+ DEFAULT_TX_ID_LENGTH, IBGIB_SPACE_NAME_DEFAULT, SPACE_ATOM,
45
42
  SPACE_LOCK_IB_TERM, SYNC_SPACE_REL8N_NAME,
46
43
  } from './space-constants.mjs';
47
44
  import { DEFAULT_TAG_DESCRIPTION, DEFAULT_TAG_ICON, TAG_REL8N_NAME } from '../../common/tag/tag-constants.mjs';
48
45
  import {
49
- DEFAULT_ROOT_DESCRIPTION, DEFAULT_ROOT_ICON,
50
- DEFAULT_ROOT_REL8N_NAME, DEFAULT_ROOT_TEXT, ROOT_REL8N_NAME
46
+ DEFAULT_ROOT_DESCRIPTION, DEFAULT_ROOT_ICON, DEFAULT_ROOT_REL8N_NAME,
47
+ DEFAULT_ROOT_TEXT, ROOT_REL8N_NAME
51
48
  } from '../../common/root/root-constants.mjs';
52
49
  import { ARCHIVE_REL8N_NAME, TRASH_REL8N_NAME } from '../../common/other/other-constants.mjs';
53
50
  import { validateBootstrapIbGib } from './bootstrap/bootstrap-helper.mjs';
54
51
  import { BootstrapData, BootstrapIbGib, BootstrapRel8ns } from './bootstrap/bootstrap-types.mjs';
55
- import { getMetaStoneIb, newUpMetaStone } from '../../common/meta-stone/meta-stone-helper.mjs';
52
+ import { newUpMetaStone } from '../../common/meta-stone/meta-stone-helper.mjs';
53
+ import { WITNESS_ATOM } from '../witness-constants.mjs';
56
54
 
57
55
  let logalot = GLOBAL_LOG_A_LOT;
58
56
 
@@ -3038,68 +3036,87 @@ export function getSpaceResultMetadata({ space }: { space: IbGibSpaceAny }): str
3038
3036
  return `${space.ib} ${getTimestampInTicks()}`;
3039
3037
  }
3040
3038
 
3039
+ /**
3040
+ * builds the space's ib based on either spaceData or space.data, depending on
3041
+ * what is passed in. if for some reason both are passed in, this does some
3042
+ * basic checking to be sure that they are the same data.
3043
+ * @returns generated spaceIb
3044
+ */
3041
3045
  export function getSpaceIb({
3042
3046
  space,
3047
+ spaceData,
3043
3048
  classname,
3044
3049
  }: {
3045
- space: IbGibSpaceAny,
3050
+ space?: IbGibSpaceAny,
3051
+ spaceData?: IbGibSpaceData,
3046
3052
  classname?: string,
3047
3053
  }): Ib {
3048
3054
  const lc = `[${getSpaceIb.name}]`;
3049
3055
  try {
3050
- if (!space) { throw new Error(`space required (E: 4dabec34ee77d67c9cc30ee3c3049622)`); }
3051
- if (!space.data) { throw new Error(`space.data required (E: 058d298876ebbeada7bbddb9e3da2f23)`); }
3052
- classname ||= space?.data!.classname;
3056
+ if (!space && !spaceData) { throw new Error(`either space or spaceData required (E: 4dabec34ee77d67c9cc30ee3c3049622)`); }
3057
+ if (space && !space.data) { throw new Error(`(UNEXPECTED) given space has falsy space.data? (E: 058d298876ebbeada7bbddb9e3da2f23)`); }
3058
+ if (space && spaceData) {
3059
+ if (space.data!.uuid !== spaceData.uuid) { throw new Error(`(UNEXPECTED) both space and spaceData given, but uuid don't match? (E: efdd4603cba93a17340a76811fe56b24)`); }
3060
+ if (space.data!.n !== spaceData.n) { throw new Error(`(UNEXPECTED) both space and spaceData given, but n don't match? (E: e51278a707c9bccc57a08a4b86524524)`); }
3061
+ }
3062
+ spaceData ??= space!.data!;
3063
+ if (!spaceData) { throw new Error(`(UNEXPECTED) spaceData falsy? (thought this was a compiler problem that this was even possible.) (E: b3c7ffedcae4b1f45b263b3825930b24)`); }
3064
+
3065
+
3066
+ if (classname && spaceData.classname && classname !== spaceData.classname) {
3067
+ throw new Error(`both classname arg (${classname}) and spaceData.classname (${spaceData.classname}) are different truthy values. (E: f98f012ee876eb8fbe7403f7b53e4624)`);
3068
+ } else {
3069
+ classname ||= space?.data!.classname;
3070
+ }
3053
3071
  if (!classname) { throw new Error(`classname required (E: fa3af4613ad56742dab51d1b0d839322)`); }
3054
- if (classname.includes(' ')) { throw new Error(`invalid classname. cannot contain spaces (E: 243adbf720dcce7904e2665933208b22)`); }
3055
- const name = space.data?.name || IBGIB_SPACE_NAME_DEFAULT;
3072
+ if (classname.includes(' ')) { throw new Error(`invalid classname (${classname}). cannot contain spaces (E: 243adbf720dcce7904e2665933208b22)`); }
3073
+
3074
+ const name = spaceData?.name || IBGIB_SPACE_NAME_DEFAULT;
3056
3075
  if (name.includes(' ')) { throw new Error(`invalid space name. cannot contain spaces (E: a8450e1651081412c8ac018520182422)`); }
3057
- const id = space.data?.uuid || undefined;
3058
- if (!id) { throw new Error(`invalid space, space.data.uuid falsy (E: 50ae723a9ab24f4fc7132613e65faf23)`); }
3076
+
3077
+ const id = spaceData?.uuid || undefined;
3078
+ if (!id) { throw new Error(`invalid space, spaceData.uuid falsy (E: 50ae723a9ab24f4fc7132613e65faf23)`); }
3059
3079
  if (id.includes(' ')) { throw new Error(`invalid space id. cannot contain spaces (E: 8696830fe7f54bfa85e670a063f3e089)`); }
3060
- let ib = `witness space ${classname} ${name} ${id}`;
3061
- return ib;
3080
+
3081
+ const spaceType = spaceData.type ?? undefined;
3082
+ const spaceSubtype = spaceData.subtype ?? undefined;
3083
+ if (spaceType && !spaceSubtype) {
3084
+ throw new Error(`spaceType (${spaceType}) is set but spaceSubtype is falsy. (E: 878ab960d7987ae2331103b4a00d0d24)`);
3085
+ }
3086
+
3087
+ return `${WITNESS_ATOM} ${SPACE_ATOM} ${classname} ${name} ${id} ${spaceType} ${spaceSubtype}`;
3062
3088
  } catch (error) {
3063
3089
  console.error(`${lc} ${error.message}`);
3064
3090
  throw error;
3065
3091
  }
3066
3092
  }
3067
3093
 
3094
+ /**
3095
+ * determines if the given ib belongs to a space ibgib.
3096
+ *
3097
+ * atow (03/2024) checks to see if the ib starts with
3098
+ *
3099
+ * `${WITNESS_ATOM} ${SPACE_ATOM} `
3100
+ */
3068
3101
  export function isSpaceIb({
3069
3102
  ib
3070
3103
  }: {
3071
3104
  ib: Ib
3072
3105
  }): boolean {
3073
3106
  const lc = `[${isSpaceIb.name}]`;
3074
- try {
3075
- if (logalot) { console.log(`${lc} starting... (I: 53ad337f8148616a77caca5dff0f8722)`); }
3076
- return ib.startsWith('witness space ') || ib.startsWith('outerspace sync ');
3077
- } catch (error) {
3078
- console.error(`${lc} ${error.message}`);
3079
- throw error;
3080
- } finally {
3081
- if (logalot) { console.log(`${lc} complete.`); }
3107
+ if (!ib) {
3108
+ const emsg = `${lc} ib required (E: dd5244f62f964359a86e59bb08ee47e6)`;
3109
+ console.error(emsg);
3110
+ throw new Error(emsg);
3082
3111
  }
3112
+ return ib.startsWith(`${WITNESS_ATOM} ${SPACE_ATOM} `);
3113
+ // return ib.startsWith('witness space ') || ib.startsWith('outerspace sync ');
3083
3114
  }
3084
3115
 
3085
3116
  /**
3086
- * ## current schema FOR LOCAL (IONIC) SPACES:
3087
- *
3088
- * `witness space [classname] [spaceName] [spaceId]`
3089
- *
3090
- * ## current schema FOR SYNC (AWS) OUTERSPACES (was in create outer space modal form code):
3117
+ * atow (03/2024), (space-delimited) schema is...
3091
3118
  *
3092
- * `outerspace sync [spaceName]
3093
- *
3094
- * ## I need to fix this somehow...
3095
- *
3096
- * This is why I'm working on streamlining space management
3097
- *
3098
- * (To start with, I just had to get the ball rolling and tried my best.)
3099
- *
3100
- * ## NOTES
3101
- *
3102
- * * both schemas are space-delimited
3119
+ * `${WITNESS_ATOM} ${SPACE_ATOM} ${classname} ${name} ${id} ${spaceType} ${spaceSubtype}`
3103
3120
  */
3104
3121
  export function parseSpaceIb({
3105
3122
  spaceIb,
@@ -3122,28 +3139,53 @@ export function parseSpaceIb({
3122
3139
  * (for better or worse)
3123
3140
  */
3124
3141
  spaceId: SpaceId | undefined,
3142
+ /**
3143
+ * if undefined, by convention, this is a user space
3144
+ */
3145
+ spaceType: SpaceType | undefined,
3146
+ /**
3147
+ * subtype, if applicable
3148
+ */
3149
+ spaceSubtype: SpaceSubtype | undefined,
3125
3150
  } {
3126
3151
  const lc = `[${parseSpaceIb.name}]`;
3127
3152
  try {
3128
3153
  if (!spaceIb) { throw new Error(`spaceIb required (E: fa5424cfb7e846e2851562f2f417944f)`); }
3129
3154
 
3130
- if (spaceIb.startsWith('witness space ')) {
3131
- const pieces = spaceIb.split(' ');
3132
- if (pieces.length < 4) { throw new Error(`space ib must have at least 3 components: witness, space, classname, name (E: e42296b41496ee99754a1f3d55dd8323)`); }
3133
- return {
3134
- spaceClassname: pieces[2],
3135
- spaceName: pieces[3],
3136
- spaceId: pieces[4],
3137
- };
3138
- } else if (spaceIb.startsWith('outerspace sync ')) {
3139
- const pieces = spaceIb.split(' ');
3140
- return {
3141
- spaceClassname: undefined,
3142
- spaceName: pieces[2],
3143
- spaceId: undefined,
3144
- };
3145
- } else {
3146
- throw new Error(`unknown spaceIb schema (spaceIb: ${spaceIb}) (E: a6d361be85d5f25d6a464a5896186322)`);
3155
+ // `${WITNESS_ATOM} ${SPACE_ATOM} ${classname} ${name} ${id} ${spaceType} ${spaceSubtype}`
3156
+ const [witnessAtom, spaceAtom, spaceClassname, spaceName, spaceId, spaceType_string, spaceSubtype_string] =
3157
+ spaceIb.split(' ');
3158
+
3159
+ if (witnessAtom !== WITNESS_ATOM) { throw new Error(`invalid spaceIb (${spaceIb}). witnessAtom !== WITNESS_ATOM (E: 5ae1ca12cf8f30ae341f3e582b025224)`); }
3160
+ if (spaceAtom !== SPACE_ATOM) { throw new Error(`invalid spaceIb (${spaceIb}). spaceAtom !== SPACE_ATOM (E: 9cc6b6f30e13455eb29748148a94fa0f)`); }
3161
+ if (!spaceClassname) { throw new Error(`invalid spaceIb (${spaceIb}). spaceClassname falsy (E: 00d3392da007ca8b2840b16b199d9a24)`); }
3162
+ if (!spaceName) { throw new Error(`invalid spaceIb (${spaceIb}). spaceName falsy (E: b957d8e74ef34d889fa64c60c7a5ea0b)`); }
3163
+ if (!spaceId) { throw new Error(`invalid spaceIb (${spaceIb}). spaceId falsy (E: 7a1773722d8e46a0866d683130b65b89)`); }
3164
+
3165
+ let spaceType: SpaceType | undefined = undefined;
3166
+ if (spaceType_string && spaceType_string !== 'undefined') {
3167
+ if (VALID_SPACE_TYPES.includes(spaceType_string as SpaceType)) {
3168
+ spaceType = spaceType_string as SpaceType;
3169
+ } else {
3170
+ throw new Error(`invalid spaceIb (${spaceIb}). spaceType (${spaceType_string}) is set but not a valid type. valid types: ${VALID_SPACE_TYPES.join(', ')} (E: 838f4638a88cfbf3545a3a3a38b6dd24)`);
3171
+ }
3172
+ }
3173
+
3174
+ let spaceSubtype: SpaceSubtype | undefined = undefined;
3175
+ if (spaceSubtype_string && spaceSubtype_string !== 'undefined') {
3176
+ if (VALID_SPACE_SUBTYPES.includes(spaceSubtype_string as SpaceSubtype)) {
3177
+ spaceSubtype = spaceSubtype_string as SpaceSubtype;
3178
+ } else {
3179
+ throw new Error(`invalid spaceIb (${spaceIb}). spaceSubtype (${spaceSubtype_string}) is set but not a valid subtype. valid subtypes: ${VALID_SPACE_SUBTYPES.join(', ')} (E: 5bdcf23027f94e73860e4340313b04ab)`);
3180
+ }
3181
+ }
3182
+
3183
+ return {
3184
+ spaceClassname,
3185
+ spaceName,
3186
+ spaceId,
3187
+ spaceType,
3188
+ spaceSubtype,
3147
3189
  }
3148
3190
  } catch (error) {
3149
3191
  console.error(`${lc} ${error.message}`);
@@ -15,6 +15,93 @@ import { WitnessCmdData, WitnessCmdIbGib, WitnessCmdRel8ns, } from '../witness-c
15
15
  */
16
16
  export type SpaceId = string;
17
17
 
18
+ export type SpaceLocation = "local" | "sync";
19
+ export const SpaceLocation = {
20
+ /**
21
+ * space is a local space, with lower latency and direct usage with
22
+ * metaspace. To be used as the primary local user space.
23
+ *
24
+ * no real proxy is involved, rather, we should be speaking "directly" with
25
+ * the local location.
26
+ */
27
+ local: 'local' as SpaceLocation,
28
+ /**
29
+ * space is an outerspace, with higher latency, probably some kind of proxy
30
+ * client access. More intended to be used with syncing...
31
+ */
32
+ outerspace: 'outerspace' as SpaceLocation,
33
+ /**
34
+ * in-memory-only space.
35
+ *
36
+ * Note: I haven't really incorporated this, but I have sketched an
37
+ * in-memory innerspace and in the future, I think this will be heavily
38
+ * utilized.
39
+ */
40
+ innerspace: 'innerspace' as SpaceLocation,
41
+ }
42
+ export const VALID_SPACE_LOCATIONS = Object.values(SpaceLocation).concat();
43
+
44
+ export type SpaceType = "user" | "sync";
45
+ export const SpaceType = {
46
+ /**
47
+ * user space that usually (always?) acts locally as the main type of
48
+ * storage for a user.
49
+ *
50
+ * This means that the user is actively working in this space, and it isn't
51
+ * a derivative space. perhaps "source" would be better?
52
+ */
53
+ user: 'user' as SpaceType,
54
+ /**
55
+ * this is a derivative user space that is used to synchronize ibgib
56
+ * timelines among two or more other spaces.
57
+ */
58
+ sync: 'sync' as SpaceType,
59
+ }
60
+ /**
61
+ * Object.values(SpaceType).concat()
62
+ *
63
+ * for now, you can add valid space types here in initialization code to
64
+ * manually extend this.
65
+ */
66
+ export const VALID_SPACE_TYPES = Object.values(SpaceType).concat();
67
+
68
+ export type UserSpaceSubtype = 'node-filesystem';
69
+ /**
70
+ * specific/concrete subtype implementations
71
+ */
72
+ export const UserSpaceSubtype = {
73
+ /**
74
+ * local user space is driven by a node filesystem concrete implementation.
75
+ *
76
+ * Note: This is actually implemented elsewhere, but I am deferring the
77
+ * additional architectural requirements for putting the node filesystem and
78
+ * extending this to include it. so I'm just putting this here. But in the
79
+ * future, this should be moved to a node-specific library and brought in if
80
+ * the app requires it.
81
+ */
82
+ node_filesystem: 'node-filesystem' as UserSpaceSubtype,
83
+ }
84
+ export type SyncSpaceSubtype = 'aws-dynamodb';
85
+ export const SyncSpaceSubtype = {
86
+ aws_dynamodb: 'aws-dynamodb' as SyncSpaceSubtype,
87
+ }
88
+
89
+ export type SpaceSubtype = UserSpaceSubtype | SyncSpaceSubtype; // extend with logical OR types here
90
+ /**
91
+ * specific, concrete implementation of space
92
+ */
93
+ export const SpaceSubtype = {
94
+ ...UserSpaceSubtype,
95
+ ...SyncSpaceSubtype,
96
+ }
97
+ /**
98
+ * Object.values(SpaceSubtype).concat()
99
+ *
100
+ * for now, you can add valid subtypes here in initialization code to manually
101
+ * extend this.
102
+ */
103
+ export const VALID_SPACE_SUBTYPES = Object.values(SpaceSubtype).concat();
104
+
18
105
  /**
19
106
  * Common data among all ibgib spaces.
20
107
  */
@@ -32,6 +119,16 @@ export interface IbGibSpaceData extends WitnessData_V1 {
32
119
  * field.
33
120
  */
34
121
  uuid: SpaceId;
122
+ /**
123
+ * if not given, defaults to "user" by convention.
124
+ * @see {@link SpaceType}
125
+ */
126
+ type?: SpaceType;
127
+ /**
128
+ * should be required if {@link type} is set (truthy).
129
+ * @see {@link SpaceSubtype}
130
+ */
131
+ subtype?: SpaceSubtype | undefined;
35
132
  /**
36
133
  * If true, when this space receives a command that includes incoming ibGibs
37
134
  * and ibGibAddrs, we will ensure the ibGibs have a 1-to-1 correspondence to
@@ -1,3 +1,4 @@
1
+ export const WITNESS_ATOM = 'witness';
1
2
  export const WITNESS_ARG_METADATA_STRING = 'witness_arg';
2
3
  export const WITNESS_RESULT_METADATA_STRING = 'witness_result';
3
4