@ibgib/core-gib 0.0.58 → 0.0.60
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/dist/witness/space/metaspace/metaspace-base.d.mts +5 -0
- package/dist/witness/space/metaspace/metaspace-base.d.mts.map +1 -1
- package/dist/witness/space/metaspace/metaspace-base.mjs.map +1 -1
- package/dist/witness/space/outer-space/outer-space-helper.d.mts.map +1 -1
- package/dist/witness/space/outer-space/outer-space-helper.mjs +4 -3
- package/dist/witness/space/outer-space/outer-space-helper.mjs.map +1 -1
- package/dist/witness/space/outer-space/outer-space-types.d.mts +5 -28
- package/dist/witness/space/outer-space/outer-space-types.d.mts.map +1 -1
- package/dist/witness/space/outer-space/outer-space-types.mjs +0 -16
- package/dist/witness/space/outer-space/outer-space-types.mjs.map +1 -1
- package/dist/witness/space/space-constants.d.mts +4 -0
- package/dist/witness/space/space-constants.d.mts.map +1 -1
- package/dist/witness/space/space-constants.mjs +4 -0
- package/dist/witness/space/space-constants.mjs.map +1 -1
- package/dist/witness/space/space-helper.d.mts +18 -17
- package/dist/witness/space/space-helper.d.mts.map +1 -1
- package/dist/witness/space/space-helper.mjs +70 -54
- package/dist/witness/space/space-helper.mjs.map +1 -1
- package/dist/witness/space/space-types.d.mts +102 -0
- package/dist/witness/space/space-types.d.mts.map +1 -1
- package/dist/witness/space/space-types.mjs +78 -0
- package/dist/witness/space/space-types.mjs.map +1 -1
- package/dist/witness/witness-constants.d.mts +1 -0
- package/dist/witness/witness-constants.d.mts.map +1 -1
- package/dist/witness/witness-constants.mjs +1 -0
- package/dist/witness/witness-constants.mjs.map +1 -1
- package/package.json +2 -2
- package/src/witness/space/metaspace/metaspace-base.mts +5 -0
- package/src/witness/space/outer-space/outer-space-helper.mts +6 -9
- package/src/witness/space/outer-space/outer-space-types.mts +6 -29
- package/src/witness/space/space-constants.mts +5 -0
- package/src/witness/space/space-helper.mts +87 -60
- package/src/witness/space/space-types.mts +97 -0
- 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;
|
|
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 +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 +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.
|
|
3
|
+
"version": "0.0.60",
|
|
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",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"@ibgib/encrypt-gib": "^0.2.25",
|
|
55
55
|
"@ibgib/helper-gib": "^0.0.22",
|
|
56
|
-
"@ibgib/ts-gib": "^0.5.
|
|
56
|
+
"@ibgib/ts-gib": "^0.5.11"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@types/node": "^20.2.1"
|
|
@@ -1652,6 +1652,11 @@ export abstract class MetaspaceBase implements MetaspaceService {
|
|
|
1652
1652
|
}: {
|
|
1653
1653
|
secretIbGibs: IbGib_V1<SecretData_V1>[],
|
|
1654
1654
|
fnPromptPassword: (title: string, msg: string) => Promise<string | null>,
|
|
1655
|
+
/**
|
|
1656
|
+
* i think this was added because I didn't want it prompting in the
|
|
1657
|
+
* background in case we were trying to sync in the background and the
|
|
1658
|
+
* user hadn't entered the password (and cached it).
|
|
1659
|
+
*/
|
|
1655
1660
|
dontPrompt?: boolean,
|
|
1656
1661
|
checkCacheFirst?: boolean,
|
|
1657
1662
|
cacheAfter?: boolean,
|
|
@@ -11,11 +11,8 @@
|
|
|
11
11
|
|
|
12
12
|
import { Ib, } from '@ibgib/ts-gib/dist/types.mjs';
|
|
13
13
|
|
|
14
|
-
import {
|
|
15
|
-
|
|
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
|
|
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 (!
|
|
77
|
+
if (!VALID_SPACE_TYPES.includes(spaceType)) { throw new Error(`invalid/unknown spaceType (${spaceType}) (E: d3ba9add427f49dda34f265f3225d9db)`); }
|
|
81
78
|
|
|
82
|
-
const spaceSubtype = pieces[4] as
|
|
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 (!
|
|
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:
|
|
668
|
-
spaceSubtype:
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
32
|
-
IbGibSpaceResultIbGib, IbGibSpaceResultData, IbGibSpaceResultRel8ns
|
|
27
|
+
SpaceLockScope, IbGibSpaceLockIbGib, SpaceId, IbGibSpaceLockOptions, TxId,
|
|
28
|
+
IbGibSpaceResultIbGib, IbGibSpaceResultData, IbGibSpaceResultRel8ns, SpaceType, SpaceSubtype, VALID_SPACE_TYPES, VALID_SPACE_SUBTYPES
|
|
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,
|
|
44
|
-
|
|
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
|
-
|
|
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 {
|
|
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
|
|
|
@@ -3049,57 +3047,61 @@ export function getSpaceIb({
|
|
|
3049
3047
|
try {
|
|
3050
3048
|
if (!space) { throw new Error(`space required (E: 4dabec34ee77d67c9cc30ee3c3049622)`); }
|
|
3051
3049
|
if (!space.data) { throw new Error(`space.data required (E: 058d298876ebbeada7bbddb9e3da2f23)`); }
|
|
3052
|
-
|
|
3050
|
+
|
|
3051
|
+
if (classname && space.data.classname && classname !== space.data.classname) {
|
|
3052
|
+
throw new Error(`both classname arg (${classname}) and space.data.classname (${space.data.classname}) are different truthy values. (E: f98f012ee876eb8fbe7403f7b53e4624)`);
|
|
3053
|
+
} else {
|
|
3054
|
+
classname ||= space?.data!.classname;
|
|
3055
|
+
}
|
|
3053
3056
|
if (!classname) { throw new Error(`classname required (E: fa3af4613ad56742dab51d1b0d839322)`); }
|
|
3054
|
-
if (classname.includes(' ')) { throw new Error(`invalid classname. cannot contain spaces (E: 243adbf720dcce7904e2665933208b22)`); }
|
|
3057
|
+
if (classname.includes(' ')) { throw new Error(`invalid classname (${classname}). cannot contain spaces (E: 243adbf720dcce7904e2665933208b22)`); }
|
|
3058
|
+
|
|
3055
3059
|
const name = space.data?.name || IBGIB_SPACE_NAME_DEFAULT;
|
|
3056
3060
|
if (name.includes(' ')) { throw new Error(`invalid space name. cannot contain spaces (E: a8450e1651081412c8ac018520182422)`); }
|
|
3061
|
+
|
|
3057
3062
|
const id = space.data?.uuid || undefined;
|
|
3058
3063
|
if (!id) { throw new Error(`invalid space, space.data.uuid falsy (E: 50ae723a9ab24f4fc7132613e65faf23)`); }
|
|
3059
3064
|
if (id.includes(' ')) { throw new Error(`invalid space id. cannot contain spaces (E: 8696830fe7f54bfa85e670a063f3e089)`); }
|
|
3060
|
-
|
|
3061
|
-
|
|
3065
|
+
|
|
3066
|
+
const spaceType = space.data.type ?? undefined;
|
|
3067
|
+
const spaceSubtype = space.data.subtype ?? undefined;
|
|
3068
|
+
if (spaceType && !spaceSubtype) {
|
|
3069
|
+
throw new Error(`spaceType (${spaceType}) is set but spaceSubtype is falsy. (E: 878ab960d7987ae2331103b4a00d0d24)`);
|
|
3070
|
+
}
|
|
3071
|
+
|
|
3072
|
+
return `${WITNESS_ATOM} ${SPACE_ATOM} ${classname} ${name} ${id} ${spaceType} ${spaceSubtype}`;
|
|
3062
3073
|
} catch (error) {
|
|
3063
3074
|
console.error(`${lc} ${error.message}`);
|
|
3064
3075
|
throw error;
|
|
3065
3076
|
}
|
|
3066
3077
|
}
|
|
3067
3078
|
|
|
3079
|
+
/**
|
|
3080
|
+
* determines if the given ib belongs to a space ibgib.
|
|
3081
|
+
*
|
|
3082
|
+
* atow (03/2024) checks to see if the ib starts with
|
|
3083
|
+
*
|
|
3084
|
+
* `${WITNESS_ATOM} ${SPACE_ATOM} `
|
|
3085
|
+
*/
|
|
3068
3086
|
export function isSpaceIb({
|
|
3069
3087
|
ib
|
|
3070
3088
|
}: {
|
|
3071
3089
|
ib: Ib
|
|
3072
3090
|
}): boolean {
|
|
3073
3091
|
const lc = `[${isSpaceIb.name}]`;
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
console.error(`${lc} ${error.message}`);
|
|
3079
|
-
throw error;
|
|
3080
|
-
} finally {
|
|
3081
|
-
if (logalot) { console.log(`${lc} complete.`); }
|
|
3092
|
+
if (!ib) {
|
|
3093
|
+
const emsg = `${lc} ib required (E: dd5244f62f964359a86e59bb08ee47e6)`;
|
|
3094
|
+
console.error(emsg);
|
|
3095
|
+
throw new Error(emsg);
|
|
3082
3096
|
}
|
|
3097
|
+
return ib.startsWith(`${WITNESS_ATOM} ${SPACE_ATOM} `);
|
|
3098
|
+
// return ib.startsWith('witness space ') || ib.startsWith('outerspace sync ');
|
|
3083
3099
|
}
|
|
3084
3100
|
|
|
3085
3101
|
/**
|
|
3086
|
-
*
|
|
3087
|
-
*
|
|
3088
|
-
* `witness space [classname] [spaceName] [spaceId]`
|
|
3089
|
-
*
|
|
3090
|
-
* ## current schema FOR SYNC (AWS) OUTERSPACES (was in create outer space modal form code):
|
|
3091
|
-
*
|
|
3092
|
-
* `outerspace sync [spaceName]
|
|
3093
|
-
*
|
|
3094
|
-
* ## I need to fix this somehow...
|
|
3102
|
+
* atow (03/2024), (space-delimited) schema is...
|
|
3095
3103
|
*
|
|
3096
|
-
*
|
|
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
|
|
3104
|
+
* `${WITNESS_ATOM} ${SPACE_ATOM} ${classname} ${name} ${id} ${spaceType} ${spaceSubtype}`
|
|
3103
3105
|
*/
|
|
3104
3106
|
export function parseSpaceIb({
|
|
3105
3107
|
spaceIb,
|
|
@@ -3122,28 +3124,53 @@ export function parseSpaceIb({
|
|
|
3122
3124
|
* (for better or worse)
|
|
3123
3125
|
*/
|
|
3124
3126
|
spaceId: SpaceId | undefined,
|
|
3127
|
+
/**
|
|
3128
|
+
* if undefined, by convention, this is a user space
|
|
3129
|
+
*/
|
|
3130
|
+
spaceType: SpaceType | undefined,
|
|
3131
|
+
/**
|
|
3132
|
+
* subtype, if applicable
|
|
3133
|
+
*/
|
|
3134
|
+
spaceSubtype: SpaceSubtype | undefined,
|
|
3125
3135
|
} {
|
|
3126
3136
|
const lc = `[${parseSpaceIb.name}]`;
|
|
3127
3137
|
try {
|
|
3128
3138
|
if (!spaceIb) { throw new Error(`spaceIb required (E: fa5424cfb7e846e2851562f2f417944f)`); }
|
|
3129
3139
|
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
}
|
|
3145
|
-
|
|
3146
|
-
|
|
3140
|
+
// `${WITNESS_ATOM} ${SPACE_ATOM} ${classname} ${name} ${id} ${spaceType} ${spaceSubtype}`
|
|
3141
|
+
const [witnessAtom, spaceAtom, spaceClassname, spaceName, spaceId, spaceType_string, spaceSubtype_string] =
|
|
3142
|
+
spaceIb.split(' ');
|
|
3143
|
+
|
|
3144
|
+
if (witnessAtom !== WITNESS_ATOM) { throw new Error(`invalid spaceIb (${spaceIb}). witnessAtom !== WITNESS_ATOM (E: 5ae1ca12cf8f30ae341f3e582b025224)`); }
|
|
3145
|
+
if (spaceAtom !== SPACE_ATOM) { throw new Error(`invalid spaceIb (${spaceIb}). spaceAtom !== SPACE_ATOM (E: 9cc6b6f30e13455eb29748148a94fa0f)`); }
|
|
3146
|
+
if (!spaceClassname) { throw new Error(`invalid spaceIb (${spaceIb}). spaceClassname falsy (E: 00d3392da007ca8b2840b16b199d9a24)`); }
|
|
3147
|
+
if (!spaceName) { throw new Error(`invalid spaceIb (${spaceIb}). spaceName falsy (E: b957d8e74ef34d889fa64c60c7a5ea0b)`); }
|
|
3148
|
+
if (!spaceId) { throw new Error(`invalid spaceIb (${spaceIb}). spaceId falsy (E: 7a1773722d8e46a0866d683130b65b89)`); }
|
|
3149
|
+
|
|
3150
|
+
let spaceType: SpaceType | undefined = undefined;
|
|
3151
|
+
if (spaceType_string && spaceType_string !== 'undefined') {
|
|
3152
|
+
if (VALID_SPACE_TYPES.includes(spaceType_string as SpaceType)) {
|
|
3153
|
+
spaceType = spaceType_string as SpaceType;
|
|
3154
|
+
} else {
|
|
3155
|
+
throw new Error(`invalid spaceIb (${spaceIb}). spaceType (${spaceType_string}) is set but not a valid type. valid types: ${VALID_SPACE_TYPES.join(', ')} (E: 838f4638a88cfbf3545a3a3a38b6dd24)`);
|
|
3156
|
+
}
|
|
3157
|
+
}
|
|
3158
|
+
|
|
3159
|
+
let spaceSubtype: SpaceSubtype | undefined = undefined;
|
|
3160
|
+
if (spaceSubtype_string && spaceSubtype_string !== 'undefined') {
|
|
3161
|
+
if (VALID_SPACE_SUBTYPES.includes(spaceSubtype_string as SpaceSubtype)) {
|
|
3162
|
+
spaceSubtype = spaceSubtype_string as SpaceSubtype;
|
|
3163
|
+
} else {
|
|
3164
|
+
throw new Error(`invalid spaceIb (${spaceIb}). spaceSubtype (${spaceSubtype_string}) is set but not a valid subtype. valid subtypes: ${VALID_SPACE_SUBTYPES.join(', ')} (E: 5bdcf23027f94e73860e4340313b04ab)`);
|
|
3165
|
+
}
|
|
3166
|
+
}
|
|
3167
|
+
|
|
3168
|
+
return {
|
|
3169
|
+
spaceClassname,
|
|
3170
|
+
spaceName,
|
|
3171
|
+
spaceId,
|
|
3172
|
+
spaceType,
|
|
3173
|
+
spaceSubtype,
|
|
3147
3174
|
}
|
|
3148
3175
|
} catch (error) {
|
|
3149
3176
|
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
|